Transfers   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 38.46%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 40
ccs 5
cts 13
cp 0.3846
rs 10

3 Methods

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