Completed
Push — master ( a03250...475c1c )
by Steevan
02:25
created

ValidateSchemaListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 43
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A validateSchema() 6 6 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 steevanb\DevBundle\EventListener;
4
5
use steevanb\DevBundle\Service\ValidateSchemaService;
6
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
7
use Symfony\Component\HttpKernel\HttpKernelInterface;
8
9 View Code Duplication
class ValidateSchemaListener
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    /** @var ValidateSchemaService */
12
    protected $validateSchema;
13
14
    /** @var array */
15
    protected $excludedEntities = array();
16
17
    /** @var array */
18
    protected $excludedProperties = array();
19
20
    /**
21
     * Messages from Doctrine\ORM\Tools\SchemaValidator
22
     *
23
     * @var array
24
     */
25
    protected $schemaValidatorMessages = array(
26
        'The field \'%s\' ',
27
        'The field %s ',
28
        'The association %s ',
29
        'Cannot map association \'%s\' ',
30
        'The mappings %s and ',
31
        'If association %s '
32
    );
33
34
    /**
35
     * @param ValidateSchemaService $validateSchema
36
     */
37
    public function __construct(ValidateSchemaService $validateSchema)
38
    {
39
        $this->validateSchema = $validateSchema;
40
    }
41
42
    /**
43
     * @param GetResponseEvent $event
44
     */
45
    public function validateSchema(GetResponseEvent $event)
46
    {
47
        if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
48
            $this->validateSchema->assertSchemaIsValid();
49
        }
50
    }
51
}
52