TextAssetCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 21 2
1
<?php
2
3
namespace Jackal\ImageMerge\Command\Asset;
4
5
use Jackal\ImageMerge\Command\AbstractCommand;
6
use Jackal\ImageMerge\Command\Options\TextCommandOption;
7
use Jackal\ImageMerge\Exception\ModuleNotFoundException;
8
use Jackal\ImageMerge\Model\Image;
9
use Jackal\ImageMerge\Utils\ColorUtils;
10
11
/**
12
 * Class TextAssetCommand
13
 * @package Jackal\ImageMerge\Command\Asset
14
 */
15
class TextAssetCommand extends AbstractCommand
16
{
17
    /**
18
     * @param Image $image
19
     * @return mixed
20
     * @throws ModuleNotFoundException
21
     */
22
    public function execute(Image $image)
23
    {
24
        /** @var TextCommandOption $options */
25
        $options = $this->options;
26
27
        $color = ColorUtils::colorIdentifier($image->getResource(),
28
            $options->getColor()
29
        );
30
31
        $fontPixel = round($options->getText()->getFontSize() * 0.75);
32
33
        if (!function_exists('imagettftext')) {
34
            throw new ModuleNotFoundException('function imagettftext not installed');
35
        }
36
37
        imagettftext($image->getResource(), $fontPixel, 0,
38
            $options->getCoordinate1()->getX(),
39
            $options->getCoordinate1()->getY() + $fontPixel,
0 ignored issues
show
Bug introduced by
$options->getCoordinate1()->getY() + $fontPixel of type double is incompatible with the type integer expected by parameter $y of imagettftext(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
            /** @scrutinizer ignore-type */ $options->getCoordinate1()->getY() + $fontPixel,
Loading history...
40
            $color, $options->getText()->getFont(), $options->getText()->getText());
41
42
        return $image;
43
    }
44
}
45