@param mixed            $value
@param ContextInterface $context

@return array

@SuppressWarnings(PHPMD.StaticAccess)

@throws ContainerExceptionInterface
@throws NotFoundExceptionInterface
429094
public static function execute($value, ContextInterface $context): array
    {
        assert(is_int($value) || is_string($value));

        $apiClass = $context->getProperties()->getProperty(static::PROPERTY_API_CLASS);

        /** @var FactoryInterface $apiFactory */
        $apiFactory = $context->getContainer()->get(FactoryInterface::class);

        /** @var CrudInterface $api */
        $api = $apiFactory->createApi($apiClass);

        $data   = $api->withIndexFilter((string)$value)->indexIdentities();
        $result = !empty($data);

        return $result === true ?
            static::createSuccessReply($value) :
            static::createErrorReply(
                $context,
                $value,
                ErrorCodes::EXIST_IN_DATABASE_SINGLE,
                Messages::EXIST_IN_DATABASE_SINGLE,
                []
            );
    }
531826
public function check($value, array $context = [])
    {
        $count = 0;

        foreach ($context as $field => $value) {
            if (in_array($field, $this->fields)) {
                $count++;
            }
        }

        return ($count === 1);
    }
440872
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (null === $value || '' === $value) {
            return [];
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            return [new Error(
                $path,
                'constraint.email.invalidtype',
                ['type' => is_object($value) ? get_class($value) : gettype($value)]
            )];
        }

        $value = (string) $value;

        if (false === filter_var($value, FILTER_VALIDATE_EMAIL)) {
            return [new Error($path, 'constraint.email.invalidformat', ['value' => $value])];
        }

        return [];
    }
374468
public function resolve(
        ValueInterface $value,
        FixtureInterface $fixture,
        ResolvedFixtureSet $fixtureSet,
        array $scope,
        GenerationContext $context
    ): ResolvedValueWithFixtureSet {
        $parameterKey = $value->getValue();
        $parameters = $fixtureSet->getParameters();
        if (false === $parameters->has($parameterKey)) {
            throw UnresolvableValueExceptionFactory::createForCouldNotFindParameter($parameterKey);
        }

        return new ResolvedValueWithFixtureSet(
            $parameters->get($parameterKey),
            $fixtureSet
        );
    }
1271356
public static function execute($value, ContextInterface $context): array
    {
        $idExists = is_int($value) === true && $value < 3;

        return $idExists === true ?
            static::createSuccessReply($value) :
            static::createErrorReply(
                $context,
                $value,
                Errors::IS_VALID_SKU,
                static::MESSAGE_TEMPLATE,
                []
            );
    }
568109
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (!is_numeric($value)) {
            return [];
        }

        if (null !== $this->min && $value < $this->min || null !== $this->max && $value > $this->max) {
            return [
                new Error(
                    $path,
                    'constraint.numericrange.outofrange',
                    ['value' => $value, 'min' => $this->min, 'max' => $this->max]
                ),
            ];
        }

        return [];
    }
293853
public static function execute($values, ContextInterface $context): array
    {
        assert(is_array($values));

        // let's consider an empty index list as `readable`
        $result = true;

        if (empty($values) === false) {
            $apiClass = $context->getProperties()->getProperty(static::PROPERTY_API_CLASS);

            /** @var FactoryInterface $apiFactory */
            $apiFactory = $context->getContainer()->get(FactoryInterface::class);

            /** @var CrudInterface $api */
            $api = $apiFactory->createApi($apiClass);

            $readIndexes = $api->withIndexesFilter($values)->indexIdentities();

            $result = count($readIndexes) === count($values);
        }

        return $result === true ?
            static::createSuccessReply($values) :
            static::createErrorReply(
                $context,
                $values,
                ErrorCodes::EXIST_IN_DATABASE_MULTIPLE,
                Messages::EXIST_IN_DATABASE_MULTIPLE,
                []
            );
    }
573205
public static function fromValue( $value )
	{
		$result = new ContextProvider();
		$result->m_iter = XPath2NodeIterator::Create( $value );
		return $result;
	}
656018
public function isValid($value, $context = null)
    {
        $this->_getValidators();
        $this->messages = array();
        $result         = false;
        foreach ($this->validators as $element) {
            /** @var $validator ValidatorInterface */
            $validator = $element['instance'];
            if (!$validator->isValid($value, $context)) {
                $messages       = $validator->getMessages();
                $this->messages = array_replace_recursive($this->messages, $messages);
                continue;
            }
            $result         = true;
        }
        return $result;
    }
