GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#2)
by Leszek
05:10
created

StringContainsIgnoringWhiteSpace   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 47
ccs 13
cts 15
cp 0.8667
rs 10
c 1
b 0
f 0
wmc 6
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A containsStringIgnoringWhiteSpace() 0 4 1
A evalSubstringOf() 0 4 1
A relationship() 0 4 1
A _stripSpace() 0 9 2
1
<?php
2
3
namespace WMDE\HamcrestHtml;
4
use Hamcrest\Text\SubstringMatcher;
5
6
class StringContainsIgnoringWhiteSpace extends SubstringMatcher
7
{
8 7
	public function __construct($substring)
9
	{
10 7
		parent::__construct($this->_stripSpace($substring));
11 7
	}
12
13
	/**
14
	 * Matches if value is a string that contains $substring consider all whitespace as single space
15
	 */
16 7
	public static function containsStringIgnoringWhiteSpace($substring)
17
	{
18 7
		return new self($substring);
19
	}
20
21
	/**
22
	 * @param \DOMElement $item
23
	 *
24
	 * @return bool
25
	 */
26 7
	protected function evalSubstringOf($item)
27
	{
28 7
		return (false !== strpos($this->_stripSpace((string) $item), $this->_substring));
29
	}
30
31
	protected function relationship()
32
	{
33
		return 'containing';
34
	}
35
36
	/**
37
	 * Copied from IsEqualIgnoringWhiteSpace
38
	 *
39
	 * @param $string
40
	 *
41
	 * @return string
42
	 */
43 8
	private function _stripSpace($string)
44
	{
45 8
		$parts = preg_split("/[\r\n\t ]+/", $string);
46 8
		foreach ($parts as $i => $part) {
47 8
			$parts[$i] = trim($part, " \r\n\t");
48 8
		}
49
50 8
		return trim(implode(' ', $parts), " \r\n\t");
51
	}
52
}
53