Completed
Push — master ( e55fb5...e250e6 )
by Andrii
05:38
created

LicenseController::getUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * License plugin for HiDev
5
 *
6
 * @link      https://github.com/hiqdev/hidev-license
7
 * @package   hidev-license
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\license\controllers;
13
14
use hidev\helpers\Helper;
15
16
/**
17
 * Goal for LICENSE generation.
18
 */
19
class LicenseController extends \hidev\controllers\TemplateController
20
{
21
    /**
22
     * The license.
23
     * @var string
24
     */
25
    protected $_license;
26
27
    /**
28
     * Set license.
29
     * @param string $value
30
     */
31 4
    public function setLicense($value)
32
    {
33 4
        $this->_license = $value;
34 4
    }
35
36
    /**
37
     * Get license.
38
     * @return string
39
     */
40 4
    public function getLicense()
41
    {
42 4
        if ($this->_license === null) {
43
            $this->_license = $this->takeGoal('package')->getLicense();
44
        }
45
46 4
        return $this->_license;
47
    }
48
49
    /**
50
     * Get license template.
51
     * @return string
52
     */
53 1
    public function getTemplate()
54
    {
55 1
        return 'licenses/' . Helper::id2camel($this->getLicense()) . '.twig';
56
    }
57
58
    /**
59
     * Returns URL to license description.
60
     * @return string
61
     */
62 1
    public function getUrl()
63
    {
64 1
        return $this->getLicense() === 'proprietary'
65 1
            ? 'https://en.wikipedia.org/wiki/Proprietary_software'
66 1
            : 'http://choosealicense.com/licenses/' . Helper::camel2id($this->getLicense());
67
    }
68
}
69