Completed
Push — master ( 28256c...92a7d3 )
by Peter
20:38
created

StaticConstantMatcher::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2.003

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 14
ccs 10
cts 11
cp 0.9091
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
crap 2.003
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL, Commercial license.
5
 *
6
 * @package maslosoft/addendum
7
 * @licence AGPL, Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes)
9
 * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes)
10
 * @copyright Copyright (c) Jan Suchal (Original version, builder, parser)
11
 * @link http://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Matcher;
16
17
use Maslosoft\Addendum\Interfaces\Matcher\MatcherInterface;
18
use Maslosoft\Addendum\Matcher\Helpers\Processor;
19
20
class StaticConstantMatcher extends RegexMatcher implements MatcherInterface
21
{
22
23 27
	public function __construct()
24
	{
25 27
		parent::__construct('([\w\\\]+::\w+)');
26 27
	}
27
28 3
	protected function process($matches)
29
	{
30 3
		$value = $matches[1];
31 3
		$parts = explode('::', $value);
32 3
		$className = $parts[0];
33 3
		$constName = $parts[1];
34 3
		$className = Processor::process($this, $className);
35 3
		$value = sprintf('%s::%s', $className, $constName);
36 3
		if (!defined($value))
37 3
		{
38
			return false;
39
		}
40 3
		return constant($value);
41
	}
42
43
}
44