Completed
Branch TemplateInspector (5726eb)
by Josh
09:25
created

ManageParagraphs   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 37
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B generateBooleanRules() 0 16 5
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2017 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\RulesGenerators;
9
10
use s9e\TextFormatter\Configurator\Helpers\TemplateInspector;
11
use s9e\TextFormatter\Configurator\RulesGenerators\Interfaces\BooleanRulesGenerator;
12
13
class ManageParagraphs implements BooleanRulesGenerator
14
{
15
	/**
16
	* @var TemplateInspector
17
	*/
18
	protected $p;
19
20
	/**
21
	* Constructor
22
	*
23
	* Prepares the TemplateInspector for <p/>
24
	*/
25 4
	public function __construct()
26
	{
27 4
		$this->p = new TemplateInspector('<p><xsl:apply-templates/></p>');
28 4
	}
29
30
	/**
31
	* {@inheritdoc}
32
	*/
33 4
	public function generateBooleanRules(TemplateInspector $src)
34
	{
35 4
		$rules = [];
36
37 4
		if ($src->allowsChild($this->p) && $src->isBlock() && !$this->p->closesParent($src))
0 ignored issues
show
Bug introduced by
The method isBlock() does not exist on s9e\TextFormatter\Config...lpers\TemplateInspector. Did you maybe mean elementIsBlock()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
		{
39
			$rules['createParagraphs'] = true;
40
		}
41
42 3
		if ($src->closesParent($this->p))
43
		{
44 2
			$rules['breakParagraph'] = true;
45
		}
46
47 3
		return $rules;
48
	}
49
}