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

CachingRecursiveParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
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
class CachingRecursiveParser extends RecursiveParser
13
{
14
	/**
15
	* @var array
16
	*/
17
	protected $cache;
18
19
	/**
20
	* {@inheritdoc}
21
	*/
22 2
	public function parse(string $str, string $restrict = '')
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
23
	{
24 2
		if (!isset($this->cache[$restrict][$str]))
25
		{
26 2
			$this->cache[$restrict][$str] = parent::parse($str, $restrict);
27
		}
28
29 2
		return $this->cache[$restrict][$str];
30
	}
31
32
	/**
33
	* {@inheritdoc}
34
	*/
35 2
	public function setMatchers(array $matchers): void
36
	{
37 2
		$this->cache = [];
38 2
		parent::setMatchers($matchers);
39
	}
40
}