Skip to content

Commit c76ad07

Browse files
Drop dragon-code/simple-dto support
1 parent 8871f45 commit c76ad07

File tree

9 files changed

+63
-22
lines changed

9 files changed

+63
-22
lines changed

UPGRADE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ You should update the following dependency in your application's composer.json f
1212

1313
- `dragon-code/laravel-cache` to `^4.0`
1414

15+
The support of the following dependencies has been removed:
16+
17+
- `dragon-code/contracts`
18+
- `dragon-code/simple-dto`
19+
1520
### Application Structure
1621

1722
The use of the dependence of the contracts `dragon-code/contracts` was removed.

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"illuminate/support": ">=6.0 <12.0"
4040
},
4141
"require-dev": {
42-
"dragon-code/simple-dto": "^2.3",
4342
"nesbot/carbon": "^2.62",
4443
"orchestra/testbench": ">=4.0 <10.0",
4544
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.0"

src/Facades/Support/Key.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
use ArrayObject;
88
use DragonCode\Cache\Support\Key as Support;
9-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
109
use Illuminate\Contracts\Support\Arrayable;
1110
use Illuminate\Support\Facades\Facade;
1211

1312
/**
14-
* @method static string get(string $separator, array|Arrayable|ArrayObject|DataTransferObject $values, bool $hash = true)
13+
* @method static string get(string $separator, array|Arrayable|ArrayObject $values, bool $hash = true)
1514
*/
1615
class Key extends Facade
1716
{

src/Facades/Support/Tag.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
namespace DragonCode\Cache\Facades\Support;
66

77
use DragonCode\Cache\Support\Tag as Support;
8-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
98
use Illuminate\Contracts\Support\Arrayable;
109
use Illuminate\Support\Facades\Facade;
1110

1211
/**
13-
* @method static array get(array|Arrayable|\ArrayObject|DataTransferObject $tags)
12+
* @method static array get(array|Arrayable|\ArrayObject $tags)
1413
*/
1514
class Tag extends Facade
1615
{

src/Support/Tag.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
use ArrayObject;
88
use DragonCode\Cache\Concerns\Arrayable;
9-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
109
use DragonCode\Support\Facades\Helpers\Str;
1110

1211
class Tag
1312
{
1413
use Arrayable;
1514

1615
/**
17-
* @param array|\Illuminate\Contracts\Support\Arrayable|ArrayObject|DataTransferObject $tags
16+
* @param array|\Illuminate\Contracts\Support\Arrayable|ArrayObject $tags
1817
*/
1918
public function get(mixed $tags): array
2019
{

tests/Fixtures/Concerns/Dtoable.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
namespace Tests\Fixtures\Concerns;
66

7-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
87
use Tests\Fixtures\Dto\DtoObject;
98

109
trait Dtoable
1110
{
12-
protected function dto(): DataTransferObject
11+
protected function dto(): DtoObject
1312
{
1413
return DtoObject::make(array_merge($this->value, [
1514
'baz' => 'Baz',

tests/Fixtures/Dto/CustomDto.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,29 @@
44

55
namespace Tests\Fixtures\Dto;
66

7-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
7+
use Illuminate\Contracts\Support\Arrayable;
88

9-
class CustomDto extends DataTransferObject
9+
class CustomDto implements Arrayable
1010
{
1111
public $wasd;
12+
13+
public static function make(array $values): CustomDto
14+
{
15+
$object = new static();
16+
17+
foreach ($values as $key => $value) {
18+
if (property_exists($object, $key)) {
19+
$object->{$key} = $value;
20+
}
21+
}
22+
23+
return $object;
24+
}
25+
26+
public function toArray(): array
27+
{
28+
return [
29+
'wasd' => $this->wasd,
30+
];
31+
}
1232
}

tests/Fixtures/Dto/DtoObject.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Tests\Fixtures\Dto;
66

7-
use DragonCode\SimpleDataTransferObject\DataTransferObject;
7+
use Illuminate\Contracts\Support\Arrayable;
88

9-
class DtoObject extends DataTransferObject
9+
class DtoObject implements Arrayable
1010
{
1111
public $foo;
1212

@@ -15,4 +15,25 @@ class DtoObject extends DataTransferObject
1515
protected $baz;
1616

1717
protected $baq;
18+
19+
public static function make(array $values): DtoObject
20+
{
21+
$object = new static();
22+
23+
foreach ($values as $key => $value) {
24+
if (property_exists($object, $key)) {
25+
$object->{$key} = $value;
26+
}
27+
}
28+
29+
return $object;
30+
}
31+
32+
public function toArray(): array
33+
{
34+
return [
35+
'foo' => $this->foo,
36+
'bar' => $this->bar,
37+
];
38+
}
1839
}

tests/Support/TtlTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ public function testObjectAsObject()
9393
$this->assertSame(600, Ttl::fromSeconds((object) ['foo' => 'Foo']));
9494
}
9595

96-
public function testContract()
96+
public function testInstances(): void
9797
{
98-
$this->assertSame(3600, Ttl::fromMinutes(new AsCarbon('foo')));
99-
$this->assertSame(7200, Ttl::fromSeconds(new AsCarbon('bar')));
98+
$this->assertSame(3600, Ttl::fromMinutes((new AsCarbon('foo'))->cacheTtl()));
99+
$this->assertSame(7200, Ttl::fromSeconds((new AsCarbon('bar'))->cacheTtl()));
100100

101-
$this->assertSame(3600, Ttl::fromMinutes(new AsDateTime('foo')));
102-
$this->assertSame(7200, Ttl::fromSeconds(new AsDateTime('bar')));
101+
$this->assertSame(3600, Ttl::fromMinutes((new AsDateTime('foo'))->cacheTtl()));
102+
$this->assertSame(7200, Ttl::fromSeconds((new AsDateTime('bar'))->cacheTtl()));
103103

104-
$this->assertSame(600, Ttl::fromMinutes(new AsInteger('foo')));
105-
$this->assertSame(20, Ttl::fromSeconds(new AsInteger('bar')));
104+
$this->assertSame(600, Ttl::fromMinutes((new AsInteger('foo'))->cacheTtl()));
105+
$this->assertSame(20, Ttl::fromSeconds((new AsInteger('bar'))->cacheTtl()));
106106

107-
$this->assertSame(600, Ttl::fromMinutes(new AsString('foo')));
108-
$this->assertSame(20, Ttl::fromSeconds(new AsString('bar')));
107+
$this->assertSame(600, Ttl::fromMinutes((new AsString('foo'))->cacheTtl()));
108+
$this->assertSame(20, Ttl::fromSeconds((new AsString('bar'))->cacheTtl()));
109109
}
110110
}

0 commit comments

Comments
 (0)