mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Code optimalisations.
This commit is contained in:
@@ -89,7 +89,7 @@ class AttachmentController extends Controller
|
||||
*/
|
||||
public function download(Attachment $attachment): LaravelResponse
|
||||
{
|
||||
if ($attachment->uploaded === false) {
|
||||
if (false === $attachment->uploaded) {
|
||||
throw new FireflyException('No file has been uploaded for this attachment (yet).');
|
||||
}
|
||||
if ($this->repository->exists($attachment)) {
|
||||
|
||||
@@ -48,6 +48,7 @@ class ConfigurationController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @noinspection UnusedConstructorDependenciesInspection */
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
@@ -62,9 +63,9 @@ class ConfigurationController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$configData = $this->getConfigData();
|
||||
|
||||
@@ -90,7 +91,7 @@ class ConfigurationController extends Controller
|
||||
switch ($name) {
|
||||
case 'is_demo_site':
|
||||
case 'single_user_mode':
|
||||
$configValue = $value === 'true';
|
||||
$configValue = 'true' === $value;
|
||||
break;
|
||||
case 'permission_update_check':
|
||||
$configValue = (int)$value >= -1 && (int)$value <= 1 ? (int)$value : -1;
|
||||
|
||||
@@ -66,7 +66,7 @@ class Controller extends BaseController
|
||||
$return = '?';
|
||||
$params = [];
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if ($key === 'page') {
|
||||
if ('page' === $key) {
|
||||
continue;
|
||||
}
|
||||
if ($value instanceof Carbon) {
|
||||
@@ -88,7 +88,7 @@ class Controller extends BaseController
|
||||
{
|
||||
$bag = new ParameterBag;
|
||||
$page = (int)request()->get('page');
|
||||
if ($page === 0) {
|
||||
if (0 === $page) {
|
||||
$page = 1;
|
||||
}
|
||||
$bag->set('page', $page);
|
||||
|
||||
@@ -162,7 +162,7 @@ class CurrencyController extends Controller
|
||||
$currency = $this->repository->store($request->getAll());
|
||||
|
||||
if (null !== $currency) {
|
||||
if ($request->boolean('default') === true) {
|
||||
if (true === $request->boolean('default')) {
|
||||
app('preferences')->set('currencyPreference', $currency->code);
|
||||
app('preferences')->mark();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class CurrencyController extends Controller
|
||||
$data = $request->getAll();
|
||||
$currency = $this->repository->update($currency, $data);
|
||||
|
||||
if ($request->boolean('default') === true) {
|
||||
if (true === $request->boolean('default')) {
|
||||
app('preferences')->set('currencyPreference', $currency->code);
|
||||
app('preferences')->mark();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class LinkTypeController extends Controller
|
||||
*/
|
||||
public function delete(LinkType $linkType): JsonResponse
|
||||
{
|
||||
if ($linkType->editable === false) {
|
||||
if (false === $linkType->editable) {
|
||||
throw new FireflyException(sprintf('You cannot delete this link type (#%d, "%s")', $linkType->id, $linkType->name));
|
||||
}
|
||||
$this->repository->destroy($linkType, null);
|
||||
@@ -180,7 +180,7 @@ class LinkTypeController extends Controller
|
||||
*/
|
||||
public function update(LinkTypeRequest $request, LinkType $linkType): JsonResponse
|
||||
{
|
||||
if ($linkType->editable === false) {
|
||||
if (false === $linkType->editable) {
|
||||
throw new FireflyException(sprintf('You cannot edit this link type (#%d, "%s")', $linkType->id, $linkType->name));
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class PreferenceController extends Controller
|
||||
break;
|
||||
case 'customFiscalYear':
|
||||
case 'twoFactorAuthEnabled':
|
||||
$newValue = (int)$data['data'] === 1;
|
||||
$newValue = 1 === (int)$data['data'];
|
||||
break;
|
||||
}
|
||||
$result = Preferences::set($preference->name, $newValue);
|
||||
|
||||
@@ -62,14 +62,14 @@ class RuleRequest extends Request
|
||||
$data['rule-triggers'][] = [
|
||||
'name' => $trigger['name'],
|
||||
'value' => $trigger['value'],
|
||||
'stop-processing' => (int)($trigger['stop-processing'] ?? 0) === 1,
|
||||
'stop-processing' => 1 === (int)($trigger['stop-processing'] ?? 0),
|
||||
];
|
||||
}
|
||||
foreach ($this->get('rule-actions') as $action) {
|
||||
$data['rule-actions'][] = [
|
||||
'name' => $action['name'],
|
||||
'value' => $action['value'],
|
||||
'stop-processing' => (int)($action['stop-processing'] ?? 0) === 1,
|
||||
'stop-processing' => 1 === (int)($action['stop-processing'] ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class RuleRequest extends Request
|
||||
$data = $validator->getData();
|
||||
$repetitions = $data['rule-actions'] ?? [];
|
||||
// need at least one transaction
|
||||
if (\count($repetitions) === 0) {
|
||||
if (0 === \count($repetitions)) {
|
||||
$validator->errors()->add('title', trans('validation.at_least_one_action'));
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class RuleRequest extends Request
|
||||
$data = $validator->getData();
|
||||
$repetitions = $data['rule-triggers'] ?? [];
|
||||
// need at least one transaction
|
||||
if (\count($repetitions) === 0) {
|
||||
if (0 === \count($repetitions)) {
|
||||
$validator->errors()->add('title', trans('validation.at_least_one_trigger'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class TransactionRequest extends Request
|
||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||
];
|
||||
|
||||
if ($this->method() === 'PUT') {
|
||||
if ('PUT' === $this->method()) {
|
||||
unset($rules['type'], $rules['piggy_bank_id'], $rules['piggy_bank_name']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user