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 ( b0dfc5...2b40df )
by Steevan
10s
created

ReadOnlyHydrator   C

Complexity

Total Complexity 54

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 54
lcom 0
cbo 3
dl 0
loc 19
rs 6.8539
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createEntity() 0 8 1

How to fix   Complexity   

Complex Class

Complex classes like ReadOnlyHydrator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ReadOnlyHydrator, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace steevanb\DoctrineReadOnlyHydrator\Hydrator;
4
5
use Doctrine\ORM\Mapping\ClassMetadata;
6
use steevanb\DoctrineStats\Doctrine\ORM\Event\OverloadedHydratorTrait;
7
8
/**
9
 * Use it with https://github.com/steevanb/doctrine-stats
10
 */
11
class ReadOnlyHydrator extends \ComposerOverloadClass\steevanb\DoctrineReadOnlyHydrator\Hydrator\ReadOnlyHydrator
12
{
13
    use OverloadedHydratorTrait;
14
15
    /**
16
     * @param ClassMetadata $classMetaData
17
     * @param array $data
18
     * @return mixed
19
     * @throws \Exception
20
     */
21
    protected function createEntity(ClassMetadata $classMetaData, array $data)
22
    {
23
        $entity = parent::createEntity($classMetaData, $data);
24
25
        $this->dispatchPostCreateEntityEvent($classMetaData, $data);
26
27
        return $entity;
28
    }
29
}
30