CriterionException::classNotImplementContract()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Repository\Exceptions;
6
7
use Exception;
8
use Rinvex\Repository\Contracts\CriterionContract;
9
10
class CriterionException extends Exception
11
{
12
    public static function wrongCriterionType($criterion)
13
    {
14
        $type = gettype($criterion);
15
        $value = $type === 'object' ? get_class($criterion) : $criterion;
16
17
        return new static('Given criterion with type '.$type.' and value '.$value.' is not allowed');
18
    }
19
20
    public static function classNotImplementContract($criterionClassName)
21
    {
22
        return new static('Given '.$criterionClassName.' class is not implement '.CriterionContract::class.'contract');
23
    }
24
25
    public static function wrongArraySignature(array $criterion)
26
    {
27
        return new static(
28
            'Array signature for criterion instantiating must contain only two elements in case of sequential array and one in case of assoc array. '.
29
            'Array with length "'.count($criterion).'" given');
30
    }
31
}
32