-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
258 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf; | ||
|
||
abstract class OptionGroup { | ||
/** @return array<string|int|float> */ | ||
public function compile(): array | ||
{ | ||
$options = []; | ||
|
||
foreach ($this as $property) { | ||
if ($property instanceof Option) { | ||
$options = array_merge($options, $property->compile()); | ||
} | ||
} | ||
|
||
return $options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\OptionGroup; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\CollateOption; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\CookieJarOption; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\NoCollateOption; | ||
use KNPLabs\Snappy\Core\Backend\Options\PageOrientation; | ||
|
||
final class GlobalOptions extends OptionGroup | ||
{ | ||
public function __construct( | ||
public readonly ?CollateOption $collate, | ||
public readonly ?NoCollateOption $noCollate, | ||
public readonly ?CookieJarOption $cookieJar, | ||
public readonly ?PageOrientation $pageOrientation, | ||
) { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Backend/WkHtmlToPdf/Options/GlobalOptions/CollateOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Option; | ||
|
||
final class CollateOption implements Option | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--collate']; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Backend/WkHtmlToPdf/Options/GlobalOptions/CookieJarOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class CookieJarOption | ||
{ | ||
public function __construct(public readonly string $path) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--no-collate']; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Backend/WkHtmlToPdf/Options/GlobalOptions/CopiesOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class CopiesOption | ||
{ | ||
public function __construct(private readonly int $number) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--copies', $this->number]; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Backend/WkHtmlToPdf/Options/GlobalOptions/DpiOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class DpiOptions | ||
{ | ||
public function __construct(private readonly int $dpi) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--dpi', $this->dpi]; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Backend/WkHtmlToPdf/Options/GlobalOptions/GrayscaleOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class GrayscaleOption | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--grayscale']; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Backend/WkHtmlToPdf/Options/GlobalOptions/ImageDpiOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class ImageDpiOption | ||
{ | ||
public function __construct(public readonly int $dpi) {} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Backend/WkHtmlToPdf/Options/GlobalOptions/NoCollateOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class NoCollateOption | ||
{ | ||
public function __construct() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters