Releases

v0.8.4 3/27/2024

👮‍♀️ Pass full key in ArrayItem/ArrayItemGetterTransformer

BREAKING CHANGE: if you used $key (low chance) then now you will get full key including the looped item key

v0.8.3 10/12/2023

🎉 Laravel: GetValueFactory->command() wraps command arguments / options for type safe access. docs 🎉 Laravel: You can extend GetValueFactoryCommand that wraps command arguments / options in GetValue $inputData property you can access within your command. docs

v0.8.2 7/25/2023

⛑️ Add support for accessing arrays by numeric index in XML 🚀 Add support for accessing XML childrens using namespace prefix

v0.8.1 10/11/2022

🚀 getFloat: Add support for float values using comma

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.8.0...v0.8.1

v0.8.0 9/23/2022

⛑ In default strategy ensure that empty string values are converted to null in all value types. 🚀 Improve validation exception text with value description: (null), (array with count X), (empty string), string value with maximum of 30 characters.

Breaking changes (small chance):

  • TransformerStrategy renamed to TransformerStrategyContract
  • Empty string values are automatically converted to null.

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.7.1...v0.8.0

v0.7.1 9/22/2022

🚀 Add ability to automatically build GetValue instance within FormRequest instance. Docs

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.7.0...v0.7.1

v0.7.0 9/12/2022

🚀 Add value to ValidationException message.

Breaking change

ExceptionBuilderContract has new function signature.

public function validationFailed(string $key, string $ruleClassName): Exception

to

public function validationFailed(string $key, string $ruleClassName, ?string $value): Exception

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.6.4...v0.7.0

v0.6.4 8/23/2022

⛑ Fix enum rule with int enum but value in string (xml)

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.6.3...v0.6.4

v0.6.3 8/19/2022

🚀 Add GetValueFactory for dependency injection usages

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.6.2...v0.6.3

v0.6.2 8/18/2022

🚀 Add getRequiredObject variant

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.6.1...v0.6.2

v0.6.1 8/17/2022

🚀 Allow passing transformer object instead of closure usingGetValueTransformerContract. Docs 💪 Get value with object transforming to desired type (using GetValueTransformerContract) with correct type hint. Docs

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.6.0...v0.6.1

v0.6.0 8/15/2022

🚀 Improved XML support

  • GetterTransformer - Wraps value into GetValue instance (xml or array)
  • getRequiredXMLGetter, getXMLAttributesGetter, getNullableXMLGetter, getXMLGetter, getRequiredXML, getNullableXML methods

🛠 Breaking change (minor)

  • ArrayGetterTransformer renamed to GetterTransformer. This class was not documented.

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.5.1...v0.6.0

v0.5.1 7/5/2022

⛑ Allow usage of Array*Transformers in all get* methods 🚀 Ignore null values while re-building an array (ArrayItemTransformer, ArrayItemGetterTransformer)

🛠 Breaking change

  • TransformerArrayContract removed

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.5.0...v0.5.1

v0.5.0 6/30/2022

🚀 Add safe dot annotation for accessing values from child arrays. Documentation 🛠 Key contains parent key for exceptions that were thrown from GetValue instances that were created as child instances.

Breaking changes

  • AbstractGetValueException has new required argument in constructor - $key
  • If you are extending GetValue: $key argument accepts string|array instead of string.

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.4.4...v0.5.0

v0.4.4 6/29/2022

⛑ Fix ArrayGetterTransformer closure type hints for PHPStan

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.4.3...v0.4.4

v0.4.3 6/29/2022

🚀 Add support for enums: get methods, EnumRule.

v0.4.2 6/29/2022

⛽️ Add ability to validate HEX colors using HexColorRule. Documentation.

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.4.1...v0.4.2

v0.4.1 6/29/2022

🚀 Add ArrayGetterTransformer to get array object wrapped in GetValue Documentation

Full Changelog: https://github.com/wrk-flow/php-get-typed-value/compare/v0.4.0...v0.4.1

v0.4.0 6/29/2022

🚀 Add array item transformer that has wrapped array value in GetValue instance. Documentation

$transformer = new ArrayItemGetterTransformer( function (\Wrkflow\GetValue\GetValue $value, string $key): string {
    return [
        self::KeyValue => $value->getRequiredString(self::KeyValue),
    ];
});

$values = $getValue->getArray('key', [$transformer]);

🛠 $getValue->makeInstance will allow you to create new instance of GetValue with same strategy/builder/actions.

Breaking changes

Critical

  • Renamed ClosureArrayItemsTransformer to ArrayItemTransformer
  • Renamed ClosureArrayTransformer to ArrayTransformer

Minor

  • Transformers transform method has new parameter GetValue $getValue - update your transformers or transform calls.
public function transform(mixed $value, string $key, GetValue $getValue): mixed

v0.3.1 6/28/2022

🚀 Array closures transformers Documentation

v0.3.0 6/28/2022

🚀 Add ability to transform value before (most transforms) and after validation (mostly your custom transformations).

Breaking change

By my opinion I've implemented default strategy based on my usage on all projects:

  • string -> string is always trimmed and if it is empty then it will be transformed to null
  • bool -> Converts most used representations of boolean in string or number ('yes','no',1,0,'1','0','true','false') and converts it to bool.

Also, if you are not using named arguments you need to update:

GetValue::__construct

  • new argument $transformerStrategy. This will be mostly used for tweaking.
  • $getValidatedValueAction was moved as last argument. Probably will not be used.
  • $exceptionBuilder - was moved before $getValidatedValueAction
 public function __construct(
        public readonly AbstractData $data,
        public readonly TransformerStrategy $transformerStrategy = new DefaultTransformerStrategy(),
        public readonly ExceptionBuilderContract $exceptionBuilder = new ExceptionBuilder(),
        GetValidatedValueAction $getValidatedValueAction = null,
    );

v0.2.1 6/28/2022

⛑ Made getArrayGetter match getArray (returns always array instance) and add getNullableArrayGetter to return null if data is missing or empty.

Breaking change

🛠 getArrayGetter does not return null any more. Use getNullableArrayGetter instead to get null if data is missing.

v0.2.0 6/28/2022

🚀 Add ability to get validated value (use rules: [] in methods). Documentation.

int|string|float|bool|string is now validated and throws \Wrkflow\GetValue\Exceptions\ValidationFailedException.

Breaking change

🛠 If you are extending exception builder then you need to implement new method

/**
 * @param class-string<RuleContract> $ruleClassName
 */
public function validationFailed(string $key, string $ruleClassName): Exception;

v0.1.0 6/27/2022

🚀 Initial release