Validates subject against dependencies

@param array $subject
@return bool
165807
public function validate($subject): bool
    {
        // This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST
        // be an array or a valid JSON Schema.
        if (\is_array($this->schema['dependencies']) && count($this->schema['dependencies']) > 0) {
            foreach ($this->schema['dependencies'] as $propertyName => $dependentProperties) {
                // If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST
                // be unique. If the dependency key is a property in the instance, each of the items in the
                // dependency value must be a property that exists in the instance.
                if (\is_int(\array_keys($dependentProperties)[0])) {
                    if (!$this->validateClassicDependencies($subject, $propertyName, $dependentProperties)) {
                        return false;
                    }
                    // If the dependency value is a subschema, and the dependency key is a property in the instance,
                    // the entire instance must validate against the dependency value.
                } elseif (\is_string(\array_keys($dependentProperties)[0])) {
                    if (!$this->validateSchemaDependencies($subject, $propertyName, $dependentProperties)) {
                        return false;
                    }
                }

            }
        }
        return true;
    }
388905
protected function preCheckedEnum($subject, array $allowedValues) : bool
    {
        if ($subject !== null && !is_scalar($subject)) {
            return false;
        }
        foreach ($allowedValues as $allowed) {
            if ($subject === $allowed) {
                return true;
            }
        }
        return false;
    }
1134416
public function check_dependencies(array $dependencies)
	{
		foreach($dependencies as $dep)
		{
			// get the section name and identifier
			$sections = explode('.', $dep);
			if (count($sections) > 1)
			{
				$identifier = array_pop($sections);
				$sections = '.'.implode('.', $sections);

			}
			else
			{
				$identifier = $dep;
				$sections = '';
			}

			// get the cache index
			$index = static::$redis->get($this->config['cache_id'].':index:'.$sections);
			is_null($index) or $index = $this->_unserialize($index);

			// get the key from the index
			$key = isset($index[$identifier][0]) ? $index[$identifier] : false;

			// key found and newer?
			if ($key === false or $key[1] > $this->created)
			{
				return false;
			}
		}
		return true;
	}
35685
public function validate($subject): bool
    {
        if (\is_string($this->schema['pattern'])) {
            if (!\preg_match(sprintf('/%s/i', $this->schema['pattern']), $subject)) {
                return false;
            }
        }
        return true;
    }
522012
protected function isSubjectSupported($subject)
    {
        if (null === $subject || \is_string($subject) || $subject instanceof FieldVote || \is_object($subject)) {
            return true;
        }

        return \is_array($subject)
            && isset($subject[0], $subject[1])

            && (\is_string($subject[0]) || \is_object($subject[0]))
            && \is_string($subject[1]);
    }
859231
public function validateSpecific(array $required = [])
    {
        foreach ($required as $field) {
            /*
             * If the field is in the required array, and the
             * object attribute equals null, we'll throw an exception.
             */
            if (in_array($field, $this->required) && $this->getAttribute($field) === null) {
                throw new AdldapException(sprintf($this->messages['required'], $field));
            }
        }

        return true;
    }
198647
public function validate($subject): bool
    {
        if (isset($this->schema['items']) && \is_array($this->schema['items'])) {
            $schemaFirstKey = \array_keys($this->schema['items'])[0];
            $schemaType = \is_int($schemaFirstKey) ? 'array' : 'object';

            if ($schemaType === 'array') {
                if (!$this->validateAdditionalItems($subject, $this->schema)) {
                    return false;
                }
            }
        }
        return true;
    }
451161
private function validateAdditionalItemsSchemaObject(array $subject, array $schema): bool
    {
        for ($i = 0; $i < count($subject); $i++) {
            $nodeValidator = new NodeValidator($schema['additionalItems'], $this->rootSchema);
            if (!$nodeValidator->validate($subject[$i])) {
                return false;
            }
        }
        return true;
    }
1370881
protected function supportSubject($subject)
    {
        foreach ($this->getSupportedClasses() as $supportedClass) {
            if ($subject instanceof StatusableInterface && $subject instanceof $supportedClass) {
                return true;
            }
        }

        return false;
    }
