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 ( 10a69a...47f9c5 )
by Bruno
02:31
created

StringGeneratorHelper::getLeftArrow()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 3
eloc 2
nc 4
nop 2
crap 3
1
<?php
2
3
namespace Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher\StringGenerator;
4
5
use Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher\StringGeneratorInterface;
6
7
class StringGeneratorHelper implements StringGeneratorHelperInterface
8
{
9
    /**
10
     * @param string $className
11
     * @param array $fields
12
     * @return string
13
     */
14 3
    public function getClassText($className, $fields)
15
    {
16 3
        $classText = '[' . str_replace('\\', '.', $className);
17 3
        $classText .= !empty($fields) ? '|' . implode(';', $fields) : '';
18 3
        $classText .= ']';
19
20 3
        return $classText;
21
    }
22
23
24
    /**
25
     * @param string $class1String
26
     * @param boolean $isInverse
27
     * @param string $association
28
     * @param int $class1Count
29
     * @param string $targetClassName
30
     * @return string
31
     */
32 4
    public function makeSingleSidedLinkString(
33
        $class1String,
34
        $isInverse,
35
        $association,
36
        $class1Count,
37
        $targetClassName
38
    ) {
39 4
        return $class1String . $this->getLeftArrow($isInverse, true) . '-' . $association . ' '
40 4
        . $this->getCountSide($class1Count) . $this->getRightArrow($isInverse, true)
41 4
        . '[' . str_replace('\\', '.', $targetClassName) . ']';
42
    }
43
44
    /**
45
     * @param string $class1String
46
     * @param string $class2String
47
     * @param boolean $bidirectional
48
     * @param boolean $isInverse
49
     * @param string $class2SideName
50
     * @param integer $class2Count
51
     * @param string $class1SideName
52
     * @param integer $class1Count
53
     *
54
     * @return string
55
     */
56 7
    public function makeDoubleSidedLinkString(
57
        $class1String,
58
        $class2String,
59
        $bidirectional,
60
        $isInverse,
61
        $class2SideName,
62
        $class2Count,
63
        $class1SideName,
64
        $class1Count
65
    ) {
66 7
        return $class1String . $this->getLeftArrow($isInverse, $bidirectional)
67 7
        . ($class2SideName ? $class2SideName . ' ' . $this->getCountSide($class2Count) : '')
68 7
        . '-' . $class1SideName . ' ' . $this->getCountSide($class1Count)
69 6
        . $this->getRightArrow($isInverse, $bidirectional) . $class2String;
70
    }
71
72
    /**
73
     * @param bool $isInverse
74
     * @param bool $bidirectional
75
     * @return string
76
     */
77 11
    private function getLeftArrow($isInverse, $bidirectional)
78
    {
79 11
        return $bidirectional ? ($isInverse ? '<' : '<>') : '';
80
    }
81
82
    /**
83
     * @param bool $isInverse
84
     * @param bool $bidirectional
85
     * @return string
86
     */
87 10
    private function getRightArrow($isInverse, $bidirectional)
88
    {
89 10
        return ($bidirectional && $isInverse) ? '<>' : '>';
90
    }
91
92
    /**
93
     * @param int $classCount
94
     * @return string
95
     */
96 11
    private function getCountSide($classCount)
97
    {
98 11
        if ($classCount > 1) {
99 5
            return '*';
100 8
        } elseif ($classCount === 1) {
101 8
            return '1';
102
        }
103 1
        throw new \Exception('Impossible class count value ' . $classCount);
104
    }
105
}
106