Passed
Push — master ( c49c81...0c069c )
by Ferry
03:05
created

Hook   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 8
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assignment() 0 5 3
A detailRender() 0 3 1
A indexRender() 0 5 5
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: User
5
 * Date: 2/13/2019
6
 * Time: 5:43 PM
7
 */
8
9
namespace crocodicstudio\crudbooster\types\money;
10
11
use crocodicstudio\crudbooster\types\TypesHook;
12
13
14
class Hook extends TypesHook
15
{
16
17
    /**
18
     * @param $value
19
     * @param $column MoneyModel
20
     * @return mixed|void
21
     */
22
    public function assignment($value, $column)
23
    {
24
        $value = str_replace($column->getThousands()?:",","", $value);
25
        $value = str_replace($column->getDecimal()?:".",".",$value);
26
        return $value;
27
    }
28
29
    public function indexRender($row, $column)
30
    {
31
        $value = $row->{$column->getField()};
32
        $prefix = ($column->getPrefix())?:"";
33
        return $prefix.number_format($value, $column->getPrecision()?:0, $column->getDecimal()?:".", $column->getThousands()?:",");
34
    }
35
36
    public function detailRender($row, $column)
37
    {
38
        return $this->indexRender($row, $column);
39
    }
40
}