Passed
Pull Request — master (#969)
by
unknown
04:54
created

_priorityItemZappableSleepProps()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * TPriorityPropertyTrait class
4
 *
5
 * @author Brad Anderson <[email protected]>
6
 * @link https://github.com/pradosoft/prado
7
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
8
 */
9
10
namespace Prado\Collections;
11
12
use Prado\TPropertyValue;
13
14
/**
15
 * TPriorityPropertyTrait class
16
 *
17
 * This trait implements the common properties and methods of IPriorityItem. You still
18
 * must "implement IPriorityItem" in your class when you use this trait as they go
19
 * together.
20
 *
21
 * The trait adds methods:
22
 *	- {@link getPriority} returns the default priority of items without priority.
23
 *	- {@link setPriority} sets the default priority. (protected)
24
 *	- {@link _priorityItemZappableSleepProps} to add the excluded trait properties on sleep.
25
 *
26
 * The priority is implement with a float.
27
 *
28
 * @author Brad Anderson <[email protected]>
29
 * @since 4.2.3
30
 */
31
trait TPriorityPropertyTrait
32
{
33
	/** @var ?float The set Priority of the item. Default null */
34
	private ?float $_priority = null;
35
36
	/**
37
	 * @return ?float The priority of the item. Default is null.
38
	 */
39
	public function getPriority(): ?float
40
	{
41
		return $this->_priority;
42
	}
43
44
	/**
45
	 * @param numeric $value The priority of the item.
0 ignored issues
show
Bug introduced by
The type Prado\Collections\numeric was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
	 */
47
	public function setPriority($value)
48
	{
49
		$this->_priority = TPropertyValue::ensureFloat($value);
50
	}
51
52
	/**
53
	 * Call this to exclude the priority property from sleep properties when there
54
	 * is no priority.
55
	 * @param array $exprops by reference
56
	 */
57
	protected function _priorityItemZappableSleepProps(&$exprops)
58
	{
59
		if ($this->_priority === null) {
60
			$exprops[] = "\0" . __CLASS__ . "\0_priority";
61
		}
62
	}
63
}
64