Permalink
Browse files

Ran PSR-2 CS fixer.

  • Loading branch information...
1 parent 4025b78 commit 5c5b1a08e0120b9a8a6156d4dd431ba40513fdc0 Kyle Spraggs committed Sep 21, 2012
@@ -53,13 +53,14 @@ public function getName()
public function addPermission($name)
{
$this->permissions[$name] = true;
+
return $this;
}
/**
* Checks if a permission exists for this role or any child roles.
*
- * @param string $name
+ * @param string $name
* @return bool
*/
public function hasPermission($name)
@@ -69,19 +70,20 @@ public function hasPermission($name)
}
$it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
- foreach($it as $leaf) {
+ foreach ($it as $leaf) {
/** @var AbstractRole $leaf */
if ($leaf->hasPermission($name)) {
return true;
}
}
+
return false;
}
/**
* Add a child.
*
- * @param AbstractRole|string $child
+ * @param AbstractRole|string $child
* @return Role
*/
public function addChild($child)
@@ -97,16 +99,18 @@ public function addChild($child)
$child->setParent($this);
$this->children[] = $child;
+
return $this;
}
/**
- * @param AbstractRole $parent
+ * @param AbstractRole $parent
* @return AbstractRole
*/
public function setParent($parent)
{
$this->parent = $parent;
+
return $this;
}
@@ -10,8 +10,6 @@
namespace Zend\Permissions\Rbac;
-use RecursiveIteratorIterator;
-
/**
* @category Zend
* @package Zend_Permissions
@@ -22,7 +20,7 @@
/**
* Assertion method - must return a boolean.
*
- * @param Rbac $bac
+ * @param Rbac $bac
* @return boolean
*/
public function assert(Rbac $rbac);
@@ -28,12 +28,13 @@ class Rbac extends AbstractIterator
protected $createMissingRoles = false;
/**
- * @param boolean $createMissingRoles
+ * @param boolean $createMissingRoles
* @return \Zend\Permissions\Rbac\Rbac
*/
public function setCreateMissingRoles($createMissingRoles)
{
$this->createMissingRoles = $createMissingRoles;
+
return $this;
}
@@ -48,7 +49,7 @@ public function getCreateMissingRoles()
/**
* Add a child.
*
- * @param string|AbstractRole $child
+ * @param string|AbstractRole $child
* @return AbstractRole
* @throws Exception\InvalidArgumentException
*/
@@ -67,7 +68,7 @@ public function addRole($child, $parents = null)
if (!is_array($parents)) {
$parents = array($parents);
}
- foreach($parents as $parent) {
+ foreach ($parents as $parent) {
if ($this->createMissingRoles && !$this->hasRole($parent)) {
$this->addRole($parent);
}
@@ -76,19 +77,21 @@ public function addRole($child, $parents = null)
}
$this->children[] = $child;
+
return $this;
}
/**
* Is a child with $name registered?
*
- * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
+ * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
* @return bool
*/
public function hasRole($objectOrName)
{
try {
$this->getRole($objectOrName);
+
return true;
} catch (Exception\InvalidArgumentException $e) {
return false;
@@ -98,7 +101,7 @@ public function hasRole($objectOrName)
/**
* Get a child.
*
- * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
+ * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
* @return AbstractRole
* @throws Exception\InvalidArgumentException
*/
@@ -111,7 +114,7 @@ public function getRole($objectOrName)
}
$it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
- foreach($it as $leaf) {
+ foreach ($it as $leaf) {
if ((is_string($objectOrName) && $leaf->getName() == $objectOrName) || $leaf == $objectOrName) {
return $leaf;
}
@@ -126,7 +129,7 @@ public function getRole($objectOrName)
/**
* Determines if access is granted by checking the role and child roles for permission.
*
- * @param string $permission
+ * @param string $permission
* @param \Zend\Permissions\Rbac\AssertionInterface|Callable|null $assert
*/
public function isGranted($role, $permission, $assert = null)
@@ -136,7 +139,7 @@ public function isGranted($role, $permission, $assert = null)
if (!$assert->assert($this)) {
return false;
}
- } else if (is_callable($assert)) {
+ } elseif (is_callable($assert)) {
if (!$assert($this)) {
return false;
}
@@ -150,6 +153,7 @@ public function isGranted($role, $permission, $assert = null)
if ($this->getRole($role)->hasPermission($permission)) {
return true;
}
+
return false;
}
}
@@ -35,7 +35,7 @@ public function __construct(AbstractRole $role)
/**
* Assertion method - must return a boolean.
*
- * @param Rbac $bac
+ * @param Rbac $bac
* @return boolean
*/
public function assert(Rbac $rbac)
@@ -24,7 +24,7 @@ class SimpleFalseAssertion implements AssertionInterface
/**
* Assertion method - must return a boolean.
*
- * @param Rbac $bac
+ * @param Rbac $bac
* @return boolean
*/
public function assert(Rbac $rbac)
@@ -24,7 +24,7 @@ class SimpleTrueAssertion implements AssertionInterface
/**
* Assertion method - must return a boolean.
*
- * @param Rbac $bac
+ * @param Rbac $bac
* @return boolean
*/
public function assert(Rbac $rbac)

0 comments on commit 5c5b1a0

Please sign in to comment.