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.
Completed
Push — master ( cb7865...06cb05 )
by Rick
02:33
created

Alpha   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 0
dl 47
loc 47
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 2
A validate() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2015 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/validator/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Validator\Rule;
10
11
use Particle\Validator\Rule;
12
13
/**
14
 * This rule checks if the value consists solely out of alphabetic characters.
15
 *
16
 * @package Particle\Validator\Rule
17
 */
18 View Code Duplication
class Alpha extends Regex
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /**
21
     * A constant that will be used for the error message when the value contains non-alphabetic characters.
22
     */
23
    const NOT_ALPHA = 'Alpha::NOT_ALPHA';
24
25
    /**
26
     * A constant indicated spaces are allowed.
27
     */
28
    const ALLOW_SPACES = true;
29
30
    /**
31
     * A constant indicating spaces are *not* allowed.
32
     */
33
    const DISALLOW_SPACES = false;
34
35
    /**
36
     * The message templates which can be returned by this validator.
37
     *
38
     * @var array
39
     */
40
    protected $messageTemplates = [
41
        self::NOT_ALPHA => '{{ name }} may only consist out of alphabetic characters'
42
    ];
43
44
    /**
45
     * Construct the Alpha rule.
46
     *
47
     * @param bool $allowWhitespace
48
     */
49 7
    public function __construct($allowWhitespace)
50
    {
51 7
        $this->regex = $allowWhitespace ? '~^[\p{L}\s]*$~iu' : '~^[\p{L}]*$~ui';
52 7
    }
53
54
    /**
55
     * Checks whether $value consists solely out of alphabetic characters.
56
     *
57
     * @param mixed $value
58
     * @return bool
59
     */
60 7
    public function validate($value)
61
    {
62 7
        return $this->match($this->regex, $value, self::NOT_ALPHA);
63
    }
64
}
65