mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 00:29:55 +02:00
Include line length check in code standards
This commit is contained in:
@@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
<rule ref="PSR12"/>
|
<rule ref="PSR12"/>
|
||||||
|
|
||||||
<rule ref="Generic.Files.LineLength">
|
|
||||||
<severity>0</severity>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<file>src/</file>
|
<file>src/</file>
|
||||||
<file>tests/</file>
|
<file>tests/</file>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@@ -21,11 +21,12 @@ class StringColorDecoder extends AbstractDecoder implements DecoderInterface
|
|||||||
*/
|
*/
|
||||||
public function decode(mixed $input): ImageInterface|ColorInterface
|
public function decode(mixed $input): ImageInterface|ColorInterface
|
||||||
{
|
{
|
||||||
if (! is_string($input)) {
|
if (!is_string($input)) {
|
||||||
throw new DecoderException('Unable to decode input');
|
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) {
|
if (preg_match($pattern, $input, $matches) != 1) {
|
||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,8 @@ class GdInputHandlerTest extends TestCase
|
|||||||
public function testHandleDataUriImage(): void
|
public function testHandleDataUriImage(): void
|
||||||
{
|
{
|
||||||
$handler = new InputHandler();
|
$handler = new InputHandler();
|
||||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNb' .
|
||||||
|
'yblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||||
$result = $handler->handle($input);
|
$result = $handler->handle($input);
|
||||||
$this->assertInstanceOf(Image::class, $result);
|
$this->assertInstanceOf(Image::class, $result);
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,8 @@ class InputHandlerTest extends TestCase
|
|||||||
public function testHandleDataUriImage(): void
|
public function testHandleDataUriImage(): void
|
||||||
{
|
{
|
||||||
$handler = new InputHandler();
|
$handler = new InputHandler();
|
||||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACN' .
|
||||||
|
'byblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||||
$result = $handler->handle($input);
|
$result = $handler->handle($input);
|
||||||
$this->assertInstanceOf(Image::class, $result);
|
$this->assertInstanceOf(Image::class, $result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user