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.

createInvalidDiffered()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Ordered Form package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\OrderedForm\Exception;
13
14
use Symfony\Component\Form\Exception\InvalidConfigurationException;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class OrderedConfigurationException extends InvalidConfigurationException
20
{
21
    /**
22
     * @param array  $stack
23
     * @param string $position
24
     *
25
     * @return OrderedConfigurationException
26
     */
27 54
    public static function createCircularDiffered(array $stack, $position)
28
    {
29 54
        $stack[] = $stack[0];
30
31 54
        return new self(sprintf(
32 54
            'The form ordering cannot be resolved due to conflict in %s positions (%s).',
33 42
            $position,
34 54
            implode(' => ', self::decorateValues($stack))
35 42
        ));
36
    }
37
38
    /**
39
     * @param string $name
40
     * @param string $position
41
     * @param string $differed
42
     *
43
     * @return OrderedConfigurationException
44
     */
45 18
    public static function createInvalidDiffered($name, $position, $differed)
46
    {
47 18
        $decoratedDiffered = self::decorateValue($differed);
48
49 18
        return new self(sprintf(
50 18
            'The %s form is configured to be placed just %s the form %s but the form %s does not exist.',
51 18
            self::decorateValue($name),
52 14
            $position,
53 14
            $decoratedDiffered,
54
            $decoratedDiffered
55 14
        ));
56
    }
57
58
    /**
59
     * @param string $name
60
     * @param string $position
61
     *
62
     * @return OrderedConfigurationException
63
     */
64 27
    public static function createInvalidStringPosition($name, $position)
65
    {
66 27
        return new self(sprintf(
67 27
            'The %s form uses position as string which can only be "first" or "last" (current: %s).',
68 27
            self::decorateValue($name),
69 27
            self::decorateValue($position)
70 21
        ));
71
    }
72
73
    /**
74
     * @param string $name
75
     * @param array  $position
76
     *
77
     * @return OrderedConfigurationException
78
     */
79 27
    public static function createInvalidArrayPosition($name, array $position)
80
    {
81 27
        return new self(sprintf(
82 27
            'The %s form uses position as array or you must define the "before" or "after" option (current: %s).',
83 27
            self::decorateValue($name),
84 27
            implode(', ', self::decorateValues(array_keys($position)))
85 21
        ));
86
    }
87
88
    /**
89
     * @param string $name
90
     * @param string $symetric
91
     *
92
     * @return OrderedConfigurationException
93
     */
94 18
    public static function createSymetricDiffered($name, $symetric)
95
    {
96 18
        return new self(sprintf(
97 18
            'The form ordering does not support symetrical before/after option (%s <=> %s).',
98 18
            self::decorateValue($name),
99 18
            self::decorateValue($symetric)
100 14
        ));
101
    }
102
103
    /**
104
     * @param array  $values
105
     * @param string $decorator
106
     *
107
     * @return array
108
     */
109 81
    private static function decorateValues(array $values, $decorator = '"')
110
    {
111 81
        $result = [];
112
113 81
        foreach ($values as $key => $value) {
114 81
            $result[$key] = self::decorateValue($value, $decorator);
115 63
        }
116
117 81
        return $result;
118
    }
119
120
    /**
121
     * @param string $value
122
     * @param string $decorator
123
     *
124
     * @return string
125
     */
126 144
    private static function decorateValue($value, $decorator = '"')
127
    {
128 144
        return $decorator.$value.$decorator;
129
    }
130
}
131