mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 14:46:37 +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\Repositories\Currency;
|
||||
@@ -33,9 +32,7 @@ use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class CurrencyRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\Currency
|
||||
* Class CurrencyRepository.
|
||||
*/
|
||||
class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
{
|
||||
@@ -54,7 +51,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
// is the only currency left
|
||||
if ($this->get()->count() === 1) {
|
||||
if (1 === $this->get()->count()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,7 +96,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by ID
|
||||
* Find by ID.
|
||||
*
|
||||
* @param int $currencyId
|
||||
*
|
||||
@@ -108,7 +105,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function find(int $currencyId): TransactionCurrency
|
||||
{
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
$currency = new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -116,7 +113,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by currency code
|
||||
* Find by currency code.
|
||||
*
|
||||
* @param string $currencyCode
|
||||
*
|
||||
@@ -125,7 +122,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function findByCode(string $currencyCode): TransactionCurrency
|
||||
{
|
||||
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
$currency = new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -133,7 +130,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by currency name
|
||||
* Find by currency name.
|
||||
*
|
||||
* @param string $currencyName
|
||||
*
|
||||
@@ -142,7 +139,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function findByName(string $currencyName): TransactionCurrency
|
||||
{
|
||||
$preferred = TransactionCurrency::whereName($currencyName)->first();
|
||||
if (is_null($preferred)) {
|
||||
if (null === $preferred) {
|
||||
$preferred = new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by currency symbol
|
||||
* Find by currency symbol.
|
||||
*
|
||||
* @param string $currencySymbol
|
||||
*
|
||||
@@ -159,7 +156,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function findBySymbol(string $currencySymbol): TransactionCurrency
|
||||
{
|
||||
$currency = TransactionCurrency::whereSymbol($currencySymbol)->first();
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
$currency = new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -192,7 +189,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function getCurrencyByPreference(Preference $preference): TransactionCurrency
|
||||
{
|
||||
$preferred = TransactionCurrency::where('code', $preference->data)->first();
|
||||
if (is_null($preferred)) {
|
||||
if (null === $preferred) {
|
||||
$preferred = TransactionCurrency::first();
|
||||
}
|
||||
|
||||
@@ -220,7 +217,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
->where('from_currency_id', $fromCurrency->id)
|
||||
->where('to_currency_id', $toCurrency->id)
|
||||
->where('date', $date->format('Y-m-d'))->first();
|
||||
if (!is_null($rate)) {
|
||||
if (null !== $rate) {
|
||||
Log::debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
|
||||
|
||||
return $rate;
|
||||
|
Reference in New Issue
Block a user