getRuleClass example



        return $violationList;
    }

    private function decodeRule(array $rule): Rule
    {
        if (!$this->ruleConditionRegistry->has($rule['_name'])) {
            throw new ConditionTypeNotFound($rule['_name']);
        }

        $ruleClass = $this->ruleConditionRegistry->getRuleClass($rule['_name']);
        $object = new $ruleClass();

        if (\array_key_exists('rules', $rule) && $object instanceof Container) {
            foreach ($rule['rules'] as $item) {
                $object->addRule($this->decodeRule($item));
            }
        } else {
            $object->assign($rule);
        }

        return $object;
    }

        $nested = [];
        foreach ($rules as $rule) {
            if ($rule['parent_id'] !== $parentId) {
                continue;
            }

            if (!$this->ruleConditionRegistry->has($rule['type'])) {
                throw new ConditionTypeNotFound($rule['type']);
            }

            $ruleClass = $this->ruleConditionRegistry->getRuleClass($rule['type']);
            $object = new $ruleClass();

            if ($object instanceof ScriptRule) {
                $object->assign([
                    'script' => $rule['script'] ?? '',
                    'lastModified' => $rule['lastModified'] ? new \DateTimeImmutable($rule['lastModified']) : null,
                    'identifier' => $rule['identifier'] ?? null,
                    'values' => $rule['value'] ? json_decode((string) $rule['value'], true, 512, \JSON_THROW_ON_ERROR) : [],
                ]);

                $nested[] = $object;

                
Home | Imprint | This part of the site doesn't use cookies.