JsonCheckSchemaSubscriber::getSubscribedEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\EventListener;
6
7
use Spiechu\SymfonyCommonsBundle\Event\ResponseSchemaCheck\Events;
8
use Spiechu\SymfonyCommonsBundle\Service\SchemaValidator\JsonSchemaValidatorFactory;
9
use Spiechu\SymfonyCommonsBundle\Service\SchemaValidator\SchemaValidatorFactoryInterface;
10
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11
12
class JsonCheckSchemaSubscriber extends AbstractCheckSchemaSubscriber implements EventSubscriberInterface
13
{
14
    /**
15
     * @var JsonSchemaValidatorFactory
16
     */
17
    protected $jsonSchemaValidatorFactory;
18
19
    /**
20
     * @param JsonSchemaValidatorFactory $jsonSchemaValidatorFactory
21
     */
22 4
    public function __construct(JsonSchemaValidatorFactory $jsonSchemaValidatorFactory)
23
    {
24 4
        $this->jsonSchemaValidatorFactory = $jsonSchemaValidatorFactory;
25 4
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 8
    public static function getSubscribedEvents(): array
31
    {
32
        return [
33 8
            Events::getCheckSchemaEventNameFor('json') => 'validateSchema',
34
        ];
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 4
    protected function getSchemaValidatorFactory(): SchemaValidatorFactoryInterface
41
    {
42 4
        return $this->jsonSchemaValidatorFactory;
43
    }
44
}
45