Completed
Push — master ( 875476...1855ce )
by Dan
02:56
created

SimpleMask::overlaps()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

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