diff --git a/.gitignore b/.gitignore index a9c49be..e1d2b15 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ /vendor/ /var/ +.phpcs-cache .phpunit.result.cache composer.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d6669e5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: php + +php: + - 8.1 + - 8.2 + +before_install: + - curl -s https://getcomposer.org/installer | php + - composer req roave/security-advisories:dev-master --no-update + - composer install + +script: + - php -v + - vendor/bin/phpcs --standard=psr2 src/ + - vendor/bin/phpunit + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 367e86d..802cb1b 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,13 @@ "require-dev": { "roave/security-advisories": "dev-latest", "symfony/test-pack": "^1.1", - "symfony/framework-bundle": "^6.3" + "symfony/framework-bundle": "^6.3", + "squizlabs/php_codesniffer": "^3.7", + "slevomat/coding-standard": "^8.13" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..d224db0 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + src/ + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..914f562 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,21 @@ +includes: + - vendor/phpstan/phpstan-symfony/extension.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + +parameters: + level: 1 + + paths: + - src + excludePaths: + - tests + - var + - vendor + + parallel: + jobSize: 32 + maximumNumberOfProcesses: 64 + minimumNumberOfJobsPerProcess: 4 + + symfony: + containerXmlPath: var/cache/test/App_KernelDevDebugContainer.xml diff --git a/src/Providers/ImgProxy/Builder/Processing/Zoom.php b/src/Providers/ImgProxy/Builder/Processing/Zoom.php index e9586d0..511e12a 100644 --- a/src/Providers/ImgProxy/Builder/Processing/Zoom.php +++ b/src/Providers/ImgProxy/Builder/Processing/Zoom.php @@ -6,7 +6,7 @@ class Zoom implements ProcessOptionInterface { - private const ZOOM_TPL = 'z:%zoom_x_y'; + private const ZOOM_TPL = 'z:%zoom_x_y'; private const ZOOM_XY_TPL = 'z:%zoom_x:%zoom_y'; public function __construct(protected string $zoomX = "1", protected ?string $zoomY = null) @@ -33,11 +33,13 @@ public function __construct(protected string $zoomX = "1", protected ?string $zo public function compile(): string { $equal = $this->zoomX === $this->zoomY; - $tpl = $equal ? self::ZOOM_TPL : self::ZOOM_XY_TPL; + $tpl = $equal ? self::ZOOM_TPL : self::ZOOM_XY_TPL; - return \strtr($tpl, $equal - ? ['%zoom_x_y' => $this->zoomX] - : ['%zoom_x' => $this->zoomX, '%zoom_y' => $this->zoomY] + return \strtr( + $tpl, + $equal + ? ['%zoom_x_y' => $this->zoomX] + : ['%zoom_x' => $this->zoomX, '%zoom_y' => $this->zoomY] ); } } diff --git a/src/Providers/ImgProxy/Security.php b/src/Providers/ImgProxy/Security.php index d4146f1..7f54165 100644 --- a/src/Providers/ImgProxy/Security.php +++ b/src/Providers/ImgProxy/Security.php @@ -1,6 +1,7 @@ 0) { + if ($key !== '') { try { $this->key = \pack('H', \mb_strtoupper($key)); } catch (\Throwable $e) { @@ -16,7 +17,7 @@ public function __construct(string $key, string $salt, private readonly int $siz } } - if (\mb_strlen($salt) > 0) { + if ($salt !== '') { try { $this->salt = \pack('H', \mb_strtoupper($salt)); } catch (\Throwable $e) { diff --git a/src/Providers/Thumbor/Security.php b/src/Providers/Thumbor/Security.php index 225997f..a1494a1 100644 --- a/src/Providers/Thumbor/Security.php +++ b/src/Providers/Thumbor/Security.php @@ -4,5 +4,4 @@ class Security { - }