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.

HideFor::applyModification()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * File containing the HideFor class
4
 *
5
 * This file is part of the MediaWiki skin Chameleon.
6
 *
7
 * @copyright 2013 - 2014, Stephan Gambke
8
 * @license   GNU General Public License, version 3 (or any later version)
9
 *
10
 * The Chameleon skin is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by the Free
12
 * Software Foundation, either version 3 of the License, or (at your option) any
13
 * later version.
14
 *
15
 * The Chameleon skin is distributed in the hope that it will be useful, but
16
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18
 * details.
19
 *
20
 * You should have received a copy of the GNU General Public License along
21
 * with this program. If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 * @file
24
 * @ingroup Skins
25
 */
26
27
namespace Skins\Chameleon\Components\Modifications;
28
use Skins\Chameleon\Components\Silent;
29
use Skins\Chameleon\PermissionsHelper;
30
31
/**
32
 * HideFor class
33
 *
34
 * @author Stephan Gambke
35
 * @since 1.1
36
 * @ingroup Skins
37
 */
38 View Code Duplication
class HideFor extends Modification {
39
40
	private $permissionsHelper;
41
42
	/**
43
	 * This method checks if the restriction is applicable and if necessary
44
	 * replaces the decorated component by a Silent component
45
	 */
46 2
	protected function applyModification() {
47 2
		if ( $this->isHidden() ) {
48 2
			$c = $this->getComponent();
49 2
			$this->setComponent( new Silent( $c->getSkinTemplate(), $c->getDomElement(), $c->getIndent() ) );
50 2
		}
51 2
	}
52
53
	/**
54
	 * @return bool
55
	 */
56 2
	private function isHidden() {
57 2
		$p = $this->getPermissionsHelper();
58 2
		return $p->userHasGroup( 'group' ) && $p->userHasPermission( 'permission' ) && $p->pageIsInNamespace( 'namespace' );
59
	}
60
61
	/**
62
	 * @return PermissionsHelper
63
	 */
64 2
	private function getPermissionsHelper() {
65 2
		if ( $this->permissionsHelper === null ) {
66 2
			$this->permissionsHelper = new PermissionsHelper( $this->getSkinTemplate()->getSkin(), $this->getDomElementOfModification(), true );
67 2
		}
68
69 2
		return $this->permissionsHelper;
70
	}
71
}