ex
Fork of mbed-os-example-mbed5-blinky by
Diff: dumi_doc-master/schema/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php
- Revision:
- 44:c1d8923072ba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dumi_doc-master/schema/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php Tue Jul 18 16:27:22 2017 +0800
@@ -0,0 +1,59 @@
+<?php
+
+namespace JsonSchema\Constraints\TypeCheck;
+
+class LooseTypeCheck implements TypeCheckInterface
+{
+ public static function isObject($value)
+ {
+ return
+ is_object($value) ||
+ (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
+ }
+
+ public static function isArray($value)
+ {
+ return
+ is_array($value) &&
+ (count($value) == 0 || !self::isAssociativeArray($value));
+ }
+
+ public static function propertyGet($value, $property)
+ {
+ if (is_object($value)) {
+ return $value->{$property};
+ }
+
+ return $value[$property];
+ }
+
+ public static function propertyExists($value, $property)
+ {
+ if (is_object($value)) {
+ return property_exists($value, $property);
+ }
+
+ return array_key_exists($property, $value);
+ }
+
+ public static function propertyCount($value)
+ {
+ if (is_object($value)) {
+ return count(get_object_vars($value));
+ }
+
+ return count($value);
+ }
+
+ /**
+ * Check if the provided array is associative or not
+ *
+ * @param array $arr
+ *
+ * @return bool
+ */
+ private static function isAssociativeArray($arr)
+ {
+ return (array_keys($arr) !== range(0, count($arr) - 1));
+ }
+}