204813
protected function validate_contextid($value) {
        $context = context::instance_by_id($value, IGNORE_MISSING);
        if (!$context) {
            return new lang_string('invalidcontext', 'error');
        } else if ($context->contextlevel != CONTEXT_SYSTEM && $context->contextlevel != CONTEXT_COURSECAT) {
            return new lang_string('invalidcontext', 'error');
        }
        return true;
    }
1265157
public function assemble(ContextInterface $context)
    {
        $class = ClassGenerator::fromArray(
            [
                'name' => $context->getName(),
            ]
        );
        $file = $context->getFile();
        $file->setClass($class);
        $file->setNamespace($context->getNamespace());
        $typeMap = $context->getTypeMap();
        $typeNamespace = $typeMap->getNamespace();
        $file->setUse($typeNamespace, preg_match('/\\\\Type$/', $typeNamespace) ? null : 'Type');

        try {
            $file->setUse(ClassMapCollection::class);
            $file->setUse(ClassMap::class);
            $linefeed = $file::LINE_FEED;
            $classMap = $this->assembleClassMap($typeMap, $linefeed, $file->getIndentation());
            $code = $this->assembleClassMapCollection($classMap, $linefeed).$linefeed;
            $class->addMethodFromGenerator(
                MethodGenerator::fromArray(
                    [
                        'name'       => 'getCollection',
                        'static'     => true,
                        'body'       => 'return '.$code,
                        'returntype' => ClassMapCollection::class,
                    ]
                )
            );
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
609041
public static function execute($value, ContextInterface $context): array
    {
        return is_float($value) === true ?
            static::createSuccessReply($value) :
            static::createErrorReply($context, $value, ErrorCodes::IS_FLOAT, Messages::IS_FLOAT, []);
    }
61233
public static function execute($value, ContextInterface $context): array
    {
        $format = $context->getProperties()->getProperty(self::PROPERTY_FORMAT);
        if (is_string($value) === true && ($parsed = static::parseFromFormat($value, $format)) !== null) {
            return static::createSuccessReply($parsed);
        } elseif ($value instanceof DateTimeInterface) {
            return static::createSuccessReply($value);
        }

        return static::createErrorReply(
            $context,
            $value,
            ErrorCodes::IS_DATE_TIME,
            Messages::IS_DATE_TIME,
            [$format]
        );
    }
841983
function applyFilters($value, $valueIdentifier, $context)
    {
        foreach ($this->filters as $selector => $filterSet) {
            /* @var $filterSet FilterSet */
            if ($selector != self::SELECTOR_ROOT && $this->itemMatchesSelector($valueIdentifier, $selector)) {
                $value = $filterSet->applyFilters($value, $valueIdentifier, $context);
            }
        }
        return $value;
    }
1045809
public function isValid($value, $context = null)
    {
        if (! $this->useContext) {
            $context = (array) $value;
        }

        $cleanedValue = $this->cleanSearchValue($value);
        $match        = $this->objectRepository->findOneBy($cleanedValue);

        if (! is_object($match)) {
            return true;
        }

        $expectedIdentifiers = $this->getExpectedIdentifiers($context);
        $foundIdentifiers    = $this->getFoundIdentifiers($match);

        if (count(array_diff_assoc($expectedIdentifiers, $foundIdentifiers)) == 0) {
            return true;
        }

        $this->error(self::ERROR_OBJECT_NOT_UNIQUE, $value);
        return false;
    }
389848
protected function resolveValue($value, Mustache_Context $context)
    {
        if (($this->strictCallables ? is_object($value) : !is_string($value)) && is_callable($value)) {
            return $this->mustache
                ->loadLambda((string) call_user_func($value))
                ->renderInternal($context);
        }

        return $value;
    }
384200
public function check($value, array $context = [])
    {
        $closure = $this->closure;
        $result = $closure($value, $context);

        if (!is_bool($result)) {
            throw new LackOfCoffeeException(
                vsprintf(
                    'Inner closure of constraint was expected to return a'
                    . ' boolean value. Got %s instead.',
                    [TypeHound::fetch($result)]
                )
            );
        }

        return $result;
    }