Skip to content

Commit

Permalink
Merge pull request #47 from TheDragonCode/3.x
Browse files Browse the repository at this point in the history
Bump `dragon-code/support` 6 and PHP 8.0+ support
  • Loading branch information
Andrey Helldar authored Apr 20, 2022
2 parents 2d5dd46 + f37d78e commit 3c173aa
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/laravel-6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
laravel: [ "6.0" ]
php: [ "7.3", "7.4", "8.0" ]
php: [ "8.0" ]

name: PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/laravel-7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
laravel: [ "7.0" ]
php: [ "7.3", "7.4", "8.0" ]
php: [ "8.0" ]

name: PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/laravel-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
laravel: [ "8.0" ]
php: [ "7.3", "7.4", "8.0", "8.1" ]
php: [ "8.0", "8.1" ]

name: PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: actions/checkout@v3

- name: Checking PHP Syntax
uses: TheDragonCode/codestyler@v1.13.1
uses: TheDragonCode/codestyler@v2.0.0
2 changes: 1 addition & 1 deletion .github/workflows/lint-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v3

- name: Checking PHP Syntax
uses: TheDragonCode/codestyler@v1.13.1
uses: TheDragonCode/codestyler@v2.0.0
with:
github_token: ${{ secrets.COMPOSER_TOKEN }}
fix: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Or manually update `require` block of `composer.json` and run `composer update`.
```json
{
"require": {
"dragon-code/laravel-cache": "^2.12"
"dragon-code/laravel-cache": "^3.0"
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"source": "https://github.com/TheDragonCode/laravel-cache"
},
"require": {
"php": "^7.3 || ^8.0",
"php": " ^8.0",
"dragon-code/contracts": "^2.16",
"dragon-code/support": "^5.7.2",
"dragon-code/support": " ^6.1",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"dragon-code/simple-dto": "^2.1",
"dragon-code/simple-dto": "^2.3",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0",
"phpunit/phpunit": "^8.5 || ^9.0"
},
Expand Down
17 changes: 7 additions & 10 deletions src/Concerns/Arrayable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
use ArrayObject;
use Closure;
use DragonCode\Contracts\Support\Arrayable as DragonCodeArrayable;
use DragonCode\Support\Facades\Helpers\Ables\Arrayable as Helper;
use DragonCode\Support\Facades\Helpers\Arr;
use DragonCode\Support\Facades\Helpers\Instance;
use DragonCode\Support\Facades\Helpers\Reflection;
use DragonCode\Support\Facades\Instances\Instance;
use DragonCode\Support\Facades\Instances\Reflection;
use DragonCode\Support\Helpers\Ables\Arrayable as ArrayableHelper;
use Illuminate\Contracts\Support\Arrayable as IlluminateArrayable;

trait Arrayable
{
protected function arrayMap(array $values, callable $callback): array
{
return Helper::of($values)
return Arr::of($values)
->map(function ($value) {
if ($this->isArrayable($value)) {
return Arr::toArray($value);
return $this->toArray($value);
}

if (is_object($value)) {
Expand All @@ -32,17 +31,15 @@ protected function arrayMap(array $values, callable $callback): array
return $value;
})
->flatten()
->filter(static function ($value) {
return ! empty($value) || is_numeric($value);
})
->filter(static fn ($value) => ! empty($value) || is_numeric($value))
->map($callback)
->values()
->get();
->toArray();
}

protected function toArray($value): array
{
return Arr::toArray($value);
return Arr::resolve($value);
}

protected function isArrayable($value): bool
Expand Down
8 changes: 4 additions & 4 deletions src/Concerns/Has.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Carbon\Carbon;
use Closure;
use DateTimeInterface;
use DragonCode\Contracts\Cache\Ttl as TtlContract;
use DragonCode\Support\Facades\Helpers\Instance;
use DragonCode\Support\Facades\Helpers\Is;
use DragonCode\Contracts\Cache\Ttl;
use DragonCode\Support\Facades\Instances\Instance;
use DragonCode\Support\Facades\Types\Is;

trait Has
{
Expand All @@ -30,6 +30,6 @@ protected function hasObject($value): bool

protected function hasContract($value): bool
{
return Instance::of($value, TtlContract::class);
return Instance::of($value, Ttl::class);
}
}
10 changes: 4 additions & 6 deletions src/Support/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use ArrayObject;
use DragonCode\Cache\Concerns\Arrayable;
use DragonCode\Contracts\DataTransferObject\DataTransferObject;
use DragonCode\Support\Facades\Helpers\Ables\Stringable;
use DragonCode\Support\Facades\Helpers\Str;

class Tag
{
Expand All @@ -18,7 +18,7 @@ class Tag
*
* @return array
*/
public function get($tags): array
public function get(mixed $tags): array
{
$tags = $this->toArray($tags);

Expand All @@ -27,13 +27,11 @@ public function get($tags): array

protected function map(array $tags): array
{
return $this->arrayMap($tags, function (string $tag) {
return $this->slug($tag);
});
return $this->arrayMap($tags, fn (string $tag) => $this->slug($tag));
}

protected function slug(string $tag): string
{
return (string) Stringable::of($tag)->trim()->slug();
return Str::of($tag)->trim()->slug()->toString();
}
}
4 changes: 2 additions & 2 deletions src/Support/Ttl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Ttl
use Call;
use Has;

protected $default = 3600;
protected int $default = 3600;

public function fromMinutes($minutes): int
{
Expand All @@ -28,7 +28,7 @@ public function fromSeconds($seconds): int

public function fromDateTime(DateTimeInterface $date_time): int
{
$seconds = Carbon::now()->diffInRealSeconds($date_time, false);
$seconds = Carbon::now()->diffInRealSeconds($date_time);

return $this->correct($seconds);
}
Expand Down
8 changes: 3 additions & 5 deletions tests/Fixtures/Ttl/AsDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

class AsDateTime implements Ttl
{
protected $value;

public function __construct(string $value)
{
$this->value = $value;
public function __construct(
protected string $value
) {
}

public function cacheTtl(): DateTimeInterface
Expand Down

0 comments on commit 3c173aa

Please sign in to comment.