Passed
Push — master ( 8692a8...cbe8ef )
by Nasrul Hazim
02:21
created

BaseDeductionProcessor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deduction() 0 5 1
A __construct() 0 10 4
A make() 0 3 1
1
<?php
2
3
namespace CleaniqueCoders\OpenPayroll\Processors\Deduction;
4
5
class BaseDeductionProcessor
6
{
7
    public $deduction;
8
9
    public function __construct($identifier)
10
    {
11
        if (is_string($identifier) || is_int($identifier)) {
12
            $this->deduction = config('open-payroll.models.deduction')::query()
13
                ->with('type')
14
                ->findByHashSlugOrId($identifier);
15
        }
16
17
        if (is_object($identifier)) {
18
            $this->deduction($identifier);
19
        }
20
    }
21
22
    public static function make($identifier)
23
    {
24
        return new self($identifier);
25
    }
26
27
    public function deduction($deduction)
28
    {
29
        $this->deduction = $deduction;
30
31
        return $this;
32
    }
33
34
    abstract public function calculate();
35
}
36