Passed
Push — master ( e7af6a...141cd5 )
by Joschi
02:15
created

ViewportFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 54
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 11 1
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\Infrastructure;
38
39
use ChrisKonnertz\StringCalc\Support\StringHelperInterface;
40
use ChrisKonnertz\StringCalc\Symbols\AbstractFunction;
41
use Jkphl\Respimgcss\Domain\Contract\AbsoluteLengthInterface;
42
43
/**
44
 * Viewport calculation function
45
 *
46
 * @package    Jkphl\Respimgcss
47
 * @subpackage Jkphl\Respimgcss\Application\Model
48
 */
49
class ViewportFunction extends AbstractFunction
50
{
51
    /**
52
     * Viewport width
53
     *
54
     * @var AbsoluteLengthInterface
55
     */
56
    protected $viewport;
57
    /**
58
     * @inheritdoc
59
     */
60
    protected $identifiers = ['viewport'];
61
62
    /**
63
     * AbstractSymbol constructor.
64
     *
65
     * @param StringHelperInterface $stringHelper String helper
66
     * @param AbsoluteLengthInterface $viewport   Viewport width
67
     *
68
     * @throws \ChrisKonnertz\StringCalc\Exceptions\InvalidIdentifierException
69
     */
70 10
    public function __construct(StringHelperInterface $stringHelper, AbsoluteLengthInterface $viewport)
71
    {
72 10
        parent::__construct($stringHelper);
73 10
        $this->viewport = $viewport;
74
//        $this->name = rand();
75
//        echo 'init '.$this->name;
76
//        try {
77
//        	throw new \Exception;
78
//        } catch (\Exception $e) {
79
//        	echo $e->getMessage().PHP_EOL.$e->getTraceAsString().PHP_EOL;
80
//        }
81
//        echo PHP_EOL.PHP_EOL;
82
//        print_r($this->viewport);
83 10
    }
84
85
    /**
86
     * Execute the function
87
     *
88
     * @param  int|float[] $arguments
89
     *
90
     * @return int|float Viewport width
91
     */
92 3
    public function execute(array $arguments)
93
    {
94
//        echo 'exec '.$this->name;
95
//        try {
96
//            throw new \Exception;
97
//        } catch (\Exception $e) {
98
//            echo $e->getMessage().PHP_EOL.$e->getTraceAsString().PHP_EOL;
99
//        }
100
//        print_r($this->viewport);
101
//        echo PHP_EOL.PHP_EOL;
102 3
        return $this->viewport->getValue();
103
    }
104
}