PHP Class Baum\SetValidator

Datei anzeigen Open project: gazsp/baum Class Usage Examples

Protected Properties

Property Type Description
$node Node Node instance for reference.

Public Methods

Method Description
__construct ( Node $node ) : void Create a new \Baum\SetValidator class instance.
fails ( ) : boolean Determine if validation fails.
passes ( ) : boolean Determine if the validation passes.

Protected Methods

Method Description
duplicatesExistForColumn ( string $column ) : boolean Checks if duplicate values for the column specified exist. Takes the Nested Set scope columns into account (if appropiate).
groupRootsByScope ( mixed $roots ) : array Given a list of root nodes, it returns an array in which the keys are the array of the actual scope column values and the values are the root nodes inside that scope themselves.
isEachRootValid ( mixed $roots ) : boolean Check that each root node in the list supplied satisfies that its bounds values (lft, rgt indexes) are less than the next.
keyForScope ( Baum\Node $node ) : string Builds a single string for the given scope columns values. Useful for making array keys for grouping.
validateBounds ( ) : boolean Validates bounds of the nested tree structure. It will perform checks on the lft, rgt and parent_id columns. Mainly that they're not null, rights greater than lefts, and that they're within the bounds of the parent.
validateDuplicates ( ) : boolean Checks that there are no duplicates for the lft and rgt columns.
validateRoots ( ) : boolean For each root of the whole nested set tree structure, checks that their lft and rgt bounds are properly set.
validateRootsByScope ( mixed $roots ) : boolean Check that each root node in the list supplied satisfies that its bounds values (lft, rgt indexes) are less than the next *within each scope*.

Method Details

__construct() public method

Create a new \Baum\SetValidator class instance.
public __construct ( Node $node ) : void
$node Node
return void

duplicatesExistForColumn() protected method

Checks if duplicate values for the column specified exist. Takes the Nested Set scope columns into account (if appropiate).
protected duplicatesExistForColumn ( string $column ) : boolean
$column string
return boolean

fails() public method

Determine if validation fails.
public fails ( ) : boolean
return boolean

groupRootsByScope() protected method

Given a list of root nodes, it returns an array in which the keys are the array of the actual scope column values and the values are the root nodes inside that scope themselves.
protected groupRootsByScope ( mixed $roots ) : array
$roots mixed
return array

isEachRootValid() protected method

Check that each root node in the list supplied satisfies that its bounds values (lft, rgt indexes) are less than the next.
protected isEachRootValid ( mixed $roots ) : boolean
$roots mixed
return boolean

keyForScope() protected method

Builds a single string for the given scope columns values. Useful for making array keys for grouping.
protected keyForScope ( Baum\Node $node ) : string
$node Baum\Node
return string

passes() public method

Determine if the validation passes.
public passes ( ) : boolean
return boolean

validateBounds() protected method

Validates bounds of the nested tree structure. It will perform checks on the lft, rgt and parent_id columns. Mainly that they're not null, rights greater than lefts, and that they're within the bounds of the parent.
protected validateBounds ( ) : boolean
return boolean

validateDuplicates() protected method

Checks that there are no duplicates for the lft and rgt columns.
protected validateDuplicates ( ) : boolean
return boolean

validateRoots() protected method

For each root of the whole nested set tree structure, checks that their lft and rgt bounds are properly set.
protected validateRoots ( ) : boolean
return boolean

validateRootsByScope() protected method

Check that each root node in the list supplied satisfies that its bounds values (lft, rgt indexes) are less than the next *within each scope*.
protected validateRootsByScope ( mixed $roots ) : boolean
$roots mixed
return boolean

Property Details

$node protected_oe property

Node instance for reference.
protected Node,Baum $node
return Node