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.

Smart_Area_Units_Fix   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 1
f 0
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 9 2
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2019 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\Settings;
31
use PHP_Typography\U;
32
33
/**
34
 * Applies smart area units (if enabled).
35
 *
36
 * @author Peter Putzer <[email protected]>
37
 *
38
 * @since 5.0.0
39
 */
40
class Smart_Area_Units_Fix extends Abstract_Node_Fix {
41
42
	const LENGTH_UNITS = '(?:p|µ|[mcdhkMGT])?m'; // Just metric for now.
43
	const NUMBER       = '[0-9]+(?:\.,)?[0-9]*';
44
	const WHITESPACE   = '\s*';
45
46
	const AREA_UNITS   = '/\b(' . self::NUMBER . ')(' . self::WHITESPACE . ')(' . self::LENGTH_UNITS . ')2\b/Su';
47
	const VOLUME_UNITS = '/\b(' . self::NUMBER . ')(' . self::WHITESPACE . ')(' . self::LENGTH_UNITS . ')3\b/Su';
48
49
	/**
50
	 * Apply the fix to a given textnode.
51
	 *
52
	 * @param \DOMText $textnode Required.
53
	 * @param Settings $settings Required.
54
	 * @param bool     $is_title Optional. Default false.
55
	 */
56 14
	public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) {
57 14
		if ( empty( $settings[ Settings::SMART_AREA_UNITS ] ) ) {
58 7
			return;
59
		}
60
61 7
		$textnode->data = \preg_replace(
62 7
			[ self::AREA_UNITS, self::VOLUME_UNITS ],
63 7
			[ '$1 $3²', '$1 $3³' ],
64 7
			$textnode->data
65
		);
66 7
	}
67
}
68