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
Pull Request — master (#54)
by joseph
28:13 queued 24:17
created

ValidationExceptionTest.php$0 ➔ setup()   A

Complexity

Conditions 2

Size

Total Lines 71

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 71
rs 9.1369
c 0
b 0
f 0
cc 2

12 Methods

Rating   Name   Duplication   Size   Complexity  
A ValidationExceptionTest.php$0 ➔ loadValidatorMetaData() 0 2 1
A ValidationExceptionTest.php$0 ➔ validateProperty() 0 2 1
A ValidationExceptionTest.php$0 ➔ isValid() 0 3 1
A ValidationExceptionTest.php$0 ➔ getPlural() 0 3 1
A ValidationExceptionTest.php$0 ➔ loadMetadata() 0 2 1
A ValidationExceptionTest.php$0 ➔ injectValidator() 0 2 1
A ValidationExceptionTest.php$0 ➔ getShortName() 0 3 1
A ValidationExceptionTest.php$0 ➔ getIdField() 0 3 1
A ValidationExceptionTest.php$0 ➔ getSingular() 0 3 1
A ValidationExceptionTest.php$0 ➔ __toString() 0 3 1
A ValidationExceptionTest.php$0 ➔ getId() 0 2 1
A ValidationExceptionTest.php$0 ➔ validate() 0 2 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Exception;
4
5
use Doctrine\ORM\Mapping\ClassMetadata as DoctrineClassMetaData;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\Validation\EntityValidatorInterface;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Validator\ConstraintViolationList;
10
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
11
12
/**
13
 * Class ValidationExceptionTest
14
 *
15
 * @package EdmondsCommerce\DoctrineStaticMeta\Exception
16
 * @SuppressWarnings(PHPMD.UnusedLocalVariable)
17
 */
18
class ValidationExceptionTest extends TestCase
19
{
20
    /**
21
     * @var ValidationException
22
     */
23
    private $exception;
24
25
    private $errors;
26
27
    private $entity;
28
29
    public function setup()
30
    {
31
        try {
32
            $this->errors = new ConstraintViolationList();
33
            $this->entity = new class implements EntityInterface
34
            {
35
                public function getId()
36
                {
37
                    // TODO: Implement getId() method.
38
                }
39
40
                public static function loadMetadata(DoctrineClassMetaData $metadata): void
41
                {
42
                    // TODO: Implement loadMetadata() method.
43
                }
44
45
                public static function getPlural(): string
46
                {
47
                    return '';
48
                }
49
50
                public static function getSingular(): string
51
                {
52
                    return '';
53
                }
54
55
                public static function getIdField(): string
56
                {
57
                    return '';
58
                }
59
60
                public function getShortName(): string
61
                {
62
                    return '';
63
                }
64
65
                public function __toString(): string
66
                {
67
                    return '';
68
                }
69
70
                public static function loadValidatorMetaData(ValidatorClassMetaData $metadata): void
71
                {
72
                    // TODO: Implement loadValidatorMetaData() method.
73
                }
74
75
                public function injectValidator(EntityValidatorInterface $validator)
76
                {
77
                    // TODO: Implement injectValidator() method.
78
                }
79
80
                public function isValid(): bool
81
                {
82
                    return false;
83
                }
84
85
                public function validate()
86
                {
87
                    // TODO: Implement validate() method.
88
                }
89
90
                public function validateProperty(string $propertyName)
91
                {
92
                    // TODO: Implement validateProperty() method.
93
                }
94
95
96
            };
97
            throw new ValidationException($this->errors, $this->entity);
98
        } catch (ValidationException $e) {
99
            $this->exception = $e;
100
        }
101
    }
102
103
    public function testGetInvalidEntity()
104
    {
105
        $expected = $this->entity;
106
        $actual   = $this->exception->getInvalidEntity();
107
        $this->assertSame($expected, $actual);
108
    }
109
110
    public function testGetValidationErrors()
111
    {
112
        $expected = $this->errors;
113
        $actual   = $this->exception->getValidationErrors();
114
        $this->assertSame($expected, $actual);
115
    }
116
}
117