original_string: public function check( $namespaces, PermissibleModel $model = null, PermissibleEntity $entity = null )
  	{
  		// Allows for static calling
  		$instance = $this ?: self::i();
  
  		if ( !is_array( $namespaces ) )
  			$namespaces = [$namespaces];
  
  		foreach ( $namespaces as &$ns )
  		{
  			if ( !is_string( $ns ) )
  				throw new PermissionException( "The permission namespace must be a string." );
  
  			$ns = static::getAlias( $ns );
  
  			if ( !preg_match( "/[a-z0-9_.]*/", $ns ) )
  				throw new PermissionException( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." );
  		}
  
  		if ( $model != null )
  		{
  			if ( $model instanceof PermissibleModel )
  			{
  				$namespaces_new = $namespaces;
  				foreach ( $model->getIdentifiers() as $key => $id )
  					$namespaces_new = str_replace( "{" . $key . "}", $id, $namespaces_new );
  
  				// Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node.
  				// $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) );
  
  				// Log::debug( "Amending namespaces [" . str_replace( "\n", "", var_export( $namespaces, true ) ) . "] with model [" . get_class( $model ) . "] resulting in [" . str_replace( "\n", "", var_export( $namespaces_new, true ) ) . "]" );
  
  				return $instance->check( $namespaces_new, null, $entity );
  			}
  			else
  				throw new PermissionException( "The 'model' must implement PermissibleModel." );
  		}
  
  		$current_state = PermissionValues::UNSET;
  
  		array_walk( $namespaces, function ( $ns ) use ( &$instance, &$entity, &$current_state )
  		{
  			$current_state = $instance->checkRaw( $ns, $entity );
  
  			Log::debug( "Checking permission [" . $ns . "] on entity [" . ( $entity ? get_class( $entity ) : "null" ) . "] with result [" . $current_state . "]" );
  
  			if ( $current_state == PermissionValues::ALWAYS )
  				return true;
  			if ( $current_state == PermissionValues::NEVER )
  				return false;
  			if ( $current_state == PermissionValues::UNSET || !PermissionValues::valid( $current_state ) )
  				throw new PermissionException( "Permission Exception!" );
  		} );
  
  		return $current_state == PermissionValues::YES;
  	}
code: public function check( $namespaces, PermissibleModel $model = null, PermissibleEntity $entity = null )
  	{
  		// Allows for static calling
  		$instance = $this ?: self::i();
  
  		if ( !is_array( $namespaces ) )
  			$namespaces = [$namespaces];
  
  		foreach ( $namespaces as &$ns )
  		{
  			if ( !is_string( $ns ) )
  				throw new PermissionException( "The permission namespace must be a string." );
  
  			$ns = static::getAlias( $ns );
  
  			if ( !preg_match( "/[a-z0-9_.]*/", $ns ) )
  				throw new PermissionException( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." );
  		}
  
  		if ( $model != null )
  		{
  			if ( $model instanceof PermissibleModel )
  			{
  				$namespaces_new = $namespaces;
  				foreach ( $model->getIdentifiers() as $key => $id )
  					$namespaces_new = str_replace( "{" . $key . "}", $id, $namespaces_new );
  
  				// Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node.
  				// $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) );
  
  				// Log::debug( "Amending namespaces [" . str_replace( "\n", "", var_export( $namespaces, true ) ) . "] with model [" . get_class( $model ) . "] resulting in [" . str_replace( "\n", "", var_export( $namespaces_new, true ) ) . "]" );
  
  				return $instance->check( $namespaces_new, null, $entity );
  			}
  			else
  				throw new PermissionException( "The 'model' must implement PermissibleModel." );
  		}
  
  		$current_state = PermissionValues::UNSET;
  
  		array_walk( $namespaces, function ( $ns ) use ( &$instance, &$entity, &$current_state )
  		{
  			$current_state = $instance->checkRaw( $ns, $entity );
  
  			Log::debug( "Checking permission [" . $ns . "] on entity [" . ( $entity ? get_class( $entity ) : "null" ) . "] with result [" . $current_state . "]" );
  
  			if ( $current_state == PermissionValues::ALWAYS )
  				return true;
  			if ( $current_state == PermissionValues::NEVER )
  				return false;
  			if ( $current_state == PermissionValues::UNSET || !PermissionValues::valid( $current_state ) )
  				throw new PermissionException( "Permission Exception!" );
  		} );
  
  		return $current_state == PermissionValues::YES;
  	}
code_tokens: public function check ( $ namespaces , PermissibleModel $ model = null , PermissibleEntity $ entity = null ) { // Allows for static calling $ instance = $ this ? : self :: i ( ) ; if ( ! is_array ( $ namespaces ) ) $ namespaces = [ $ namespaces ] ; foreach ( $ namespaces as & $ ns ) { if ( ! is_string ( $ ns ) ) throw new PermissionException ( "The permission namespace must be a string." ) ; $ ns = static :: getAlias ( $ ns ) ; if ( ! preg_match ( "/[a-z0-9_.]*/" , $ ns ) ) throw new PermissionException ( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." ) ; } if ( $ model != null ) { if ( $ model instanceof PermissibleModel ) { $ namespaces_new = $ namespaces ; foreach ( $ model -> getIdentifiers ( ) as $ key => $ id ) $ namespaces_new = str_replace ( "{" . $ key . "}" , $ id , $ namespaces_new ) ; // Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node. // $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) ); // Log::debug( "Amending namespaces [" . str_replace( "\n", "", var_export( $namespaces, true ) ) . "] with model [" . get_class( $model ) . "] resulting in [" . str_replace( "\n", "", var_export( $namespaces_new, true ) ) . "]" ); return $ instance -> check ( $ namespaces_new , null , $ entity ) ; } else throw new PermissionException ( "The 'model' must implement PermissibleModel." ) ; } $ current_state = PermissionValues :: UNSET ; array_walk ( $ namespaces , function ( $ ns ) use ( & $ instance , & $ entity , & $ current_state ) { $ current_state = $ instance -> checkRaw ( $ ns , $ entity ) ; Log :: debug ( "Checking permission [" . $ ns . "] on entity [" . ( $ entity ? get_class ( $ entity ) : "null" ) . "] with result [" . $ current_state . "]" ) ; if ( $ current_state == PermissionValues :: ALWAYS ) return true ; if ( $ current_state == PermissionValues :: NEVER ) return false ; if ( $ current_state == PermissionValues :: UNSET || ! PermissionValues :: valid ( $ current_state ) ) throw new PermissionException ( "Permission Exception!" ) ; } ) ; return $ current_state == PermissionValues :: YES ; }
docstring: Checks a permission for assignment and policy checks
  
  @param string|array $namespace
  @param PermissibleEntity|null $entity
  
  @return bool
docstring_tokens: Checks a permission for assignment and policy checks