Passed
Push — master ( 57b88f...5a4f78 )
by David
03:01
created

ServiceException::invalidServiceData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Service\Exception;
4
5
use Opis\JsonSchema\ValidationError;
6
7
class ServiceException extends \Exception
8
{
9
    /**
10
     * @param ValidationError $vError
11
     * @return ServiceException
12
     */
13
    public static function invalidServiceData(ValidationError $vError): ServiceException
14
    {
15
        $message = 'Invalid service data' . PHP_EOL
16
            . 'Error: ' . $vError->keyword() . PHP_EOL
17
            . json_encode($vError->keywordArgs(), JSON_PRETTY_PRINT);
18
        return new self($message);
19
    }
20
}
21