mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-22 19:21:23 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -30,18 +29,15 @@ use Illuminate\Support\Collection;
|
||||
use Preferences as Prefs;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class Amount.
|
||||
*/
|
||||
class Amount
|
||||
{
|
||||
|
||||
/**
|
||||
* bool $sepBySpace is $localeconv['n_sep_by_space']
|
||||
* int $signPosn = $localeconv['n_sign_posn']
|
||||
* string $sign = $localeconv['negative_sign']
|
||||
* bool $csPrecedes = $localeconv['n_cs_precedes']
|
||||
* bool $csPrecedes = $localeconv['n_cs_precedes'].
|
||||
*
|
||||
* @param bool $sepBySpace
|
||||
* @param int $signPosn
|
||||
@@ -74,7 +70,6 @@ class Amount
|
||||
// AD%v_B%sCE (amount before currency)
|
||||
// the _ is the optional space
|
||||
|
||||
|
||||
// switch on how to display amount:
|
||||
switch ($signPosn) {
|
||||
default:
|
||||
@@ -140,7 +135,7 @@ class Amount
|
||||
$result = $formatted . $space . $format->symbol;
|
||||
}
|
||||
|
||||
if ($coloured === true) {
|
||||
if (true === $coloured) {
|
||||
if ($amount > 0) {
|
||||
return sprintf('<span class="text-success">%s</span>', $result);
|
||||
}
|
||||
@@ -206,6 +201,7 @@ class Amount
|
||||
|
||||
/**
|
||||
* @return \FireflyIII\Models\TransactionCurrency
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getDefaultCurrency(): TransactionCurrency
|
||||
@@ -219,6 +215,7 @@ class Amount
|
||||
* @param User $user
|
||||
*
|
||||
* @return \FireflyIII\Models\TransactionCurrency
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getDefaultCurrencyByUser(User $user): TransactionCurrency
|
||||
@@ -231,7 +228,7 @@ class Amount
|
||||
}
|
||||
$currencyPreference = Prefs::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
throw new FireflyException(sprintf('No currency found with code "%s"', $currencyPreference->data));
|
||||
}
|
||||
$cache->store($currency);
|
||||
@@ -249,8 +246,8 @@ class Amount
|
||||
*/
|
||||
public function getJsConfig(array $config): array
|
||||
{
|
||||
$negative = self::getAmountJsConfig($config['n_sep_by_space'] === 1, $config['n_sign_posn'], $config['negative_sign'], $config['n_cs_precedes'] === 1);
|
||||
$positive = self::getAmountJsConfig($config['p_sep_by_space'] === 1, $config['p_sign_posn'], $config['positive_sign'], $config['p_cs_precedes'] === 1);
|
||||
$negative = self::getAmountJsConfig(1 === $config['n_sep_by_space'], $config['n_sign_posn'], $config['negative_sign'], 1 === $config['n_cs_precedes']);
|
||||
$positive = self::getAmountJsConfig(1 === $config['p_sep_by_space'], $config['p_sign_posn'], $config['positive_sign'], 1 === $config['p_cs_precedes']);
|
||||
|
||||
return [
|
||||
'pos' => $positive,
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -28,13 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class AccountList
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class AccountList.
|
||||
*/
|
||||
class AccountList implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
/**
|
||||
* Interface BinderInterface
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Interface BinderInterface.
|
||||
*/
|
||||
interface BinderInterface
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -28,13 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class BudgetList
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class BudgetList.
|
||||
*/
|
||||
class BudgetList implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -28,13 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class CategoryList
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class CategoryList.
|
||||
*/
|
||||
class CategoryList implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class CurrencyCode
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class CurrencyCode.
|
||||
*/
|
||||
class CurrencyCode implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
@@ -43,7 +39,7 @@ class CurrencyCode implements BinderInterface
|
||||
public static function routeBinder($value, $route)
|
||||
{
|
||||
$currency = TransactionCurrency::where('code', $value)->first();
|
||||
if (!is_null($currency)) {
|
||||
if (null !== $currency) {
|
||||
return $currency;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -30,14 +29,10 @@ use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class Date
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class Date.
|
||||
*/
|
||||
class Date implements BinderInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
@@ -70,7 +65,6 @@ class Date implements BinderInterface
|
||||
return $fiscalHelper->startOfFiscalYear(Carbon::now());
|
||||
case 'currentFiscalYearEnd':
|
||||
return $fiscalHelper->endOfFiscalYear(Carbon::now());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -28,13 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class JournalList
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class JournalList.
|
||||
*/
|
||||
class JournalList implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
@@ -48,7 +44,7 @@ class JournalList implements BinderInterface
|
||||
/** @var \Illuminate\Support\Collection $object */
|
||||
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
|
||||
->where('transaction_journals.user_id', auth()->user()->id)
|
||||
->get(['transaction_journals.*',]);
|
||||
->get(['transaction_journals.*']);
|
||||
|
||||
if ($object->count() > 0) {
|
||||
return $object;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -29,13 +28,10 @@ use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class TagList
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class TagList.
|
||||
*/
|
||||
class TagList implements BinderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
@@ -27,14 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class Date
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
* Class Date.
|
||||
*/
|
||||
class UnfinishedJournal implements BinderInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -28,14 +27,11 @@ use Illuminate\Support\Collection;
|
||||
use Preferences as Prefs;
|
||||
|
||||
/**
|
||||
* Class CacheProperties
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class CacheProperties.
|
||||
*/
|
||||
class CacheProperties
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $hash = '';
|
||||
/** @var Collection */
|
||||
protected $properties;
|
||||
@@ -81,7 +77,7 @@ class CacheProperties
|
||||
*/
|
||||
public function has(): bool
|
||||
{
|
||||
if (getenv('APP_ENV') === 'testing') {
|
||||
if ('testing' === getenv('APP_ENV')) {
|
||||
return false;
|
||||
}
|
||||
$this->hash();
|
||||
@@ -98,7 +94,6 @@ class CacheProperties
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function hash()
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
/**
|
||||
* Class ChartColour
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class ChartColour.
|
||||
*/
|
||||
class ChartColour
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
/**
|
||||
* Class Domain
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class Domain.
|
||||
*/
|
||||
class Domain
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Events;
|
||||
@@ -27,9 +26,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BillScanner
|
||||
*
|
||||
* @package FireflyIII\Support\Events
|
||||
* Class BillScanner.
|
||||
*/
|
||||
class BillScanner
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -28,19 +27,14 @@ use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Input;
|
||||
use RuntimeException;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
* Class ExpandedForm
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
*
|
||||
* Class ExpandedForm.
|
||||
*/
|
||||
class ExpandedForm
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
@@ -87,7 +81,7 @@ class ExpandedForm
|
||||
*/
|
||||
public function checkbox(string $name, $value = 1, $checked = null, $options = []): string
|
||||
{
|
||||
$options['checked'] = $checked === true ? true : null;
|
||||
$options['checked'] = true === $checked ? true : null;
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
@@ -173,7 +167,6 @@ class ExpandedForm
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Takes any collection and tries to make a sensible select list compatible array of it.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $set
|
||||
@@ -190,7 +183,7 @@ class ExpandedForm
|
||||
$title = null;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (isset($entry->$field) && is_null($title)) {
|
||||
if (isset($entry->$field) && null === $title) {
|
||||
$title = $entry->$field;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +209,7 @@ class ExpandedForm
|
||||
$title = null;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (isset($entry->$field) && is_null($title)) {
|
||||
if (isset($entry->$field) && null === $title) {
|
||||
$title = $entry->$field;
|
||||
}
|
||||
}
|
||||
@@ -287,11 +280,10 @@ class ExpandedForm
|
||||
unset($options['placeholder']);
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (!is_null($value) && $value !== '') {
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = round($value, $selectedCurrency->decimal_places);
|
||||
}
|
||||
|
||||
|
||||
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
@@ -316,12 +308,11 @@ class ExpandedForm
|
||||
unset($options['placeholder']);
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (!is_null($value) && $value !== '') {
|
||||
if (null !== $value && '' !== $value) {
|
||||
$decimals = $selectedCurrency->decimal_places ?? 2;
|
||||
$value = round($value, $decimals);
|
||||
}
|
||||
|
||||
|
||||
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
@@ -364,7 +355,7 @@ class ExpandedForm
|
||||
// don't care
|
||||
}
|
||||
|
||||
$previousValue = is_null($previousValue) ? 'store' : $previousValue;
|
||||
$previousValue = null === $previousValue ? 'store' : $previousValue;
|
||||
$html = view('form.options', compact('type', 'name', 'previousValue'))->render();
|
||||
|
||||
return $html;
|
||||
@@ -508,10 +499,10 @@ class ExpandedForm
|
||||
{
|
||||
if (Session::has('preFilled')) {
|
||||
$preFilled = session('preFilled');
|
||||
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
|
||||
$value = isset($preFilled[$name]) && null === $value ? $preFilled[$name] : $value;
|
||||
}
|
||||
try {
|
||||
if (!is_null(request()->old($name))) {
|
||||
if (null !== request()->old($name)) {
|
||||
$value = request()->old($name);
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
@@ -521,7 +512,6 @@ class ExpandedForm
|
||||
$value = $value->format('Y-m-d');
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -532,14 +522,12 @@ class ExpandedForm
|
||||
*/
|
||||
protected function getHolderClasses(string $name): string
|
||||
{
|
||||
/*
|
||||
* Get errors from session:
|
||||
*/
|
||||
// Get errors from session:
|
||||
/** @var MessageBag $errors */
|
||||
$errors = session('errors');
|
||||
$classes = 'form-group';
|
||||
|
||||
if (!is_null($errors) && $errors->has($name)) {
|
||||
if (null !== $errors && $errors->has($name)) {
|
||||
$classes = 'form-group has-error has-feedback';
|
||||
}
|
||||
|
||||
@@ -596,11 +584,10 @@ class ExpandedForm
|
||||
}
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (!is_null($value) && $value !== '') {
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = round($value, $defaultCurrency->decimal_places);
|
||||
}
|
||||
|
||||
|
||||
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class Amount.
|
||||
*/
|
||||
class Amount extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class Amount.
|
||||
*/
|
||||
class ExpandedForm extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class FireflyConfig
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class FireflyConfig.
|
||||
*/
|
||||
class FireflyConfig extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class Navigation.
|
||||
*/
|
||||
class Navigation extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Preferences
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class Preferences.
|
||||
*/
|
||||
class Preferences extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Facades;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Support\Facades
|
||||
* Class Steam.
|
||||
*/
|
||||
class Steam extends Facade
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -28,9 +27,7 @@ use FireflyIII\Models\Configuration;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FireflyConfig
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class FireflyConfig.
|
||||
*/
|
||||
class FireflyConfig
|
||||
{
|
||||
@@ -38,6 +35,7 @@ class FireflyConfig
|
||||
* @param $name
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete($name): bool
|
||||
@@ -72,7 +70,7 @@ class FireflyConfig
|
||||
return $config;
|
||||
}
|
||||
// no preference found and default is null:
|
||||
if (is_null($default)) {
|
||||
if (null === $default) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -100,7 +98,7 @@ class FireflyConfig
|
||||
{
|
||||
Log::debug('Set new value for ', ['name' => $name]);
|
||||
$config = Configuration::whereName($name)->first();
|
||||
if (is_null($config)) {
|
||||
if (null === $config) {
|
||||
Log::debug('Does not exist yet ', ['name' => $name]);
|
||||
$item = new Configuration;
|
||||
$item->name = $name;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support\Import\Configuration;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
|
||||
/**
|
||||
* Class ConfigurationInterface
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Configuration
|
||||
* Class ConfigurationInterface.
|
||||
*/
|
||||
interface ConfigurationInterface
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
||||
@@ -31,9 +30,7 @@ use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class CsvInitial
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Configuration
|
||||
* Class CsvInitial.
|
||||
*/
|
||||
class Initial implements ConfigurationInterface
|
||||
{
|
||||
@@ -109,23 +106,22 @@ class Initial implements ConfigurationInterface
|
||||
$importId = $data['csv_import_account'] ?? 0;
|
||||
$account = $repository->find(intval($importId));
|
||||
|
||||
$hasHeaders = isset($data['has_headers']) && intval($data['has_headers']) === 1 ? true : false;
|
||||
$hasHeaders = isset($data['has_headers']) && 1 === intval($data['has_headers']) ? true : false;
|
||||
$config = $this->job->configuration;
|
||||
$config['initial-config-complete'] = true;
|
||||
$config['has-headers'] = $hasHeaders;
|
||||
$config['date-format'] = $data['date_format'];
|
||||
$config['delimiter'] = $data['csv_delimiter'];
|
||||
$config['delimiter'] = $config['delimiter'] === 'tab' ? "\t" : $config['delimiter'];
|
||||
$config['delimiter'] = 'tab' === $config['delimiter'] ? "\t" : $config['delimiter'];
|
||||
|
||||
Log::debug('Entered import account.', ['id' => $importId]);
|
||||
|
||||
|
||||
if (!is_null($account->id)) {
|
||||
if (null !== $account->id) {
|
||||
Log::debug('Found account.', ['id' => $account->id, 'name' => $account->name]);
|
||||
$config['import-account'] = $account->id;
|
||||
}
|
||||
|
||||
if (is_null($account->id)) {
|
||||
if (null === $account->id) {
|
||||
Log::error('Could not find anything for csv_import_account.', ['id' => $importId]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
||||
@@ -33,9 +32,7 @@ use League\Csv\Reader;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Mapping
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Configuration\Csv
|
||||
* Class Mapping.
|
||||
*/
|
||||
class Map implements ConfigurationInterface
|
||||
{
|
||||
@@ -43,13 +40,14 @@ class Map implements ConfigurationInterface
|
||||
private $configuration = [];
|
||||
/** @var array that holds each column to be mapped by the user */
|
||||
private $data = [];
|
||||
/** @var ImportJob */
|
||||
/** @var ImportJob */
|
||||
private $job;
|
||||
/** @var array */
|
||||
private $validSpecifics = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getData(): array
|
||||
@@ -79,10 +77,9 @@ class Map implements ConfigurationInterface
|
||||
}
|
||||
$value = $row[$index];
|
||||
if (strlen($value) > 0) {
|
||||
|
||||
// we can do some preprocessing here,
|
||||
// which is exclusively to fix the tags:
|
||||
if (!is_null($this->data[$index]['preProcessMap']) && strlen($this->data[$index]['preProcessMap']) > 0) {
|
||||
if (null !== $this->data[$index]['preProcessMap'] && strlen($this->data[$index]['preProcessMap']) > 0) {
|
||||
/** @var PreProcessorInterface $preProcessor */
|
||||
$preProcessor = app($this->data[$index]['preProcessMap']);
|
||||
$result = $preProcessor->run($value);
|
||||
@@ -92,7 +89,6 @@ class Map implements ConfigurationInterface
|
||||
Log::debug($rowIndex . ':' . $index . 'Value after preprocessor', ['value-new' => $result]);
|
||||
Log::debug($rowIndex . ':' . $index . 'Value after joining', ['value-complete' => $this->data[$index]['values']]);
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -154,7 +150,7 @@ class Map implements ConfigurationInterface
|
||||
$config['column-mapping-config'][$index] = [];
|
||||
foreach ($data as $value => $mapId) {
|
||||
$mapId = intval($mapId);
|
||||
if ($mapId !== 0) {
|
||||
if (0 !== $mapId) {
|
||||
$config['column-mapping-config'][$index][$value] = intval($mapId);
|
||||
}
|
||||
}
|
||||
@@ -192,15 +188,13 @@ class Map implements ConfigurationInterface
|
||||
$config = $this->job->configuration;
|
||||
|
||||
/**
|
||||
* @var int $index
|
||||
* @var int
|
||||
* @var bool $mustBeMapped
|
||||
*/
|
||||
foreach ($config['column-do-mapping'] as $index => $mustBeMapped) {
|
||||
$column = $this->validateColumnName($config['column-roles'][$index] ?? '_ignore');
|
||||
$shouldMap = $this->shouldMapColumn($column, $mustBeMapped);
|
||||
if ($shouldMap) {
|
||||
|
||||
|
||||
// create configuration entry for this specific column and add column to $this->data array for later processing.
|
||||
$this->data[$index] = [
|
||||
'name' => $column,
|
||||
@@ -226,7 +220,7 @@ class Map implements ConfigurationInterface
|
||||
$hasPreProcess = config('csv.import_roles.' . $column . '.pre-process-map');
|
||||
$preProcessClass = config('csv.import_roles.' . $column . '.pre-process-mapper');
|
||||
|
||||
if (!is_null($hasPreProcess) && $hasPreProcess === true && !is_null($preProcessClass)) {
|
||||
if (null !== $hasPreProcess && true === $hasPreProcess && null !== $preProcessClass) {
|
||||
$name = sprintf('\\FireflyIII\\Import\\MapperPreProcess\\%s', $preProcessClass);
|
||||
}
|
||||
|
||||
@@ -237,6 +231,7 @@ class Map implements ConfigurationInterface
|
||||
* @param array $row
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function runSpecifics(array $row): array
|
||||
@@ -269,13 +264,14 @@ class Map implements ConfigurationInterface
|
||||
{
|
||||
$canBeMapped = config('csv.import_roles.' . $column . '.mappable');
|
||||
|
||||
return ($canBeMapped && $mustBeMapped);
|
||||
return $canBeMapped && $mustBeMapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function validateColumnName(string $column): string
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
||||
@@ -30,14 +29,12 @@ use League\Csv\Reader;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Roles
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Configuration\Csv
|
||||
* Class Roles.
|
||||
*/
|
||||
class Roles implements ConfigurationInterface
|
||||
{
|
||||
private $data = [];
|
||||
/** @var ImportJob */
|
||||
/** @var ImportJob */
|
||||
private $job;
|
||||
|
||||
/** @var string */
|
||||
@@ -75,7 +72,7 @@ class Roles implements ConfigurationInterface
|
||||
$count = count($row);
|
||||
$this->data['total'] = $count > $this->data['total'] ? $count : $this->data['total'];
|
||||
$this->processRow($row);
|
||||
$start++;
|
||||
++$start;
|
||||
}
|
||||
|
||||
$this->updateColumCount();
|
||||
@@ -118,7 +115,7 @@ class Roles implements ConfigurationInterface
|
||||
Log::debug('Now in storeConfiguration of Roles.');
|
||||
$config = $this->job->configuration;
|
||||
$count = $config['column-count'];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$role = $data['role'][$i] ?? '_ignore';
|
||||
$mapping = isset($data['map'][$i]) && $data['map'][$i] === '1' ? true : false;
|
||||
$config['column-roles'][$i] = $role;
|
||||
@@ -126,7 +123,6 @@ class Roles implements ConfigurationInterface
|
||||
Log::debug(sprintf('Column %d has been given role %s', $i, $role));
|
||||
}
|
||||
|
||||
|
||||
$this->job->configuration = $config;
|
||||
$this->job->save();
|
||||
|
||||
@@ -134,7 +130,6 @@ class Roles implements ConfigurationInterface
|
||||
$this->setRolesComplete();
|
||||
$this->isMappingNecessary();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -158,11 +153,11 @@ class Roles implements ConfigurationInterface
|
||||
{
|
||||
$config = $this->job->configuration;
|
||||
$count = $config['column-count'];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$role = $config['column-roles'][$i] ?? '_ignore';
|
||||
$mapping = $config['column-do-mapping'][$i] ?? false;
|
||||
|
||||
if ($role === '_ignore' && $mapping === true) {
|
||||
if ('_ignore' === $role && true === $mapping) {
|
||||
$mapping = false;
|
||||
Log::debug(sprintf('Column %d has type %s so it cannot be mapped.', $i, $role));
|
||||
}
|
||||
@@ -183,14 +178,14 @@ class Roles implements ConfigurationInterface
|
||||
$config = $this->job->configuration;
|
||||
$count = $config['column-count'];
|
||||
$toBeMapped = 0;
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$mapping = $config['column-do-mapping'][$i] ?? false;
|
||||
if ($mapping === true) {
|
||||
$toBeMapped++;
|
||||
if (true === $mapping) {
|
||||
++$toBeMapped;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Found %d columns that need mapping.', $toBeMapped));
|
||||
if ($toBeMapped === 0) {
|
||||
if (0 === $toBeMapped) {
|
||||
// skip setting of map, because none need to be mapped:
|
||||
$config['column-mapping-complete'] = true;
|
||||
$this->job->configuration = $config;
|
||||
@@ -201,7 +196,7 @@ class Roles implements ConfigurationInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* make unique example data
|
||||
* make unique example data.
|
||||
*/
|
||||
private function makeExamplesUnique(): bool
|
||||
{
|
||||
@@ -258,12 +253,12 @@ class Roles implements ConfigurationInterface
|
||||
$count = $config['column-count'];
|
||||
$assigned = 0;
|
||||
$hasAmount = false;
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$role = $config['column-roles'][$i] ?? '_ignore';
|
||||
if ($role !== '_ignore') {
|
||||
$assigned++;
|
||||
if ('_ignore' !== $role) {
|
||||
++$assigned;
|
||||
}
|
||||
if ($role === 'amount') {
|
||||
if ('amount' === $role) {
|
||||
$hasAmount = true;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +268,7 @@ class Roles implements ConfigurationInterface
|
||||
$this->job->save();
|
||||
$this->warning = '';
|
||||
}
|
||||
if ($assigned === 0 || !$hasAmount) {
|
||||
if (0 === $assigned || !$hasAmount) {
|
||||
$this->warning = strval(trans('csv.roles_warning'));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Information;
|
||||
@@ -38,14 +37,11 @@ use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class BunqInformation
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Information
|
||||
* Class BunqInformation.
|
||||
*/
|
||||
class BunqInformation implements InformationInterface
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
@@ -92,7 +88,7 @@ class BunqInformation implements InformationInterface
|
||||
];
|
||||
/** @var Alias $alias */
|
||||
foreach ($account->getAliases() as $alias) {
|
||||
if ($alias->getType() === 'IBAN') {
|
||||
if ('IBAN' === $alias->getType()) {
|
||||
$current['number'] = $alias->getValue();
|
||||
}
|
||||
}
|
||||
@@ -161,6 +157,7 @@ class BunqInformation implements InformationInterface
|
||||
* @param SessionToken $sessionToken
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getUserInformation(SessionToken $sessionToken): int
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Information;
|
||||
@@ -26,13 +25,10 @@ namespace FireflyIII\Support\Import\Information;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Interface InformationInterface
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Information
|
||||
* Interface InformationInterface.
|
||||
*/
|
||||
interface InformationInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks.
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Prerequisites;
|
||||
@@ -41,12 +40,10 @@ use Requests_Exception;
|
||||
|
||||
/**
|
||||
* This class contains all the routines necessary to connect to Bunq.
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Prerequisites
|
||||
*/
|
||||
class BunqPrerequisites implements PrerequisitesInterface
|
||||
{
|
||||
/** @var User */
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
@@ -80,7 +77,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
{
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key', false);
|
||||
|
||||
return ($apiKey->data === false || is_null($apiKey->data));
|
||||
return false === $apiKey->data || null === $apiKey->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,6 +153,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
* to try and detect the server ID for this firefly instance.
|
||||
*
|
||||
* @return DeviceServerId
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getExistingDevice(): DeviceServerId
|
||||
@@ -187,7 +185,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
{
|
||||
Log::debug('Get installation token.');
|
||||
$token = Preferences::getForUser($this->user, 'bunq_installation_token', null);
|
||||
if (!is_null($token)) {
|
||||
if (null !== $token) {
|
||||
return $token->data;
|
||||
}
|
||||
Log::debug('Have no token, request one.');
|
||||
@@ -219,7 +217,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
{
|
||||
Log::debug('get private key');
|
||||
$preference = Preferences::getForUser($this->user, 'bunq_private_key', null);
|
||||
if (is_null($preference)) {
|
||||
if (null === $preference) {
|
||||
Log::debug('private key is null');
|
||||
// create key pair
|
||||
$this->createKeyPair();
|
||||
@@ -239,7 +237,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
{
|
||||
Log::debug('get public key');
|
||||
$preference = Preferences::getForUser($this->user, 'bunq_public_key', null);
|
||||
if (is_null($preference)) {
|
||||
if (null === $preference) {
|
||||
Log::debug('public key is null');
|
||||
// create key pair
|
||||
$this->createKeyPair();
|
||||
@@ -254,18 +252,19 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
* Request users server remote IP. Let's assume this value will not change any time soon.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getRemoteIp(): string
|
||||
{
|
||||
$preference = Preferences::getForUser($this->user, 'external_ip', null);
|
||||
if (is_null($preference)) {
|
||||
if (null === $preference) {
|
||||
try {
|
||||
$response = Requests::get('https://api.ipify.org');
|
||||
} catch (Requests_Exception $e) {
|
||||
throw new FireflyException(sprintf('Could not retrieve external IP: %s', $e->getMessage()));
|
||||
}
|
||||
if ($response->status_code !== 200) {
|
||||
if (200 !== $response->status_code) {
|
||||
throw new FireflyException(sprintf('Could not retrieve external IP: %d %s', $response->status_code, $response->body));
|
||||
}
|
||||
$serverIp = $response->body;
|
||||
@@ -299,7 +298,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
Log::debug('Now in registerDevice');
|
||||
$deviceServerId = Preferences::getForUser($this->user, 'bunq_device_server_id', null);
|
||||
$serverIp = $this->getRemoteIp();
|
||||
if (!is_null($deviceServerId)) {
|
||||
if (null !== $deviceServerId) {
|
||||
Log::debug('Have device server ID.');
|
||||
|
||||
return $deviceServerId->data;
|
||||
@@ -323,7 +322,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
if (is_null($deviceServerId)) {
|
||||
if (null === $deviceServerId) {
|
||||
// try get the current from a list:
|
||||
$deviceServerId = $this->getExistingDevice();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Prerequisites;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Models;
|
||||
@@ -35,19 +34,18 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalTrait
|
||||
* Class TransactionJournalTrait.
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon $date
|
||||
* @property string $transaction_type_type
|
||||
* @property TransactionType $transactionType
|
||||
*
|
||||
* @package FireflyIII\Support\Models
|
||||
*/
|
||||
trait TransactionJournalTrait
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function amount(): string
|
||||
@@ -100,7 +98,7 @@ trait TransactionJournalTrait
|
||||
public function budgetId(): int
|
||||
{
|
||||
$budget = $this->budgets()->first();
|
||||
if (!is_null($budget)) {
|
||||
if (null !== $budget) {
|
||||
return $budget->id;
|
||||
}
|
||||
|
||||
@@ -123,7 +121,7 @@ trait TransactionJournalTrait
|
||||
public function categoryAsString(): string
|
||||
{
|
||||
$category = $this->categories()->first();
|
||||
if (!is_null($category)) {
|
||||
if (null !== $category) {
|
||||
return $category->name;
|
||||
}
|
||||
|
||||
@@ -137,10 +135,10 @@ trait TransactionJournalTrait
|
||||
*/
|
||||
public function dateAsString(string $dateField = ''): string
|
||||
{
|
||||
if ($dateField === '') {
|
||||
if ('' === $dateField) {
|
||||
return $this->date->format('Y-m-d');
|
||||
}
|
||||
if (!is_null($this->$dateField) && $this->$dateField instanceof Carbon) {
|
||||
if (null !== $this->$dateField && $this->$dateField instanceof Carbon) {
|
||||
// make field NULL
|
||||
$carbon = clone $this->$dateField;
|
||||
$this->$dateField = null;
|
||||
@@ -153,7 +151,7 @@ trait TransactionJournalTrait
|
||||
return $carbon->format('Y-m-d');
|
||||
}
|
||||
$metaField = $this->getMeta($dateField);
|
||||
if (!is_null($metaField)) {
|
||||
if (null !== $metaField) {
|
||||
$carbon = new Carbon($metaField);
|
||||
|
||||
return $carbon->format('Y-m-d');
|
||||
@@ -205,7 +203,6 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
@@ -226,7 +223,7 @@ trait TransactionJournalTrait
|
||||
public function isJoined(Builder $query, string $table): bool
|
||||
{
|
||||
$joins = $query->getQuery()->joins;
|
||||
if (is_null($joins)) {
|
||||
if (null === $joins) {
|
||||
return false;
|
||||
}
|
||||
foreach ($joins as $join) {
|
||||
@@ -239,19 +236,16 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isOpeningBalance(): bool;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isTransfer(): bool;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isWithdrawal(): bool;
|
||||
@@ -284,7 +278,7 @@ trait TransactionJournalTrait
|
||||
/**
|
||||
* Save the model to the database.
|
||||
*
|
||||
* @param array $options
|
||||
* @param array $options
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -27,19 +26,17 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class Navigation.
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param $skip
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip): Carbon
|
||||
@@ -75,7 +72,7 @@ class Navigation
|
||||
// if period is 1M and diff in month is 2 and new DOM = 1, sub a day:
|
||||
$months = ['1M', 'month', 'monthly'];
|
||||
$difference = $date->month - $theDate->month;
|
||||
if (in_array($repeatFreq, $months) && $difference === 2 && $date->day === 1) {
|
||||
if (in_array($repeatFreq, $months) && 2 === $difference && 1 === $date->day) {
|
||||
$date->subDay();
|
||||
}
|
||||
|
||||
@@ -87,6 +84,7 @@ class Navigation
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfPeriod(\Carbon\Carbon $end, string $repeatFreq): Carbon
|
||||
@@ -113,7 +111,7 @@ class Navigation
|
||||
// if the range is custom, the end of the period
|
||||
// is another X days (x is the difference between start)
|
||||
// and end added to $theCurrentEnd
|
||||
if ($repeatFreq === 'custom') {
|
||||
if ('custom' === $repeatFreq) {
|
||||
/** @var Carbon $tStart */
|
||||
$tStart = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $tEnd */
|
||||
@@ -178,7 +176,7 @@ class Navigation
|
||||
$currentEnd->$function();
|
||||
}
|
||||
|
||||
if (!is_null($maxDate) && $currentEnd > $maxDate) {
|
||||
if (null !== $maxDate && $currentEnd > $maxDate) {
|
||||
return clone $maxDate;
|
||||
}
|
||||
|
||||
@@ -227,6 +225,7 @@ class Navigation
|
||||
* @param $repeatFrequency
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function periodShow(Carbon $theDate, string $repeatFrequency): string
|
||||
@@ -248,13 +247,12 @@ class Navigation
|
||||
'year' => trans('config.year'),
|
||||
'yearly' => trans('config.year'),
|
||||
'6M' => trans('config.half_year'),
|
||||
|
||||
];
|
||||
|
||||
if (isset($formatMap[$repeatFrequency])) {
|
||||
return $date->formatLocalized(strval($formatMap[$repeatFrequency]));
|
||||
}
|
||||
if ($repeatFrequency === '3M' || $repeatFrequency === 'quarter') {
|
||||
if ('3M' === $repeatFrequency || 'quarter' === $repeatFrequency) {
|
||||
$quarter = ceil($theDate->month / 3);
|
||||
|
||||
return sprintf('Q%d %d', $quarter, $theDate->year);
|
||||
@@ -384,6 +382,7 @@ class Navigation
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon
|
||||
@@ -412,7 +411,7 @@ class Navigation
|
||||
|
||||
return $date;
|
||||
}
|
||||
if ($repeatFreq === 'half-year' || $repeatFreq === '6M') {
|
||||
if ('half-year' === $repeatFreq || '6M' === $repeatFreq) {
|
||||
$month = $date->month;
|
||||
$date->startOfYear();
|
||||
if ($month >= 7) {
|
||||
@@ -421,11 +420,10 @@ class Navigation
|
||||
|
||||
return $date;
|
||||
}
|
||||
if ($repeatFreq === 'custom') {
|
||||
if ('custom' === $repeatFreq) {
|
||||
return $date; // the date is already at the start.
|
||||
}
|
||||
|
||||
|
||||
throw new FireflyException(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));
|
||||
}
|
||||
|
||||
@@ -435,6 +433,7 @@ class Navigation
|
||||
* @param int $subtract
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1): Carbon
|
||||
@@ -476,7 +475,7 @@ class Navigation
|
||||
// a custom range requires the session start
|
||||
// and session end to calculate the difference in days.
|
||||
// this is then subtracted from $theDate (* $subtract).
|
||||
if ($repeatFreq === 'custom') {
|
||||
if ('custom' === $repeatFreq) {
|
||||
/** @var Carbon $tStart */
|
||||
$tStart = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $tEnd */
|
||||
@@ -495,6 +494,7 @@ class Navigation
|
||||
* @param \Carbon\Carbon $start
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function updateEndDate(string $range, Carbon $start): Carbon
|
||||
@@ -515,7 +515,7 @@ class Navigation
|
||||
|
||||
return $end;
|
||||
}
|
||||
if ($range === '6M') {
|
||||
if ('6M' === $range) {
|
||||
if ($start->month >= 7) {
|
||||
$end->endOfYear();
|
||||
|
||||
@@ -533,6 +533,7 @@ class Navigation
|
||||
* @param \Carbon\Carbon $start
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function updateStartDate(string $range, Carbon $start): Carbon
|
||||
@@ -551,7 +552,7 @@ class Navigation
|
||||
|
||||
return $start;
|
||||
}
|
||||
if ($range === '6M') {
|
||||
if ('6M' === $range) {
|
||||
if ($start->month >= 7) {
|
||||
$start->startOfYear()->addMonths(6);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -30,9 +29,7 @@ use Illuminate\Support\Collection;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
* Class Preferences
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class Preferences.
|
||||
*/
|
||||
class Preferences
|
||||
{
|
||||
@@ -53,6 +50,7 @@ class Preferences
|
||||
* @param $name
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(string $name): bool
|
||||
@@ -87,7 +85,7 @@ class Preferences
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
$user = auth()->user();
|
||||
if (is_null($user)) {
|
||||
if (null === $user) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
@@ -119,7 +117,7 @@ class Preferences
|
||||
|
||||
/**
|
||||
* @param \FireflyIII\User $user
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @param null|string $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Preference|null
|
||||
@@ -139,7 +137,7 @@ class Preferences
|
||||
return $preference;
|
||||
}
|
||||
// no preference found and default is null:
|
||||
if (is_null($default)) {
|
||||
if (null === $default) {
|
||||
// return NULL
|
||||
return null;
|
||||
}
|
||||
@@ -154,7 +152,7 @@ class Preferences
|
||||
{
|
||||
$lastActivity = microtime();
|
||||
$preference = $this->get('lastActivity', microtime());
|
||||
if (!is_null($preference)) {
|
||||
if (null !== $preference) {
|
||||
$lastActivity = $preference->data;
|
||||
}
|
||||
|
||||
@@ -173,15 +171,15 @@ class Preferences
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $name
|
||||
* @param $value
|
||||
*
|
||||
* @return Preference
|
||||
*/
|
||||
public function set($name, $value): Preference
|
||||
{
|
||||
$user = auth()->user();
|
||||
if (is_null($user)) {
|
||||
if (null === $user) {
|
||||
// make new preference, return it:
|
||||
$pref = new Preference;
|
||||
$pref->name = $name;
|
||||
@@ -206,7 +204,7 @@ class Preferences
|
||||
Cache::forget($fullName);
|
||||
$pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data']);
|
||||
|
||||
if (!is_null($pref)) {
|
||||
if (null !== $pref) {
|
||||
$pref->data = $value;
|
||||
$pref->save();
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Search;
|
||||
@@ -56,6 +55,7 @@ class Modifier
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function apply(array $modifier, Transaction $transaction): bool
|
||||
@@ -149,7 +149,7 @@ class Modifier
|
||||
*/
|
||||
public static function stringCompare(string $haystack, string $needle): bool
|
||||
{
|
||||
$res = !(strpos(strtolower($haystack), strtolower($needle)) === false);
|
||||
$res = !(false === strpos(strtolower($haystack), strtolower($needle)));
|
||||
Log::debug(sprintf('"%s" is in "%s"? %s', $needle, $haystack, var_export($res, true)));
|
||||
|
||||
return $res;
|
||||
@@ -164,11 +164,11 @@ class Modifier
|
||||
private static function budget(Transaction $transaction, string $search): bool
|
||||
{
|
||||
$journalBudget = '';
|
||||
if (!is_null($transaction->transaction_journal_budget_name)) {
|
||||
if (null !== $transaction->transaction_journal_budget_name) {
|
||||
$journalBudget = Steam::decrypt(intval($transaction->transaction_journal_budget_encrypted), $transaction->transaction_journal_budget_name);
|
||||
}
|
||||
$transactionBudget = '';
|
||||
if (!is_null($transaction->transaction_budget_name)) {
|
||||
if (null !== $transaction->transaction_budget_name) {
|
||||
$journalBudget = Steam::decrypt(intval($transaction->transaction_budget_encrypted), $transaction->transaction_budget_name);
|
||||
}
|
||||
|
||||
@@ -184,11 +184,11 @@ class Modifier
|
||||
private static function category(Transaction $transaction, string $search): bool
|
||||
{
|
||||
$journalCategory = '';
|
||||
if (!is_null($transaction->transaction_journal_category_name)) {
|
||||
if (null !== $transaction->transaction_journal_category_name) {
|
||||
$journalCategory = Steam::decrypt(intval($transaction->transaction_journal_category_encrypted), $transaction->transaction_journal_category_name);
|
||||
}
|
||||
$transactionCategory = '';
|
||||
if (!is_null($transaction->transaction_category_name)) {
|
||||
if (null !== $transaction->transaction_category_name) {
|
||||
$journalCategory = Steam::decrypt(intval($transaction->transaction_category_encrypted), $transaction->transaction_category_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Search;
|
||||
@@ -33,9 +32,7 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Search
|
||||
*
|
||||
* @package FireflyIII\Search
|
||||
* Class Search.
|
||||
*/
|
||||
class Search implements SearchInterface
|
||||
{
|
||||
@@ -43,13 +40,13 @@ class Search implements SearchInterface
|
||||
private $limit = 100;
|
||||
/** @var Collection */
|
||||
private $modifiers;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $originalQuery = '';
|
||||
/** @var User */
|
||||
private $user;
|
||||
/** @var array */
|
||||
private $validModifiers = [];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
private $words = [];
|
||||
|
||||
/**
|
||||
@@ -67,7 +64,7 @@ class Search implements SearchInterface
|
||||
public function getWordsAsString(): string
|
||||
{
|
||||
$string = join(' ', $this->words);
|
||||
if (strlen($string) === 0) {
|
||||
if (0 === strlen($string)) {
|
||||
return is_string($this->originalQuery) ? $this->originalQuery : '';
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ class Search implements SearchInterface
|
||||
Log::debug(sprintf('Total count is now %d', $result->count()));
|
||||
|
||||
// Update counters
|
||||
$page++;
|
||||
++$page;
|
||||
$processed += count($set);
|
||||
|
||||
Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed));
|
||||
@@ -235,7 +232,6 @@ class Search implements SearchInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
@@ -245,12 +241,12 @@ class Search implements SearchInterface
|
||||
private function extractModifier(string $string)
|
||||
{
|
||||
$parts = explode(':', $string);
|
||||
if (count($parts) === 2 && strlen(trim(strval($parts[0]))) > 0 && strlen(trim(strval($parts[1])))) {
|
||||
if (2 === count($parts) && strlen(trim(strval($parts[0]))) > 0 && strlen(trim(strval($parts[1])))) {
|
||||
$type = trim(strval($parts[0]));
|
||||
$value = trim(strval($parts[1]));
|
||||
if (in_array($type, $this->validModifiers)) {
|
||||
// filter for valid type
|
||||
$this->modifiers->push(['type' => $type, 'value' => $value,]);
|
||||
$this->modifiers->push(['type' => $type, 'value' => $value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,6 +255,7 @@ class Search implements SearchInterface
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function matchModifiers(Transaction $transaction): bool
|
||||
@@ -278,7 +275,7 @@ class Search implements SearchInterface
|
||||
// then a for-each and a switch for every possible other thingie.
|
||||
foreach ($this->modifiers as $modifier) {
|
||||
$res = Modifier::apply($modifier, $transaction);
|
||||
if ($res === false) {
|
||||
if (false === $res) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -294,11 +291,11 @@ class Search implements SearchInterface
|
||||
*/
|
||||
private function strposArray(string $haystack, array $needle)
|
||||
{
|
||||
if (strlen($haystack) === 0) {
|
||||
if (0 === strlen($haystack)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($needle as $what) {
|
||||
if (stripos($haystack, $what) !== false) {
|
||||
if (false !== stripos($haystack, $what)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Search;
|
||||
@@ -27,9 +26,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface SearchInterface
|
||||
*
|
||||
* @package FireflyIII\Support\Search
|
||||
* Interface SearchInterface.
|
||||
*/
|
||||
interface SearchInterface
|
||||
{
|
||||
@@ -48,7 +45,6 @@ interface SearchInterface
|
||||
*/
|
||||
public function parseQuery(string $query);
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Support;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class CacheProperties
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class CacheProperties.
|
||||
*/
|
||||
class SingleCacheProperties extends CacheProperties
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
@@ -32,15 +31,11 @@ use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class Steam.
|
||||
*/
|
||||
class Steam
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
* @param \Carbon\Carbon $date
|
||||
*
|
||||
@@ -48,7 +43,6 @@ class Steam
|
||||
*/
|
||||
public function balance(Account $account, Carbon $date): string
|
||||
{
|
||||
|
||||
// abuse chart properties:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($account->id);
|
||||
@@ -59,7 +53,7 @@ class Steam
|
||||
}
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
// use system default currency:
|
||||
if ($currencyId === 0) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$currencyId = $currency->id;
|
||||
}
|
||||
@@ -81,7 +75,7 @@ class Steam
|
||||
->sum('transactions.foreign_amount')
|
||||
);
|
||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||
$virtual = is_null($account->virtual_balance) ? '0' : strval($account->virtual_balance);
|
||||
$virtual = null === $account->virtual_balance ? '0' : strval($account->virtual_balance);
|
||||
$balance = bcadd($balance, $virtual);
|
||||
$cache->store($balance);
|
||||
|
||||
@@ -89,7 +83,6 @@ class Steam
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
* @param \Carbon\Carbon $date
|
||||
*
|
||||
@@ -97,7 +90,6 @@ class Steam
|
||||
*/
|
||||
public function balanceIgnoreVirtual(Account $account, Carbon $date): string
|
||||
{
|
||||
|
||||
// abuse chart properties:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($account->id);
|
||||
@@ -132,7 +124,7 @@ class Steam
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the balance for the given account during the whole range, using this format:
|
||||
* Gets the balance for the given account during the whole range, using this format:.
|
||||
*
|
||||
* [yyyy-mm-dd] => 123,2
|
||||
*
|
||||
@@ -187,10 +179,10 @@ class Steam
|
||||
/** @var Transaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
// normal amount and foreign amount
|
||||
$modified = is_null($entry->modified) ? '0' : strval($entry->modified);
|
||||
$foreignModified = is_null($entry->modified_foreign) ? '0' : strval($entry->modified_foreign);
|
||||
$modified = null === $entry->modified ? '0' : strval($entry->modified);
|
||||
$foreignModified = null === $entry->modified_foreign ? '0' : strval($entry->modified_foreign);
|
||||
$amount = '0';
|
||||
if ($currencyId === $entry->transaction_currency_id || $currencyId === 0) {
|
||||
if ($currencyId === $entry->transaction_currency_id || 0 === $currencyId) {
|
||||
// use normal amount:
|
||||
$amount = $modified;
|
||||
}
|
||||
@@ -250,7 +242,7 @@ class Steam
|
||||
*/
|
||||
public function decrypt(int $isEncrypted, string $value)
|
||||
{
|
||||
if ($isEncrypted === 1) {
|
||||
if (1 === $isEncrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
@@ -285,7 +277,7 @@ class Steam
|
||||
*/
|
||||
public function negative(string $amount): string
|
||||
{
|
||||
if (bccomp($amount, '0') === 1) {
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
@@ -313,21 +305,21 @@ class Steam
|
||||
{
|
||||
$string = strtolower($string);
|
||||
|
||||
if (!(stripos($string, 'k') === false)) {
|
||||
if (!(false === stripos($string, 'k'))) {
|
||||
// has a K in it, remove the K and multiply by 1024.
|
||||
$bytes = bcmul(rtrim($string, 'kK'), '1024');
|
||||
|
||||
return intval($bytes);
|
||||
}
|
||||
|
||||
if (!(stripos($string, 'm') === false)) {
|
||||
if (!(false === stripos($string, 'm'))) {
|
||||
// has a M in it, remove the M and multiply by 1048576.
|
||||
$bytes = bcmul(rtrim($string, 'mM'), '1048576');
|
||||
|
||||
return intval($bytes);
|
||||
}
|
||||
|
||||
if (!(stripos($string, 'g') === false)) {
|
||||
if (!(false === stripos($string, 'g'))) {
|
||||
// has a G in it, remove the G and multiply by (1024)^3.
|
||||
$bytes = bcmul(rtrim($string, 'gG'), '1073741824');
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -31,13 +30,11 @@ use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Contains all amount formatting routines.
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
*/
|
||||
class AmountFormat extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFilters(): array
|
||||
{
|
||||
@@ -48,7 +45,7 @@ class AmountFormat extends Twig_Extension
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
@@ -74,7 +71,6 @@ class AmountFormat extends Twig_Extension
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
protected function formatAmount(): Twig_SimpleFilter
|
||||
@@ -102,7 +98,7 @@ class AmountFormat extends Twig_Extension
|
||||
function (AccountModel $account, string $amount, bool $coloured = true): string {
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
|
||||
if ($currencyId !== 0) {
|
||||
if (0 !== $currencyId) {
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
@@ -175,7 +171,6 @@ class AmountFormat extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'formatDestinationAfter',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
@@ -183,7 +178,7 @@ class AmountFormat extends Twig_Extension
|
||||
$string = app('amount')->formatAnything($format, $transaction['destination_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_destination_amount'])) {
|
||||
if (null !== $transaction['foreign_destination_amount']) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
@@ -191,7 +186,6 @@ class AmountFormat extends Twig_Extension
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_destination_amount'], true) . ')';
|
||||
}
|
||||
|
||||
|
||||
return $string;
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
@@ -206,7 +200,6 @@ class AmountFormat extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'formatDestinationBefore',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
@@ -226,7 +219,6 @@ class AmountFormat extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'formatSourceAfter',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
@@ -234,7 +226,7 @@ class AmountFormat extends Twig_Extension
|
||||
$string = app('amount')->formatAnything($format, $transaction['source_account_after'], true);
|
||||
|
||||
// also append foreign amount for clarity:
|
||||
if (!is_null($transaction['foreign_source_amount'])) {
|
||||
if (null !== $transaction['foreign_source_amount']) {
|
||||
// build fake currency for foreign amount
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['foreign_currency_dp'];
|
||||
@@ -242,7 +234,6 @@ class AmountFormat extends Twig_Extension
|
||||
$string .= ' (' . app('amount')->formatAnything($format, $transaction['foreign_source_amount'], true) . ')';
|
||||
}
|
||||
|
||||
|
||||
return $string;
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
@@ -257,7 +248,6 @@ class AmountFormat extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'formatSourceBefore',
|
||||
function (array $transaction): string {
|
||||
|
||||
// build fake currency for main amount.
|
||||
$format = new TransactionCurrency;
|
||||
$format->decimal_places = $transaction['transaction_currency_dp'];
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Extension;
|
||||
@@ -33,13 +32,10 @@ use Lang;
|
||||
use Twig_Extension;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*
|
||||
* @package FireflyIII\Support\Twig\Extension
|
||||
* Class Transaction.
|
||||
*/
|
||||
class Transaction extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Can show the amount of a transaction, if that transaction has been collected by the journal collector.
|
||||
*
|
||||
@@ -61,16 +57,16 @@ class Transaction extends Twig_Extension
|
||||
$format = '%s';
|
||||
$coloured = true;
|
||||
|
||||
if ($transaction->transaction_type_type === TransactionType::DEPOSIT) {
|
||||
if (TransactionType::DEPOSIT === $transaction->transaction_type_type) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
if ($transaction->transaction_type_type === TransactionType::TRANSFER) {
|
||||
if (TransactionType::TRANSFER === $transaction->transaction_type_type) {
|
||||
$amount = app('steam')->positive($amount);
|
||||
$coloured = false;
|
||||
$format = '<span class="text-info">%s</span>';
|
||||
}
|
||||
if ($transaction->transaction_type_type === TransactionType::OPENING_BALANCE) {
|
||||
if (TransactionType::OPENING_BALANCE === $transaction->transaction_type_type) {
|
||||
$amount = strval($transaction->transaction_amount);
|
||||
}
|
||||
|
||||
@@ -79,15 +75,13 @@ class Transaction extends Twig_Extension
|
||||
$currency->decimal_places = $transaction->transaction_currency_dp;
|
||||
$str = sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured));
|
||||
|
||||
|
||||
if (!is_null($transaction->transaction_foreign_amount)) {
|
||||
if (null !== $transaction->transaction_foreign_amount) {
|
||||
$amount = bcmul(app('steam')->positive(strval($transaction->transaction_foreign_amount)), '-1');
|
||||
if ($transaction->transaction_type_type === TransactionType::DEPOSIT) {
|
||||
if (TransactionType::DEPOSIT === $transaction->transaction_type_type) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
|
||||
if ($transaction->transaction_type_type === TransactionType::TRANSFER) {
|
||||
if (TransactionType::TRANSFER === $transaction->transaction_type_type) {
|
||||
$amount = app('steam')->positive($amount);
|
||||
$coloured = false;
|
||||
$format = '<span class="text-info">%s</span>';
|
||||
@@ -120,7 +114,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
// first display amount:
|
||||
$amount = $transaction['journal_type'] === TransactionType::WITHDRAWAL ? $transaction['source_amount']
|
||||
$amount = TransactionType::WITHDRAWAL === $transaction['journal_type'] ? $transaction['source_amount']
|
||||
: $transaction['destination_amount'];
|
||||
$fakeCurrency = new TransactionCurrency;
|
||||
$fakeCurrency->decimal_places = $transaction['transaction_currency_dp'];
|
||||
@@ -128,8 +122,8 @@ class Transaction extends Twig_Extension
|
||||
$string = app('amount')->formatAnything($fakeCurrency, $amount, true);
|
||||
|
||||
// then display (if present) the foreign amount:
|
||||
if (!is_null($transaction['foreign_source_amount'])) {
|
||||
$amount = $transaction['journal_type'] === TransactionType::WITHDRAWAL ? $transaction['foreign_source_amount']
|
||||
if (null !== $transaction['foreign_source_amount']) {
|
||||
$amount = TransactionType::WITHDRAWAL === $transaction['journal_type'] ? $transaction['foreign_source_amount']
|
||||
: $transaction['foreign_destination_amount'];
|
||||
$fakeCurrency = new TransactionCurrency;
|
||||
$fakeCurrency->decimal_places = $transaction['foreign_currency_dp'];
|
||||
@@ -176,7 +170,7 @@ class Transaction extends Twig_Extension
|
||||
|
||||
// see if the transaction has a budget:
|
||||
$budgets = $transaction->budgets()->get();
|
||||
if ($budgets->count() === 0) {
|
||||
if (0 === $budgets->count()) {
|
||||
$budgets = $transaction->transactionJournal()->first()->budgets()->get();
|
||||
}
|
||||
if ($budgets->count() > 0) {
|
||||
@@ -231,7 +225,7 @@ class Transaction extends Twig_Extension
|
||||
|
||||
// see if the transaction has a category:
|
||||
$categories = $transaction->categories()->get();
|
||||
if ($categories->count() === 0) {
|
||||
if (0 === $categories->count()) {
|
||||
$categories = $transaction->transactionJournal()->first()->categories()->get();
|
||||
}
|
||||
if ($categories->count() > 0) {
|
||||
@@ -296,14 +290,14 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && !is_null($transaction->opposing_account_id)) {
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null !== $transaction->opposing_account_id) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = intval($transaction->opposing_account_id);
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
|
||||
// Find the opposing account and use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && is_null($transaction->opposing_account_id)) {
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null === $transaction->opposing_account_id) {
|
||||
// if the amount is negative, find the opposing account and use that one:
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
@@ -320,7 +314,7 @@ class Transaction extends Twig_Extension
|
||||
$type = $other->type;
|
||||
}
|
||||
|
||||
if ($type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
$cache->store($txt);
|
||||
|
||||
@@ -418,7 +412,7 @@ class Transaction extends Twig_Extension
|
||||
return $cache->get();
|
||||
}
|
||||
$icon = '';
|
||||
if (intval($transaction->reconciled) === 1) {
|
||||
if (1 === intval($transaction->reconciled)) {
|
||||
$icon = '<i class="fa fa-check"></i>';
|
||||
}
|
||||
|
||||
@@ -477,13 +471,13 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === 1 && !is_null($transaction->opposing_account_id)) {
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null !== $transaction->opposing_account_id) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = intval($transaction->opposing_account_id);
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
// Find the opposing account and use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === 1 && is_null($transaction->opposing_account_id)) {
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null === $transaction->opposing_account_id) {
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
|
||||
@@ -499,7 +493,7 @@ class Transaction extends Twig_Extension
|
||||
$type = $other->type;
|
||||
}
|
||||
|
||||
if ($type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
$cache->store($txt);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Extension;
|
||||
@@ -31,7 +30,6 @@ use Twig_Extension;
|
||||
|
||||
class TransactionJournal extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* @param JournalModel $journal
|
||||
*
|
||||
@@ -63,7 +61,7 @@ class TransactionJournal extends Twig_Extension
|
||||
}
|
||||
$totals[$currencyId]['amount'] = bcadd($transaction->amount, $totals[$currencyId]['amount']);
|
||||
|
||||
if (!is_null($transaction->foreign_currency_id)) {
|
||||
if (null !== $transaction->foreign_currency_id) {
|
||||
$foreignId = $transaction->foreign_currency_id;
|
||||
$foreign = $transaction->foreignCurrency;
|
||||
if (!isset($totals[$foreignId])) {
|
||||
@@ -77,7 +75,7 @@ class TransactionJournal extends Twig_Extension
|
||||
}
|
||||
$array = [];
|
||||
foreach ($totals as $total) {
|
||||
if ($type === TransactionType::WITHDRAWAL) {
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
$total['amount'] = bcmul($total['amount'], '-1');
|
||||
}
|
||||
$array[] = app('amount')->formatAnything($total['currency'], $total['amount']);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -33,15 +32,10 @@ use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class TwigSupport
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
* Class TwigSupport.
|
||||
*/
|
||||
class General extends Twig_Extension
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -51,12 +45,11 @@ class General extends Twig_Extension
|
||||
$this->balance(),
|
||||
$this->formatFilesize(),
|
||||
$this->mimeIcon(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
@@ -70,12 +63,11 @@ class General extends Twig_Extension
|
||||
$this->steamPositive(),
|
||||
$this->activeRoutePartial(),
|
||||
$this->activeRoutePartialWhat(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
@@ -96,7 +88,7 @@ class General extends Twig_Extension
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||
if (!(strpos($name, $route) === false)) {
|
||||
if (!(false === strpos($name, $route))) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
@@ -121,7 +113,7 @@ class General extends Twig_Extension
|
||||
$what = $args[2]; // name of the route.
|
||||
$activeWhat = $context['what'] ?? false;
|
||||
|
||||
if ($what === $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
|
||||
if ($what === $activeWhat && !(false === strpos(Route::getCurrentRoute()->getName(), $route))) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
@@ -162,7 +154,7 @@ class General extends Twig_Extension
|
||||
return new Twig_SimpleFilter(
|
||||
'balance',
|
||||
function (?Account $account): string {
|
||||
if (is_null($account)) {
|
||||
if (null === $account) {
|
||||
return 'NULL';
|
||||
}
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
@@ -193,7 +185,6 @@ class General extends Twig_Extension
|
||||
return new Twig_SimpleFilter(
|
||||
'filesize',
|
||||
function (int $size): string {
|
||||
|
||||
// less than one GB, more than one MB
|
||||
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
|
||||
return round($size / (1024 * 1024), 2) . ' MB';
|
||||
@@ -209,7 +200,6 @@ class General extends Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -34,14 +33,10 @@ use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class Journal
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
* Class Journal.
|
||||
*/
|
||||
class Journal extends Twig_Extension
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
@@ -62,7 +57,7 @@ class Journal extends Twig_Extension
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $entry->accountType->type) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
}
|
||||
@@ -134,7 +129,7 @@ class Journal extends Twig_Extension
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if ($entry->accountType->type === AccountType::CASH) {
|
||||
if (AccountType::CASH === $entry->accountType->type) {
|
||||
$array[] = '<span class="text-success">(cash)</span>';
|
||||
continue;
|
||||
}
|
||||
@@ -165,7 +160,6 @@ class Journal extends Twig_Extension
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
$budgets = [];
|
||||
// get all budgets:
|
||||
foreach ($journal->budgets as $budget) {
|
||||
@@ -205,7 +199,7 @@ class Journal extends Twig_Extension
|
||||
foreach ($journal->categories as $category) {
|
||||
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
|
||||
}
|
||||
if (count($categories) === 0) {
|
||||
if (0 === count($categories)) {
|
||||
$set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')
|
||||
->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')
|
||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Loader;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Support\Twig\Extension\TransactionJournal;
|
||||
use Twig_RuntimeLoaderInterface;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalLoader
|
||||
*
|
||||
* @package FireflyIII\Support\Twig\Extension
|
||||
* Class TransactionJournalLoader.
|
||||
*/
|
||||
class TransactionJournalLoader implements Twig_RuntimeLoaderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates the runtime implementation of a Twig element (filter/function/test).
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig\Loader;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Support\Twig\Extension\Transaction;
|
||||
use Twig_RuntimeLoaderInterface;
|
||||
|
||||
/**
|
||||
* Class TransactionLoader
|
||||
*
|
||||
* @package FireflyIII\Support\Twig\Extension
|
||||
* Class TransactionLoader.
|
||||
*/
|
||||
class TransactionLoader implements Twig_RuntimeLoaderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates the runtime implementation of a Twig element (filter/function/test).
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -28,14 +27,10 @@ use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class PiggyBank
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
* Class PiggyBank.
|
||||
*/
|
||||
class PiggyBank extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -28,13 +27,10 @@ use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class Rule
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
* Class Rule.
|
||||
*/
|
||||
class Rule extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
@@ -84,7 +80,7 @@ class Rule extends Twig_Extension
|
||||
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
||||
$possibleTriggers = [];
|
||||
foreach ($ruleTriggers as $key) {
|
||||
if ($key !== 'user_action') {
|
||||
if ('user_action' !== $key) {
|
||||
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
||||
}
|
||||
}
|
||||
@@ -93,7 +89,6 @@ class Rule extends Twig_Extension
|
||||
|
||||
return $possibleTriggers;
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -28,9 +27,7 @@ use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
* Class Transaction.
|
||||
*/
|
||||
class Transaction extends Twig_Extension
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
@@ -28,14 +27,10 @@ use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Budget
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
* Class Budget.
|
||||
*/
|
||||
class Translation extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -54,20 +49,18 @@ class Translation extends Twig_Extension
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
$this->journalLinkTranslation(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user