@param mixed            $value
@param ContextInterface $context

@return array

@SuppressWarnings(PHPMD.StaticAccess)
351786
public static function execute($value, ContextInterface $context): array
    {
        return $value instanceof DateTimeInterface ?
            static::createSuccessReply($value) :
            static::createErrorReply($context, $value, ErrorCodes::IS_DATE_TIME, Messages::IS_DATE_TIME, []);
    }
1188690
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (null === $value) {
            return [];
        }

        $type = gettype($value);

        if ('object' === $type) {
            if ($value instanceof $this->wishedType) {
                return [];
            }

            return [$this->getInvalidTypeErrorByPathAndType($path, get_class($value))];
        }

        if ($type === $this->wishedType) {
            return [];
        }

        return [$this->getInvalidTypeErrorByPathAndType($path, $type)];
    }
1208325
public function check($value, array $context = [])
    {
        $length = mb_strlen($value);

        return !Std::truthy(
            ($this->min > $length),
            ($this->max !== -1 && $this->max < $length)
        );
    }
1175268
public function validate(
        string $path,
        $value,
        ValidatorContextInterface $context,
        ValidatorInterface $validator = null
    ) {
        if (null === $value) {
            return [];
        }

        if (!is_array($value) && !$value instanceof \Traversable) {
            return [new Error(
                $path.'[_all]',
                'constraint.all.invalidtype',
                ['type' => is_object($value) ? get_class($value) : gettype($value)]
            )];
        }

        $errors = [];
        foreach ($value as $i => $subValue) {
            foreach ($this->constraints as $constraint) {
                $errors = array_merge(
                    $errors,
                    $constraint->validate($path.'['.$i.']', $subValue, $context, $validator)
                );
            }
        }

        return $errors;
    }
439150
public function context($context, $value = null)
    {
        if (! is_array($context)) {
            $context = [$context => $value];
        }

        foreach ($context as $key => $value) {
            $this->context[$key] = $value;
        }

        return $this;
    }
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,
                []
            );
    }
1275639
public function checkLocalizedDate($value, ExecutionContextInterface $context)
    {
        $format = LangQuery::create()->findOneByByDefault(true)->getDatetimeFormat();

        if (false === \DateTime::createFromFormat($format, $value)) {
            $context->addViolation(
                Translator::getInstance()->trans(
                    "Date '%date' is invalid, please enter a valid date using %fmt format",
                    [
                        '%fmt'  => $format,
                        '%date' => $value
                    ]
                )
            );
        }
    }
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,
                []
            );
    }
537820
public function verifyTemplates($value, ExecutionContextInterface $context)
    {
        $data = $context->getRoot()->getData();

        if (!empty($data['templates']) && $data['method'] !== BaseHook::INJECT_TEMPLATE_METHOD_NAME) {
            $context->addViolation(
                $this->trans(
                    "If you use automatic insert templates, you should use the method %method%",
                    [
                        '%method%' => BaseHook::INJECT_TEMPLATE_METHOD_NAME
                    ]
                )
            );
        }
    }
629622
public function isValid($value, $context = array())
    {
        $this->_setValue((string) $value);

        $fieldSet = (boolean) isset($context[$this->_fieldName]) && $context[$this->_fieldName];
        $valueSet = (boolean) $value;

        if ($valueSet && (! $fieldSet))  {
            return true;
        }

        if ((! $valueSet) && $fieldSet)  {
            return true;
        }

        $this->_error(self::NEITHER);
        return false;
    }
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;
    }
1318356
public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $properties = $context->getType()->getProperties();
        $firstProperty = count($properties) ? current($properties) : null;

        try {
            $interfaceAssembler = new InterfaceAssembler(ResultProviderInterface::class);
            if ($interfaceAssembler->canAssemble($context)) {
                $interfaceAssembler->assemble($context);
            }

            if ($firstProperty) {
                $this->implementGetResult($context, $class, $firstProperty);
            }
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
1165917
protected function formatObjectHandleArray($value, array $context)
    {
        if (is_array($value)) {
            $objs = array();
            foreach ($value as $key => $value2) {
                $objs[$key] = $this->format('', $value2, $context);
            }
            return $objs;
        } else {
            return $this->format('', $value, $context);
        }
    }
860731
public function isValid($value, $context = null)
    {
        $context = array_change_key_case($context, CASE_LOWER);

        switch ($this->hashAlgorithm) {
            case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_HMAC_SHA512:
            case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_SHA512:
                $stringLength = 128;
                break;
            case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_MD5:
                $stringLength = 32;
                break;
            default:
                throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException(sprintf("Used hash algorithm '%s' is not supported. MD5, SHA512, or HMAC_SHA512 are currently supported.",
                    $this->hashAlgorithm));
                break;
        }

        if (strlen($value) != $stringLength) {
            return false;
        }

        if ($this->fingerprintOrderType == self::TYPE_FIXED) {
            $fingerprintOrder = $this->fingerprintOrder;
        } else {
            if (array_key_exists($this->fingerprintOrderField, $context)) {
                $fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder(strtolower($context[$this->fingerprintOrderField]));
            } else {
                $this->_error(self::FINGERPRINTORDER_MISSING);

                return false;
            }
        }

        $fingerprintOrder->setOrder(array_map('strtolower', $this->fingerprintOrder->__toArray()));
        if (!in_array('secret', $fingerprintOrder->__toArray())) {
            throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
        }

        $fingerprintFields = Array();
        foreach ($fingerprintOrder as $fingerprintFieldKey) {
            if ($fingerprintFieldKey == 'secret') {
                $fingerprintFields[$fingerprintFieldKey] = $this->secret;
            } else {
                $fingerprintFields[$fingerprintFieldKey] = isset( $context[$fingerprintFieldKey] ) ? $context[$fingerprintFieldKey] : '';
            }
        }

        if (!WirecardCEE_Stdlib_Fingerprint::compare($fingerprintFields, $fingerprintOrder, $value)) {
            $this->_error(self::INVALID);

            return false;
        }

        return true;
    }
233036
public static function addTranslationContext($value, $context) {
		if (is_array($value) || $value instanceof Traversable) {
			$array = array();
			foreach ($value as $key => $string) {
				$array[$key] = self::addTranslationContext($string, $context);
			}
			return $array;
		}
		return (string)$context . chr(4) . (string)$value;
	}
505388
public function set(string $name, $value): ContextInterface
    {
        $this->bagContext->offsetSet($name, $value);

        return $this;
    }
504136
public function check($value, array $context = [])
    {
        $hound = new TypeHound($value);

        return $this->expectedType === $hound->resolve();
    }