mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +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\Helpers\Attachments; | ||||
| @@ -33,14 +32,11 @@ use Storage; | ||||
| use Symfony\Component\HttpFoundation\File\UploadedFile; | ||||
|  | ||||
| /** | ||||
|  * Class AttachmentHelper | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Attachments | ||||
|  * Class AttachmentHelper. | ||||
|  */ | ||||
| class AttachmentHelper implements AttachmentHelperInterface | ||||
| { | ||||
|  | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     public $attachments; | ||||
|     /** @var MessageBag */ | ||||
|     public $errors; | ||||
| @@ -114,7 +110,7 @@ class AttachmentHelper implements AttachmentHelperInterface | ||||
|         if (is_array($files)) { | ||||
|             /** @var UploadedFile $entry */ | ||||
|             foreach ($files as $entry) { | ||||
|                 if (!is_null($entry)) { | ||||
|                 if (null !== $entry) { | ||||
|                     $this->processFile($entry, $model); | ||||
|                 } | ||||
|             } | ||||
| @@ -152,7 +148,6 @@ class AttachmentHelper implements AttachmentHelperInterface | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * @param UploadedFile $file | ||||
|      * @param Model        $model | ||||
|      * | ||||
| @@ -161,7 +156,7 @@ class AttachmentHelper implements AttachmentHelperInterface | ||||
|     protected function processFile(UploadedFile $file, Model $model): Attachment | ||||
|     { | ||||
|         $validation = $this->validateUpload($file, $model); | ||||
|         if ($validation === false) { | ||||
|         if (false === $validation) { | ||||
|             return new Attachment; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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\Helpers\Attachments; | ||||
| @@ -29,13 +28,10 @@ use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\MessageBag; | ||||
|  | ||||
| /** | ||||
|  * Interface AttachmentHelperInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Attachments | ||||
|  * Interface AttachmentHelperInterface. | ||||
|  */ | ||||
| interface AttachmentHelperInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * @param Attachment $attachment | ||||
|      * | ||||
| @@ -60,7 +56,6 @@ interface AttachmentHelperInterface | ||||
|  | ||||
|     /** | ||||
|      * @param Model      $model | ||||
|      * | ||||
|      * @param null|array $files | ||||
|      * | ||||
|      * @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\Helpers\Chart; | ||||
| @@ -41,23 +40,19 @@ use Illuminate\Support\Collection; | ||||
| use Steam; | ||||
|  | ||||
| /** | ||||
|  * Class MetaPieChart | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Chart | ||||
|  * | ||||
|  * | ||||
|  * Class MetaPieChart. | ||||
|  */ | ||||
| class MetaPieChart implements MetaPieChartInterface | ||||
| { | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $accounts; | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $budgets; | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $categories; | ||||
|     /** @var bool */ | ||||
|     protected $collectOtherObjects = false; | ||||
|     /** @var  Carbon */ | ||||
|     /** @var Carbon */ | ||||
|     protected $end; | ||||
|     /** @var array */ | ||||
|     protected $grouping | ||||
| @@ -75,13 +70,13 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|             'category' => CategoryRepositoryInterface::class, | ||||
|             'tag'      => TagRepositoryInterface::class, | ||||
|         ]; | ||||
|     /** @var  Carbon */ | ||||
|     /** @var Carbon */ | ||||
|     protected $start; | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $tags; | ||||
|     /** @var  string */ | ||||
|     /** @var string */ | ||||
|     protected $total = '0'; | ||||
|     /** @var  User */ | ||||
|     /** @var User */ | ||||
|     protected $user; | ||||
|  | ||||
|     public function __construct() | ||||
| @@ -108,7 +103,7 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|         $key          = strval(trans('firefly.everything_else')); | ||||
|  | ||||
|         // also collect all other transactions | ||||
|         if ($this->collectOtherObjects && $direction === 'expense') { | ||||
|         if ($this->collectOtherObjects && 'expense' === $direction) { | ||||
|             /** @var JournalCollectorInterface $collector */ | ||||
|             $collector = app(JournalCollectorInterface::class); | ||||
|             $collector->setUser($this->user); | ||||
| @@ -121,7 +116,7 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|             $chartData[$key] = $sum; | ||||
|         } | ||||
|  | ||||
|         if ($this->collectOtherObjects && $direction === 'income') { | ||||
|         if ($this->collectOtherObjects && 'income' === $direction) { | ||||
|             /** @var JournalCollectorInterface $collector */ | ||||
|             $collector = app(JournalCollectorInterface::class); | ||||
|             $collector->setUser($this->user); | ||||
| @@ -258,7 +253,7 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|         $collector = app(JournalCollectorInterface::class); | ||||
|         $types     = [TransactionType::DEPOSIT, TransactionType::TRANSFER]; | ||||
|         $collector->addFilter(NegativeAmountFilter::class); | ||||
|         if ($direction === 'expense') { | ||||
|         if ('expense' === $direction) { | ||||
|             $types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; | ||||
|             $collector->addFilter(PositiveAmountFilter::class); | ||||
|             $collector->removeFilter(NegativeAmountFilter::class); | ||||
| @@ -271,7 +266,7 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|         $collector->withOpposingAccount(); | ||||
|         $collector->addFilter(OpposingAccountFilter::class); | ||||
|  | ||||
|         if ($direction === 'income') { | ||||
|         if ('income' === $direction) { | ||||
|             $collector->removeFilter(TransferFilter::class); | ||||
|         } | ||||
|  | ||||
| @@ -294,11 +289,10 @@ class MetaPieChart implements MetaPieChartInterface | ||||
|      * @return array | ||||
|      * | ||||
|      * @SuppressWarnings(PHPMD.CyclomaticComplexity) | ||||
|      * | ||||
|      */ | ||||
|     protected function groupByFields(Collection $set, array $fields): array | ||||
|     { | ||||
|         if (count($fields) === 0 && $this->tags->count() > 0) { | ||||
|         if (0 === count($fields) && $this->tags->count() > 0) { | ||||
|             // do a special group on tags: | ||||
|             return $this->groupByTag($set); | ||||
|         } | ||||
|   | ||||
| @@ -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\Helpers\Chart; | ||||
| @@ -28,9 +27,7 @@ use FireflyIII\User; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface MetaPieChartInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Chart | ||||
|  * Interface MetaPieChartInterface. | ||||
|  */ | ||||
| interface MetaPieChartInterface | ||||
| { | ||||
| @@ -47,54 +44,54 @@ interface MetaPieChartInterface | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setAccounts(Collection $accounts): MetaPieChartInterface; | ||||
|     public function setAccounts(Collection $accounts): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $budgets | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setBudgets(Collection $budgets): MetaPieChartInterface; | ||||
|     public function setBudgets(Collection $budgets): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $categories | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setCategories(Collection $categories): MetaPieChartInterface; | ||||
|     public function setCategories(Collection $categories): self; | ||||
|  | ||||
|     /** | ||||
|      * @param bool $collectOtherObjects | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setCollectOtherObjects(bool $collectOtherObjects): MetaPieChartInterface; | ||||
|     public function setCollectOtherObjects(bool $collectOtherObjects): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $end | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setEnd(Carbon $end): MetaPieChartInterface; | ||||
|     public function setEnd(Carbon $end): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $start | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setStart(Carbon $start): MetaPieChartInterface; | ||||
|     public function setStart(Carbon $start): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $tags | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setTags(Collection $tags): MetaPieChartInterface; | ||||
|     public function setTags(Collection $tags): self; | ||||
|  | ||||
|     /** | ||||
|      * @param User $user | ||||
|      * | ||||
|      * @return MetaPieChartInterface | ||||
|      */ | ||||
|     public function setUser(User $user): MetaPieChartInterface; | ||||
|     public function setUser(User $user): self; | ||||
| } | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -26,18 +25,14 @@ namespace FireflyIII\Helpers\Collection; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class Balance | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class Balance. | ||||
|  */ | ||||
| class Balance | ||||
| { | ||||
|  | ||||
|     /** @var  BalanceHeader */ | ||||
|     /** @var BalanceHeader */ | ||||
|     protected $balanceHeader; | ||||
|  | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $balanceLines; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -26,16 +25,11 @@ namespace FireflyIII\Helpers\Collection; | ||||
| use FireflyIII\Models\Account as AccountModel; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class BalanceEntry | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class BalanceEntry. | ||||
|  */ | ||||
| class BalanceEntry | ||||
| { | ||||
|  | ||||
|  | ||||
|     /** @var  AccountModel */ | ||||
|     /** @var AccountModel */ | ||||
|     protected $account; | ||||
|     /** @var string */ | ||||
|     protected $left = '0'; | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -27,15 +26,11 @@ use FireflyIII\Models\Account as AccountModel; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class BalanceHeader | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class BalanceHeader. | ||||
|  */ | ||||
| class BalanceHeader | ||||
| { | ||||
|  | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $accounts; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -29,10 +28,7 @@ use FireflyIII\Models\BudgetLimit; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class BalanceLine | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class BalanceLine. | ||||
|  */ | ||||
| class BalanceLine | ||||
| { | ||||
| @@ -40,12 +36,12 @@ class BalanceLine | ||||
|     const ROLE_TAGROLE     = 2; | ||||
|     const ROLE_DIFFROLE    = 3; | ||||
|  | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $balanceEntries; | ||||
|  | ||||
|     /** @var BudgetModel */ | ||||
|     protected $budget; | ||||
|     /** @var  BudgetLimit */ | ||||
|     /** @var BudgetLimit */ | ||||
|     protected $budgetLimit; | ||||
|     /** @var int */ | ||||
|     protected $role = self::ROLE_DEFAULTROLE; | ||||
| @@ -148,20 +144,21 @@ class BalanceLine | ||||
|  | ||||
|     /** | ||||
|      * @SuppressWarnings(PHPMD.CyclomaticComplexity) | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getTitle(): string | ||||
|     { | ||||
|         if ($this->getBudget() instanceof BudgetModel && !is_null($this->getBudget()->id)) { | ||||
|         if ($this->getBudget() instanceof BudgetModel && null !== $this->getBudget()->id) { | ||||
|             return $this->getBudget()->name; | ||||
|         } | ||||
|         if ($this->getRole() === self::ROLE_DEFAULTROLE) { | ||||
|         if (self::ROLE_DEFAULTROLE === $this->getRole()) { | ||||
|             return strval(trans('firefly.no_budget')); | ||||
|         } | ||||
|         if ($this->getRole() === self::ROLE_TAGROLE) { | ||||
|         if (self::ROLE_TAGROLE === $this->getRole()) { | ||||
|             return strval(trans('firefly.coveredWithTags')); | ||||
|         } | ||||
|         if ($this->getRole() === self::ROLE_DIFFROLE) { | ||||
|         if (self::ROLE_DIFFROLE === $this->getRole()) { | ||||
|             return strval(trans('firefly.leftUnbalanced')); | ||||
|         } | ||||
|  | ||||
| @@ -172,7 +169,7 @@ class BalanceLine | ||||
|      * If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine | ||||
|      * should have a "spent" value, which is the amount of money that has been spent | ||||
|      * on the given budget/repetition. If you subtract all those amounts from the budget/repetition's | ||||
|      * total amount, this is returned: | ||||
|      * total amount, this is returned:. | ||||
|      * | ||||
|      * @return 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\Helpers\Collection; | ||||
| @@ -29,20 +28,17 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class Bill | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class Bill. | ||||
|  */ | ||||
| class Bill | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * @var Collection | ||||
|      */ | ||||
|     private $bills; | ||||
|     /** @var  Carbon */ | ||||
|     /** @var Carbon */ | ||||
|     private $endDate; | ||||
|     /** @var  Carbon */ | ||||
|     /** @var Carbon */ | ||||
|     private $startDate; | ||||
|  | ||||
|     /** | ||||
| @@ -105,14 +101,13 @@ class Bill | ||||
|     { | ||||
|         $set = $this->bills->sortBy( | ||||
|             function (BillLine $bill) { | ||||
|                 $active = intval($bill->getBill()->active) === 0 ? 1 : 0; | ||||
|                 $active = 0 === intval($bill->getBill()->active) ? 1 : 0; | ||||
|                 $name   = $bill->getBill()->name; | ||||
|  | ||||
|                 return $active . $name; | ||||
|             } | ||||
|         ); | ||||
|  | ||||
|  | ||||
|         return $set; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -27,27 +26,23 @@ use Carbon\Carbon; | ||||
| use FireflyIII\Models\Bill as BillModel; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class BillLine | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class BillLine. | ||||
|  */ | ||||
| class BillLine | ||||
| { | ||||
|  | ||||
|     /** @var  string */ | ||||
|     /** @var string */ | ||||
|     protected $amount; | ||||
|     /** @var  BillModel */ | ||||
|     /** @var BillModel */ | ||||
|     protected $bill; | ||||
|     /** @var  bool */ | ||||
|     /** @var bool */ | ||||
|     protected $hit; | ||||
|     /** @var  string */ | ||||
|     /** @var string */ | ||||
|     protected $max; | ||||
|     /** @var  string */ | ||||
|     /** @var string */ | ||||
|     protected $min; | ||||
|     /** @var  Carbon */ | ||||
|     /** @var Carbon */ | ||||
|     private $lastHitDate; | ||||
|     /** @var  int */ | ||||
|     /** @var int */ | ||||
|     private $transactionJournalId; | ||||
|  | ||||
|     /** | ||||
| @@ -159,7 +154,7 @@ class BillLine | ||||
|      */ | ||||
|     public function isActive(): bool | ||||
|     { | ||||
|         return intval($this->bill->active) === 1; | ||||
|         return 1 === intval($this->bill->active); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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\Helpers\Collection; | ||||
| @@ -27,15 +26,11 @@ use FireflyIII\Models\Category as CategoryModel; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * Class Category | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collection | ||||
|  * Class Category. | ||||
|  */ | ||||
| class Category | ||||
| { | ||||
|  | ||||
|     /** @var  Collection */ | ||||
|     /** @var Collection */ | ||||
|     protected $categories; | ||||
|     /** @var string */ | ||||
|     protected $total = '0'; | ||||
| @@ -79,7 +74,6 @@ class Category | ||||
|             } | ||||
|         ); | ||||
|  | ||||
|  | ||||
|         return $set; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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\Helpers\Collector; | ||||
| @@ -51,7 +50,6 @@ use Steam; | ||||
|  * | ||||
|  * Class JournalCollector | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collector | ||||
|  * | ||||
|  * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) | ||||
|  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||||
| @@ -59,10 +57,9 @@ use Steam; | ||||
|  */ | ||||
| class JournalCollector implements JournalCollectorInterface | ||||
| { | ||||
|  | ||||
|     /** @var array */ | ||||
|     private $accountIds = []; | ||||
|     /** @var  int */ | ||||
|     /** @var int */ | ||||
|     private $count = 0; | ||||
|     /** @var array */ | ||||
|     private $fields | ||||
| @@ -101,22 +98,21 @@ class JournalCollector implements JournalCollectorInterface | ||||
|             'accounts.encrypted as account_encrypted', | ||||
|             'accounts.iban as account_iban', | ||||
|             'account_types.type as account_type', | ||||
|  | ||||
|         ]; | ||||
|     /** @var array */ | ||||
|     private $filters = [InternalTransferFilter::class]; | ||||
|  | ||||
|     /** @var  bool */ | ||||
|     /** @var bool */ | ||||
|     private $joinedBudget = false; | ||||
|     /** @var  bool */ | ||||
|     /** @var bool */ | ||||
|     private $joinedCategory = false; | ||||
|     /** @var bool */ | ||||
|     private $joinedOpposing = false; | ||||
|     /** @var bool */ | ||||
|     private $joinedTag = false; | ||||
|     /** @var  int */ | ||||
|     /** @var int */ | ||||
|     private $limit; | ||||
|     /** @var  int */ | ||||
|     /** @var int */ | ||||
|     private $offset; | ||||
|     /** @var int */ | ||||
|     private $page = 1; | ||||
| @@ -218,11 +214,12 @@ class JournalCollector implements JournalCollectorInterface | ||||
|  | ||||
|     /** | ||||
|      * @return int | ||||
|      * | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public function count(): int | ||||
|     { | ||||
|         if ($this->run === true) { | ||||
|         if (true === $this->run) { | ||||
|             throw new FireflyException('Cannot count after run in JournalCollector.'); | ||||
|         } | ||||
|  | ||||
| @@ -258,7 +255,7 @@ class JournalCollector implements JournalCollectorInterface | ||||
|                 $transaction->date        = new Carbon($transaction->date); | ||||
|                 $transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description); | ||||
|  | ||||
|                 if (!is_null($transaction->bill_name)) { | ||||
|                 if (null !== $transaction->bill_name) { | ||||
|                     $transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name); | ||||
|                 } | ||||
|                 $transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); | ||||
| @@ -272,11 +269,12 @@ class JournalCollector implements JournalCollectorInterface | ||||
|  | ||||
|     /** | ||||
|      * @return LengthAwarePaginator | ||||
|      * | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public function getPaginatedJournals(): LengthAwarePaginator | ||||
|     { | ||||
|         if ($this->run === true) { | ||||
|         if (true === $this->run) { | ||||
|             throw new FireflyException('Cannot getPaginatedJournals after run in JournalCollector.'); | ||||
|         } | ||||
|         $this->count(); | ||||
| @@ -294,7 +292,7 @@ class JournalCollector implements JournalCollectorInterface | ||||
|     public function removeFilter(string $filter): JournalCollectorInterface | ||||
|     { | ||||
|         $key = array_search($filter, $this->filters, true); | ||||
|         if (!($key === false)) { | ||||
|         if (!(false === $key)) { | ||||
|             Log::debug(sprintf('Removed filter %s', $filter)); | ||||
|             unset($this->filters[$key]); | ||||
|         } | ||||
| @@ -320,7 +318,6 @@ class JournalCollector implements JournalCollectorInterface | ||||
|             $this->addFilter(TransferFilter::class); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         return $this; | ||||
|     } | ||||
|  | ||||
| @@ -416,7 +413,7 @@ class JournalCollector implements JournalCollectorInterface | ||||
|     public function setBudgets(Collection $budgets): JournalCollectorInterface | ||||
|     { | ||||
|         $budgetIds = $budgets->pluck('id')->toArray(); | ||||
|         if (count($budgetIds) === 0) { | ||||
|         if (0 === count($budgetIds)) { | ||||
|             return $this; | ||||
|         } | ||||
|         $this->joinBudgetTables(); | ||||
| @@ -440,7 +437,7 @@ class JournalCollector implements JournalCollectorInterface | ||||
|     public function setCategories(Collection $categories): JournalCollectorInterface | ||||
|     { | ||||
|         $categoryIds = $categories->pluck('id')->toArray(); | ||||
|         if (count($categoryIds) === 0) { | ||||
|         if (0 === count($categoryIds)) { | ||||
|             return $this; | ||||
|         } | ||||
|         $this->joinCategoryTables(); | ||||
| @@ -514,11 +511,11 @@ class JournalCollector implements JournalCollectorInterface | ||||
|         $this->page = $page; | ||||
|  | ||||
|         if ($page > 0) { | ||||
|             $page--; | ||||
|             --$page; | ||||
|         } | ||||
|         Log::debug(sprintf('Page is %d', $page)); | ||||
|  | ||||
|         if (!is_null($this->limit)) { | ||||
|         if (null !== $this->limit) { | ||||
|             $offset       = ($this->limit * $page); | ||||
|             $this->offset = $offset; | ||||
|             $this->query->skip($offset); | ||||
|   | ||||
| @@ -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\Helpers\Collector; | ||||
| @@ -32,9 +31,7 @@ use Illuminate\Pagination\LengthAwarePaginator; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface JournalCollectorInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Collector | ||||
|  * Interface JournalCollectorInterface. | ||||
|  */ | ||||
| interface JournalCollectorInterface | ||||
| { | ||||
| @@ -43,28 +40,28 @@ interface JournalCollectorInterface | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function addFilter(string $filter): JournalCollectorInterface; | ||||
|     public function addFilter(string $filter): self; | ||||
|  | ||||
|     /** | ||||
|      * @param string $amount | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function amountIs(string $amount): JournalCollectorInterface; | ||||
|     public function amountIs(string $amount): self; | ||||
|  | ||||
|     /** | ||||
|      * @param string $amount | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function amountLess(string $amount): JournalCollectorInterface; | ||||
|     public function amountLess(string $amount): self; | ||||
|  | ||||
|     /** | ||||
|      * @param string $amount | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function amountMore(string $amount): JournalCollectorInterface; | ||||
|     public function amountMore(string $amount): self; | ||||
|  | ||||
|     /** | ||||
|      * @return int | ||||
| @@ -86,89 +83,89 @@ interface JournalCollectorInterface | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function removeFilter(string $filter): JournalCollectorInterface; | ||||
|     public function removeFilter(string $filter): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $accounts | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setAccounts(Collection $accounts): JournalCollectorInterface; | ||||
|     public function setAccounts(Collection $accounts): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $after | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setAfter(Carbon $after): JournalCollectorInterface; | ||||
|     public function setAfter(Carbon $after): self; | ||||
|  | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setAllAssetAccounts(): JournalCollectorInterface; | ||||
|     public function setAllAssetAccounts(): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $before | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setBefore(Carbon $before): JournalCollectorInterface; | ||||
|     public function setBefore(Carbon $before): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $bills | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setBills(Collection $bills): JournalCollectorInterface; | ||||
|     public function setBills(Collection $bills): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Budget $budget | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setBudget(Budget $budget): JournalCollectorInterface; | ||||
|     public function setBudget(Budget $budget): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $budgets | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setBudgets(Collection $budgets): JournalCollectorInterface; | ||||
|     public function setBudgets(Collection $budgets): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $categories | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setCategories(Collection $categories): JournalCollectorInterface; | ||||
|     public function setCategories(Collection $categories): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Category $category | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setCategory(Category $category): JournalCollectorInterface; | ||||
|     public function setCategory(Category $category): self; | ||||
|  | ||||
|     /** | ||||
|      * @param int $limit | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setLimit(int $limit): JournalCollectorInterface; | ||||
|     public function setLimit(int $limit): self; | ||||
|  | ||||
|     /** | ||||
|      * @param int $offset | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setOffset(int $offset): JournalCollectorInterface; | ||||
|     public function setOffset(int $offset): self; | ||||
|  | ||||
|     /** | ||||
|      * @param int $page | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setPage(int $page): JournalCollectorInterface; | ||||
|     public function setPage(int $page): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $start | ||||
| @@ -176,28 +173,28 @@ interface JournalCollectorInterface | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setRange(Carbon $start, Carbon $end): JournalCollectorInterface; | ||||
|     public function setRange(Carbon $start, Carbon $end): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Tag $tag | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setTag(Tag $tag): JournalCollectorInterface; | ||||
|     public function setTag(Tag $tag): self; | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $tags | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setTags(Collection $tags): JournalCollectorInterface; | ||||
|     public function setTags(Collection $tags): self; | ||||
|  | ||||
|     /** | ||||
|      * @param array $types | ||||
|      * | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function setTypes(array $types): JournalCollectorInterface; | ||||
|     public function setTypes(array $types): self; | ||||
|  | ||||
|     public function setUser(User $user); | ||||
|  | ||||
| @@ -209,25 +206,25 @@ interface JournalCollectorInterface | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function withBudgetInformation(): JournalCollectorInterface; | ||||
|     public function withBudgetInformation(): self; | ||||
|  | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function withCategoryInformation(): JournalCollectorInterface; | ||||
|     public function withCategoryInformation(): self; | ||||
|  | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function withOpposingAccount(): JournalCollectorInterface; | ||||
|     public function withOpposingAccount(): self; | ||||
|  | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function withoutBudget(): JournalCollectorInterface; | ||||
|     public function withoutBudget(): self; | ||||
|  | ||||
|     /** | ||||
|      * @return JournalCollectorInterface | ||||
|      */ | ||||
|     public function withoutCategory(): JournalCollectorInterface; | ||||
|     public function withoutCategory(): self; | ||||
| } | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -28,12 +27,10 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class AmountFilter | ||||
|  * Class AmountFilter. | ||||
|  * | ||||
|  * This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount | ||||
|  * ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal. | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class AmountFilter implements FilterInterface | ||||
| { | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -26,14 +25,10 @@ namespace FireflyIII\Helpers\Filter; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Class EmptyFilter | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  * Class EmptyFilter. | ||||
|  */ | ||||
| class EmptyFilter implements FilterInterface | ||||
| { | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $set | ||||
|      * | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -28,13 +27,11 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class InternalTransferFilter | ||||
|  * Class InternalTransferFilter. | ||||
|  * | ||||
|  * This filter removes any filters that are from A to B or from B to A given a set of | ||||
|  * account id's (in $parameters) where A and B are mentioned. So transfers between the mentioned | ||||
|  * accounts will be removed. | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class InternalTransferFilter implements FilterInterface | ||||
| { | ||||
| @@ -60,7 +57,7 @@ class InternalTransferFilter implements FilterInterface | ||||
|     { | ||||
|         return $set->filter( | ||||
|             function (Transaction $transaction) { | ||||
|                 if (is_null($transaction->opposing_account_id)) { | ||||
|                 if (null === $transaction->opposing_account_id) { | ||||
|                     return $transaction; | ||||
|                 } | ||||
|                 // both id's in $parameters? | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -28,11 +27,9 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class NegativeAmountFilter | ||||
|  * Class NegativeAmountFilter. | ||||
|  * | ||||
|  * This filter removes entries with a negative amount (the original modifier is -1). | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class NegativeAmountFilter implements FilterInterface | ||||
| { | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -28,12 +27,10 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class OpposingAccountFilter | ||||
|  * Class OpposingAccountFilter. | ||||
|  * | ||||
|  * This filter is similar to the internal transfer filter but only removes transactions when the opposing account is | ||||
|  * amongst $parameters (list of account ID's). | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class OpposingAccountFilter implements FilterInterface | ||||
| { | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -28,14 +27,12 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class PositiveAmountFilter | ||||
|  * Class PositiveAmountFilter. | ||||
|  * | ||||
|  * This filter removes entries with a negative amount (the original modifier is -1). | ||||
|  * | ||||
|  * This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount | ||||
|  * ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal. | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class PositiveAmountFilter implements FilterInterface | ||||
| { | ||||
| @@ -49,7 +46,7 @@ class PositiveAmountFilter implements FilterInterface | ||||
|         return $set->filter( | ||||
|             function (Transaction $transaction) { | ||||
|                 // remove by amount | ||||
|                 if (bccomp($transaction->transaction_amount, '0') === 1) { | ||||
|                 if (1 === bccomp($transaction->transaction_amount, '0')) { | ||||
|                     Log::debug(sprintf('Filtered #%d because amount is %f.', $transaction->id, $transaction->transaction_amount)); | ||||
|  | ||||
|                     return null; | ||||
|   | ||||
| @@ -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\Helpers\Filter; | ||||
| @@ -29,11 +28,9 @@ use Illuminate\Support\Collection; | ||||
| use Steam; | ||||
|  | ||||
| /** | ||||
|  * Class TransferFilter | ||||
|  * Class TransferFilter. | ||||
|  * | ||||
|  * This filter removes any transfers that are in the collection twice (from A to B and from B to A). | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Filter | ||||
|  */ | ||||
| class TransferFilter implements FilterInterface | ||||
| { | ||||
| @@ -48,7 +45,7 @@ class TransferFilter implements FilterInterface | ||||
|         $new   = new Collection; | ||||
|         /** @var Transaction $transaction */ | ||||
|         foreach ($set as $transaction) { | ||||
|             if ($transaction->transaction_type_type !== TransactionType::TRANSFER) { | ||||
|             if (TransactionType::TRANSFER !== $transaction->transaction_type_type) { | ||||
|                 $new->push($transaction); | ||||
|                 continue; | ||||
|             } | ||||
|   | ||||
| @@ -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\Helpers; | ||||
| @@ -27,20 +26,15 @@ use Carbon\Carbon; | ||||
| use Preferences; | ||||
|  | ||||
| /** | ||||
|  * Class FiscalHelper | ||||
|  * | ||||
|  * @package FireflyIII\Helpers | ||||
|  * Class FiscalHelper. | ||||
|  */ | ||||
| class FiscalHelper implements FiscalHelperInterface | ||||
| { | ||||
|  | ||||
|     /** @var bool */ | ||||
|     protected $useCustomFiscalYear; | ||||
|  | ||||
|     /** | ||||
|      * FiscalHelper constructor. | ||||
|      * | ||||
|      * | ||||
|      */ | ||||
|     public function __construct() | ||||
|     { | ||||
| @@ -56,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface | ||||
|     { | ||||
|         // get start of fiscal year for passed date | ||||
|         $endDate = $this->startOfFiscalYear($date); | ||||
|         if ($this->useCustomFiscalYear === true) { | ||||
|         if (true === $this->useCustomFiscalYear) { | ||||
|             // add 1 year and sub 1 day | ||||
|             $endDate->addYear(); | ||||
|             $endDate->subDay(); | ||||
| @@ -65,7 +59,6 @@ class FiscalHelper implements FiscalHelperInterface | ||||
|         } | ||||
|         $endDate->endOfYear(); | ||||
|  | ||||
|  | ||||
|         return $endDate; | ||||
|     } | ||||
|  | ||||
| @@ -78,7 +71,7 @@ class FiscalHelper implements FiscalHelperInterface | ||||
|     { | ||||
|         // get start mm-dd. Then create a start date in the year passed. | ||||
|         $startDate = clone $date; | ||||
|         if ($this->useCustomFiscalYear === true) { | ||||
|         if (true === $this->useCustomFiscalYear) { | ||||
|             $prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data; | ||||
|             list($mth, $day) = explode('-', $prefStartStr); | ||||
|             $startDate->month(intval($mth))->day(intval($day)); | ||||
|   | ||||
| @@ -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\Helpers; | ||||
| @@ -26,13 +25,10 @@ namespace FireflyIII\Helpers; | ||||
| use Carbon\Carbon; | ||||
|  | ||||
| /** | ||||
|  * Interface FiscalHelperInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers | ||||
|  * Interface FiscalHelperInterface. | ||||
|  */ | ||||
| interface FiscalHelperInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * This method produces a clone of the Carbon date object passed, checks preferences | ||||
|      * and calculates the last day of the fiscal year. | ||||
|   | ||||
| @@ -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\Helpers\Help; | ||||
| @@ -31,9 +30,7 @@ use Requests_Exception; | ||||
| use Route; | ||||
|  | ||||
| /** | ||||
|  * Class Help | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Help | ||||
|  * Class Help. | ||||
|  */ | ||||
| class Help implements HelpInterface | ||||
| { | ||||
| @@ -76,7 +73,7 @@ class Help implements HelpInterface | ||||
|  | ||||
|         Log::debug(sprintf('Status code is %d', $result->status_code)); | ||||
|  | ||||
|         if ($result->status_code === 200) { | ||||
|         if (200 === $result->status_code) { | ||||
|             $content = trim($result->body); | ||||
|         } | ||||
|  | ||||
| @@ -90,7 +87,6 @@ class Help implements HelpInterface | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * @param string $route | ||||
|      * | ||||
|      * @return bool | ||||
| @@ -121,11 +117,9 @@ class Help implements HelpInterface | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * @param string $route | ||||
|      * @param string $language | ||||
|      * @param string $content | ||||
|      * | ||||
|      */ | ||||
|     public function putInCache(string $route, string $language, string $content) | ||||
|     { | ||||
|   | ||||
| @@ -18,19 +18,15 @@ | ||||
|  * 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\Helpers\Help; | ||||
|  | ||||
| /** | ||||
|  * Interface HelpInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Help | ||||
|  * Interface HelpInterface. | ||||
|  */ | ||||
| interface HelpInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * @param string $route | ||||
|      * @param string $language | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -34,15 +33,13 @@ use Illuminate\Support\Collection; | ||||
| use Log; | ||||
|  | ||||
| /** | ||||
|  * Class BalanceReportHelper | ||||
|  * Class BalanceReportHelper. | ||||
|  * | ||||
|  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // I can't really help it. | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  */ | ||||
| class BalanceReportHelper implements BalanceReportHelperInterface | ||||
| { | ||||
|  | ||||
|     /** @var  BudgetRepositoryInterface */ | ||||
|     /** @var BudgetRepositoryInterface */ | ||||
|     protected $budgetRepository; | ||||
|  | ||||
|     /** | ||||
| @@ -56,7 +53,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|         $this->budgetRepository = $budgetRepository; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $accounts | ||||
|      * @param Carbon     $start | ||||
| @@ -77,7 +73,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|  | ||||
|         /** @var BudgetLimit $budgetLimit */ | ||||
|         foreach ($budgetLimits as $budgetLimit) { | ||||
|             if (!is_null($budgetLimit->budget)) { | ||||
|             if (null !== $budgetLimit->budget) { | ||||
|                 $line = $this->createBalanceLine($budgetLimit, $accounts); | ||||
|                 $balance->addBalanceLine($line); | ||||
|             } | ||||
| @@ -96,7 +92,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|         return $balance; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param BudgetLimit $budgetLimit | ||||
|      * @param Collection  $accounts | ||||
| @@ -126,7 +121,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|         return $line; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param Collection $accounts | ||||
|      * @param Carbon     $start | ||||
| @@ -150,7 +144,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|         return $empty; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param Balance $balance | ||||
|      * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. | ||||
| @@ -162,7 +155,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface | ||||
|         $set    = $balance->getBalanceLines(); | ||||
|         $newSet = new Collection; | ||||
|         foreach ($set as $entry) { | ||||
|             if (!is_null($entry->getBudget()->id)) { | ||||
|             if (null !== $entry->getBudget()->id) { | ||||
|                 $sum = '0'; | ||||
|                 foreach ($entry->getBalanceEntries() as $balanceEntry) { | ||||
|                     $sum = bcadd($sum, $balanceEntry->getSpent()); | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -28,9 +27,7 @@ use FireflyIII\Helpers\Collection\Balance; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface BalanceReportHelperInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Interface BalanceReportHelperInterface. | ||||
|  */ | ||||
| interface BalanceReportHelperInterface | ||||
| { | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -30,9 +29,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Class BudgetReportHelper | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Class BudgetReportHelper. | ||||
|  */ | ||||
| class BudgetReportHelper implements BudgetReportHelperInterface | ||||
| { | ||||
| @@ -52,6 +49,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface | ||||
|     /** | ||||
|      * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. | ||||
|      * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // all the arrays make it long. | ||||
|      * | ||||
|      * @param Carbon     $start | ||||
|      * @param Carbon     $end | ||||
|      * @param Collection $accounts | ||||
| @@ -66,9 +64,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface | ||||
|         /** @var Budget $budget */ | ||||
|         foreach ($set as $budget) { | ||||
|             $budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end); | ||||
|             if ($budgetLimits->count() === 0) { // no budget limit(s) for this budget | ||||
|  | ||||
|                 $spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range | ||||
|             if (0 === $budgetLimits->count()) { // no budget limit(s) for this budget | ||||
|                 $spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end); // spent for budget in time range | ||||
|                 if (bccomp($spent, '0') === -1) { | ||||
|                     $line    = [ | ||||
|                         'type'      => 'budget', | ||||
| @@ -156,9 +153,9 @@ class BudgetReportHelper implements BudgetReportHelperInterface | ||||
|     { | ||||
|         $array              = []; | ||||
|         $expenses           = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date); | ||||
|         $array['left']      = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? bcadd($budgetLimit->amount, $expenses) : '0'; | ||||
|         $array['spent']     = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? $expenses : '0'; | ||||
|         $array['overspent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $budgetLimit->amount); | ||||
|         $array['left']      = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? bcadd($budgetLimit->amount, $expenses) : '0'; | ||||
|         $array['spent']     = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? $expenses : '0'; | ||||
|         $array['overspent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? '0' : bcadd($expenses, $budgetLimit->amount); | ||||
|         $array['expenses']  = $expenses; | ||||
|  | ||||
|         return $array; | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -27,13 +26,10 @@ use Carbon\Carbon; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface BudgetReportHelperInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Interface BudgetReportHelperInterface. | ||||
|  */ | ||||
| interface BudgetReportHelperInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon     $start | ||||
|      * @param Carbon     $end | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -32,14 +31,10 @@ use FireflyIII\Models\TransactionType; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Class PopupReport | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Class PopupReport. | ||||
|  */ | ||||
| class PopupReport implements PopupReportInterface | ||||
| { | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @param $account | ||||
|      * @param $attributes | ||||
| @@ -58,11 +53,10 @@ class PopupReport implements PopupReportInterface | ||||
|             ->withoutBudget(); | ||||
|         $journals = $collector->getJournals(); | ||||
|  | ||||
|  | ||||
|         return $journals->filter( | ||||
|             function (Transaction $transaction) { | ||||
|                 $tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count(); | ||||
|                 if ($tags === 0) { | ||||
|                 if (0 === $tags) { | ||||
|                     return true; | ||||
|                 } | ||||
|  | ||||
| @@ -120,10 +114,10 @@ class PopupReport implements PopupReportInterface | ||||
|  | ||||
|         $collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']); | ||||
|  | ||||
|         if (is_null($budget->id)) { | ||||
|         if (null === $budget->id) { | ||||
|             $collector->setTypes([TransactionType::WITHDRAWAL])->withoutBudget(); | ||||
|         } | ||||
|         if (!is_null($budget->id)) { | ||||
|         if (null !== $budget->id) { | ||||
|             $collector->setBudget($budget); | ||||
|         } | ||||
|         $journals = $collector->getJournals(); | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -29,13 +28,10 @@ use FireflyIII\Models\Category; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface PopupReportInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Interface PopupReportInterface. | ||||
|  */ | ||||
| interface PopupReportInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * @param $account | ||||
|      * @param $attributes | ||||
|   | ||||
| @@ -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\Helpers\Report; | ||||
| @@ -35,14 +34,11 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Class ReportHelper | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Class ReportHelper. | ||||
|  */ | ||||
| class ReportHelper implements ReportHelperInterface | ||||
| { | ||||
|  | ||||
|     /** @var  BudgetRepositoryInterface */ | ||||
|     /** @var BudgetRepositoryInterface */ | ||||
|     protected $budgetRepository; | ||||
|  | ||||
|     /** | ||||
| @@ -95,7 +91,7 @@ class ReportHelper implements ReportHelperInterface | ||||
|                 } | ||||
|             ); | ||||
|             $first = $entry->first(); | ||||
|             if (!is_null($first)) { | ||||
|             if (null !== $first) { | ||||
|                 $billLine->setTransactionJournalId($first->id); | ||||
|                 $billLine->setAmount($first->transaction_amount); | ||||
|                 $billLine->setLastHitDate($first->date); | ||||
|   | ||||
| @@ -18,25 +18,19 @@ | ||||
|  * 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\Helpers\Report; | ||||
|  | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Helpers\Collection\Bill as BillCollection; | ||||
| use FireflyIII\Helpers\Collection\Expense; | ||||
| use FireflyIII\Helpers\Collection\Income; | ||||
| use Illuminate\Support\Collection; | ||||
|  | ||||
| /** | ||||
|  * Interface ReportHelperInterface | ||||
|  * | ||||
|  * @package FireflyIII\Helpers\Report | ||||
|  * Interface ReportHelperInterface. | ||||
|  */ | ||||
| interface ReportHelperInterface | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * This method generates a full report for the given period on all | ||||
|      * the users bills and their payments. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user