Completed
Branch master (5a81ac)
by Albert
02:06
created

CustomersRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findCustomer() 0 4 1
A createCustomer() 0 5 1
1
<?php
2
namespace Elimuswift\Core\Repositories;
3
4
use Elimuswift\Core\Customer;
5
6
/**
7
* Update data repository
8
*/
9
class CustomersRepository
10
{
11
	/**
12
	 * Customer Model instance
13
	 *
14
	 * @var mixed
15
	 **/
16
	public $customer;
17
	/**
18
	 * Create a new instance of the CustomerRepository::class
19
	 * 
20
	 **/
21
	
22
	public function __construct(Customer $customer)
23
	{
24
		$this->customer = $customer;
25
	}
26
27
	/**
28
	 * Find a customer by a field
29
	 *
30
	 * @return mixid $this 
31
	 **/
32
	public function findCustomer($key, $value)
33
	{
34
		return $this->customer->where($key, $value)->first();
35
	}
36
	
37
	/**
38
	 * Create Customer with the received response
39
	 *
40
	 * @return object Customer 
41
	 * @param array $data  
42
	 **/
43
	public function createCustomer($data)
44
	{
45
		// TODO: Perform basic validation on the customer object before saving
46
		return $this->customer->create($data);
47
	}
48
49
50
51
52
}