Replace string operators.

This commit is contained in:
James Cole
2025-05-04 12:20:54 +02:00
parent cda90df995
commit d5240f7afd
5 changed files with 19 additions and 24 deletions

View File

@@ -147,10 +147,7 @@ class OutputsInstructions extends Command
*/
private function showLine(): void
{
$line = '+';
$line .= str_repeat('-', 78);
$line .= '+';
$this->line($line);
$this->line(sprintf('+%s+', str_repeat('-', 78)));
}
/**

View File

@@ -95,9 +95,9 @@ class IntroController extends Controller
{
$specialPage ??= '';
$route = str_replace('.', '_', $route);
$key = 'shown_demo_'.$route;
$key = sprintf('shown_demo_%s', $route);
if ('' !== $specialPage) {
$key .= '_'.$specialPage;
$key = sprintf('%s_%s', $key, $specialPage);
}
app('log')->debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key));
app('preferences')->set($key, false);
@@ -114,9 +114,9 @@ class IntroController extends Controller
public function postFinished(string $route, ?string $specialPage = null): JsonResponse
{
$specialPage ??= '';
$key = 'shown_demo_'.$route;
$key = sprintf('shown_demo_%s', $route);
if ('' !== $specialPage) {
$key .= '_'.$specialPage;
$key = sprintf('%s_%s', $key, $specialPage);
}
app('log')->debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key));
app('preferences')->set($key, true);

View File

@@ -104,7 +104,7 @@ class EditController extends Controller
$repetition = $recurrence->recurrenceRepetitions()->first();
$currentRepType = $repetition->repetition_type;
if ('' !== $repetition->repetition_moment) {
$currentRepType .= ','.$repetition->repetition_moment;
$currentRepType = sprintf('%s,%s', $currentRepType,$repetition->repetition_moment);
}
// put previous url in session if not redirect from store (not "return_to_edit").

View File

@@ -117,10 +117,7 @@ class GroupCloneService
private function cloneNote(Note $note, TransactionJournal $newJournal, int $oldGroupId): void
{
$newNote = $note->replicate();
$newNote->text .= sprintf(
"\n\n%s",
trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId])
);
$newNote->text = sprintf("%s\n\n%s",$newNote->text, trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId]));
$newNote->noteable_id = $newJournal->id;
$newNote->save();
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
/**
* Class CacheProperties.
@@ -55,7 +56,7 @@ class CacheProperties
*/
public function get()
{
return \Cache::get($this->hash);
return Cache::get($this->hash);
}
public function getHash(): string
@@ -70,7 +71,7 @@ class CacheProperties
}
$this->hash();
return \Cache::has($this->hash);
return Cache::has($this->hash);
}
private function hash(): void
@@ -78,10 +79,10 @@ class CacheProperties
$content = '';
foreach ($this->properties as $property) {
try {
$content .= \Safe\json_encode($property, JSON_THROW_ON_ERROR);
$content = sprintf('%s%s', $content, \Safe\json_encode($property, JSON_THROW_ON_ERROR));
} catch (\JsonException $e) {
// @ignoreException
$content .= hash('sha256', (string) time());
$content = sprintf('%s%s', $content, hash('sha256', (string) time()));
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
@@ -92,6 +93,6 @@ class CacheProperties
*/
public function store($data): void
{
\Cache::forever($this->hash, $data);
Cache::forever($this->hash, $data);
}
}