Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ composer require digitalrevolution/ipp
$ipp->print($printer, $ippFile);
```

### Print job validation
To test a print operation without actually printing anything, you can use the `validatePrintJob` operation instead.
```php
$ipp->validatePrintJob($printer, $ippFile);
```

### Fetch job attributes

```php
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
},
"require": {
"php": "^8.3",
"digitalrevolution/utils": "^1.0",
"nyholm/psr7": "^1.8",
"psr/http-client": "^1.0",
"psr/log": "^3.0",
"digitalrevolution/utils": "^1.0"
"psr/log": "^3.0"
},
"require-dev": {
"digitalrevolution/accessorpair-constraint": "^v2.4.1",
"digitalrevolution/php-codesniffer-baseline": "^1.3",
"digitalrevolution/phpunit-file-coverage-inspection": "^3.0",
"digitalrevolution/php-codesniffer-baseline": "^1.1",
"phpmd/phpmd": "^2.12",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^2.0.0",
"phpstan/phpstan-phpunit": "^2.0.0",
"phpunit/phpunit": "^12.0",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^4.0",
"slevomat/coding-standard": "^8.16"
"slevomat/coding-standard": "^8.16",
"squizlabs/php_codesniffer": "^4.0"
},
"scripts": {
"baseline": [
Expand Down
6 changes: 6 additions & 0 deletions phpcs.baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpcs-baseline version="4.0.0">
<violation file="src/Factory/IppJobFactory.php" sniff="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh" signature="f331be3bcc865734cb225efffb01022d16b72339"/>
<violation file="src/Factory/IppPrinterFactory.php" sniff="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh" signature="26390268ae58e9656b8ba15b681fd37d2a51e34e"/>
</phpcs-baseline>

7 changes: 7 additions & 0 deletions phpmd.baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<phpmd-baseline>
<violation rule="PHPMD\Rule\Design\TooManyFields" file="src/Entity/IppJob.php"/>
<violation rule="PHPMD\Rule\Design\TooManyFields" file="src/Entity/IppPrinter.php"/>
<violation rule="PHPMD\Rule\Design\NpathComplexity" file="src/Factory/IppJobFactory.php" method="create"/>
<violation rule="PHPMD\Rule\Design\NpathComplexity" file="src/Factory/IppPrinterFactory.php" method="create"/>
</phpmd-baseline>
5 changes: 2 additions & 3 deletions src/Client/CupsIppHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

class CupsIppHttpClient implements IppHttpClientInterface
{
private const int HTTP_STATUS_UNAUTHORIZED = 401;
private const int HTTP_STATUS_SERVER_ERROR = 500;
private const int HTTP_STATUS_BAD_REQUEST = 400;

public function __construct(private readonly IppServer $server, private readonly ClientInterface $client)
{
Expand All @@ -42,7 +41,7 @@ public function sendRequest(IppOperation $operation): ResponseInterface
$response = $this->client->sendRequest($request);

// a server error won't be an ipp response we can parse.
if ($response->getStatusCode() === self::HTTP_STATUS_UNAUTHORIZED || $response->getStatusCode() >= self::HTTP_STATUS_SERVER_ERROR) {
if ($response->getStatusCode() >= self::HTTP_STATUS_BAD_REQUEST) {
throw new IppRequestException($request, $response);
}

Expand Down
92 changes: 85 additions & 7 deletions src/Entity/IppJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ class IppJob
{
private int $id;
private string $uri;
private ?string $name = null;
private JobStateEnum $jobState;
private JobStateReasonEnum $jobStateReason;
private ?string $userName;
private ?int $fileSize;
private ?int $numberOfDocuments;
private ?int $copies;
private ?DateTimeInterface $creationDate;
private ?DateTimeInterface $completionDate;
private ?string $documentFormat;
private ?string $userName = null;
private ?int $fileSize = null;
private ?int $numberOfDocuments = null;
private ?int $copies = null;
private ?DateTimeInterface $creationDate = null;
private ?DateTimeInterface $processingDate = null;
private ?DateTimeInterface $completionDate = null;
private ?string $documentFormat = null;
private ?string $documentName = null;
private ?string $printerUri = null;
private ?DateTimeInterface $printerUpSince = null;
private ?int $priority = null;

public function getId(): int
{
Expand All @@ -46,6 +52,18 @@ public function setUri(string $uri): self
return $this;
}

public function getName(): ?string
{
return $this->name;
}

public function setName(?string $name): self
{
$this->name = $name;

return $this;
}

public function getJobStateReason(): JobStateReasonEnum
{
return $this->jobStateReason;
Expand Down Expand Up @@ -130,6 +148,18 @@ public function setCreationDate(?DateTimeInterface $creationDate): self
return $this;
}

public function getProcessingDate(): ?DateTimeInterface
{
return $this->processingDate;
}

public function setProcessingDate(?DateTimeInterface $processingDate): self
{
$this->processingDate = $processingDate;

return $this;
}

public function getCompletionDate(): ?DateTimeInterface
{
return $this->completionDate;
Expand All @@ -153,4 +183,52 @@ public function setDocumentFormat(?string $documentFormat): self

return $this;
}

public function getDocumentName(): ?string
{
return $this->documentName;
}

public function setDocumentName(?string $documentName): self
{
$this->documentName = $documentName;

return $this;
}

public function getPrinterUpSince(): ?DateTimeInterface
{
return $this->printerUpSince;
}

public function setPrinterUpSince(?DateTimeInterface $printerUpTime): self
{
$this->printerUpSince = $printerUpTime;

return $this;
}

public function getPrinterUri(): ?string
{
return $this->printerUri;
}

public function setPrinterUri(?string $setPrinterUri): self
{
$this->printerUri = $setPrinterUri;

return $this;
}

public function getPriority(): ?int
{
return $this->priority;
}

public function setPriority(?int $priority): self
{
$this->priority = $priority;

return $this;
}
}
Loading