Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Link | |
100.00% |
18 / 18 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
1 / 1 |
readByDepartmentId | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
4 | |||
writeEntity | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
deleteEntity | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb; |
4 | |
5 | use BO\Zmsentities\Link as Entity; |
6 | use BO\Zmsentities\Collection\LinkList as Collection; |
7 | |
8 | class Link extends Base |
9 | { |
10 | /** |
11 | * Fetch status from db |
12 | * |
13 | * @return \BO\Zmsentities\Collection\LinkList |
14 | */ |
15 | public function readByDepartmentId($departmentId) |
16 | { |
17 | $linkList = new Collection(); |
18 | $query = new Query\Link(Query\Base::SELECT); |
19 | $query |
20 | ->addEntityMapping() |
21 | ->addConditionDepartmentId($departmentId); |
22 | $result = $this->fetchList($query, new Entity()); |
23 | if (count($result)) { |
24 | foreach ($result as $entity) { |
25 | if ($entity instanceof Entity) { |
26 | $linkList->addEntity($entity); |
27 | } |
28 | } |
29 | } |
30 | return $linkList; |
31 | } |
32 | |
33 | /** |
34 | * write a link |
35 | * |
36 | * @param |
37 | * entity, |
38 | * organisationId |
39 | * |
40 | * @return Entity |
41 | */ |
42 | public function writeEntity(Entity $entity, $departmentId) |
43 | { |
44 | $query = new Query\Link(Query\Base::INSERT); |
45 | $values = $query->reverseEntityMapping($entity, $departmentId); |
46 | $query->addValues($values); |
47 | return $this->writeItem($query); |
48 | } |
49 | |
50 | public function deleteEntity($itemId) |
51 | { |
52 | $query = new Query\Link(Query\Base::DELETE); |
53 | $query->addConditionLinkId($itemId); |
54 | return ($this->deleteItem($query)); |
55 | } |
56 | } |