mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Refactor old methods.
This commit is contained in:
@@ -23,9 +23,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Category;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class CacheProperties.
|
||||
@@ -34,10 +33,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class CacheProperties
|
||||
{
|
||||
/** @var string */
|
||||
protected $hash = '';
|
||||
/** @var Collection */
|
||||
protected $properties;
|
||||
protected string $hash = '';
|
||||
protected Collection $properties;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -52,8 +49,7 @@ class CacheProperties
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $property
|
||||
* @param Collection|Carbon|Category|array|int|string $property
|
||||
* @param mixed $property
|
||||
*/
|
||||
public function addProperty($property): void
|
||||
{
|
||||
@@ -90,19 +86,24 @@ class CacheProperties
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
private function hash(): void
|
||||
{
|
||||
$content = '';
|
||||
foreach ($this->properties as $property) {
|
||||
$content .= json_encode($property, JSON_THROW_ON_ERROR, 512);
|
||||
try {
|
||||
$content .= json_encode($property, JSON_THROW_ON_ERROR, 512);
|
||||
} catch (JsonException $e) {
|
||||
// @ignoreException
|
||||
$content .= md5(time());
|
||||
}
|
||||
}
|
||||
$this->hash = substr(hash('sha256', $content), 0, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param (array|mixed)[]|Collection|\Carbon\Carbon|string $data
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function store($data): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user