Skip to content

Commit

Permalink
wip v8
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerockett committed Oct 15, 2023
1 parent 49f9696 commit c89f247
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 61 deletions.
15 changes: 3 additions & 12 deletions src/Contracts/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,22 @@

use Illuminate\Contracts\Support\Renderable;
use Symfony\Component\HttpFoundation\StreamedResponse;
use WeasyPrint\Objects\{Config, Output, Source};
use WeasyPrint\Objects\Config;
use WeasyPrint\Objects\Output;
use WeasyPrint\Objects\Source;

interface Factory
{
public function getWeasyPrintVersion(): string;

public function setConfig(Config $config): self;

public function tapConfig(callable $callback): self;

public function getConfig(): Config;

public function prepareSource(Source|Renderable|string $source): self;

public function getSource(): Source;

public function addAttachment(string $pathToAttachment): Factory;

public function build(): Output;

public function download(string $filename, array $headers = [], bool $inline = false): StreamedResponse;

public function inline(string $filename, array $headers = []): StreamedResponse;

public function putFile(string $path, string $disk = null, array $options = []): bool;

public function getData(): string;
}
3 changes: 2 additions & 1 deletion src/Objects/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace WeasyPrint\Objects;

use Illuminate\Contracts\Support\Arrayable;
use WeasyPrint\Enums\{PDFVariant, PDFVersion};
use WeasyPrint\Enums\PDFVariant;
use WeasyPrint\Enums\PDFVersion;

final class Config implements Arrayable
{
Expand Down
3 changes: 2 additions & 1 deletion src/Objects/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Objects;

use Illuminate\Support\Facades\{Response, Storage};
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;

final class Output
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/EnsureSourceIsSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Exceptions\SourceNotSetException;
use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class EnsureSourceIsSet implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/Execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class Execute implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/PersistTemporaryInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class PersistTemporaryInput implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/PrepareBuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Commands\BuildCommand;
use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class PrepareBuildCommand implements BuildStage
{
Expand Down
6 changes: 4 additions & 2 deletions src/Pipeline/Stages/PrepareOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Exceptions\{MissingOutputFileException, OutputReadFailedException};
use WeasyPrint\Exceptions\MissingOutputFileException;
use WeasyPrint\Exceptions\OutputReadFailedException;
use WeasyPrint\Objects\Output;
use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class PrepareOutput implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/SetInputPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class SetInputPath implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/SetOutputPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class SetOutputPath implements BuildStage
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pipeline/Stages/UnlinkTemporaryInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace WeasyPrint\Pipeline\Stages;

use WeasyPrint\Pipeline\{BuildStage, BuildTraveler};
use WeasyPrint\Pipeline\BuildStage;
use WeasyPrint\Pipeline\BuildTraveler;

class UnlinkTemporaryInput implements BuildStage
{
Expand Down
7 changes: 5 additions & 2 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
use WeasyPrint\Commands\VersionCommand;
use WeasyPrint\Contracts\Factory;
use WeasyPrint\Exceptions\MissingSourceException;
use WeasyPrint\Objects\{Config, Output, Source};
use WeasyPrint\Pipeline\{BuildTraveler, Stages as Pipes};
use WeasyPrint\Objects\Config;
use WeasyPrint\Objects\Output;
use WeasyPrint\Objects\Source;
use WeasyPrint\Pipeline\BuildTraveler;
use WeasyPrint\Pipeline\Stages as Pipes;

class Service implements Factory
{
Expand Down
33 changes: 2 additions & 31 deletions stout.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
{
"indent": " ",
"preset": "psr12",
"preset": "per",
"rules": {
"array_indentation": true,
"array_syntax": {
"syntax": "short"
},
"blank_line_between_import_groups": false,
"cast_spaces": true,
"class_attributes_separation": {
"elements": {
"case": "none",
"const": "none",
"method": "one",
"property": "only_if_meta",
"trait_import": "none"
}
},
"global_namespace_import": true,
"group_import": true,
"method_chaining_indentation": true,
"no_unused_imports": true,
"no_useless_else": true,
"ordered_class_elements": true,
"ordered_imports": true,
"ordered_interfaces": true,
"return_assignment": true,
"self_static_accessor": true,
"single_import_per_statement": false,
"single_line_empty_body": true,
"single_quote": true,
"ternary_to_null_coalescing": true,
"trailing_comma_in_multiline": true
"@PER-CS2.0": true
}
}
7 changes: 4 additions & 3 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
declare(strict_types=1);

use Illuminate\Support\Env;
use WeasyPrint\Enums\{PDFVariant, PDFVersion};
use WeasyPrint\Enums\PDFVariant;
use WeasyPrint\Enums\PDFVersion;
use WeasyPrint\Objects\Config;
use WeasyPrint\Service;

Expand Down Expand Up @@ -48,7 +49,7 @@
});

test('pdf variant can be set from environment', function (): void {
Env::getRepository()->set($key = 'WEASYPRINT_PDF_VARIANT', 'pdf/a-1b', );
Env::getRepository()->set($key = 'WEASYPRINT_PDF_VARIANT', 'pdf/a-1b');

expect(PDFVariant::fromEnvironment($key))
->toEqual(PDFVariant::PDF_A_1B);
Expand All @@ -57,7 +58,7 @@
});

test('pdf version can be set from environment', function (): void {
Env::getRepository()->set($key = 'WEASYPRINT_PDF_VERSION', '1.7', );
Env::getRepository()->set($key = 'WEASYPRINT_PDF_VERSION', '1.7');

expect(PDFVersion::fromEnvironment($key))
->toEqual(PDFVersion::VERSION_1_7);
Expand Down
3 changes: 2 additions & 1 deletion tests/InstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
declare(strict_types=1);

use WeasyPrint\Contracts\Factory;
use WeasyPrint\{Facade, Service};
use WeasyPrint\Facade;
use WeasyPrint\Service;

test('can be instantiated via dependency injection', function (): void {
expect($this->app->make(Factory::class))->toBeValidServiceInstance();
Expand Down
3 changes: 2 additions & 1 deletion tests/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
declare(strict_types=1);

use Smalot\PdfParser\Parser;
use Symfony\Component\HttpFoundation\{ResponseHeaderBag, StreamedResponse};
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\StreamedResponse;
use WeasyPrint\Enums\PDFVersion;
use WeasyPrint\Objects\Config;
use WeasyPrint\Service;
Expand Down

0 comments on commit c89f247

Please sign in to comment.