SDEs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 35
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getSDE() 0 8 1
1
<?php
2
/**
3
 * SDEs
4
 *
5
 * @package LivePersonInc\LiveEngageLaravel\Collections
6
 */
7
8
namespace LivePersonInc\LiveEngageLaravel\Collections;
9
10
use Illuminate\Support\Collection;
11
use LivePersonInc\LiveEngageLaravel\Models\SDE;
12
13
/**
14
 * SDEs class.
15
 * 
16
 * @extends Collection
17
 */
18
class SDEs extends Collection
19
{
20
	/**
21
	 * __construct function.
22
	 * 
23
	 * @access public
24
	 * @param array $models (default: [])
25
	 * @return void
26
	 */
27
	public function __construct(array $models = [])
28
	{
29
		
30
		
31
		$models = array_map(function($item) {
32
			return is_a($item, 'LivePersonInc\LiveEngageLaravel\Models\SDE') ? $item : new SDE((array) $item);
33
		}, $models);
34
		
35
		parent::__construct($models);
36
	}
37
	
38
	/**
39
	 * getSDE function.
40
	 * 
41
	 * @access public
42
	 * @param mixed $type
43
	 * @return mixed
44
	 */
45
	public function getSDE($type)
46
	{
47
		
48
		$sorted = $this->sortByDesc(function($item) {
49
			return $item->serverTimeStamp;
50
		});
51
		
52
		return $sorted->firstWhere('sdeType', $type);
53
		
54
	}
55
	
56
}