Passed
Push — master ( 297d0e...a57d9e )
by Joschi
02:13
created

ViewportLength::isAbsolute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * responsive-images-css
5
 *
6
 * @category   Jkphl
7
 * @package    Jkphl\Respimgcss
8
 * @subpackage Jkphl\Respimgcss\Application\Model
9
 * @author     Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright  Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license    http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Jkphl\Respimgcss\Application\Model;
38
39
use ChrisKonnertz\StringCalc\Parser\Nodes\ContainerNode;
40
use Jkphl\Respimgcss\Application\Contract\UnitLengthInterface;
41
use Jkphl\Respimgcss\Application\Service\LengthNormalizerService;
42
43
/**
44
 * Viewport length
45
 *
46
 * @package    Jkphl\Respimgcss
47
 * @subpackage Jkphl\Respimgcss\Application\Model
48
 */
49
class ViewportLength implements UnitLengthInterface
50
{
51
    /**
52
     * Calculation nodes
53
     *
54
     * @var ContainerNode
55
     */
56
    protected $calculation;
57
    /**
58
     * Length normalizer service
59
     *
60
     * @var LengthNormalizerService
61
     */
62
    protected $lengthNormalizerService;
63
64
    /**
65
     * Absolute length constructor
66
     *
67
     * @param ContainerNode $calculation                       Calculation nodes
68
     * @param LengthNormalizerService $lengthNormalizerService Length normalizer service
69
     */
70
    public function __construct(ContainerNode $calculation, LengthNormalizerService $lengthNormalizerService)
71
    {
72
        $this->lengthNormalizerService = $lengthNormalizerService;
73
        $this->calculation             = $calculation;
74
    }
75
76
    /**
77
     * Return the length value
78
     *
79
     * @return float Length value
80
     */
81
    public function getValue(): float
82
    {
83
        return 999;
84
    }
85
86
    /**
87
     * Return the lengths unit
88
     *
89
     * @return string Unit
90
     */
91
    public function getUnit(): string
92
    {
93
        return UnitLengthInterface::UNIT_PIXEL;
94
    }
95
96
    /**
97
     * Return the original value (in source units)
98
     *
99
     * @return float Original value (in source units)
100
     */
101
    public function getOriginalValue(): float
102
    {
103
        return 999;
104
    }
105
106
    /**
107
     * Return whether this is an absolute length
108
     *
109
     * @return boolean Absolute length
110
     */
111
    public function isAbsolute(): bool
112
    {
113
        return false;
114
    }
115
116
    /**
117
     * Return the serialized length
118
     *
119
     * @return string Serialized length
120
     */
121
    public function __toString(): string
122
    {
123
        return strval($this->getValue());
124
    }
125
}