Passed
Branch master (96b04a)
by Robert
03:20
created

AgentParticipants::findById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace LivePersonInc\LiveEngageLaravel\Collections;
4
5
use Illuminate\Support\Collection;
6
use LivePersonInc\LiveEngageLaravel\Models\Agent;
7
8
class AgentParticipants extends Collection
9
{
10
	public $metaData;
11
	
12
	public function __construct(array $models = [])
13
	{
14
		
15
		$models = array_map(function($item) {
16
			return new Agent((array) $item);
17
		}, $models);
18
		
19
		parent::__construct($models);
20
	}
21
	
22
	public function state($state = 'ONLINE')
23
	{
24
		$result = $this->filter(function($value) use ($state) {
25
			return strtolower($value->currentStatus) == strtolower($state);
26
		});
27
		
28
		return $result;
29
	}
30
	
31
	public function findById($agentId)
32
	{
33
		$result = $this->filter(function($value) use ($agentId) {
34
			return strtolower($value->agentId) == $agentId;
35
		});
36
		
37
		return $result->first();
38
	}
39
}
40