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

QueuesMacros::queueMacro()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 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