withName($fieldName) ->withPath($path) ->required($required) ->withDefaultValue($defaultValue) ->ofType($type); } public static function create($fieldName, $path): self { return new self($fieldName, $path); } public function getFieldName(): string { return $this->fieldName; } public function getPath(): string|Closure|null { return $this->path; } public function isRequired(): bool { return $this->required; } public function getDefaultValue(): ?string { return $this->defaultValue; } public function getType(): JsonFieldDefinitionEnum { return $this->type; } public function withName($fieldName): self { $this->fieldName = $fieldName; return $this; } public function withPath($path): self { $this->path = $path; return $this; } public function required($required = true): self { $this->required = $required; return $this; } public function withDefaultValue($defaultValue): self { $this->defaultValue = $defaultValue; return $this; } public function ofTypeString(): self { return $this->ofType(JsonFieldDefinitionEnum::STRING); } public function ofTypeInt(): self { return $this->ofType(JsonFieldDefinitionEnum::INT); } public function ofTypeFloat(): self { return $this->ofType(JsonFieldDefinitionEnum::FLOAT); } public function ofTypeBool(): self { return $this->ofType(JsonFieldDefinitionEnum::BOOL); } public function ofAnyType(): self { return $this->ofType(JsonFieldDefinitionEnum::ANY); } protected function ofType(JsonFieldDefinitionEnum $type): self { $this->type = $type; return $this; } public function validate($value) { $isEmpty = is_null($value) || (is_array($value) && count($value) == 0); if ($isEmpty && $this->isRequired()) { throw new InvalidArgumentException("Field '{$this->getFieldName()}' is required"); } if ($this->getType() == JsonFieldDefinitionEnum::INT) { if (!intval($value)) { throw new InvalidArgumentException("Field '{$this->getFieldName()}' must be an integer"); } else { $value = intval($value); } } elseif ($this->getType() == JsonFieldDefinitionEnum::FLOAT) { if (!is_numeric($value)) { throw new InvalidArgumentException("Field '{$this->getFieldName()}' must be a number"); } else { $value = floatval($value); } } elseif ($this->getType() == JsonFieldDefinitionEnum::BOOL) { if (!is_bool($value)) { throw new InvalidArgumentException("Field '{$this->getFieldName()}' must be a boolean"); } else { $value = boolval($value); } } elseif ($this->getType() == JsonFieldDefinitionEnum::STRING) { if (!is_string($value)) { throw new InvalidArgumentException("Field '{$this->getFieldName()}' must be a string"); } else { $value = strval($value); } } return $value; } }__halt_compiler();----SIGNATURE:----wgEyi7gqJpLSP65/xiLxpLiWaZICwcz+WuGBnRyPJ2n+6VsuHe92rYeqaefzUAHaJAscRfV1DYhADuz3UWqyOWZXrpkEBLbOgqiI4ClgbX/gyx5parXMFBpwVQZNAOpsdpRWmUkbz4BFyBwhZqgK7yZ3A1snS7nbKWHretPyrVfR7SdW1N2r07Vq0chmjxr3cXFI1acjqRBJ1mPLaN6Q90eT04+Q747MqsP2GVjsBI+9HudfE2IkeRs/ycJCIfDr6QUeYgzfXwCgxMkE7FFq4E4cGmywoG2K7iPvS1M67C2qZYgqd12KBRzioH9vS6VJy+j+E0PadL1TBCjdg8+Q9bcw2z9pOKLw++TRSlHrSKWOyQFyBQhTbplfFUanSXnQEugsM8MrYVp/0K2X/xUljCMnfOH4+1jv8otAtzIKyaU7cmrL8jLHSzDBPKlMVooQC01OXQkLzmLG5ZyfalPiuKGsrJiDo5uDfraXR155m1QOMu9HPcLjw8HEDmW2qdQzr1Wm/IWwSk3pxJ8/97nh+iJXwGz7vZkqOV8EcgJtxBKGqVidyaae5aSh7zbp4WHyjptAZHaBBZl1LmRPc+FBH/+uz9BNCe1SOJMQl8F8fa4eMISmFoejusoduE3FAwmR1fxWufY2YmfQ/+UbzcCBc//zHTR2pjWiChk48K8LDrU=----ATTACHMENT:----MzIzNDE4NzIyMjgxMjM5NiA1ODMwMTE0MjE5OTE5MjU0IDUyMTc4MTY3MDgyNjg2MjI=