DataSift\Storyplayer\DefinitionLib\TestEnvironment_RolesValidator::validate PHP Method

validate() public method

throws an exception if there's anything wrong with the roles
public validate ( mixed $roles ) : void
$roles mixed the roles to validate
return void
    public function validate($roles)
    {
        $this->validateMustBeArray($roles);
        // empty arrays are allowed
        if (count($roles) === 0) {
            return;
        }
        $this->validateMustBeKeyValuePairs($roles);
    }

Usage Example

Example #1
0
 /**
  * tell this host what roles it supports
  *
  * @param array<string> $roles
  *        a list of the roles that it supports
  */
 public function setRoles($roles)
 {
     // make sure we have what we expect
     $rolesValidator = new TestEnvironment_RolesValidator($this);
     $rolesValidator->validate($roles);
     // remember the roles
     $this->roles = $roles;
     // all done
     // fluent interface support
     return $this;
 }