src/Manager.php
public function addRole($role, $inherits = null)
    {
        if (is_string($role)) {
            $name = $role;
            $role = $this->createRole($name);
        } elseif ($role instanceof RoleInterface) {
            $name = $role->getName();
        } else {
            throw new \InvalidArgumentException('Role must be a string or implement RoleInterface');
        }

        if ($inherits) {

            if (!is_array($inherits)) {
                $inherits = [$inherits];
            }

            foreach ($inherits as $inherit) {
                $role->inherit($this->getRole($inherit));
            }
        }

        $this->roles[$name] = $role;
        return $role;
    }
public function addRole($role, $inherits = null)
    {
        if (is_string($role)) {
            $name = $role;
            $role = $this->createRole($name);
        } elseif ($role instanceof RoleInterface) {
            $name = $role->getName();
        } else {
            throw new \InvalidArgumentException('Role must be a string or implement RoleInterface');
        }

        if ($inherits) {

            if (!is_array($inherits)) {
                $inherits = [$inherits];
            }

            foreach ($inherits as $inherit) {
                $role->inherit($this->getRole($inherit));
            }
        }

        $this->roles[$name] = $role;
        return $role;
    }
public function addRole ( $ role , $ inherits = null ) { if ( is_string ( $ role ) ) { $ name = $ role ; $ role = $ this -> createRole ( $ name ) ; } elseif ( $ role instanceof RoleInterface ) { $ name = $ role -> getName ( ) ; } else { throw new \ InvalidArgumentException ( 'Role must be a string or implement RoleInterface' ) ; } if ( $ inherits ) { if ( ! is_array ( $ inherits ) ) { $ inherits = [ $ inherits ] ; } foreach ( $ inherits as $ inherit ) { $ role -> inherit ( $ this -> getRole ( $ inherit ) ) ; } } $ this -> roles [ $ name ] = $ role ; return $ role ; }
Creates a new Role to the RBAC system.

@param string $role
@param string|array|RoleInterface $inherits
@return RoleInterface
Creates a new Role to the RBAC system .