Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ClusterList
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
3 / 3
11
100.00% covered (success)
100.00%
1 / 1
 hasScope
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
4
 withUniqueClusters
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 sortByName
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace BO\Zmsentities\Collection;
4
5class ClusterList extends Base
6{
7    const ENTITY_CLASS = '\BO\Zmsentities\Cluster';
8
9    public function hasScope($scopeId)
10    {
11        foreach ($this as $entity) {
12            foreach ($entity['scopes'] as $scope) {
13                $scope = new \BO\Zmsentities\Scope($scope);
14                if ($scopeId == $scope->id) {
15                    return true;
16                }
17            }
18        }
19        return false;
20    }
21
22    public function withUniqueClusters()
23    {
24        $clusterList = new self();
25        foreach ($this as $cluster) {
26            if ($cluster && ! $clusterList->hasEntity($cluster->id)) {
27                $clusterList->addEntity($cluster);
28            }
29        }
30        return $clusterList;
31    }
32
33    public function sortByName()
34    {
35        parent::sortByName();
36        foreach ($this as $cluster) {
37            if ($cluster->scopes instanceof ScopeList) {
38                $cluster->scopes->sortByName();
39            }
40        }
41        return $this;
42    }
43}