Passed
Branch master (ac8b07)
by Robert
03:36
created

AgentParticipants   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 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 function __construct(array $models = [])
11
	{
12
		
13
		$models = array_map(function($item) {
14
			return new Agent((array) $item);
15
		}, $models);
16
		
17
		parent::__construct($models);
18
	}
19
	
20
	public function state($state = 'ONLINE')
21
	{
22
		$result = $this->filter(function($value, $key) use ($state) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
		$result = $this->filter(function($value, /** @scrutinizer ignore-unused */ $key) use ($state) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
			return strtolower($value->currentStatus) == strtolower($state);
24
		});
25
		
26
		return $result;
27
	}
28
}
29