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

LM-Commons / LmcRbacMvc / 9213709239

23 May 2024 07:23PM UTC coverage: 92.785% (+5.5%) from 87.306%
9213709239

push

github

web-flow
Merge pull request #78 from visto9259/4.x

Merged documentation from master

128 of 135 new or added lines in 42 files covered. (94.81%)

10 existing lines in 3 files now uncovered.

643 of 693 relevant lines covered (92.78%)

5.17 hits per line

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

0.0
/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 LmcRbacMvc\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($roles)
×
34
    {
35
        if ($roles instanceof Traversable) {
×
36
            $roles = iterator_to_array($roles);
×
37
        }
38
        
39
        parent::__construct($roles);
×
40
    }
41
    
42
    /**
43
     * @return bool
44
     */
45
    public function valid() : bool
×
46
    {
47
        return ($this->current() instanceof RoleInterface);
×
48
    }
49
    
50
    /**
51
     * @return bool
52
     */
53
    public function hasChildren() : bool
×
54
    {
55
        $current = $this->current();
×
56
        
57
        if (!$current instanceof RoleInterface) {
×
58
            return false;
×
59
        }
NEW
60
        return !empty($current->getChildren());
×
61
    }
62

63
    /**
64
     * @return RecursiveRoleIterator|null
65
     */
66
    public function getChildren() :? RecursiveRoleIterator
×
67
    {
68
        return new RecursiveRoleIterator($this->current()->getChildren());
×
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