Completed
Push — develop ( f34a65...a0b033 )
by Abdelrahman
02:30
created

CriterionException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongCriterionType() 0 7 2
A classNotImplementContract() 0 4 1
A wrongArraySignature() 0 6 1
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Repository Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Repository Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Repository\Exceptions;
17
18
use Exception;
19
use Rinvex\Repository\Contracts\CriterionContract;
20
21
class CriterionException extends Exception
22
{
23
    public static function wrongCriterionType($criterion)
24
    {
25
        $type  = gettype($criterion);
26
        $value = $type === 'object' ? get_class($criterion) : $criterion;
27
28
        return new static('Given criterion with type '.$type.' and value '.$value.' is not allowed');
29
    }
30
31
    public static function classNotImplementContract($criterionClassName)
32
    {
33
        return new static('Given '.$criterionClassName.' class is not implement '.CriterionContract::class.'contract');
34
    }
35
36
    public static function wrongArraySignature(array $criterion)
37
    {
38
        return new static(
39
            '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...
40
            'Array with length "'.count($criterion).'" given');
41
    }
42
}
43