* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class TypeAssert { /** * @param TypeInterface $type * @see https://typeschema.org/specification#Properties * @throws InvalidSchemaException */ public static function assertProperty(TypeInterface $type) { if ($type instanceof StructType) { throw new InvalidSchemaException('Property must not contain a nested struct, got ' . get_class($type)); } } /** * @param TypeInterface $type * @see https://typeschema.org/specification#ArrayProperties * @throws InvalidSchemaException */ public static function assertItem(TypeInterface $type) { if (!($type instanceof BooleanType || $type instanceof NumberType || $type instanceof StringType || $type instanceof IntersectionType || $type instanceof UnionType || $type instanceof ReferenceType || $type instanceof GenericType || $type instanceof AnyType)) { throw new InvalidSchemaException('Item must be of type boolean, number, string, intersection, union, reference, generic or any type, got ' . get_class($type)); } } /** * @param array $items * @see https://typeschema.org/specification#AllOfProperties * @throws InvalidSchemaException */ public static function assertIntersection(array $items) { foreach ($items as $index => $item) { if (!($item instanceof ReferenceType)) { throw new InvalidSchemaException('All of item must be of type reference, at index ' . $index . ' we got ' . get_class($item)); } } } /** * @param array $items * @see https://typeschema.org/specification#OneOfProperties * @throws InvalidSchemaException */ public static function assertUnion(array $items) { foreach ($items as $index => $item) { if (!($item instanceof NumberType || $item instanceof StringType || $item instanceof BooleanType || $item instanceof ReferenceType)) { throw new InvalidSchemaException('One of item must be of type string, number, boolean or reference, at index ' . $index . ' we got ' . get_class($item)); } } } } __halt_compiler();----SIGNATURE:----hONxy+xT7YwLVmPdlHf8b08CQSbXsZEf9+FsdGttVTq8i6rcM1z9rPMOWfruSNC8yEoCDfRO6mvf/i7tS5f9D2vaOdrZtk5txGA+IAGj/J9yiSwbCqPFrsoyYeQQGmPSdxFWdwjCVQ36DhoWPCoLACVwpDX4eFPnqpN+kF0S7mGo9SLsFz5g9EA2whCOmnu4uVWP43LTm3jL8DMMO4SWavbLPb5ZXpdaasbQ+u68G4NyAtZGl0iO4PCGHLJb27tMUpzmESwpk6fQ32eobO8JJUtOmKAkV3QaSkmE6IDMHUj75ArKlGjFX0gR9TulmVAW8KEVAonxoE5uiUAcfaxokqdxlq4Ygqbkf46pL5vGx8tIy0GkW4WkKOzgL71c8twY09PdlsLGNTSKZQFCqKPReW1PdibEGcUXds3pgMj7tNhrXHsWc1vGUSJfhRdjvLuDrEtt3mlRrUBcJbBdVYtb2CbaLgkshbQc3iRb99f8sRM/caMBB12fCaLtxESqH2hqGB0nS0zb+ARPQMg6xAdr9bktjw+PrVczZMfXQ6wtMqPV9X1OQF48V0ifW00qAjOoebYr5TuApm1MyFPGd0muV5SXHpc3DCNycG6VROWynhD/e0+I+aOPAxkXYFDhNEEpuTlb0fkNB5J58MebsCiQHqiDoORBnhx+eeHu4fNl+To=----ATTACHMENT:----OTk0MzMzMTk5ODczNTc2MSA3NjQ0NzU0MDMzODgwNjMzIDYxMTI1MjkzMDE5ODg2OTY=