Completed
Push — master ( 7cd28a...9f85d3 )
by Josh
04:13
created

AbstractRecursiveMatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A recurse() 0 4 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2019 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\RecursiveParser;
9
10
use s9e\TextFormatter\Configurator\RecursiveParser;
11
12
abstract class AbstractRecursiveMatcher implements MatcherInterface
13
{
14
	/**
15
	* @param  RecursiveParser $parser 
16
	* @return void
17
	*/
18 1
	public function __construct(RecursiveParser $parser)
19
	{
20 1
		$this->parser = $parser;
0 ignored issues
show
Bug introduced by
The property parser does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
	}
22
23
	/**
24
	* Parse given string and return its value
25
	*
26
	* @param  string $str
27
	* @param  string $restrict Pipe-separated list of allowed matches (ignored if empty)
28
	* @return mixed
29
	*/
30 1
	protected function recurse(string $str, string $restrict = '')
31
	{
32 1
		return $this->parser->parse($str, $restrict)['value'];
33
	}
34
}