SplPriorityQueue::insert()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * Purple - Run tasks on collections
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Queue
13
 * @package   Jnjxp\Purple
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      https://github.com/jnjxp/jnjxp.purple
18
 */
19
20
namespace Jnjxp\Purple;
21
22
/**
23
 * SplPriorityQueue
24
 *
25
 * @category Queue
26
 * @package  Jnjxp\Purple
27
 * @author   Jake Johns <[email protected]>
28
 * @license  http://jnj.mit-license.org/ MIT License
29
 * @link     https://github.com/jnjxp/jnjxp.purple
30
 */
31
class SplPriorityQueue extends \SplPriorityQueue
32
{
33
    protected $order = PHP_INT_MAX;
34
35
    /**
36
     * Insert
37
     *
38
     * @param mixed $value    value
39
     * @param mixed $priority order priority
40
     *
41
     * @return mixed
42
     *
43
     * @access public
44
     */
45 4
    public function insert($value, $priority)
46
    {
47 4
        if (is_int($priority)) {
48 4
            $priority = array($priority, $this->order--);
49 4
        }
50 4
        parent::insert($value, $priority);
51 4
    }
52
}
53