mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 17:19:50 +02:00
Merge pull request #1276 from Intervention/oblakstudio-feat/phpcs
Oblakstudio feat/phpcs
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.php]
|
||||
indent_size = 4
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,10 +1,12 @@
|
||||
* text=auto
|
||||
|
||||
/.editorconfig export-ignore
|
||||
/.github export-ignore
|
||||
/tests export-ignore
|
||||
/.github export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
/phpcs.xml export-ignore
|
||||
/phpunit.xml export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/docker-compose.yml export-ignore
|
||||
|
3
.github/workflows/run-tests.yml
vendored
3
.github/workflows/run-tests.yml
vendored
@@ -100,3 +100,6 @@ jobs:
|
||||
|
||||
- name: Run analyzer
|
||||
run: vendor/bin/phpstan analyze --level=4 ./src
|
||||
|
||||
- name: Validate coding standards
|
||||
run: vendor/bin/phpcs
|
||||
|
@@ -2,7 +2,14 @@
|
||||
"name": "intervention/image",
|
||||
"description": "PHP image manipulation",
|
||||
"homepage": "https://image.intervention.io/",
|
||||
"keywords": ["image", "gd", "imagick", "watermark", "thumbnail", "resize"],
|
||||
"keywords": [
|
||||
"image",
|
||||
"gd",
|
||||
"imagick",
|
||||
"watermark",
|
||||
"thumbnail",
|
||||
"resize"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -19,11 +26,11 @@
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9",
|
||||
"mockery/mockery": "^1.6",
|
||||
"phpstan/phpstan": "^1"
|
||||
"phpstan/phpstan": "^1",
|
||||
"squizlabs/php_codesniffer": "^3.8"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-exif": "Recommended to be able to read EXIF data properly."
|
||||
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@@ -21,3 +21,9 @@ services:
|
||||
command: bash -c "composer install && ./vendor/bin/phpstan analyze --memory-limit=512M --level=4 ./src"
|
||||
volumes:
|
||||
- ./:/project
|
||||
standards:
|
||||
build: ./
|
||||
working_dir: /project
|
||||
command: bash -c "composer install && ./vendor/bin/phpcs"
|
||||
volumes:
|
||||
- ./:/project
|
||||
|
8
phpcs.xml
Normal file
8
phpcs.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Intervention/image">
|
||||
|
||||
<rule ref="PSR12"/>
|
||||
|
||||
<file>src/</file>
|
||||
<file>tests/</file>
|
||||
</ruleset>
|
@@ -25,7 +25,8 @@ class StringColorDecoder extends AbstractDecoder implements DecoderInterface
|
||||
throw new DecoderException('Unable to decode input');
|
||||
}
|
||||
|
||||
$pattern = '/^s?rgba?\((?P<r>[0-9\.]+%?), ?(?P<g>[0-9\.]+%?), ?(?P<b>[0-9\.]+%?)(?:, ?(?P<a>(?:1)|(?:1\.0*)|(?:0)|(?:0?\.\d+%?)|(?:\d{1,3}%)))?\)$/i';
|
||||
$pattern = '/^s?rgba?\((?P<r>[0-9\.]+%?), ?(?P<g>[0-9\.]+%?), ?(?P<b>[0-9\.]+%?)' .
|
||||
'(?:, ?(?P<a>(?:1)|(?:1\.0*)|(?:0)|(?:0?\.\d+%?)|(?:\d{1,3}%)))?\)$/i';
|
||||
if (preg_match($pattern, $input, $matches) != 1) {
|
||||
throw new DecoderException('Unable to decode input');
|
||||
}
|
||||
|
@@ -61,7 +61,8 @@ class GdInputHandlerTest extends TestCase
|
||||
public function testHandleDataUriImage(): void
|
||||
{
|
||||
$handler = new InputHandler();
|
||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNb' .
|
||||
'yblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||
$result = $handler->handle($input);
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
}
|
||||
|
@@ -61,7 +61,8 @@ class InputHandlerTest extends TestCase
|
||||
public function testHandleDataUriImage(): void
|
||||
{
|
||||
$handler = new InputHandler();
|
||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACN' .
|
||||
'byblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||
$result = $handler->handle($input);
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user