• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LM-Commons / LmcRbacMvc / 11015011643

24 Sep 2024 01:38PM UTC coverage: 98.397%. Remained the same
11015011643

push

github

web-flow
Merge pull request #144 from visto9259/fix/142

Fixing 142: outdated namespace in 403 template. Fixing 143: PHPUnit deprecations

491 of 499 relevant lines covered (98.4%)

5.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/Role/RecursiveRoleIterator.php
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18

19
namespace Lmc\Rbac\Mvc\Role;
20

21
use ArrayIterator;
22
use Laminas\Permissions\Rbac\RoleInterface;
23
use RecursiveIterator;
24
use Traversable;
25

26
class RecursiveRoleIterator extends ArrayIterator implements RecursiveIterator
27
{
28
    /**
29
     * Override constructor to accept {@link Traversable} as well
30
     *
31
     * @param RoleInterface[]|Traversable $roles
32
     */
33
    public function __construct(iterable $roles)
4✔
34
    {
35
        if ($roles instanceof Traversable) {
4✔
36
            $roles = iterator_to_array($roles);
×
37
        }
38
        
39
        parent::__construct($roles);
4✔
40
    }
41
    
42
    /**
43
     * @return bool
44
     */
45
    public function valid() : bool
4✔
46
    {
47
        return ($this->current() instanceof RoleInterface);
4✔
48
    }
49
    
50
    /**
51
     * @return bool
52
     */
53
    public function hasChildren() : bool
3✔
54
    {
55
        $current = $this->current();
3✔
56
        
57
        if (!$current instanceof RoleInterface) {
3✔
58
            return false;
×
59
        }
60
        return !empty($current->getChildren());
3✔
61
    }
62

63
    /**
64
     * @return RecursiveRoleIterator|null
65
     */
66
    public function getChildren() :? RecursiveRoleIterator
2✔
67
    {
68
        return new RecursiveRoleIterator($this->current()->getChildren());
2✔
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc