Completed
Push — master ( d2591b...99069a )
by Andrii
06:43
created

License   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 50
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setLicense() 0 4 1
A getTemplate() 0 4 1
A getLicense() 0 8 2
A getUrl() 0 6 2
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