100% of 157OPs |
76% of 70Lines |
88% of 8Branches |
100% of 6Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\scripts\tagger::__construct() | 18 | 100% | 3 | 100% | 1 | 0% | 1 | 100% |
mageekguy\atoum\scripts\tagger::setEngine() | 21 | 100% | 3 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\scripts\tagger::getEngine() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\scripts\tagger::setArgumentHandlers() | 101 | 100% | 61 | 72% | 4 | 100% | 2 | 100% |
mageekguy\atoum\scripts\tagger::doRun() | 11 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\scripts; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\scripts, |
8 |
mageekguy\atoum\exceptions, |
9 |
mageekguy\atoum\scripts\tagger |
10 |
; |
11 |
|
12 |
class tagger extends atoum\script |
13 |
{ |
14 |
protected $engine = null; |
15 |
|
16 |
public function __construct($name, atoum\adapter $adapter = null)100% |
17 |
{ |
18 |
parent::__construct($name, $adapter); |
19 |
|
20 |
$this->setEngine(); |
21 |
} |
22 |
|
23 |
public function setEngine(tagger\engine $engine = null)100% |
24 |
{ |
25 |
$this->engine = $engine ?: new scripts\tagger\engine(); |
26 |
|
27 |
$this->setArgumentHandlers(); |
28 |
|
29 |
return $this; |
30 |
} |
31 |
|
32 |
public function getEngine()100% |
33 |
{ |
34 |
return $this->engine; |
35 |
} |
36 |
|
37 |
protected function setArgumentHandlers()72% |
38 |
{ |
39 |
if ($this->engine !== null) |
40 |
{ |
41 |
$engine = $this->engine; |
42 |
|
43 |
$this |
44 |
->addArgumentHandler( |
45 |
function($script, $argument, $values) { |
46 |
if (sizeof($values) != 0) |
47 |
{ |
48 |
throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); |
49 |
} |
50 |
|
51 |
$script->help(); |
52 |
}, |
53 |
array('-h', '--help'), |
54 |
null, |
55 |
$this->locale->_('Display this help') |
56 |
) |
57 |
->addArgumentHandler( |
58 |
function($script, $argument, $version) use ($engine) { |
59 |
if (sizeof($version) != 1) |
60 |
{ |
61 |
throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); |
62 |
} |
63 |
|
64 |
$engine->setVersion(current($version)); |
65 |
}, |
66 |
array('-v', '--version'), |
67 |
'<string>', |
68 |
$this->locale->_('Use <string> as version value') |
69 |
) |
70 |
->addArgumentHandler( |
71 |
function($script, $argument, $versionPattern) use ($engine) { |
72 |
if (sizeof($versionPattern) != 1) |
73 |
{ |
74 |
throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); |
75 |
} |
76 |
|
77 |
$engine->setVersionPattern(current($versionPattern)); |
78 |
}, |
79 |
array('-vp', '--version-pattern'), |
80 |
'<regex>', |
81 |
$this->locale->_('Use <regex> to set version in source files') |
82 |
) |
83 |
->addArgumentHandler( |
84 |
function($script, $argument, $directory) use ($engine) { |
85 |
if (sizeof($directory) != 1) |
86 |
{ |
87 |
throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); |
88 |
} |
89 |
|
90 |
$engine->setSrcDirectory(current($directory)); |
91 |
}, |
92 |
array('-s', '--src-directory'), |
93 |
'<directory>', |
94 |
$this->locale->_('Use <directory> as source directory') |
95 |
) |
96 |
->addArgumentHandler( |
97 |
function($script, $argument, $directory) use ($engine) { |
98 |
if (sizeof($directory) != 1) |
99 |
{ |
100 |
throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); |
101 |
} |
102 |
|
103 |
$engine->setDestinationDirectory(current($directory)); |
104 |
}, |
105 |
array('-d', '--destination-directory'), |
106 |
'<directory>', |
107 |
$this->locale->_('Save tagged files in <directory>') |
108 |
) |
109 |
; |
110 |
} |
111 |
|
112 |
return $this; |
113 |
} |
114 |
|
115 |
protected function doRun()100% |
116 |
{ |
117 |
$this->engine->tagVersion(); |
118 |
|
119 |
return $this; |
120 |
} |
121 |
} |