Passed
Push — dev5a ( c9bcfe...7155d2 )
by Ron
07:44
created

SetCustomerDetails   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createCustomer() 0 10 2
A validateParentID() 0 5 2
1
<?php
2
3
namespace App\Domains\Customers;
4
5
use App\Customers;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
9
10
class SetCustomerDetails
11
{
12 6
    public function createCustomer($request)
13
    {
14 6
        if($request->parent_id != null)
15
        {
16 2
            $request->parent_id = $this->validateParentID($request->parent_id);
17
        }
18
19 6
        $newCust = Customers::create($request->toArray());
20
21 6
        return $newCust->cust_id;
22
    }
23
24
    //  Determine if the assigned parent has a partent of its own
25 2
    protected function validateParentID($parentID)
26
    {
27 2
        $parent = Customers::find($parentID);
28
29 2
        return $parent->parent_id ? $parent->parent_id : $parentID;
30
    }
31
}
32