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

CustomersRepository::findCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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
}