Image   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 54
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getWidth() 0 4 2
A getHeight() 0 4 2
A returnObject() 0 4 1
A isValueConsideredNull() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\GuidedImage\Demand;
6
7
use ReliqArts\GuidedImage\Contract\ImageDemand;
8
9
abstract class Image implements ImageDemand
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $width;
15
16
    /**
17
     * @var mixed
18
     */
19
    private $height;
20
21
    /**
22
     * @var mixed
23
     */
24
    private $returnObject;
25
26
    /**
27
     * Image constructor.
28
     *
29
     * @param mixed $width
30
     * @param mixed $height
31
     * @param mixed $returnObject
32
     */
33
    public function __construct($width, $height, $returnObject = null)
34
    {
35
        $this->width = $width;
36
        $this->height = $height;
37
        $this->returnObject = $returnObject;
38
    }
39
40
    final public function getWidth(): ?int
41
    {
42
        return $this->isValueConsideredNull($this->width) ? null : (int)$this->width;
43
    }
44
45
    final public function getHeight(): ?int
46
    {
47
        return $this->isValueConsideredNull($this->height) ? null : (int)$this->height;
48
    }
49
50
    final public function returnObject(): bool
51
    {
52
        return !$this->isValueConsideredNull($this->returnObject);
53
    }
54
55
    /**
56
     * @param mixed $value
57
     */
58
    final public function isValueConsideredNull($value): bool
59
    {
60
        return in_array($value, static::NULLS, true);
61
    }
62
}
63