FailedSchemaCheckListener::onCheckResult()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 2
rs 10
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