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.

Dash_Style::get_styled_dashes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
ccs 8
cts 8
cp 1
cc 2
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 *  This file is part of PHP-Typography.
4
 *
5
 *  Copyright 2017-2019 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\Settings;
28
29
use PHP_Typography\Settings;
30
use PHP_Typography\U;
31
32
/**
33
 * A factory class for different dash styles.
34
 *
35
 * @author Peter Putzer <[email protected]>
36
 *
37
 * @since 5.0.0
38
 */
39
abstract class Dash_Style {
40
41
	/**
42
	 * Traditional US dash style (using em dashes).
43
	 */
44
	const TRADITIONAL_US = 'traditionalUS';
45
46
	/**
47
	 * "International" dash style (using en dashes).
48
	 */
49
	const INTERNATIONAL = 'international';
50
51
	/**
52
	 * "International" dash style (using en dashes), Duden-style (without hair spaces).
53
	 */
54
	const INTERNATIONAL_NO_HAIR_SPACES = 'internationalNoHairSpaces';
55
56
	/**
57
	 * Available dash styles.
58
	 *
59
	 * @var array
60
	 */
61
	private static $styles = [
62
		self::TRADITIONAL_US               => [
63
			self::_PARENTHETICAL       => U::EM_DASH,
64
			self::_PARENTHETICAL_SPACE => U::THIN_SPACE,
65
			self::_INTERVAL            => U::EN_DASH,
66
			self::_INTERVAL_SPACE      => U::THIN_SPACE,
67
		],
68
		self::INTERNATIONAL                => [
69
			self::_PARENTHETICAL       => U::EN_DASH,
70
			self::_PARENTHETICAL_SPACE => ' ',
71
			self::_INTERVAL            => U::EN_DASH,
72
			self::_INTERVAL_SPACE      => U::HAIR_SPACE,
73
		],
74
		self::INTERNATIONAL_NO_HAIR_SPACES => [
75
			self::_PARENTHETICAL       => U::EN_DASH,
76
			self::_PARENTHETICAL_SPACE => ' ',
77
			self::_INTERVAL            => U::EN_DASH,
78
			self::_INTERVAL_SPACE      => '',
79
		],
80
	];
81
82
	/**
83
	 * Interval dash.
84
	 *
85
	 * @internal
86
	 *
87
	 * @var int
88
	 */
89
	const _INTERVAL = 0;
90
91
	/**
92
	 * Interval dash space.
93
	 *
94
	 * @internal
95
	 *
96
	 * @var int
97
	 */
98
	const _INTERVAL_SPACE = 1;
99
100
	/**
101
	 * Parenthetical dash.
102
	 *
103
	 * @internal
104
	 *
105
	 * @var int
106
	 */
107
	const _PARENTHETICAL = 2;
108
109
	/**
110
	 * Parenthetical dash space.
111
	 *
112
	 * @internal
113
	 *
114
	 * @var int
115
	 */
116
	const _PARENTHETICAL_SPACE = 3;
117
118
	/**
119
	 * Creates a new Dashes object in the given style.
120
	 *
121
	 * @since 6.5.0 The $settings parameter has been deprecated.
122
	 *
123
	 * @param string   $style    The dash style.
124
	 * @param Settings $settings The current settings.
125
	 *
126
	 * @return Dashes|null Returns null in case of an invalid $style parameter.
127
	 */
128 4
	public static function get_styled_dashes( $style, /** Currently unused. @scrutinizer ignore-unused */ Settings $settings ) {
129 4
		if ( isset( self::$styles[ $style ] ) ) {
130 2
			return new Simple_Dashes(
131 2
				self::$styles[ $style ][ self::_PARENTHETICAL ],
132 2
				self::$styles[ $style ][ self::_PARENTHETICAL_SPACE ],
133 2
				self::$styles[ $style ][ self::_INTERVAL ],
134 2
				self::$styles[ $style ][ self::_INTERVAL_SPACE ]
135
			);
136
		}
137
138 2
		return null;
139
	}
140
}
141