1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Jira-CLI library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/jira-cli |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\JiraCLI; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use chobie\Jira\Api; |
15
|
|
|
use chobie\Jira\Api\Authentication\Basic; |
16
|
|
|
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor; |
17
|
|
|
use ConsoleHelpers\JiraCLI\Cache\CacheFactory; |
18
|
|
|
use ConsoleHelpers\JiraCLI\Issue\BackportableIssueCloner; |
19
|
|
|
use ConsoleHelpers\JiraCLI\Issue\ChangeLogIssueCloner; |
20
|
|
|
|
21
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function __construct(array $values = array()) |
28
|
|
|
{ |
29
|
|
|
parent::__construct($values); |
30
|
|
|
|
31
|
|
|
$this['app_name'] = 'Jira-CLI'; |
32
|
|
|
$this['app_version'] = '@git-version@'; |
33
|
|
|
|
34
|
|
|
$this['working_directory_sub_folder'] = '.jira-cli'; |
35
|
|
|
|
36
|
|
|
$this['config_defaults'] = array( |
37
|
|
|
'jira.url' => '', |
38
|
|
|
'jira.username' => '', |
39
|
|
|
'jira.password' => '', |
40
|
|
|
'cache.provider' => '', |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$this['cache'] = function ($c) { |
|
|
|
|
44
|
|
|
/** @var ConfigEditor $config_editor */ |
45
|
|
|
$config_editor = $c['config_editor']; |
46
|
|
|
$cache_provider = $config_editor->get('cache.provider'); |
47
|
|
|
|
48
|
|
|
$cache_factory = new CacheFactory('jira_url:' . $config_editor->get('jira.url')); |
49
|
|
|
|
50
|
|
|
return $cache_factory->create('chain', array('array', $cache_provider)); |
51
|
|
|
}; |
52
|
|
|
|
53
|
|
|
$this['jira_api'] = function ($c) { |
54
|
|
|
/** @var ConfigEditor $config_editor */ |
55
|
|
|
$config_editor = $c['config_editor']; |
56
|
|
|
|
57
|
|
|
$authentication = new Basic( |
58
|
|
|
$config_editor->get('jira.username'), |
59
|
|
|
$config_editor->get('jira.password') |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
return new Api( |
63
|
|
|
$config_editor->get('jira.url'), |
64
|
|
|
$authentication |
65
|
|
|
); |
66
|
|
|
}; |
67
|
|
|
|
68
|
|
|
$this['backportable_issue_cloner'] = function ($c) { |
69
|
|
|
return new BackportableIssueCloner($c['jira_api']); |
70
|
|
|
}; |
71
|
|
|
|
72
|
|
|
$this['changelog_issue_cloner'] = function ($c) { |
73
|
|
|
return new ChangeLogIssueCloner($c['jira_api']); |
74
|
|
|
}; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.