Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/Facades/Support/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions src/Facades/Support/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions src/Support/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

use ArrayObject;
use DragonCode\Cache\Concerns\Arrayable;
use DragonCode\SimpleDataTransferObject\DataTransferObject;
use DragonCode\Support\Facades\Helpers\Str;

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
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Fixtures/Concerns/Dtoable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 22 additions & 2 deletions tests/Fixtures/Dto/CustomDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
}
25 changes: 23 additions & 2 deletions tests/Fixtures/Dto/DtoObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
];
}
}
18 changes: 9 additions & 9 deletions tests/Support/TtlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Loading