Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

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.

Style_Caps_Fix   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 62
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2017 Peter Putzer.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License along
18
 *  with this program; if not, write to the Free Software Foundation, Inc.,
19
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 *
21
 *  ***
22
 *
23
 *  @package mundschenk-at/php-typography
24
 *  @license http://www.gnu.org/licenses/gpl-2.0.html
25
 */
26
27
namespace PHP_Typography\Fixes\Node_Fixes;
28
29
use PHP_Typography\DOM;
30
use PHP_Typography\Settings;
31
use PHP_Typography\U;
32
33
/**
34
 * Wraps words of all caps (may include numbers) in <span class="caps"> if enabled.
35
 *
36
 * Call before style_numbers().Only call if you are certain that no html tags have been
37
 * injected containing capital letters.
38
 *
39
 * @author Peter Putzer <[email protected]>
40
 *
41
 * @since 5.0.0
42
 */
43
class Style_Caps_Fix extends Simple_Style_Fix {
44
	/*
45
	// \p{Lu} equals upper case letters and should match non english characters; since PHP 4.4.0 and 5.1.0
46
	// for more info, see http://www.regextester.com/pregsyntax.html#regexp.reference.unicode
47
	$this->components[ Settings::STYLE_CAPS ]  = '
48
	(?<![\w\-_'.U::ZERO_WIDTH_SPACE.U::SOFT_HYPHEN.'])
49
	# negative lookbehind assertion
50
	(
51
	(?:							# CASE 1: " 9A "
52
	[0-9]+					# starts with at least one number
53
	\p{Lu}					# must contain at least one capital letter
54
	(?:\p{Lu}|[0-9]|\-|_|'.U::ZERO_WIDTH_SPACE.'|'.U::SOFT_HYPHEN.')*
55
	# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
56
	)
57
	|
58
	(?:							# CASE 2: " A9 "
59
	\p{Lu}					# starts with capital letter
60
	(?:\p{Lu}|[0-9])		# must be followed a number or capital letter
61
	(?:\p{Lu}|[0-9]|\-|_|'.U::ZERO_WIDTH_SPACE.'|'.U::SOFT_HYPHEN.')*
62
	# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
63
64
	)
65
	)
66
	(?![\w\-_'.U::ZERO_WIDTH_SPACE.U::SOFT_HYPHEN.'])
67
	# negative lookahead assertion
68
	'; // required modifiers: x (multiline pattern) u (utf8)
69
	*/
70
71
	// Servers with PCRE compiled without "--enable-unicode-properties" fail at \p{Lu} by returning an empty string (this leaving the screen void of text
72
	// thus are testing this alternative.
73
	const REGEX = '/
74
		(?<![\w' . self::COMBINING_MARKS . ']) # negative lookbehind assertion
75
		(
76
			(?:							# CASE 1: " 9A "
77
				[0-9]+					# starts with at least one number
78
				(?:[' . self::COMBINING_MARKS . '])*
79
						                # may contain hyphens, underscores, zero width spaces, or soft hyphens,
80
				[A-ZÀ-ÖØ-Ý]				# but must contain at least one capital letter
81
				(?:[A-ZÀ-ÖØ-Ý]|[0-9]|[' . self::COMBINING_MARKS . '])*
82
										# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
83
			)
84
			|
85
			(?:							# CASE 2: " A9 "
86
				[A-ZÀ-ÖØ-Ý]				# starts with capital letter
87
				(?:[A-ZÀ-ÖØ-Ý]|[0-9])	# must be followed a number or capital letter
88
				(?:[A-ZÀ-ÖØ-Ý]|[0-9]|[' . self::COMBINING_MARKS . '])*
89
										# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
90
			)
91
		)
92
		(?![\w' . self::COMBINING_MARKS . ']) # negative lookahead assertion
93
	/Sxu';
94
95
	const COMBINING_MARKS = '\-_' . U::HYPHEN . U::SOFT_HYPHEN . U::ZERO_WIDTH_SPACE; // Needs to be part of character class.
96
97
	/**
98
	 * Creates a new node fix with a class.
99
	 *
100
	 * @param string $css_class       HTML class used in markup.
101
	 * @param bool   $feed_compatible Optional. Default false.
102
	 */
103 12
	public function __construct( $css_class, $feed_compatible = false ) {
104 12
		parent::__construct( self::REGEX, Settings::STYLE_CAPS, $css_class, $feed_compatible );
105 12
	}
106
}
107