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

QuadTreeMask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 5 1
A overlaps() 0 4 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