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\Generator\Chart\Basic;
@@ -27,15 +26,12 @@ use FireflyIII\Support\ChartColour;
use Steam;
/**
* Class ChartJsGenerator
*
* @package FireflyIII\Generator\Chart\Basic
* Class ChartJsGenerator.
*/
class ChartJsGenerator implements GeneratorInterface
{
/**
* Will generate a Chart JS compatible array from the given input. Expects this format
* Will generate a Chart JS compatible array from the given input. Expects this format.
*
* Will take labels for all from first set.
*
@@ -102,7 +98,7 @@ class ChartJsGenerator implements GeneratorInterface
}
/**
* Expects data as:
* Expects data as:.
*
* key => value
*
@@ -123,7 +119,7 @@ class ChartJsGenerator implements GeneratorInterface
// different sort when values are positive and when they're negative.
asort($data);
$next = next($data);
if (!is_bool($next) && bccomp($next, '0') === 1) {
if (!is_bool($next) && 1 === bccomp($next, '0')) {
// next is positive, sort other way around.
arsort($data);
}
@@ -131,19 +127,18 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0;
foreach ($data as $key => $value) {
// make larger than 0
$chartData['datasets'][0]['data'][] = floatval(Steam::positive($value));
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key;
$index++;
++$index;
}
return $chartData;
}
/**
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
* Will generate a (ChartJS) compatible array from the given input. Expects this format:.
*
* 'label-of-entry' => value
* 'label-of-entry' => value

View File

@@ -18,21 +18,17 @@
* 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\Generator\Chart\Basic;
/**
* Interface GeneratorInterface
*
* @package FireflyIII\Generator\Chart\Basic
* Interface GeneratorInterface.
*/
interface GeneratorInterface
{
/**
* Will generate a Chart JS compatible array from the given input. Expects this format
* Will generate a Chart JS compatible array from the given input. Expects this format.
*
* Will take labels for all from first set.
*
@@ -66,7 +62,7 @@ interface GeneratorInterface
public function multiSet(array $data): array;
/**
* Expects data as:
* Expects data as:.
*
* key => value
*
@@ -77,7 +73,7 @@ interface GeneratorInterface
public function pieChart(array $data): array;
/**
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
* Will generate a (ChartJS) compatible array from the given input. Expects this format:.
*
* 'label-of-entry' => value
* 'label-of-entry' => value

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\Generator\Report\Audit;
@@ -27,23 +26,20 @@ use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
use Steam;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Audit
* Class MonthReportGenerator.
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Carbon */
/** @var Carbon */
private $start;
/**
@@ -74,7 +70,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
'create_date', 'update_date',
];
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render();
@@ -153,7 +148,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
*
*/
private function getAuditReport(Account $account, Carbon $date): array
{
@@ -169,7 +163,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$startBalance = $dayBeforeBalance;
$currency = $currencyRepos->find(intval($account->getMeta('currency_id')));
/** @var Transaction $journal */
// @var Transaction $journal
foreach ($journals as $transaction) {
$transaction->before = $startBalance;
$transactionAmount = $transaction->transaction_amount;

View File

@@ -18,19 +18,14 @@
* 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\Generator\Report\Audit;
/**
* Class MultiYearReportGenerator
*
* @package FireflyIII\Generator\Report\Audit
* Class MultiYearReportGenerator.
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

View File

@@ -18,20 +18,14 @@
* 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\Generator\Report\Audit;
/**
* Class YearReportGenerator
*
* @package FireflyIII\Generator\Report\Audit
* Class YearReportGenerator.
*/
class YearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

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\Generator\Report\Budget;
@@ -36,23 +35,21 @@ use Illuminate\Support\Collection;
use Log;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Budget
* Class MonthReportGenerator.
*/
class MonthReportGenerator extends Support implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Collection */
/** @var Collection */
private $budgets;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Collection */
private $expenses;
/** @var Collection */
private $income;
/** @var Carbon */
/** @var Carbon */
private $start;
/**

View File

@@ -18,19 +18,14 @@
* 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\Generator\Report\Budget;
/**
* Class MultiYearReportGenerator
*
* @package FireflyIII\Generator\Report\Budget
* Class MultiYearReportGenerator.
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

View File

@@ -18,20 +18,14 @@
* 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\Generator\Report\Budget;
/**
* Class YearReportGenerator
*
* @package FireflyIII\Generator\Report\Budget
* Class YearReportGenerator.
*/
class YearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

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\Generator\Report\Category;
@@ -37,23 +36,21 @@ use Illuminate\Support\Collection;
use Log;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Category
* Class MonthReportGenerator.
*/
class MonthReportGenerator extends Support implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Collection */
/** @var Collection */
private $categories;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Collection */
private $expenses;
/** @var Collection */
private $income;
/** @var Carbon */
/** @var Carbon */
private $start;
/**
@@ -82,7 +79,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses();
$topIncome = $this->getTopIncome();
// render!
return view(
'reports.category.month',

View File

@@ -18,19 +18,14 @@
* 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\Generator\Report\Category;
/**
* Class MultiYearReportGenerator
*
* @package FireflyIII\Generator\Report\Category
* Class MultiYearReportGenerator.
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

View File

@@ -18,20 +18,14 @@
* 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\Generator\Report\Category;
/**
* Class YearReportGenerator
*
* @package FireflyIII\Generator\Report\Category
* Class YearReportGenerator.
*/
class YearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

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\Generator\Report;
@@ -27,19 +26,17 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
/**
* Class ReportGeneratorFactory
*
* @package FireflyIII\Generator\Report
* Class ReportGeneratorFactory.
*/
class ReportGeneratorFactory
{
/**
* @param string $type
* @param Carbon $start
* @param Carbon $end
*
* @return ReportGeneratorInterface
*
* @throws FireflyException
*/
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
@@ -55,7 +52,6 @@ class ReportGeneratorFactory
$period = 'MultiYear';
}
$class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period);
if (class_exists($class)) {
/** @var ReportGeneratorInterface $obj */

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\Generator\Report;
@@ -27,9 +26,7 @@ use Carbon\Carbon;
use Illuminate\Support\Collection;
/**
* Interface ReportGeneratorInterface
*
* @package FireflyIII\Generator\Report
* Interface ReportGeneratorInterface.
*/
interface ReportGeneratorInterface
{
@@ -43,40 +40,40 @@ interface ReportGeneratorInterface
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface;
public function setAccounts(Collection $accounts): self;
/**
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface;
public function setBudgets(Collection $budgets): self;
/**
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface;
public function setCategories(Collection $categories): self;
/**
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setEndDate(Carbon $date): ReportGeneratorInterface;
public function setEndDate(Carbon $date): self;
/**
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
public function setStartDate(Carbon $date): ReportGeneratorInterface;
public function setStartDate(Carbon $date): self;
/**
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
public function setTags(Collection $tags): ReportGeneratorInterface;
public function setTags(Collection $tags): self;
}

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\Generator\Report\Standard;
@@ -29,17 +28,15 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
use Illuminate\Support\Collection;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Standard
* Class MonthReportGenerator.
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Carbon */
/** @var Carbon */
private $start;
/**

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\Generator\Report\Standard;
@@ -28,17 +27,15 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Standard
* Class MonthReportGenerator.
*/
class MultiYearReportGenerator implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Carbon */
/** @var Carbon */
private $start;
/**

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\Generator\Report\Standard;
@@ -28,17 +27,15 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Standard
* Class MonthReportGenerator.
*/
class YearReportGenerator implements ReportGeneratorInterface
{
/** @var Collection */
/** @var Collection */
private $accounts;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Carbon */
/** @var Carbon */
private $start;
/**

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\Generator\Report;
@@ -27,9 +26,7 @@ use FireflyIII\Models\Transaction;
use Illuminate\Support\Collection;
/**
* Class Support
*
* @package FireflyIII\Generator\Report\Category
* Class Support.
*/
class Support
{
@@ -79,7 +76,7 @@ class Support
];
continue;
}
$result[$opposingId]['count']++;
++$result[$opposingId]['count'];
$result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount);
$result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count']));
}
@@ -97,6 +94,7 @@ class Support
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
*
* @param array $spent
* @param array $earned
*
@@ -107,7 +105,7 @@ class Support
$return = [];
/**
* @var int $accountId
* @var int
* @var string $entry
*/
foreach ($spent as $objectId => $entry) {
@@ -120,7 +118,7 @@ class Support
unset($entry);
/**
* @var int $accountId
* @var int
* @var string $entry
*/
foreach ($earned as $objectId => $entry) {
@@ -131,7 +129,6 @@ class Support
$return[$objectId]['earned'] = $entry;
}
return $return;
}

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\Generator\Report\Tag;
@@ -38,22 +37,19 @@ use Illuminate\Support\Collection;
use Log;
/**
* Class MonthReportGenerator
*
* @package FireflyIII\Generator\Report\Tag
* Class MonthReportGenerator.
*/
class MonthReportGenerator extends Support implements ReportGeneratorInterface
{
/** @var Collection */
private $accounts;
/** @var Carbon */
/** @var Carbon */
private $end;
/** @var Collection */
private $expenses;
/** @var Collection */
private $income;
/** @var Carbon */
/** @var Carbon */
private $start;
/** @var Collection */
private $tags;
@@ -84,7 +80,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses();
$topIncome = $this->getTopIncome();
// render!
return view(
'reports.tag.month',

View File

@@ -18,19 +18,14 @@
* 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\Generator\Report\Tag;
/**
* Class MultiYearReportGenerator
*
* @package FireflyIII\Generator\Report\Tag
* Class MultiYearReportGenerator.
*/
class MultiYearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}

View File

@@ -18,20 +18,14 @@
* 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\Generator\Report\Tag;
/**
* Class YearReportGenerator
*
* @package FireflyIII\Generator\Report\Tag
* Class YearReportGenerator.
*/
class YearReportGenerator extends MonthReportGenerator
{
/**
* Doesn't do anything different.
*/
// Doesn't do anything different.
}