public static function check(Resource $resource)
 {
     foreach ($resource->mandatory() as $key => $value) {
         if (isset($value['when']['condition']) && $value['when']['condition'] === 'is_present' && $resource->hasProperty($value['when']['property']) && $resource->hasNotProperty($key)) {
             throw new RuntimeException("Property `" . get_class($resource) . "::\${$key}` is mandatory but not set");
         }
     }
 }
 public static function check(Resource $resource)
 {
     foreach ($resource->mandatory() as $key => $value) {
         if (is_numeric($key) && $resource->hasNotProperty($value) && !isset($resource->defaults()[$value])) {
             throw new RuntimeException("Property `" . get_class($resource) . "::\${$value}` is mandatory but not set. " . "Mandatory fields are: " . join(',', $resource->mandatory()) . ".");
         }
     }
 }
 public static function check(Resource $resource)
 {
     $allowed = array_merge($resource->allowed(), $resource->mandatory());
     foreach ($resource->properties() as $key => $value) {
         if (!in_array($key, $allowed)) {
             $isAllowed = false;
             foreach ($allowed as $kk => $vv) {
                 if (!is_numeric($kk) && $resource->hasProperty($vv['when']['property'])) {
                     $isAllowed = true;
                 }
             }
             if (!$isAllowed) {
                 throw new RuntimeException("Key `" . get_class($resource) . "::\${$key}` with value `" . $value . "` is not allowed");
             }
         }
     }
 }
 public static function check(Resource $resource)
 {
     foreach ($resource->mandatory() as $key => $value) {
         if (isset($value['when']['has_value'])) {
             $propertyName = $value['when']['property'];
             $propertyValue = $value['when']['has_value'];
             if (is_array($propertyValue)) {
                 foreach ($propertyValue as $value) {
                     if ($resource->get($propertyName) === $value && $resource->hasNotProperty($key)) {
                         throw new RuntimeException('When property `' . $key . '` has value ' . '`' . $value . '` also `' . $key . '` is mandatory');
                     }
                 }
             } else {
                 if ($resource->get($propertyName) === $propertyValue && $resource->hasNotProperty($key)) {
                     throw new RuntimeException('When property `' . $propertyName . '` has value ' . '`' . $propertyValue . '` also `' . $key . '` is mandatory');
                 }
             }
         }
     }
 }