Completed
Push — 1.1 ( d166b0...e7f438 )
by Patrick
11:31 queued 07:46
created

QueuesMacros   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
callMacro() 0 1 ?
queue() 0 1 ?
A queueMacro() 0 10 2
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Builders\Traits;
4
5
use LaravelDoctrine\Fluent\Buildable;
6
7
trait QueuesMacros
8
{
9
    /**
10
     * @param string $method
11
     * @param array  $params
12
     *
13
     * @return mixed
14
     */
15
    abstract protected function callMacro($method, array $params = []);
16
17
    /**
18
     * @param Buildable $buildable
19
     */
20
    abstract protected function queue(Buildable $buildable);
21
22
    /**
23
     * Intercept the Macro call and queue the result if it's a Buildable object.
24
     *
25
     * @param string $method
26
     * @param array  $args
27
     *
28
     * @return mixed
29
     */
30
    protected function queueMacro($method, $args)
31
    {
32
        $result = $this->callMacro($method, $args);
33
34
        if ($result instanceof Buildable) {
35
            $this->queue($result);
36
        }
37
38
        return $result;
39
    }
40
}
41