diff --git a/UPGRADE.md b/UPGRADE.md index 3f6bda9..5919ffe 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -12,6 +12,11 @@ You should update the following dependency in your application's composer.json f - `dragon-code/laravel-cache` to `^4.0` +The support of the following dependencies has been removed: + +- `dragon-code/contracts` +- `dragon-code/simple-dto` + ### Application Structure The use of the dependence of the contracts `dragon-code/contracts` was removed. diff --git a/composer.json b/composer.json index 38db603..5beeb97 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,6 @@ "illuminate/support": ">=6.0 <12.0" }, "require-dev": { - "dragon-code/simple-dto": "^2.3", "nesbot/carbon": "^2.62", "orchestra/testbench": ">=4.0 <10.0", "phpunit/phpunit": "^8.5 || ^9.6 || ^10.0" diff --git a/src/Facades/Support/Key.php b/src/Facades/Support/Key.php index 92a4d40..f2b2aa5 100644 --- a/src/Facades/Support/Key.php +++ b/src/Facades/Support/Key.php @@ -6,12 +6,11 @@ use ArrayObject; use DragonCode\Cache\Support\Key as Support; -use DragonCode\SimpleDataTransferObject\DataTransferObject; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Facades\Facade; /** - * @method static string get(string $separator, array|Arrayable|ArrayObject|DataTransferObject $values, bool $hash = true) + * @method static string get(string $separator, array|Arrayable|ArrayObject $values, bool $hash = true) */ class Key extends Facade { diff --git a/src/Facades/Support/Tag.php b/src/Facades/Support/Tag.php index 7564fd5..d893569 100644 --- a/src/Facades/Support/Tag.php +++ b/src/Facades/Support/Tag.php @@ -5,12 +5,11 @@ namespace DragonCode\Cache\Facades\Support; use DragonCode\Cache\Support\Tag as Support; -use DragonCode\SimpleDataTransferObject\DataTransferObject; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Facades\Facade; /** - * @method static array get(array|Arrayable|\ArrayObject|DataTransferObject $tags) + * @method static array get(array|Arrayable|\ArrayObject $tags) */ class Tag extends Facade { diff --git a/src/Support/Tag.php b/src/Support/Tag.php index 1d038bc..f024311 100644 --- a/src/Support/Tag.php +++ b/src/Support/Tag.php @@ -6,7 +6,6 @@ use ArrayObject; use DragonCode\Cache\Concerns\Arrayable; -use DragonCode\SimpleDataTransferObject\DataTransferObject; use DragonCode\Support\Facades\Helpers\Str; class Tag @@ -14,7 +13,7 @@ class Tag use Arrayable; /** - * @param array|\Illuminate\Contracts\Support\Arrayable|ArrayObject|DataTransferObject $tags + * @param array|\Illuminate\Contracts\Support\Arrayable|ArrayObject $tags */ public function get(mixed $tags): array { diff --git a/tests/Fixtures/Concerns/Dtoable.php b/tests/Fixtures/Concerns/Dtoable.php index 039b10a..8d4445b 100644 --- a/tests/Fixtures/Concerns/Dtoable.php +++ b/tests/Fixtures/Concerns/Dtoable.php @@ -4,12 +4,11 @@ namespace Tests\Fixtures\Concerns; -use DragonCode\SimpleDataTransferObject\DataTransferObject; use Tests\Fixtures\Dto\DtoObject; trait Dtoable { - protected function dto(): DataTransferObject + protected function dto(): DtoObject { return DtoObject::make(array_merge($this->value, [ 'baz' => 'Baz', diff --git a/tests/Fixtures/Dto/CustomDto.php b/tests/Fixtures/Dto/CustomDto.php index e192738..232c7fd 100644 --- a/tests/Fixtures/Dto/CustomDto.php +++ b/tests/Fixtures/Dto/CustomDto.php @@ -4,9 +4,29 @@ namespace Tests\Fixtures\Dto; -use DragonCode\SimpleDataTransferObject\DataTransferObject; +use Illuminate\Contracts\Support\Arrayable; -class CustomDto extends DataTransferObject +class CustomDto implements Arrayable { public $wasd; + + public static function make(array $values): CustomDto + { + $object = new static(); + + foreach ($values as $key => $value) { + if (property_exists($object, $key)) { + $object->{$key} = $value; + } + } + + return $object; + } + + public function toArray(): array + { + return [ + 'wasd' => $this->wasd, + ]; + } } diff --git a/tests/Fixtures/Dto/DtoObject.php b/tests/Fixtures/Dto/DtoObject.php index 5000b95..f7db530 100644 --- a/tests/Fixtures/Dto/DtoObject.php +++ b/tests/Fixtures/Dto/DtoObject.php @@ -4,9 +4,9 @@ namespace Tests\Fixtures\Dto; -use DragonCode\SimpleDataTransferObject\DataTransferObject; +use Illuminate\Contracts\Support\Arrayable; -class DtoObject extends DataTransferObject +class DtoObject implements Arrayable { public $foo; @@ -15,4 +15,25 @@ class DtoObject extends DataTransferObject protected $baz; protected $baq; + + public static function make(array $values): DtoObject + { + $object = new static(); + + foreach ($values as $key => $value) { + if (property_exists($object, $key)) { + $object->{$key} = $value; + } + } + + return $object; + } + + public function toArray(): array + { + return [ + 'foo' => $this->foo, + 'bar' => $this->bar, + ]; + } } diff --git a/tests/Support/TtlTest.php b/tests/Support/TtlTest.php index 7756f6f..ac1f5c4 100644 --- a/tests/Support/TtlTest.php +++ b/tests/Support/TtlTest.php @@ -93,18 +93,18 @@ public function testObjectAsObject() $this->assertSame(600, Ttl::fromSeconds((object) ['foo' => 'Foo'])); } - public function testContract() + public function testInstances(): void { - $this->assertSame(3600, Ttl::fromMinutes(new AsCarbon('foo'))); - $this->assertSame(7200, Ttl::fromSeconds(new AsCarbon('bar'))); + $this->assertSame(3600, Ttl::fromMinutes((new AsCarbon('foo'))->cacheTtl())); + $this->assertSame(7200, Ttl::fromSeconds((new AsCarbon('bar'))->cacheTtl())); - $this->assertSame(3600, Ttl::fromMinutes(new AsDateTime('foo'))); - $this->assertSame(7200, Ttl::fromSeconds(new AsDateTime('bar'))); + $this->assertSame(3600, Ttl::fromMinutes((new AsDateTime('foo'))->cacheTtl())); + $this->assertSame(7200, Ttl::fromSeconds((new AsDateTime('bar'))->cacheTtl())); - $this->assertSame(600, Ttl::fromMinutes(new AsInteger('foo'))); - $this->assertSame(20, Ttl::fromSeconds(new AsInteger('bar'))); + $this->assertSame(600, Ttl::fromMinutes((new AsInteger('foo'))->cacheTtl())); + $this->assertSame(20, Ttl::fromSeconds((new AsInteger('bar'))->cacheTtl())); - $this->assertSame(600, Ttl::fromMinutes(new AsString('foo'))); - $this->assertSame(20, Ttl::fromSeconds(new AsString('bar'))); + $this->assertSame(600, Ttl::fromMinutes((new AsString('foo'))->cacheTtl())); + $this->assertSame(20, Ttl::fromSeconds((new AsString('bar'))->cacheTtl())); } }