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.

Cache::get_hyphenator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
ccs 4
cts 4
cp 1
cc 2
nc 2
nop 1
crap 2
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\Hyphenator;
28
29
use PHP_Typography\Hyphenator;
30
31
/**
32
 * Per-language cache of Hyphenator instances.
33
 *
34
 * @since 5.2.0
35
 *
36
 * @author Peter Putzer <[email protected]>
37
 */
38
class Cache {
39
40
	/**
41
	 * An array of Hyphenator instances indexed by language.
42
	 *
43
	 * @var array
44
	 */
45
	protected $cache = [];
46
47
	/**
48
	 * A flag that indicated that the cache has changed since creation/deserialization.
49
	 *
50
	 * @var bool
51
	 */
52
	protected $changed = false;
53
54
	/**
55
	 * Ignore the "changed" flag during serialization.
56
	 *
57
	 * @return array
58
	 */
59 1
	public function __sleep() {
60
		return [
61 1
			'cache',
62
		];
63
	}
64
65
	/**
66
	 * Caches a Hyphenator instance.
67
	 *
68
	 * @param string     $lang       A language code.
69
	 * @param Hyphenator $hyphenator The object to cache.
70
	 */
71 1
	public function set_hyphenator( $lang, Hyphenator $hyphenator ) {
72 1
		$this->cache[ $lang ] = $hyphenator;
73 1
		$this->changed        = true;
74 1
	}
75
76
	/**
77
	 * Retrieves a cached Hyphenator.
78
	 *
79
	 * @param string $lang A language code.
80
	 *
81
	 * @return Hyphenator|null
82
	 */
83 1
	public function get_hyphenator( $lang ) {
84 1
		if ( isset( $this->cache[ $lang ] ) ) {
85 1
			return $this->cache[ $lang ];
86
		}
87
88 1
		return null;
89
	}
90
91
	/**
92
	 * Determines whether the cache (not its content) has been modified since
93
	 * instance creatino (or deserialization).
94
	 *
95
	 * @return bool
96
	 */
97 1
	public function has_changed() {
98 1
		return $this->changed;
99
	}
100
}
101