src/MVQN/REST/RestObject.php
public function validate(string $method, array &$missing = null, array &$ignored = null): bool
    {
        // Setup the Reflection instance for the calling class.
        $class = get_called_class();
        $reflection = new \ReflectionClass($class);

        // Get an array of all Model properties, via Reflection.
        $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED);

        // Initialize a collection to store missing entries.
        $missing = [];

        // Loop through each property of the protected properties...
        foreach($properties as $property)
        {
            // Get the name of the property.
            $name = $property->getName();

            if($name === "firstName" || $name === "lastName")
            {

                echo "";
            }

            // Create an AnnotationReader to parse the annotations for this property and get the list of annotations.
            $annotations = new AnnotationReader($class);
            $params = $annotations->getPropertyAnnotations($name)[$name];

            // IF this is a required property, per the use of '@<method>Required'...
            if(array_key_exists(ucfirst($method)."Required", $params) || array_key_exists($method."-required", $params))
            {
                $conditional = $params[ucfirst($method)."Required"];
                $required = true;

                if ($conditional === "")
                {
                    $required = true;
                }
                else
                    if($conditional !== "" && Strings::contains($conditional, "`"))
                    {
                        $conditional = str_replace("`", "", $conditional);
                        $required = eval("use $class; return $conditional;");
                    }
                    else
                    {
                        throw new \Exception("[MVQN\Annotations\AnnotationReader] An annotation of '@{$method}Required' needs to either have a ".
                            "value set, or a conditional statement enclosed in back-ticks (`) to be evaluated at runtime.");
                    }

                // THEN set the property accessible for this test only.
                $property->setAccessible(true);

                // Get the actual value of this property instance.
                $value = $property->getValue($this);

                // IF the value of this property is NULL, THEN we need to mark it as missing.
                if($required && $value === null)
                    $missing[] = $name;
            }

            if (!array_key_exists(ucfirst($method)."Required", $params) &&
                !array_key_exists($method."-required", $params) &&
                !array_key_exists(ucfirst($method), $params) &&
                !array_key_exists($method, $params) && ($method !== "post" && $name !== "id"))
            {
                // Unset this property, as it should not be passed to the Endpoint!
                unset($this->{$name});

                $ignored[] = $name;
            }
        }

        // If there are any required properties missing, then return false!
        return ($missing === []);
    }
public function validate(string $method, array &$missing = null, array &$ignored = null): bool
    {
        // Setup the Reflection instance for the calling class.
        $class = get_called_class();
        $reflection = new \ReflectionClass($class);

        // Get an array of all Model properties, via Reflection.
        $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED);

        // Initialize a collection to store missing entries.
        $missing = [];

        // Loop through each property of the protected properties...
        foreach($properties as $property)
        {
            // Get the name of the property.
            $name = $property->getName();

            if($name === "firstName" || $name === "lastName")
            {

                echo "";
            }

            // Create an AnnotationReader to parse the annotations for this property and get the list of annotations.
            $annotations = new AnnotationReader($class);
            $params = $annotations->getPropertyAnnotations($name)[$name];

            // IF this is a required property, per the use of '@<method>Required'...
            if(array_key_exists(ucfirst($method)."Required", $params) || array_key_exists($method."-required", $params))
            {
                $conditional = $params[ucfirst($method)."Required"];
                $required = true;

                if ($conditional === "")
                {
                    $required = true;
                }
                else
                    if($conditional !== "" && Strings::contains($conditional, "`"))
                    {
                        $conditional = str_replace("`", "", $conditional);
                        $required = eval("use $class; return $conditional;");
                    }
                    else
                    {
                        throw new \Exception("[MVQN\Annotations\AnnotationReader] An annotation of '@{$method}Required' needs to either have a ".
                            "value set, or a conditional statement enclosed in back-ticks (`) to be evaluated at runtime.");
                    }

                // THEN set the property accessible for this test only.
                $property->setAccessible(true);

                // Get the actual value of this property instance.
                $value = $property->getValue($this);

                // IF the value of this property is NULL, THEN we need to mark it as missing.
                if($required && $value === null)
                    $missing[] = $name;
            }

            if (!array_key_exists(ucfirst($method)."Required", $params) &&
                !array_key_exists($method."-required", $params) &&
                !array_key_exists(ucfirst($method), $params) &&
                !array_key_exists($method, $params) && ($method !== "post" && $name !== "id"))
            {
                // Unset this property, as it should not be passed to the Endpoint!
                unset($this->{$name});

                $ignored[] = $name;
            }
        }

        // If there are any required properties missing, then return false!
        return ($missing === []);
    }
Checks to determine the validity of a RestObject, by comparing each properties value to NULL, when it has been
annotated with either '@<method>' or '@<method>Required'.

@param string $method The HTTP method/verb for which to examine each property for validity.
@param array|null $missing A reference array used to store the missing/unset properties for later use.
@param array|null $ignored A reference array used to store any ignored properties for later use.
@return bool Returns TRUE if all required properties have a value set, otherwise FALSE.
@throws \Exception