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

SimpleMask::overlaps()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace SixtyNine\Cloud\Usher;
4
5
use Imagine\Image\PointInterface;
6
use SixtyNine\Cloud\Model\Box;
7
8
class SimpleMask
9
{
10
    /** @var Box[] */
11
    protected  $boundingBoxes = array();
12
13
    /**
14
     * @param \Imagine\Image\PointInterface $position
15
     * @param Box $box
16
     */
17
    public function add(PointInterface $position, Box $box)
18
    {
19
        $box = $box->move($position->getX(), $position->getY());
20
        $this->boundingBoxes[] = $box;
21
    }
22
23
    /**
24
     * @param Box $box
25
     * @return bool
26
     */
27
    public function overlaps(Box $box)
28
    {
29
        foreach ($this->boundingBoxes as $dBox) {
30
            if ($box->intersects($dBox)) {
31
                return true;
32
            }
33
        }
34
        return false;
35
    }
36
}
37