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 ( f187b7...b86164 )
by Vadim
12:28
created

PropertyAnnotationListener   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 66
Duplicated Lines 75.76 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 11
c 2
b 0
f 2
lcom 1
cbo 7
dl 50
loc 66
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A handleIdAnnotation() 10 10 2
A handleColumnAnnotation() 10 10 2
A handleOneToOneAnnotation() 10 10 2
A attach() 0 8 1
A handleOneToManyAnnotation() 10 10 2
A handleManyToManyAnnotation() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Newage\Annotations\Mapper\Annotation;
4
5
use Newage\Annotations\Entity\Annotation;
6
use Zend\EventManager\EventInterface;
7
use Zend\EventManager\EventManagerInterface;
8
9
/**
10
 * Class PropertyAnnotationListener
11
 * @package SimpleOrm\Mapper\Annotation
12
 */
13
class PropertyAnnotationListener extends AbstractAnnotationListener
14
{
15
    public function attach(EventManagerInterface $events)
16
    {
17
        $this->listeners[] = $events->attach('configureProperty', [$this, 'handleIdAnnotation']);
18
        $this->listeners[] = $events->attach('configureProperty', [$this, 'handleColumnAnnotation']);
19
        $this->listeners[] = $events->attach('configureProperty', [$this, 'handleOneToOneAnnotation']);
20
        $this->listeners[] = $events->attach('configureProperty', [$this, 'handleOneToManyAnnotation']);
21
        $this->listeners[] = $events->attach('configureProperty', [$this, 'handleManyToManyAnnotation']);
22
    }
23
24 View Code Duplication
    public function handleIdAnnotation(EventInterface $event)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $annotation = $event->getParam('annotation');
27
        if (!$annotation instanceof Annotation\Id) {
28
            return;
29
        }
30
31
        $spec = $event->getParam('spec');
32
        $spec['autoincrement'] = true;
33
    }
34
35 View Code Duplication
    public function handleColumnAnnotation(EventInterface $event)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $annotation = $event->getParam('annotation');
38
        if (!$annotation instanceof Annotation\Column) {
39
            return;
40
        }
41
42
        $spec = $event->getParam('spec');
43
        $spec['column'] = $annotation->getName();
44
    }
45
46 View Code Duplication
    public function handleOneToOneAnnotation(EventInterface $event)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $annotation = $event->getParam('annotation');
49
        if (!$annotation instanceof Annotation\OneToOne) {
50
            return;
51
        }
52
53
        $spec = $event->getParam('spec');
54
        $spec['oneToOne'] = $annotation->getName();
55
    }
56
57 View Code Duplication
    public function handleOneToManyAnnotation(EventInterface $event)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $annotation = $event->getParam('annotation');
60
        if (!$annotation instanceof Annotation\OneToMany) {
61
            return;
62
        }
63
64
        $spec = $event->getParam('spec');
65
        $spec['oneToMany'] = $annotation->getName();
66
    }
67
68 View Code Duplication
    public function handleManyToManyAnnotation(EventInterface $event)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        $annotation = $event->getParam('annotation');
71
        if (!$annotation instanceof Annotation\ManyToMany) {
72
            return;
73
        }
74
75
        $spec = $event->getParam('spec');
76
        $spec['manyToMany'] = $annotation->getName();
77
    }
78
}
79