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

AbstractRecursiveMatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
}