Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
galeaspablo committed Nov 28, 2019
1 parent 0a57fdd commit 4015d5b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions DataTransformer/BuildQueryToResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ protected function resolveColumnsHumanReadable(ReportInterface $report, BuildRep
protected function transformValueToString($value): string
{
if ($value instanceof \DateTime || $value instanceof \DateTimeImmutable) {
if ($value->format('H:i') === '00:00') {
if ('00:00' === $value->format('H:i')) {
$value = $value->format('d-m-Y');
} else {
$value = $value->format('d-m-Y H:i');
}
}

if ($value === true) {
if (true === $value) {
$value = $this->translator->trans('Yes');
}

if ($value === false) {
if (false === $value) {
$value = $this->translator->trans('No');
}

Expand Down
3 changes: 3 additions & 0 deletions Event/ResultColumnCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
class ResultColumnCreatedEvent extends Event
{
const EVENT_NAME = 'fl_reports.result_column_created';

const RESULTS_TYPE_HTML = 0;

const RESULTS_TYPE_CSV = 1;

const ALL_RESULTS_TYPES = [
self::RESULTS_TYPE_HTML,
self::RESULTS_TYPE_CSV,
Expand Down
2 changes: 1 addition & 1 deletion Model/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function setColumns(array $columns): ReportInterface
*/
public function addSortColumn(string $sortColumn, string $order): ReportInterface
{
if ($order !== 'ASC' && $order !== 'DESC') {
if ('ASC' !== $order && 'DESC' !== $order) {
throw new \InvalidArgumentException();
}
$this->sortColumns[$sortColumn] = $order;
Expand Down
24 changes: 12 additions & 12 deletions Model/ReportInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getReportName(): string;
*
* @return ReportInterface
*/
public function setReportName(string $reportName): ReportInterface;
public function setReportName(string $reportName): self;

/**
* @return string
Expand All @@ -31,7 +31,7 @@ public function getReportBuilderId(): string;
*
* @return ReportInterface
*/
public function setReportBuilderId(string $reportBuilderId): ReportInterface;
public function setReportBuilderId(string $reportBuilderId): self;

/**
* @return string
Expand All @@ -43,7 +43,7 @@ public function getReportBuilderHumanReadableName(): string;
*
* @return ReportInterface
*/
public function setReportBuilderHumanReadableName(string $reportBuilderHumanReadableName): ReportInterface;
public function setReportBuilderHumanReadableName(string $reportBuilderHumanReadableName): self;

/**
* @return string
Expand All @@ -55,7 +55,7 @@ public function getRulesJsonString(): string;
*
* @return ReportInterface
*/
public function setRulesJsonString(string $rulesJsonString): ReportInterface;
public function setRulesJsonString(string $rulesJsonString): self;

/**
* @return string
Expand All @@ -74,19 +74,19 @@ public function getColumns(): array;
*
* @return ReportInterface
*/
public function addColumn(string $column): ReportInterface;
public function addColumn(string $column): self;

/**
* @param string $column
*
* @return ReportInterface
*/
public function removeColumn(string $column): ReportInterface;
public function removeColumn(string $column): self;

/**
* @return ReportInterface
*/
public function clearColumns(): ReportInterface;
public function clearColumns(): self;

/**
* @return string
Expand All @@ -106,32 +106,32 @@ public function getSortColumns(): array;
*
* @return ReportInterface
*/
public function setColumns(array $columns): ReportInterface;
public function setColumns(array $columns): self;

/**
* @param string $sortColumn
* @param string $order
*
* @return ReportInterface
*/
public function addSortColumn(string $sortColumn, string $order): ReportInterface;
public function addSortColumn(string $sortColumn, string $order): self;

/**
* @param string $sortColumn
*
* @return ReportInterface
*/
public function removeSortColumn(string $sortColumn): ReportInterface;
public function removeSortColumn(string $sortColumn): self;

/**
* @return ReportInterface
*/
public function clearSortColumns(): ReportInterface;
public function clearSortColumns(): self;

/**
* @param array $sortColumns
*
* @return ReportInterface
*/
public function setSortColumns(array $sortColumns): ReportInterface;
public function setSortColumns(array $sortColumns): self;
}
12 changes: 6 additions & 6 deletions Storage/DoctrineORM/ReportResultsStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function __construct(EntityManagerInterface $entityManager)
public function resultsFromParsedRuleGroup(AbstractParsedRuleGroup $parsedRuleGroup, int $currentPage = null, int $resultsPerPage = null): array
{
if (
$currentPage !== null &&
$resultsPerPage !== null &&
($currentPage === 0 || $resultsPerPage === 0)
null !== $currentPage &&
null !== $resultsPerPage &&
(0 === $currentPage || 0 === $resultsPerPage)
) {
return [];
}
Expand All @@ -54,8 +54,8 @@ public function resultsFromParsedRuleGroup(AbstractParsedRuleGroup $parsedRuleGr
$query->setParameters($parsedRuleGroup->getParameters());

if (
$currentPage !== null &&
$resultsPerPage !== null
null !== $currentPage &&
null !== $resultsPerPage
) {
$query->setMaxResults($resultsPerPage)
->setFirstResult(($currentPage - 1) * $resultsPerPage);
Expand All @@ -66,7 +66,7 @@ public function resultsFromParsedRuleGroup(AbstractParsedRuleGroup $parsedRuleGr
foreach ($query->getResult(Query::HYDRATE_SCALAR) as $result) {
$resultIds[] = $result['root_entity_id'];
}
if (count($resultIds) === 0) {
if (0 === count($resultIds)) {
return []; // WHERE IN [] would have returned all results
}

Expand Down

0 comments on commit 4015d5b

Please sign in to comment.