Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
muhajirrr authored and github-actions[bot] committed Aug 31, 2023
1 parent 57b9895 commit ba3ed93
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
3 changes: 2 additions & 1 deletion database/migrations/create_document_files_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::create('document_files', function (Blueprint $table) {
Expand Down
3 changes: 2 additions & 1 deletion database/migrations/create_document_templates_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::create('document_templates', function (Blueprint $table) {
Expand Down
4 changes: 0 additions & 4 deletions src/Contract/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ interface Driver
{
/**
* Render HTML to PDF and return temporary file path of the rendered PDF.
*
* @param string $html
* @param array $options
* @return string
*/
public function render(string $html, array $options = []): string;
}
4 changes: 2 additions & 2 deletions src/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace AsevenTeam\Documents;

use AsevenTeam\Documents\Contract\Driver;
use AsevenTeam\Documents\Drivers\DriverDecorator;
use AsevenTeam\Documents\Drivers\BrowsershotDriver;
use AsevenTeam\Documents\Drivers\DriverDecorator;
use Illuminate\Support\Str;
use InvalidArgumentException;

Expand All @@ -18,7 +18,7 @@ protected function getDefaultDriver(): string
return config('documents.default_driver');
}

public function driver(?string $driver = null): DriverDecorator
public function driver(string $driver = null): DriverDecorator
{
$driver ??= $this->getDefaultDriver();

Expand Down
15 changes: 6 additions & 9 deletions src/Drivers/DriverDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ class DriverDecorator implements Driver
{
public function __construct(
protected Driver $driver,
)
{
) {
}

public function create(
HasDocuments $model,
DocumentTemplate $template,
array $variables = [],
array $options = [],
?string $documentType = null,
): DocumentFile
{
string $documentType = null,
): DocumentFile {
$variables = array_merge($template->variables, $variables);

Check failure on line 27 in src/Drivers/DriverDecorator.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property AsevenTeam\Documents\Models\DocumentTemplate::$variables.
$options = array_merge($template->options, $options);

Check failure on line 28 in src/Drivers/DriverDecorator.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property AsevenTeam\Documents\Models\DocumentTemplate::$options.

Expand All @@ -47,9 +45,8 @@ public function createFromHtml(
HasDocuments $model,
string $html,
array $options = [],
?string $documentType = null,
): DocumentFile
{
string $documentType = null,
): DocumentFile {
$filePath = $this->renderHtml($html, $options);

$size = Storage::fileSize($filePath);
Expand Down Expand Up @@ -79,7 +76,7 @@ protected function renderHtml(string $html, array $options): string
protected function savePdf(string $pdfContent): string
{
$filename = Str::random(40);
$path = date('Y/m/') . 'documents/' . $filename . '.pdf';
$path = date('Y/m/').'documents/'.$filename.'.pdf';

Storage::put($path, $pdfContent, ['visibility' => 'public']);

Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AsevenTeam\Documents\Tests;

use AsevenTeam\Documents\DocumentServiceProvider;
use AsevenTeam\Documents\Tests\TestModels\TestModel;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Expand Down

0 comments on commit ba3ed93

Please sign in to comment.