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

LicenseController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 50
ccs 12
cts 14
cp 0.8571
rs 10

4 Methods

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