Code clean up.

This commit is contained in:
James Cole
2017-11-15 12:25:49 +01:00
parent 57dcdfa0c4
commit ffca858b8d
476 changed files with 2055 additions and 4181 deletions

View File

@@ -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\TransactionRules\Actions;
@@ -32,24 +31,21 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Log;
/**
* Class SetDestinationAccount
*
* @package FireflyIII\TransactionRules\Action
* Class SetDestinationAccount.
*/
class SetDestinationAccount implements ActionInterface
{
private $action;
/** @var TransactionJournal */
/** @var TransactionJournal */
private $journal;
/** @var Account */
/** @var Account */
private $newDestinationAccount;
/** @var AccountRepositoryInterface */
private $repository;
/**
* TriggerInterface constructor.
*
@@ -81,7 +77,7 @@ class SetDestinationAccount implements ActionInterface
$type = $journal->transactionType->type;
// if this is a deposit or a transfer, the destination account must be an asset account or a default account, and it MUST exist:
if (($type === TransactionType::DEPOSIT || $type === TransactionType::TRANSFER) && !$this->findAssetAccount()) {
if ((TransactionType::DEPOSIT === $type || TransactionType::TRANSFER === $type) && !$this->findAssetAccount()) {
Log::error(
sprintf(
'Cannot change destination account of journal #%d because no asset account with name "%s" exists.',
@@ -94,7 +90,7 @@ class SetDestinationAccount implements ActionInterface
}
// if this is a withdrawal, the new destination account must be a expense account and may be created:
if ($type === TransactionType::WITHDRAWAL) {
if (TransactionType::WITHDRAWAL === $type) {
$this->findExpenseAccount();
}
@@ -117,7 +113,7 @@ class SetDestinationAccount implements ActionInterface
{
$account = $this->repository->findByName($this->action->action_value, [AccountType::DEFAULT, AccountType::ASSET]);
if (is_null($account->id)) {
if (null === $account->id) {
Log::debug(sprintf('There is NO asset account called "%s".', $this->action->action_value));
return false;
@@ -134,7 +130,7 @@ class SetDestinationAccount implements ActionInterface
private function findExpenseAccount()
{
$account = $this->repository->findByName($this->action->action_value, [AccountType::EXPENSE]);
if (is_null($account->id)) {
if (null === $account->id) {
// create new revenue account with this name:
$data = [
'name' => $this->action->action_value,