FailedSchemaCheckListener   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onCheckResult() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\EventListener;
6
7
use Spiechu\SymfonyCommonsBundle\Event\ResponseSchemaCheck\CheckResult;
8
9
class FailedSchemaCheckListener
10
{
11
    /**
12
     * @param CheckResult $checkResult
13
     *
14
     * @throws \RuntimeException
15
     */
16 5
    public function onCheckResult(CheckResult $checkResult): void
17
    {
18 5
        if ($checkResult->isValid()) {
19 3
            return;
20
        }
21
22 2
        throw new \RuntimeException(sprintf(
23 2
            '"%s" Schema violations: "%s"',
24 2
            $checkResult->getFormat(),
25 2
            implode(', ', $checkResult->getValidationResult()->getViolations())
26
        ));
27
    }
28
}
29