Skip to content

Commit

Permalink
Add new quality standard
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGauthier authored and guvra committed Oct 13, 2022
1 parent 9c6e391 commit 63955ee
Show file tree
Hide file tree
Showing 42 changed files with 162 additions and 813 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ jobs:
- name: 'Run composer audit'
run: 'composer audit --format=plain'

- name: 'Run Parallel Lint'
run: 'vendor/bin/parallel-lint --exclude vendor .'

- name: 'Run PHP CodeSniffer'
run: 'vendor/bin/phpcs --extensions=php,phtml'

- name: 'Run PHPMD'
run: 'vendor/bin/phpmd . xml phpmd.xml.dist'

- name: 'Run PHPStan'
run: 'vendor/bin/phpstan analyse'
25 changes: 3 additions & 22 deletions Block/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@
*/
class Toolbar extends MagentoTemplateBlock
{
/**
* @var DataHelper
*/
protected $dataHelper;
protected DataHelper $dataHelper;
protected SummaryFactory $blockSummaryFactory;

/**
* @var Zone\AbstractZone[]
*/
protected $zones = [];

/**
* @var SummaryFactory
*/
protected $blockSummaryFactory;
protected array $zones = [];

/**
* @param Context $context
* @param DataHelper $dataHelper
* @param SummaryFactory $blockSummaryFactory
* @param array $data
*/
public function __construct(
Context $context,
DataHelper $dataHelper,
Expand All @@ -56,9 +43,6 @@ public function __construct(

/**
* Load the zones.
*
* @param MagentoRequest $request
* @param MagentoResponse $response
*/
public function loadZones(MagentoRequest $request, MagentoResponse $response): void
{
Expand Down Expand Up @@ -96,8 +80,6 @@ public function getZones(): array

/**
* Do we have a warning?
*
* @return bool
*/
public function isWarning(): bool
{
Expand All @@ -115,7 +97,6 @@ public function isWarning(): bool
/**
* Get the toolbar id.
*
* @return string
* @throws RuntimeException
*/
public function getToolbarId(): string
Expand Down
10 changes: 1 addition & 9 deletions Block/Toolbars.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,8 @@
*/
class Toolbars extends MagentoTemplateBlock
{
/**
* @var DataHelper
*/
protected $dataHelper;
protected DataHelper $dataHelper;

/**
* @param Context $context
* @param DataHelper $dataHelper
* @param array $data
*/
public function __construct(Context $context, DataHelper $dataHelper, array $data = [])
{
parent::__construct($context, $data);
Expand Down
80 changes: 9 additions & 71 deletions Block/Zone/AbstractZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,12 @@
*/
abstract class AbstractZone extends MagentoTemplateBlock
{
/**
* @var bool
*/
protected $warning = false;

/**
* @var DataHelper
*/
protected $dataHelper;

/**
* @var FormatterFactory
*/
protected $formatterFactory;
protected DataHelper $dataHelper;
protected FormatterFactory $formatterFactory;
protected Summary $summaryBlock;
protected bool $warning = false;
protected array $tablesToDisplay = [];

/**
* @var Summary
*/
protected $summaryBlock;

/**
* @var array
*/
protected $tablesToDisplay = [];

/**
* @param Context $context
* @param DataHelper $dataHelper
* @param FormatterFactory $formatterFactory
* @param array $data
*/
public function __construct(
Context $context,
DataHelper $dataHelper,
Expand All @@ -63,15 +38,11 @@ public function __construct(

/**
* Get the code.
*
* @return string
*/
abstract public function getCode(): string;

/**
* Get the title.
*
* @return string
*/
abstract public function getTitle(): string;

Expand All @@ -85,12 +56,8 @@ public function toHtml()

/**
* Add the summary block.
*
* @param Summary $block
*
* @return $this
*/
public function setSummaryBlock(Summary $block): AbstractZone
public function setSummaryBlock(Summary $block): self
{
$this->summaryBlock = $block;

Expand All @@ -100,8 +67,6 @@ public function setSummaryBlock(Summary $block): AbstractZone
/**
* Add a value to the summary.
*
* @param string $sectionName
* @param string $key
* @param mixed $value
*/
public function addToSummary(string $sectionName, string $key, $value): void
Expand All @@ -111,10 +76,8 @@ public function addToSummary(string $sectionName, string $key, $value): void

/**
* Set the warning flag.
*
* @return $this
*/
public function hasWarning(): AbstractZone
public function hasWarning(): self
{
$this->warning = true;

Expand All @@ -123,8 +86,6 @@ public function hasWarning(): AbstractZone

/**
* Have we a warning?
*
* @return bool
*/
public function isWarning(): bool
{
Expand All @@ -133,9 +94,6 @@ public function isWarning(): bool

/**
* Display sections.
*
* @param array $sections
* @return string
*/
public function displaySections(array $sections = []): string
{
Expand Down Expand Up @@ -163,9 +121,6 @@ public function displaySections(array $sections = []): string

/**
* Display sections.
*
* @param array $sections
* @return string
*/
public function displaySectionsGrouped(array $sections = []): string
{
Expand Down Expand Up @@ -198,7 +153,8 @@ public function displaySectionsGrouped(array $sections = []): string
*/
protected function getClassAndValue($value): array
{
if (!is_array($value)
if (
!is_array($value)
|| !array_key_exists('value', $value)
|| !array_key_exists('css_class', $value)
) {
Expand All @@ -213,7 +169,6 @@ protected function getClassAndValue($value): array
*
* @param string|int $name
* @param mixed $value
* @return string
*/
protected function displaySectionValue($name, $value): string
{
Expand All @@ -224,8 +179,6 @@ protected function displaySectionValue($name, $value): string

/**
* Get the toolbar id.
*
* @return string
*/
public function getToolbarId(): string
{
Expand All @@ -234,12 +187,6 @@ public function getToolbarId(): string

/**
* Display the table.
*
* @param string $title
* @param array $values
* @param array $columns
* @param string|null $additional
* @return string
*/
public function displayTable(string $title, array &$values, array $columns, ?string $additional = null): string
{
Expand Down Expand Up @@ -274,8 +221,6 @@ public function displayTable(string $title, array &$values, array $columns, ?str

/**
* Get the tables to display.
*
* @return array
*/
public function getTablesToDisplay(): array
{
Expand All @@ -284,9 +229,6 @@ public function getTablesToDisplay(): array

/**
* Get a timer.
*
* @param string $code
* @return float
*/
public function getTimer(string $code): float
{
Expand All @@ -297,10 +239,6 @@ public function getTimer(string $code): float
* Format a value, using rules, and type.
*
* @param string|float $value
* @param array $rules
* @param string|null $type
*
* @return array
*/
public function formatValue($value, array $rules = [], ?string $type = null): array
{
Expand Down
30 changes: 2 additions & 28 deletions Block/Zone/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,9 @@
*/
class Cache extends AbstractZone
{
/**
* @var DeploymentConfig
*/
protected $deployConfig;

/**
* @var CacheHelper
*/
protected $cacheHelper;
protected DeploymentConfig $deployConfig;
protected CacheHelper $cacheHelper;

/**
* @param Context $context
* @param DataHelper $dataHelper
* @param FormatterFactory $formatterFactory
* @param DeploymentConfig $deployConfig
* @param CacheHelper $cacheHelper
* @param array $data
*/
public function __construct(
Context $context,
DataHelper $dataHelper,
Expand Down Expand Up @@ -64,8 +49,6 @@ public function getTitle(): string

/**
* Get the cache mode.
*
* @return string
*/
public function getCacheMode(): string
{
Expand Down Expand Up @@ -94,8 +77,6 @@ public function getCacheInfo()

/**
* Get the cache types.
*
* @return array
*/
public function getCacheTypes(): array
{
Expand All @@ -104,8 +85,6 @@ public function getCacheTypes(): array

/**
* Get the cache usage.
*
* @return array
*/
public function getCacheUsage(): array
{
Expand All @@ -114,8 +93,6 @@ public function getCacheUsage(): array

/**
* Get the usage per action.
*
* @return array
*/
public function getStatsPerAction(): array
{
Expand All @@ -124,9 +101,6 @@ public function getStatsPerAction(): array

/**
* Prepare calls for display in the table.
*
* @param array $calls
* @return string
*/
public function buildHtmlInfo(array $calls = []): string
{
Expand Down
Loading

0 comments on commit 63955ee

Please sign in to comment.