Completed
Pull Request — develop (#153)
by
unknown
02:22 queued 16s
created

CriterionException::missingPackage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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. '.
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 150 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
29
            'Array with length "'.count($criterion).'" given');
30
    }
31
32
    public static function missingPackage($methodName, $packageName)
33
    {
34
        return new static('Method '.$methodName.' is only available with "'.$packageName .'" package installed');
35
    }
36
}
37