Pageable   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 88.46%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 27
c 1
b 0
f 0
dl 0
loc 68
ccs 23
cts 26
cp 0.8846
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A next() 0 25 3
A prev() 0 25 3
1
<?php
2
	
3
namespace LivePersonInc\LiveEngageLaravel\Traits;
4
5
use LivePersonInc\LiveEngageLaravel\Facades\LiveEngageLaravel as LiveEngage;
6
use LivePersonInc\LiveEngageLaravel\Models\MetaData;
7
	
8
/**
9
 * Pageable trait.
10
 */
11
trait Pageable
12
{
13
	
14
	/**
15
	 * next function.
16
	 * 
17
	 * @access public
18
	 * @return mixed
19
	 */
20 2
	public function next()
21
	{
22
		/** @scrutinizer ignore-call */
23 2
		if ($this->metaData->next) {
24
			/** @scrutinizer ignore-call */
25 2
			$func = $this->historyFunction;
26 2
			$next = LiveEngage::$func($this->metaData->start, $this->metaData->end, $this->metaData->next->href);
27 2
			if ($next) {
28
		
29 2
				$next->_metadata->start = $this->metaData->start;
30 2
				$next->_metadata->end = $this->metaData->end;
31
		
32 2
				$meta = new MetaData((array) $next->_metadata);
33
				
34 2
				$collection = new self($next->records);
0 ignored issues
show
Unused Code introduced by
The call to LivePersonInc\LiveEngage...Pageable::__construct() has too many arguments starting with $next->records. ( Ignorable by Annotation )

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

34
				$collection = /** @scrutinizer ignore-call */ new self($next->records);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
35 2
				$collection->metaData = $meta;
0 ignored issues
show
Bug Best Practice introduced by
The property metaData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
				
37 2
				return $collection;
38
				
39
			} else {
40
				return null;
41
			}
42
		}
43
		
44 2
		return null;
45
		
46
	}
47
48
	/**
49
	 * prev function.
50
	 * 
51
	 * @access public
52
	 * @return mixed
53
	 */
54 2
	public function prev()
55
	{
56
		/** @scrutinizer ignore-call */
57 2
		if ($this->metaData->prev) {
58
			/** @scrutinizer ignore-call */
59 2
			$func = $this->historyFunction;
60 2
			$prev = LiveEngage::$func($this->metaData->start, $this->metaData->end, $this->metaData->prev->href);
61 2
			if ($prev) {
62
		
63 2
				$prev->_metadata->start = $this->metaData->start;
64 2
				$prev->_metadata->end = $this->metaData->end;
65
		
66 2
				$meta = new MetaData((array) $prev->_metadata);
67
				
68 2
				$collection = new self($prev->records);
0 ignored issues
show
Unused Code introduced by
The call to LivePersonInc\LiveEngage...Pageable::__construct() has too many arguments starting with $prev->records. ( Ignorable by Annotation )

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

68
				$collection = /** @scrutinizer ignore-call */ new self($prev->records);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
69 2
				$collection->metaData = $meta;
0 ignored issues
show
Bug Best Practice introduced by
The property metaData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
70
				
71 2
				return $collection;
72
				
73
			} else {
74
				return null;
75
			}
76
		}
77
		
78
		return null;
79
		
80
	}
81
	
82
}