SquareAssetCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 15 1
1
<?php
2
3
namespace Jackal\ImageMerge\Command\Asset;
4
5
use Jackal\ImageMerge\Command\AbstractCommand;
6
use Jackal\ImageMerge\Command\Options\DoubleCoordinateColorCommandOption;
7
use Jackal\ImageMerge\Model\Image;
8
use Jackal\ImageMerge\Utils\ColorUtils;
9
10
/**
11
 * Class SquareAssetCommand
12
 * @package Jackal\ImageMerge\Command\Asset
13
 */
14
class SquareAssetCommand extends AbstractCommand
15
{
16
    /**
17
     * @param Image $image
18
     * @return Image
19
     */
20
    public function execute(Image $image)
21
    {
22
        /** @var DoubleCoordinateColorCommandOption $options */
23
        $options = $this->options;
24
25
        $color = ColorUtils::colorIdentifier($image->getResource(), $options->getColor());
26
        imagefilledrectangle($image->getResource(),
27
            $options->getCoordinate1()->getX(),
28
            $options->getCoordinate1()->getY(),
29
            $options->getCoordinate2()->getX(),
30
            $options->getCoordinate2()->getY(),
31
            $color
32
        );
33
34
        return $image;
35
    }
36
}
37