Completed
Push — master ( 528bde...9b95d3 )
by Andrii
11:01
created

LicenseController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

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
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, 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
    public function setLicense($value)
32
    {
33
        $this->_license = $value;
34
    }
35
36
    /**
37
     * Get license.
38
     * @return string
39
     */
40
    public function getLicense()
41
    {
42
        if ($this->_license === null) {
43
            $this->_license = $this->takeGoal('package')->getLicense();
44
        }
45
46
        return $this->_license;
47
    }
48
49
    /**
50
     * Get license template.
51
     * @return string
52
     */
53
    public function getTemplate()
54
    {
55
        return 'licenses/' . Helper::id2camel($this->getLicense()) . '.twig';
56
    }
57
58
    /**
59
     * Returns URL to license description.
60
     * @return string
61
     */
62
    public function getUrl()
63
    {
64
        return $this->getLicense() === 'proprietary'
65
            ? 'https://en.wikipedia.org/wiki/Proprietary_software'
66
            : 'http://choosealicense.com/licenses/' . Helper::camel2id($this->getLicense());
67
    }
68
}
69