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.

Simple_Style_Fix   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 56
rs 10
c 0
b 0
f 0
ccs 10
cts 10
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A apply_internal() 0 6 2
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2017-2018 Peter Putzer.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify 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\RE;
31
use PHP_Typography\Settings;
32
33
/**
34
 * An abstract base class for adding simple wrapping spans to style certain elements.
35
 *
36
 * @author Peter Putzer <[email protected]>
37
 *
38
 * @since 5.0.0
39
 */
40
abstract class Simple_Style_Fix extends Classes_Dependent_Fix {
41
42
	/**
43
	 * The setting string used to enable/disable the fix (e.g. 'styleAmpersands').
44
45
	 * @var string
46
	 */
47
	protected $settings_switch;
48
49
	/**
50
	 * The regular expressions used to match the text that should be wrapped in spans.
51
	 *
52
	 * It must contain a single matching expression.
53
	 *
54
	 * @var string
55
	 */
56
	protected $regex;
57
58
	/**
59
	 * The css class name to include in the generated markup.
60
	 *
61
	 * @var string
62
	 */
63
	protected $css_class;
64
65
	/**
66
	 * Creates a new node fix with a class.
67
	 *
68
	 * @param string $regex           Regular expression to match the text.
69
	 * @param string $settings_switch On/off switch for fix.
70
	 * @param string $css_class       HTML class used in markup.
71
	 * @param bool   $feed_compatible Optional. Default false.
72
	 */
73 1
	public function __construct( $regex, $settings_switch, $css_class, $feed_compatible = false ) {
74 1
		parent::__construct( $css_class, $feed_compatible );
75
76 1
		$this->regex           = $regex;
77 1
		$this->settings_switch = $settings_switch;
78 1
		$this->css_class       = $css_class;
79 1
	}
80
81
	/**
82
	 * Apply the fix to a given textnode.
83
	 *
84
	 * @since 6.0.0 The method was accidentally made public and is now protected.
85
	 *
86
	 * @param \DOMText $textnode Required.
87
	 * @param Settings $settings Required.
88
	 * @param bool     $is_title Optional. Default false.
89
	 */
90 2
	protected function apply_internal( \DOMText $textnode, Settings $settings, $is_title = false ) {
91 2
		if ( empty( $settings[ $this->settings_switch ] ) ) {
92 1
			return;
93
		}
94
95 1
		$textnode->data = \preg_replace( $this->regex, RE::escape_tags( "<span class=\"{$this->css_class}\">\$1</span>" ), $textnode->data );
96 1
	}
97
}
98