Completed
Push — master ( 6ce1e6...80cd7b )
by Andrii
08:55
created

License::getUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

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