PHP Class Authority\RuleRepository

Inheritance: implements Countabl\Countable, implements ArrayAcces\ArrayAccess, implements IteratorAggregat\IteratorAggregate
Show file Open project: machuga/authority Class Usage Examples

Protected Properties

Property Type Description
$rules Internal container for the rules

Public Methods

Method Description
__construct ( array $rules = [] ) RuleRepository constructor
add ( Rule $rule ) : void Add a rule to the collection
all ( ) : array Return a raw array of all rules
count ( ) : integer Returns the number of rules
first ( ) : Rule | null Return the first element in the array or null if empty
getIterator ( ) : ArrayIterator Returns an iterator for the internal array
getRelevantRules ( string $action, string $resource ) : RuleRepository Get all rules only relevant to the given action and resource
isEmpty ( ) : boolean Determine if empty
last ( ) : Rule | null Return the last element in the array or null if empty
offsetExists ( $key ) : boolean Determine if the rule exists by key
offsetGet ( $key ) : Rule Returns the requested Rule
offsetSet ( $key, $value ) : void Sets the rule at the given key
offsetUnset ( $key ) : void Unsets the rule at the given key
reduce ( Closure $callback, mixed $initialValue = [] ) : RuleRepository Runs a reduce callback on the collection

Method Details

__construct() public method

RuleRepository constructor
public __construct ( array $rules = [] )
$rules array Initial list of rules for the collection

add() public method

Add a rule to the collection
public add ( Rule $rule ) : void
$rule Rule
return void

all() public method

Return a raw array of all rules
public all ( ) : array
return array

count() public method

Returns the number of rules
public count ( ) : integer
return integer

first() public method

Return the first element in the array or null if empty
public first ( ) : Rule | null
return Rule | null

getIterator() public method

Returns an iterator for the internal array

getRelevantRules() public method

Get all rules only relevant to the given action and resource
public getRelevantRules ( string $action, string $resource ) : RuleRepository
$action string Action to check against
$resource string Resource to check against
return RuleRepository

isEmpty() public method

Determine if empty
public isEmpty ( ) : boolean
return boolean

last() public method

Return the last element in the array or null if empty
public last ( ) : Rule | null
return Rule | null

offsetExists() public method

Determine if the rule exists by key
public offsetExists ( $key ) : boolean
return boolean

offsetGet() public method

Returns the requested Rule
public offsetGet ( $key ) : Rule
return Rule

offsetSet() public method

Sets the rule at the given key
public offsetSet ( $key, $value ) : void
return void

offsetUnset() public method

Unsets the rule at the given key
public offsetUnset ( $key ) : void
return void

reduce() public method

Runs a reduce callback on the collection
public reduce ( Closure $callback, mixed $initialValue = [] ) : RuleRepository
$callback Closure Callback to use for the reduce algorithm
$initialValue mixed Initial value for the reduce set
return RuleRepository

Property Details

$rules protected property

Internal container for the rules
protected $rules