Completed
Push — master ( c1ded8...e35cdb )
by
unknown
06:05
created

ImgixUrlViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
namespace Aoe\Imgix\ViewHelpers;
3
4
use Aoe\Imgix\TYPO3\Configuration;
5
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
6
7
class ImgixUrlViewHelper extends AbstractViewHelper
8
{
9
10
    /**
11
     * @var Configuration
12
     */
13
    private $configuration;
14
15
    /**
16
     * @param Configuration $configuration
17
     */
18 2
    public function __construct(Configuration $configuration)
19
    {
20 2
        $this->configuration = $configuration;
21 2
    }
22
23
    /**
24
     * @return void
25
     */
26
    public function initializeArguments()
27
    {
28
        parent::initializeArguments();
29
        $this->registerArgument('imageUrl', 'string', 'URL to image file', true);
30
    }
31
32
    /**
33
     * @return string
34
     */
35 2
    public function render()
36
    {
37 2
        if (false === $this->configuration->isEnabled()) {
38 1
            return $this->arguments['imageUrl'];
39
        }
40 1
        return '//' . $this->configuration->getHost() . '/' . $this->arguments['imageUrl'];
41
    }
42
}
43