Completed
Push — master ( 5bcf33...3feb07 )
by Dan
27:10
created

QuadTreeMask::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace SixtyNine\Cloud\Usher;
4
5
use Imagine\Image\PointInterface;
6
use SixtyNine\Cloud\Model\Box;
7
use SixtyNine\Cloud\Model\QuadTree;
8
9
class QuadTreeMask implements MaskInterface
10
{
11
    /** @var QuadTree */
12
    protected $tree;
13
14 4
    function __construct($width, $height)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
    {
16 4
        $this->tree = new QuadTree(new Box(0, 0, $width, $height));
17 4
    }
18
19
20
    /**
21
     * @param \Imagine\Image\PointInterface $position
22
     * @param Box $box
23
     */
24 4
    public function add(PointInterface $position, Box $box)
25
    {
26 4
        $box = $box->move($position->getX(), $position->getY());
27 4
        $this->tree->insert($box);
28 4
    }
29
30
    /**
31
     * @param Box $box
32
     * @return bool
33
     */
34 4
    public function overlaps(Box $box)
35
    {
36 4
        return $this->tree->collides($box);
37
    }
38
}
39