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.

Identifier   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 82
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A __toString() 0 4 1
A generate() 0 4 1
A slag() 0 9 1
A setDelimiter() 0 4 1
A getDelimiter() 0 4 1
1
<?php
2
/**
3
 * Util
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\Util;
10
11
/**
12
 * Identifier util for unified resource generation.
13
 *
14
 * <code>
15
 * $identifier = new class Identifier(1, '23', 123, 'ZZ-TOP', 'Some_Class_name');
16
 *
17
 * print $identifier; // --> '1_23_123_zz_top_some_class_name'
18
 *
19
 * $identifier->setDelimiter('/');
20
 *
21
 * print $identifier->generate(); // --> '1/23/123/zz/top/some/class/name'
22
 * </code>
23
 *
24
 * @package Util
25
 * @author  Gjero Krsteski <[email protected]>
26
 */
27
class Identifier
28
{
29
    /**
30
     * @var string
31
     */
32
    protected static $delimiter = '_';
33
34
    /**
35
     * @var array
36
     */
37
    protected $args = array();
38
39
    /**
40
     * Create a new Cache Identifier based on the given parameters.
41
     * Integer and string but not array and objects.
42
     *
43
     * @throws \BadMethodCallException If no identifiers received.
44
     */
45
    public function __construct()
46
    {
47
        $args = func_get_args();
48
49
        if (!count($args) || !implode('', $args)) {
50
            throw new \BadMethodCallException('No identifiers received');
51
        }
52
53
        $this->args = $args;
54
    }
55
56
    /**
57
     * Return String representation of this Cache Identifier.
58
     *
59
     * @return string
60
     */
61
    public function __toString()
62
    {
63
        return $this->generate();
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function generate()
70
    {
71
        return (string)$this->slag();
72
    }
73
74
    /**
75
     * Slags the identifier.
76
     *
77
     * @return string
78
     */
79
    protected function slag()
80
    {
81
        $ident = str_replace('-', '_', implode(self::getDelimiter(), $this->args));
82
        $ident = str_replace('_', self::getDelimiter(), $ident);
83
        $ident = trim($ident);
84
        $ident = str_replace(' ', '', $ident);
85
86
        return strip_tags(strtolower($ident));
87
    }
88
89
    /**
90
     * Set the delimiter used to create a Cache Identifier.
91
     *
92
     * @param string $delimiter The delimiter character.
93
     */
94
    public function setDelimiter($delimiter)
95
    {
96
        self::$delimiter = $delimiter;
97
    }
98
99
    /**
100
     * Get the delimiter used to create a Cache Identifier.
101
     *
102
     * @return string
103
     */
104
    public function getDelimiter()
105
    {
106
        return self::$delimiter;
107
    }
108
}
109