Пример #1
0
 /**
  * Compare Restrictions
  * 
  * This allows restrictions to be compared despite their configurations
  * This comes up when trying to compare restrictions like so:
  * 
  * $this->restrictions == $that->restrictions
  * 
  * This takes into count configurations, so this avoids that.
  * 
  * @param Falcraft\Data\Types\Restrictions The first restriction
  * @param Falcraft\Data\Types\Restrictions The second restriction
  * 
  * @return bool Equal?
  * 
  */
 public static function compare(Restrictions $R1, Restrictions $R2)
 {
     $types1 = $R1->getAllowedTypes();
     $types2 = $R2->getAllowedTypes();
     if (!array_diff($types1, $types2) && !array_diff($types2, $types1)) {
         $classes1 = $R1->getAllowedClasses();
         $classes2 = $R2->getAllowedClasses();
         if (!array_diff($classes1, $classes2) && !array_diff($classes2, $classes1)) {
             return true;
         }
     }
     return false;
 }
Пример #2
0
if ($success) {
    echo "Success!\n\nAllowed Types -- \n\n";
    var_dump($defaultRestrictions->getAllowedTypes());
    echo "\n";
} else {
    echo "Failure...\n";
}
echo "Predicate Retrieval -> ";
$success = true;
$testRestrictions = $allowedTypes = $allowedClasses = null;
require_once '../../../Data/Types/Set.php';
require_once '../../../Data/Types/Range.php';
try {
    $testRestrictions = new Types\Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Data\\Types\\Set', 'Falcraft\\Data\\Types\\Range'), array('autoload' => false));
    $allowedTypes = $testRestrictions->getAllowedTypes();
    $allowedClasses = $testRestrictions->getAllowedClasses();
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
    echo "Allowed Types -- \n\n";
    var_dump($allowedTypes);
    echo "\nAllowed Classes -- \n\n";
    var_dump($allowedClasses);
    echo "\n";
} else {
    echo "Failure...\n";
}
echo "Allowances -> \n";
echo "    Boolean (new Type(Type::BASIC_BOOL)): ";