phpcs fixes

This commit is contained in:
Dennis Eichhorn 2019-10-06 17:41:41 +02:00
parent 1746444975
commit b35b7f1d7a
28 changed files with 177 additions and 29 deletions

View File

@ -22,28 +22,32 @@ namespace phpOMS\Algorithm\CoinMatching;
* @link https://orange-management.org
* @since 1.0.0
*/
class MinimumCoinProblem
final class MinimumCoinProblem
{
private function __construct()
{
/**
* Constructure
*
* @since 1.0.0
*/
private function __construct()
{
}
}
/**
* Find the minimum amount of coins that are required to match a value
*
* @param array $coins Types of coins available (every coin has infinite availablity)
* @param int $value Value to match with the coins
*
* @return array
*
* @since 1.0.0
*/
/**
* Find the minimum amount of coins that are required to match a value
*
* @param array $coins Types of coins available (every coin has infinite availablity)
* @param int $value Value to match with the coins
*
* @return array
*
* @since 1.0.0
*/
public static function getMinimumCoinsForValueI(array $coins, int $value) : array
{
// amount of required coins for different values
$table = [0];
$usedCoins = [];
$table = [0];
$usedCoins = [];
for ($i = 1; $i <= $value; ++$i) {
$table[$i] = \PHP_INT_MAX;
@ -67,5 +71,5 @@ class MinimumCoinProblem
}
return $usedCoins[$value] ?? [];
}
}
}

View File

@ -66,7 +66,7 @@ class JumpPointSearch implements PathFinderInterface
if (!$neighbor->isOpened() || $ng < $neighbor->getG()) {
$neighbor->setG($ng);
$neighbor->setH($neighbor->getG() ?? $neighbor->getWeight() * Heuristic::heuristic($neighbor->getCoordinates(), $endNode->getCoordinates(), $heuristic));
$neighbor->setH($neighbor->getG() ?? $neighbor->getWeight() * Heuristic::metric($neighbor->getCoordinates(), $endNode->getCoordinates(), $heuristic));
$neighbor->setF($neighbor->getG() + $neighbor->getH());
$neighbor->setParent($node);

View File

@ -26,7 +26,7 @@ use phpOMS\Math\Topology\Metrics2D;
*/
class Heuristic
{
public static function heuristic(array $node1, array $node2, int $heuristic) : float
public static function metric(array $node1, array $node2, int $heuristic) : float
{
if ($heuristic === HeuristicType::MANHATTAN) {
return Metrics2D::manhattan($node1, $node2);

View File

@ -79,12 +79,12 @@ class JumpPointSearch implements PathFinderInterface
continue;
}
$d = Heuristic::heuristic($node->getCoordinates(), $jumpPoint->getCoordinates(), HeuristicType::OCTILE);
$d = Heuristic::metric($node->getCoordinates(), $jumpPoint->getCoordinates(), HeuristicType::OCTILE);
$ng = $node->getG() + $d;
if (!$jumpPoint->isOpened() || $ng < $jumpPoint->getG()) {
$jumpPoint->setG($ng);
$jumpPoint->setH($jumpPoint->getH() ?? Heuristic::heuristic($jumpPoint->getCoordinates(), $endNode->getCoordinates(), $heuristic));
$jumpPoint->setH($jumpPoint->getH() ?? Heuristic::metric($jumpPoint->getCoordinates(), $endNode->getCoordinates(), $metric));
$jumpPoint->setF($jumpPoint->getG() + $jumpPoint->getH());
$jumpPoint->setParent($node);

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class BitonicSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$n = \count($list);
@ -38,7 +41,7 @@ class BitonicSort implements SortInterface
return self::merge(\array_merge($first, $second), $order);
}
public static function merge(array $list, int $order) : array
private static function merge(array $list, int $order) : array
{
$n = \count($list);

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class BubbleSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$n = \count($list);

View File

@ -24,6 +24,18 @@ namespace phpOMS\Algorithm\Sort;
*/
class BucketSort
{
/**
* Sort array
*
* @param array $list List of sortable elements
* @param int $bucketCount Buckets to divide the list into
* @param string $algo Algorithm to use for sort
* @param int $order Sort order
*
* @return array Sorted array
*
* @since 1.0.0
*/
public static function sort(array $list, int $bucketCount, string $algo = InsertionSort::class, int $order = SortOrder::ASC) : array
{
$buckets = [];

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class CocktailShakerSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$start = 0;

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class CombSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$sorted = false;

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class CycleSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$writes = 0;

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class FlashSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$n = \count($list);

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class GnomeSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$n = \count($list);

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class OddEvenSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$sorted = false;

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class QuickSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$copy = $list;

View File

@ -24,6 +24,9 @@ namespace phpOMS\Algorithm\Sort;
*/
class SelectionSort implements SortInterface
{
/**
* {@inheritdoc}
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array
{
$n = \count($list);

View File

@ -24,5 +24,15 @@ namespace phpOMS\Algorithm\Sort;
*/
interface SortInterface
{
/**
* Sort array
*
* @param array $list List of sortable elements
* @param int $order Sort order
*
* @return array Sorted array
*
* @since 1.0.0
*/
public static function sort(array $list, int $order = SortOrder::ASC) : array;
}

View File

@ -24,11 +24,46 @@ namespace phpOMS\Algorithm\Sort;
*/
interface SortableInterface
{
/**
* Compare current object with other object
*
* @param SortableInterface $obj Object to compare with
* @param int $order Sort order
*
* @return bool
*
* @since 1.0.0
*/
public function compare(self $obj, int $order = SortOrder::ASC) : bool;
/**
* Get element value
*
* @return mixed
*
* @since 1.0.0
*/
public function getValue();
/**
* Get maximum element
*
* @param SortableInterface[] $list List to order
*
* @return mixed
*
* @since 1.0.0
*/
public static function max(array $list);
/**
* Get minimum element
*
* @param SortableInterface[] $list List to order
*
* @return mixed
*
* @since 1.0.0
*/
public static function min(array $list);
}

View File

@ -26,6 +26,15 @@ namespace phpOMS\Business\Marketing;
*/
final class Metrics
{
/**
* Constructure
*
* @since 1.0.0
*/
private function __construct()
{
}
/**
* Calculate customer retention
*

View File

@ -26,6 +26,15 @@ namespace phpOMS\Business\Programming;
*/
final class Metrics
{
/**
* Constructure
*
* @since 1.0.0
*/
private function __construct()
{
}
/**
* Calculate ABC metric score
*

View File

@ -27,6 +27,15 @@ namespace phpOMS\Business\Sales;
*/
final class MarketShareEstimation
{
/**
* Constructure
*
* @since 1.0.0
*/
private function __construct()
{
}
/**
* Calculate rank (r) based on market share (m)
*

View File

@ -14,6 +14,14 @@ declare(strict_types=1);
namespace phpOMS\Dispatcher;
/**
* Dispatcher interface
*
* @package phpOMS\Dispatcher
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
interface DispatcherInterface
{
/**

View File

@ -35,6 +35,16 @@ final class NumericUtils
{
}
/**
* Unsigned right shift
*
* @param int $a Value to shift
* @param int $b Shift by
*
* @return int unsigned int
*
* @since 1.0.0
*/
public static function uRightShift(int $a, int $b) : int
{
if ($b === 0) {

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\Views;
/**

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\phpOMS\Model\Message;

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\phpOMS\Model\Message;

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\phpOMS\Model\Message;

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\phpOMS\Model\Message;

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\phpOMS\Model\Message;