diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce043b..b75aaae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Refactored package file structure + ## v0.3.9 (2023-09-26) * Converted phpstan doc comments to generic diff --git a/README.md b/README.md index 756d8e9..694c57f 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ $myDate = Lucid::make('tomorrow', 'date', [ If you need more fine grained control of the responses to constraints, use validate(): ```php -$result = Lucid::validate('int', 'potato', [ +$result = Lucid::validate('potato', 'int', [ 'min' => 4 ]); diff --git a/composer.json b/composer.json index 157ee8c..e2b8e32 100644 --- a/composer.json +++ b/composer.json @@ -2,12 +2,12 @@ "name": "decodelabs/lucid", "description": "Flexible and expansive sanitisation and validation framework", "type": "library", - "keywords": ["validation", "sanitisation", "input"], + "keywords": [ "validation", "sanitisation", "input" ], "license": "MIT", - "authors": [{ - "name": "Tom Wright", - "email": "tom@inflatablecookie.com" - }], + "authors": [ { + "name": "Tom Wright", + "email": "tom@inflatablecookie.com" + } ], "require": { "php": "^8.0", @@ -31,11 +31,10 @@ }, "autoload": { "psr-4": { - "DecodeLabs\\Archetype\\": "src/Archetype/", - "DecodeLabs\\Lucid\\": "src/Lucid/" + "DecodeLabs\\Lucid\\": "src/" }, "files": [ - "src/global.php" + "src/Context.php" ] }, "extra": { diff --git a/src/Lucid/Constraint/Color/MaxLightness.php b/src/Constraint/Color/MaxLightness.php similarity index 100% rename from src/Lucid/Constraint/Color/MaxLightness.php rename to src/Constraint/Color/MaxLightness.php diff --git a/src/Lucid/Constraint/Color/MaxSaturation.php b/src/Constraint/Color/MaxSaturation.php similarity index 100% rename from src/Lucid/Constraint/Color/MaxSaturation.php rename to src/Constraint/Color/MaxSaturation.php diff --git a/src/Lucid/Constraint/Color/MinLightness.php b/src/Constraint/Color/MinLightness.php similarity index 100% rename from src/Lucid/Constraint/Color/MinLightness.php rename to src/Constraint/Color/MinLightness.php diff --git a/src/Lucid/Constraint/Color/MinSaturation.php b/src/Constraint/Color/MinSaturation.php similarity index 100% rename from src/Lucid/Constraint/Color/MinSaturation.php rename to src/Constraint/Color/MinSaturation.php diff --git a/src/Lucid/Constraint/Compass/Max.php b/src/Constraint/Compass/Max.php similarity index 100% rename from src/Lucid/Constraint/Compass/Max.php rename to src/Constraint/Compass/Max.php diff --git a/src/Lucid/Constraint/Compass/Min.php b/src/Constraint/Compass/Min.php similarity index 100% rename from src/Lucid/Constraint/Compass/Min.php rename to src/Constraint/Compass/Min.php diff --git a/src/Lucid/Constraint/Compass/Range.php b/src/Constraint/Compass/Range.php similarity index 100% rename from src/Lucid/Constraint/Compass/Range.php rename to src/Constraint/Compass/Range.php diff --git a/src/Lucid/Constraint/Compass/V4.php b/src/Constraint/Compass/V4.php similarity index 100% rename from src/Lucid/Constraint/Compass/V4.php rename to src/Constraint/Compass/V4.php diff --git a/src/Lucid/Constraint/Compass/V6.php b/src/Constraint/Compass/V6.php similarity index 100% rename from src/Lucid/Constraint/Compass/V6.php rename to src/Constraint/Compass/V6.php diff --git a/src/Lucid/Constraint/DateTime/Max.php b/src/Constraint/DateTime/Max.php similarity index 100% rename from src/Lucid/Constraint/DateTime/Max.php rename to src/Constraint/DateTime/Max.php diff --git a/src/Lucid/Constraint/DateTime/Min.php b/src/Constraint/DateTime/Min.php similarity index 100% rename from src/Lucid/Constraint/DateTime/Min.php rename to src/Constraint/DateTime/Min.php diff --git a/src/Lucid/Constraint/DateTime/Range.php b/src/Constraint/DateTime/Range.php similarity index 100% rename from src/Lucid/Constraint/DateTime/Range.php rename to src/Constraint/DateTime/Range.php diff --git a/src/Lucid/Constraint/DefaultValue.php b/src/Constraint/DefaultValue.php similarity index 100% rename from src/Lucid/Constraint/DefaultValue.php rename to src/Constraint/DefaultValue.php diff --git a/src/Lucid/Constraint/Interval/Max.php b/src/Constraint/Interval/Max.php similarity index 100% rename from src/Lucid/Constraint/Interval/Max.php rename to src/Constraint/Interval/Max.php diff --git a/src/Lucid/Constraint/Interval/Min.php b/src/Constraint/Interval/Min.php similarity index 100% rename from src/Lucid/Constraint/Interval/Min.php rename to src/Constraint/Interval/Min.php diff --git a/src/Lucid/Constraint/Interval/Range.php b/src/Constraint/Interval/Range.php similarity index 100% rename from src/Lucid/Constraint/Interval/Range.php rename to src/Constraint/Interval/Range.php diff --git a/src/Lucid/Constraint/Number/Max.php b/src/Constraint/Number/Max.php similarity index 100% rename from src/Lucid/Constraint/Number/Max.php rename to src/Constraint/Number/Max.php diff --git a/src/Lucid/Constraint/Number/Min.php b/src/Constraint/Number/Min.php similarity index 100% rename from src/Lucid/Constraint/Number/Min.php rename to src/Constraint/Number/Min.php diff --git a/src/Lucid/Constraint/Number/Range.php b/src/Constraint/Number/Range.php similarity index 100% rename from src/Lucid/Constraint/Number/Range.php rename to src/Constraint/Number/Range.php diff --git a/src/Lucid/Constraint/Required.php b/src/Constraint/Required.php similarity index 100% rename from src/Lucid/Constraint/Required.php rename to src/Constraint/Required.php diff --git a/src/Lucid/Constraint/Sanitize.php b/src/Constraint/Sanitize.php similarity index 100% rename from src/Lucid/Constraint/Sanitize.php rename to src/Constraint/Sanitize.php diff --git a/src/Lucid/Constraint/String/Emojis.php b/src/Constraint/String/Emojis.php similarity index 100% rename from src/Lucid/Constraint/String/Emojis.php rename to src/Constraint/String/Emojis.php diff --git a/src/Lucid/Constraint/String/MaxLength.php b/src/Constraint/String/MaxLength.php similarity index 100% rename from src/Lucid/Constraint/String/MaxLength.php rename to src/Constraint/String/MaxLength.php diff --git a/src/Lucid/Constraint/String/MaxWords.php b/src/Constraint/String/MaxWords.php similarity index 100% rename from src/Lucid/Constraint/String/MaxWords.php rename to src/Constraint/String/MaxWords.php diff --git a/src/Lucid/Constraint/String/MinLength.php b/src/Constraint/String/MinLength.php similarity index 100% rename from src/Lucid/Constraint/String/MinLength.php rename to src/Constraint/String/MinLength.php diff --git a/src/Lucid/Constraint/String/MinWords.php b/src/Constraint/String/MinWords.php similarity index 100% rename from src/Lucid/Constraint/String/MinWords.php rename to src/Constraint/String/MinWords.php diff --git a/src/Lucid/Constraint/String/Pattern.php b/src/Constraint/String/Pattern.php similarity index 100% rename from src/Lucid/Constraint/String/Pattern.php rename to src/Constraint/String/Pattern.php diff --git a/src/Lucid/Constraint/String/Trim.php b/src/Constraint/String/Trim.php similarity index 100% rename from src/Lucid/Constraint/String/Trim.php rename to src/Constraint/String/Trim.php diff --git a/src/Lucid/Constraint/Validate.php b/src/Constraint/Validate.php similarity index 100% rename from src/Lucid/Constraint/Validate.php rename to src/Constraint/Validate.php diff --git a/src/Archetype/Resolver/LucidConstraint.php b/src/ConstraintResolver.php similarity index 89% rename from src/Archetype/Resolver/LucidConstraint.php rename to src/ConstraintResolver.php index 7388d85..e53c2f9 100644 --- a/src/Archetype/Resolver/LucidConstraint.php +++ b/src/ConstraintResolver.php @@ -7,12 +7,11 @@ declare(strict_types=1); -namespace DecodeLabs\Archetype\Resolver; +namespace DecodeLabs\Lucid; use DecodeLabs\Archetype\Resolver; -use DecodeLabs\Lucid\Constraint; -class LucidConstraint implements Resolver +class ConstraintResolver implements Resolver { /** * Get mapped interface diff --git a/src/Lucid/Context.php b/src/Context.php similarity index 69% rename from src/Lucid/Context.php rename to src/Context.php index 4fb9db1..d7595c2 100644 --- a/src/Lucid/Context.php +++ b/src/Context.php @@ -9,9 +9,12 @@ namespace DecodeLabs\Lucid; +use DecodeLabs\Archetype; +use DecodeLabs\Lucid; use DecodeLabs\Lucid\Provider\DirectContext; use DecodeLabs\Lucid\Provider\DirectContextTrait; use DecodeLabs\Lucid\Sanitizer\ValueContainer; +use DecodeLabs\Veneer; /** * @template TValue @@ -25,3 +28,10 @@ public function newSanitizer(mixed $value): Sanitizer return new ValueContainer($value); } } + + +// Veneer +Veneer::register(Context::class, Lucid::class); + +// Load Archetype Constraint Resolver +Archetype::register(new ConstraintResolver()); diff --git a/src/Lucid/Processor/BoolNative.php b/src/Processor/BoolNative.php similarity index 100% rename from src/Lucid/Processor/BoolNative.php rename to src/Processor/BoolNative.php diff --git a/src/Lucid/Processor/Camel.php b/src/Processor/Camel.php similarity index 100% rename from src/Lucid/Processor/Camel.php rename to src/Processor/Camel.php diff --git a/src/Lucid/Processor/Color.php b/src/Processor/Color.php similarity index 100% rename from src/Lucid/Processor/Color.php rename to src/Processor/Color.php diff --git a/src/Lucid/Processor/Date.php b/src/Processor/Date.php similarity index 100% rename from src/Lucid/Processor/Date.php rename to src/Processor/Date.php diff --git a/src/Lucid/Processor/Email.php b/src/Processor/Email.php similarity index 100% rename from src/Lucid/Processor/Email.php rename to src/Processor/Email.php diff --git a/src/Lucid/Processor/FloatNative.php b/src/Processor/FloatNative.php similarity index 100% rename from src/Lucid/Processor/FloatNative.php rename to src/Processor/FloatNative.php diff --git a/src/Lucid/Processor/IntNative.php b/src/Processor/IntNative.php similarity index 100% rename from src/Lucid/Processor/IntNative.php rename to src/Processor/IntNative.php diff --git a/src/Lucid/Processor/Interval.php b/src/Processor/Interval.php similarity index 100% rename from src/Lucid/Processor/Interval.php rename to src/Processor/Interval.php diff --git a/src/Lucid/Processor/Ip.php b/src/Processor/Ip.php similarity index 100% rename from src/Lucid/Processor/Ip.php rename to src/Processor/Ip.php diff --git a/src/Lucid/Processor/IpRange.php b/src/Processor/IpRange.php similarity index 100% rename from src/Lucid/Processor/IpRange.php rename to src/Processor/IpRange.php diff --git a/src/Lucid/Processor/ListNative.php b/src/Processor/ListNative.php similarity index 100% rename from src/Lucid/Processor/ListNative.php rename to src/Processor/ListNative.php diff --git a/src/Lucid/Processor/Name.php b/src/Processor/Name.php similarity index 100% rename from src/Lucid/Processor/Name.php rename to src/Processor/Name.php diff --git a/src/Lucid/Processor/PathSlug.php b/src/Processor/PathSlug.php similarity index 100% rename from src/Lucid/Processor/PathSlug.php rename to src/Processor/PathSlug.php diff --git a/src/Lucid/Processor/Slug.php b/src/Processor/Slug.php similarity index 100% rename from src/Lucid/Processor/Slug.php rename to src/Processor/Slug.php diff --git a/src/Lucid/Processor/StringNative.php b/src/Processor/StringNative.php similarity index 100% rename from src/Lucid/Processor/StringNative.php rename to src/Processor/StringNative.php diff --git a/src/Lucid/Processor/Url.php b/src/Processor/Url.php similarity index 100% rename from src/Lucid/Processor/Url.php rename to src/Processor/Url.php diff --git a/src/Lucid/ProcessorTrait.php b/src/ProcessorTrait.php similarity index 100% rename from src/Lucid/ProcessorTrait.php rename to src/ProcessorTrait.php diff --git a/src/Lucid/Sanitizer/ValueContainer.php b/src/Sanitizer/ValueContainer.php similarity index 100% rename from src/Lucid/Sanitizer/ValueContainer.php rename to src/Sanitizer/ValueContainer.php diff --git a/src/global.php b/src/global.php deleted file mode 100644 index 3a010a0..0000000 --- a/src/global.php +++ /dev/null @@ -1,26 +0,0 @@ -