RoleAggregate::getRolesNames()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace SimpleAcl\Role;
4
5
use SimpleAcl\Object\ObjectAggregate;
6
use SimpleAcl\Role;
7
8
/**
9
 * Holds roles.
10
 *
11
 * Allow pass itself to Acl::isAllowed method as $roleName.
12
 *
13
 * @package SimpleAcl\Role
14
 */
15 View Code Duplication
class RoleAggregate extends ObjectAggregate implements RoleAggregateInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
  /**
18
   * Add role.
19
   *
20
   * @param Role $role
21 9
   */
22
  public function addRole(Role $role)
23 9
  {
24 9
    parent::addObject($role);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (addObject() instead of addRole()). Are you sure this is correct? If so, you might want to change this to $this->addObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
25
  }
26
27
  /**
28
   * Remove all roles.
29
   */
30 1
  public function removeRoles()
31
  {
32 1
    parent::removeObjects();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (removeObjects() instead of removeRoles()). Are you sure this is correct? If so, you might want to change this to $this->removeObjects().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
33 1
  }
34
35
  /**
36
   * Remove role by name.
37
   *
38
   * @param Object|string $roleName
39
   */
40 2
  public function removeRole($roleName)
41
  {
42 2
    parent::removeObject($roleName);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (removeObject() instead of removeRole()). Are you sure this is correct? If so, you might want to change this to $this->removeObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
Bug introduced by
It seems like $roleName defined by parameter $roleName on line 40 can also be of type object; however, SimpleAcl\Object\ObjectAggregate::removeObject() does only seem to accept object<SimpleAcl\BaseObject>|string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
43 2
  }
44
45
  /**
46
   * Add roles from array.
47
   *
48
   * @param array $roles
49
   */
50 1
  public function setRoles($roles)
51
  {
52 1
    parent::setObjects($roles);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setObjects() instead of setRoles()). Are you sure this is correct? If so, you might want to change this to $this->setObjects().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
53 1
  }
54
55
  /**
56
   * Return all roles.
57
   *
58
   * @return array()|Role[]
0 ignored issues
show
Documentation introduced by
The doc-type array()|Role[] could not be parsed: Expected "|" or "end of type", but got "(" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
59
   */
60 6
  public function getRoles()
61
  {
62 6
    return parent::getObjects();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObjects() instead of getRoles()). Are you sure this is correct? If so, you might want to change this to $this->getObjects().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
63
  }
64
65
  /**
66
   * Return array of names for registered roles.
67
   *
68
   * @return array
69
   */
70 6
  public function getRolesNames(): array
71
  {
72 6
    return parent::getObjectNames();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObjectNames() instead of getRolesNames()). Are you sure this is correct? If so, you might want to change this to $this->getObjectNames().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
73
  }
74
75
  /**
76
   * Return role by name.
77
   *
78
   * @param Role|string $roleName
79
   *
80
   * @return null|Role
81
   */
82 3
  public function getRole($roleName)
83
  {
84 3
    return parent::getObject($roleName);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObject() instead of getRole()). Are you sure this is correct? If so, you might want to change this to $this->getObject().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
85
  }
86
}
87