DatatableGenerator::prepareAdd()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.9666
c 1
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Distilleries\DatatableBuilder\Console\Lib\Generators;
4
5
use Kris\LaravelFormBuilder\Console\FormGenerator;
6
7
class DatatableGenerator extends FormGenerator
8
{
9
10
    /**
11
     * Prepare template for single add field.
12
     *
13
     * @param string $field
14
     * @param bool $isLast
15
     * @return string
16
     */
17 4
    protected function prepareAdd($field, $isLast = false)
18
    {
19 4
        $field = trim($field);
20
        $textArr = [
21 4
            "            ->add('",
22 4
            $field,
23 4
            "', null",
24 4
            ", trans('datatable." . strtolower($field) . "')",
25 4
            ")",
26 4
            ($isLast) ? "" : "\n"
27
        ];
28
29 4
        return join('', $textArr);
30
    }
31
}
32