SimpleMask   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 5 1
A overlaps() 0 9 3
1
<?php
2
3
namespace SixtyNine\Cloud\Usher;
4
5
use Imagine\Image\PointInterface;
6
use SixtyNine\DataTypes\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