Completed
Push — master ( 13a5b7...3bf9bc )
by Elf
05:43
created

EloquentEngine   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 34
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C addColumn() 0 23 7
1
<?php
2
3
namespace ElfSundae\Laravel\DataTables\Engines;
4
5
use Yajra\DataTables\Engines\EloquentEngine as BaseEngine;
6
7
class EloquentEngine extends BaseEngine
8
{
9
    /**
10
     * Add column in collection.
11
     *
12
     * @param  string|string[]  $name
13
     * @param  string|callable|bool|int|null  $content
14
     * @param  bool|int  $order
15
     * @return $this
16
     */
17
    public function addColumn($name, $content = null, $order = false)
18
    {
19
        if (is_bool($content) || is_int($content)) {
20
            $order = $content;
21
            $content = null;
22
        }
23
24
        if (is_null($content) && is_string($name)) {
25
            $content = function ($model) use ($name) {
26
                return $model->{$name};
27
            };
28
        }
29
30
        if (is_array($name)) {
31
            foreach ($name as $n) {
32
                $this->addColumn($n, $content, $order);
33
            }
34
35
            return $this;
36
        }
37
38
        return parent::addColumn($name, $content, $order);
39
    }
40
}
41