PayrollProcessor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A calculate() 0 7 1
A payroll() 0 5 1
A make() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace CleaniqueCoders\OpenPayroll\Processors;
4
5
use CleaniqueCoders\OpenPayroll\Contracts\CalculateContract;
6
7
class PayrollProcessor implements CalculateContract
8
{
9
    public $payroll;
10
11
    public function __construct($identifier = null)
12
    {
13
        $this->payroll = config('open-payroll.models.payroll')::query()
14
            ->with('payslips', 'payslips.earnings', 'payslips.deductions', 'payslips.employee', 'payslips.employee.salary')
15
            ->findByHashSlugOrId($identifier);
16
    }
17
18
    public static function make($identifier = null)
19
    {
20
        return new self($identifier);
21
    }
22
23
    public function payroll($payroll)
24
    {
25
        $this->payroll = $payroll;
26
27
        return $this;
28
    }
29
30
    public function calculate()
31
    {
32
        $this->payroll->payslips->each(function($payslip) {
33
            payslip($payslip)->calculate();
34
        });
35
36
        return $this;
37
    }
38
}
39