Completed
Push — master ( 5649ba...c37d73 )
by recca
03:09
created

Criteria   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 72
rs 10
c 0
b 0
f 0
ccs 10
cts 10
cp 1
wmc 6
lcom 1
cbo 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A expr() 0 4 1
A raw() 0 4 1
A each() 0 6 2
A toArray() 0 9 1
1
<?php
2
3
namespace Recca0120\Repository;
4
5
use Closure;
6
7
class Criteria
8
{
9
    use Concerns\BuildsQueries,
10
        Concerns\QueriesRelationships,
11
        Concerns\EloquentBuildsQueries,
12
        Concerns\SoftDeletingScope;
13
14
    /**
15
     * $methods.
16
     *
17
     * @var \Recca0120\Repository\Method[]
18
     */
19
    protected $methods = [];
20
21
    /**
22
     * create.
23
     *
24
     * @return static
25
     */
26
    public static function create()
27
    {
28
        return new static();
29
    }
30
31
    /**
32
     * alias raw.
33
     *
34
     * @param mixed $value
35
     * @return Expression
36
     */
37
    public static function expr($value)
38
    {
39
        return static::raw($value);
40
    }
41
42
    /**
43
     * @param mixed $value
44
     * @return \Recca0120\Repository\Expression
45 25
     */
46
    public static function raw($value)
47 25
    {
48 24
        return new Expression($value);
49
    }
50 24
51
    /**
52
     * each.
53 1
     *
54
     * @param  Closure $callback
55
     * @return void
56
     */
57
    public function each(Closure $callback)
58
    {
59
        foreach ($this->methods as $method) {
60
            $callback($method);
61
        }
62
    }
63 1
64
    /**
65 1
     * toArray.
66
     *
67 1
     * @return array
68
     */
69
    public function toArray()
70
    {
71
        return array_map(function ($method) {
72
            return [
73
                'method' => $method->name,
74
                'parameters' => $method->parameters,
75 22
            ];
76
        }, $this->methods);
77 22
    }
78
}
79