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

AgentParticipants   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 30
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A findById() 0 7 1
A state() 0 7 1
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