678188
public function empty($subject) : bool
    {
        if (!$subject) {
            // Stringed zero - '0' - is not empty.
            return $subject !== '0';
        }
        if (is_object($subject)) {
            if ($subject instanceof \Countable) {
                return !count($subject);
            }
            if ($subject instanceof \Traversable) {
                // No need to check/use ArrayObject|ArrayIterator, because
                // those are both Countable (checked before this check).

                // Have to iterate; horrible.
                foreach ($subject as $ignore) {
                    return false;
                }
                return true;
            }
            if ($subject instanceof \ArrayAccess) {
                return false;
            }
            return !get_object_vars($subject);
        }
        return false;
    }
241924
protected function checkDependency($dependencies = null)
    {
        $errors = array();

        if (is_null($dependencies)) $dependencies = array();

        $i = 0;
        $clean = true;
        foreach ($dependencies as $module => $version)
        {
            if ($module == $this->systemName)
            {
                if (!$this->sysVersionDependency($version))
                    $clean = false;

                continue;
            }

            $depModule = ModuleModel::where('module_name', $module)->first();
            if (!$depModule)
            {
                $this->errors->add("module_dependency_$i", "Module $module with version $version not installed");
                $clean = false;
            }
            else
            {
                $depVersion = $depModule->module_version;
                $needVersion = $version;

                $depVersion = new Version($depVersion);
                $needVersion = new Version($needVersion);

                if (!$depVersion->isPartOf($needVersion))
                {
                    $this->errors->add("module_dependency_$i", 'Module '.$module.' v'.$needVersion->getVersion().' must install, but '.$depVersion->getVersion().' installed.');
                    $clean = false;
                }
            }
            $i++;
        }

        if(!$clean)
            return false;

        return true;
    }
734422
public function check_dependencies(array $dependencies)
	{
		foreach($dependencies as $dep)
		{
			if (is_file($file = static::$path.str_replace('.', DS, $dep).'.cache'))
			{
				$filemtime = filemtime($file);
				if ($filemtime === false || $filemtime > $this->created)
				{
					return false;
				}
			}
			elseif (is_file($dep))
			{
				$filemtime = filemtime($dep);
				if ($filemtime === false || $filemtime > $this->created)
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}

		return true;
	}
159478
public function ipAddress($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        return $v === '' ? false : !!filter_var($v, FILTER_VALIDATE_IP);
    }
139428
protected function supportSubject($subject)
    {
        if (is_object($subject)) {
            return $this->supportClasses(
                $subject,
                array(
                    'OpenOrchestra\ModelInterface\Model\KeywordInterface',
                    'OpenOrchestra\BaseApi\Model\ApiClientInterface'
                )
            );
        }

        return in_array(
            $subject,
            array(
                KeywordInterface::ENTITY_TYPE,
                ApiClientInterface::ENTITY_TYPE
            )
        );
    }
383422
public function isEligible(PromotionSubjectInterface $subject, array $configuration): bool
    {
        if (!$subject instanceof OrderInterface) {
            throw new UnsupportedTypeException($subject, OrderInterface::class);
        }

        $channelCode = $subject->getChannel()->getCode();
        if (!isset($configuration[$channelCode])) {
            return false;
        }

        return $this->itemTotalRuleChecker->isEligible($subject, $configuration[$channelCode]);
    }
775185
public function validate($subject): bool
    {
        // Validation with "additionalProperties" applies only to the child values of instance names that do
        // not match any names in "properties", and do not match any regular expression in "patternProperties".
        $subject = $this->removePropertiesFromSubject($subject, $this->schema);
        $subject = $this->removePatternPropertiesFromSubject($subject, $this->schema);
        // The value of "additionalProperties" MUST be a valid JSON Schema (including boolean false)
        if (\is_bool($this->schema['additionalProperties']) && $this->schema['additionalProperties'] === false) {
            if (count($subject) > 0) {
                return false;
            }
        } elseif (\is_array($this->schema['additionalProperties'])) {
            foreach ($subject as $propertyValue) {
                $nodeValidator = new NodeValidator($this->schema['additionalProperties'], $this->rootSchema);
                if (!$nodeValidator->validate($propertyValue)) {
                    return false;
                }
            }
        }
        return true;
    }
859856
private function matches($pattern, $subject)
    {
        if (preg_match($pattern, $subject, $matches)) {
            $args = array();

            foreach ($matches as $key => $value) {
                if (!is_int($key)) {
                    $args[$key] = $value;
                }
            }

            return $args;
        }

        return false;
    }