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.

Token::setDelimiter()   B
last analyzed

Complexity

Conditions 6
Paths 20

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 16
cts 16
cp 1
rs 8.9457
c 0
b 0
f 0
cc 6
nc 20
nop 3
crap 6
1
<?php
2
/*
3
4
MIT License
5
Copyright 2013-2020 Zordius Chen. All Rights Reserved.
6
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
10
Origin: https://github.com/zordius/lightncandy
11
*/
12
13
/**
14
 * file to handle LightnCandy token
15
 *
16
 * @package    LightnCandy
17
 * @author     Zordius <[email protected]>
18
 */
19
20
namespace LightnCandy;
21
22
/**
23
 * LightnCandy Token handler
24
 */
25
class Token
26
{
27
    // RegExps
28
    const VARNAME_SEARCH = '/(\\[[^\\]]+\\]|[^\\[\\]\\.]+)/';
29
30
    // Positions of matched token
31
    const POS_LOTHER = 1;
32
    const POS_LSPACE = 2;
33
    const POS_BEGINTAG = 3;
34
    const POS_LSPACECTL = 4;
35
    const POS_BEGINRAW = 5;
36
    const POS_OP = 6;
37
    const POS_INNERTAG = 7;
38
    const POS_ENDRAW = 8;
39
    const POS_RSPACECTL = 9;
40
    const POS_ENDTAG = 10;
41
    const POS_RSPACE = 11;
42
    const POS_ROTHER = 12;
43
    const POS_BACKFILL = 13;
44
45
    /**
46
     * Setup delimiter by default or provided string
47
     *
48
     * @param array<string,array|string|integer> $context Current context
49
     * @param string|null $left left string of a token
50
     * @param string|null $right right string of a token
51
     */
52 795
    public static function setDelimiter(&$context, $left = null, $right = null)
53
    {
54 795
        if ($left === null) {
55 795
            $left = $context['delimiters'][0];
56
        }
57 795
        if ($right === null) {
58 795
            $right = $context['delimiters'][1];
59
        }
60 795
        if (preg_match('/=/', "$left$right")) {
61 1
            $context['error'][] = "Can not set delimiter contains '=' , you try to set delimiter as '$left' and '$right'.";
62 1
            return;
63
        }
64
65 795
        $context['tokens']['startchar'] = substr($left, 0, 1);
66 795
        $context['tokens']['left'] = $left;
67 795
        $context['tokens']['right'] = $right;
68 795
        $rawcount = $context['rawblock'] ? '{2}' : ($context['flags']['rawblock'] ? '{0,2}' : '?');
69 795
        $left = preg_quote($left);
70 795
        $right = preg_quote($right);
71
72 795
        $context['tokens']['search'] = "/^(.*?)(\\s*)($left)(~?)(\\{{$rawcount})\\s*([\\^#\\/!&>\\*]{0,2})(.*?)\\s*(\\}{$rawcount})(~?)($right)(\\s*)(.*)\$/s";
73 795
    }
74
75
    /**
76
     * return token string
77
     *
78
     * @param string[] $token detected handlebars {{ }} token
79
     * @param string[]|null $merge list of token strings to be merged
80
     *
81
     * @return string Return whole token
82
     *
83
     * @expect 'c' when input array(0, 'a', 'b', 'c', 'd', 'e')
84
     * @expect 'cd' when input array(0, 'a', 'b', 'c', 'd', 'e', 'f')
85
     * @expect 'qd' when input array(0, 'a', 'b', 'c', 'd', 'e', 'f'), array(3 => 'q')
86
     */
87 754
    public static function toString($token, $merge = null)
88
    {
89 754
        if (is_array($merge)) {
90 12
            $token = array_replace($token, $merge);
91
        }
92 754
        return implode('', array_slice($token, 3, -2));
93
    }
94
}
95