Completed
Push — master ( 816aee...21d47f )
by Nasrul Hazim
02:48
created

BaseEarningProcessor::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 4
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CleaniqueCoders\OpenPayroll\Processors\Earning;
4
5
class BaseEarningProcessor
6
{
7
    public $earning;
8
9
    public function __construct($identifier)
10
    {
11
        if (is_string($identifier) || is_int($identifier)) {
12
            $this->earning = config('open-payroll.models.earning')::query()
13
                ->with('type')
14
                ->findByHashSlugOrId($identifier);
15
        }
16
17
        if (is_object($identifier)) {
18
            $this->earning($identifier);
19
        }
20
    }
21
22
    public static function make($identifier)
23
    {
24
        return new self($identifier);
25
    }
26
27
    public function earning($earning)
28
    {
29
        $this->earning = $earning;
30
31
        return $this;
32
    }
33
34
    abstract public function calculate();
35
}
36