mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
PHP Coding Standards Fixer > fix coding standard
This commit is contained in:
@@ -30,7 +30,6 @@ class Templates extends Collection
|
||||
*/
|
||||
public function findTemplate(string $index): Template
|
||||
{
|
||||
/* @var Template $template */
|
||||
$template = $this->getByIndex($index);
|
||||
|
||||
if ($template instanceof Template) {
|
||||
|
||||
@@ -28,9 +28,6 @@ class UnknownDatePartTypeException extends UnknownTypeException
|
||||
*/
|
||||
public static function createException($unknownDatePart, $value)
|
||||
{
|
||||
/* @var UnknownDatePartTypeException $exception */
|
||||
$exception = parent::create($unknownDatePart, new DatePartType(), sprintf('date part (with value %s)', $value));
|
||||
|
||||
return $exception;
|
||||
return parent::create($unknownDatePart, new DatePartType(), sprintf('date part (with value %s)', $value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ class UnknownOopVisibilityTypeException extends UnknownTypeException
|
||||
*/
|
||||
public static function createException($unknownType)
|
||||
{
|
||||
/* @var UnknownOopVisibilityTypeException $exception */
|
||||
$exception = parent::create($unknownType, new OopVisibilityType(), 'OOP-related visibility');
|
||||
|
||||
return $exception;
|
||||
return parent::create($unknownType, new OopVisibilityType(), 'OOP-related visibility');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ trait ArrayAccessTrait
|
||||
/**
|
||||
* Returns information if element with given index/key exists
|
||||
*
|
||||
* @param string|int $index The index/key of element
|
||||
* @param int|string $index The index/key of element
|
||||
* @return bool
|
||||
*/
|
||||
private function exists($index)
|
||||
|
||||
@@ -58,6 +58,7 @@ trait MainTrait
|
||||
foreach ($elements as $index => $element) {
|
||||
if ($useIndexes) {
|
||||
$this->add($element, $index);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -93,6 +94,7 @@ trait MainTrait
|
||||
foreach ($this->elements as $index => $existing) {
|
||||
if ($element === $existing) {
|
||||
unset($this->elements[$index]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +152,7 @@ trait MainTrait
|
||||
* Returns previous element for given element
|
||||
*
|
||||
* @param mixed $element The element to verify
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function getPrevious($element)
|
||||
{
|
||||
@@ -161,7 +163,7 @@ trait MainTrait
|
||||
* Returns next element for given element
|
||||
*
|
||||
* @param mixed $element The element to verify
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function getNext($element)
|
||||
{
|
||||
@@ -192,7 +194,7 @@ trait MainTrait
|
||||
* Returns element with given index
|
||||
*
|
||||
* @param mixed $index Index / key of the element
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function getByIndex($index)
|
||||
{
|
||||
|
||||
@@ -163,7 +163,7 @@ trait BaseTestCaseTrait
|
||||
* Verifies visibility and arguments of method
|
||||
*
|
||||
* @param string $classNamespace Namespace of class that contains method to verify
|
||||
* @param string|ReflectionMethod $method Name of method or just the method to verify
|
||||
* @param ReflectionMethod|string $method Name of method or just the method to verify
|
||||
* @param string $visibilityType Expected visibility of verified method. One of
|
||||
* OopVisibilityType class constants.
|
||||
* @param int $argumentsCount (optional) Expected count/amount of arguments of the
|
||||
@@ -183,19 +183,15 @@ trait BaseTestCaseTrait
|
||||
$argumentsCount = 0,
|
||||
$requiredArgumentsCount = 0
|
||||
) {
|
||||
/*
|
||||
* Type of visibility is correct?
|
||||
*/
|
||||
// Type of visibility is not correct?
|
||||
if (!(new OopVisibilityType())->isCorrectType($visibilityType)) {
|
||||
throw new UnknownOopVisibilityTypeException($visibilityType);
|
||||
}
|
||||
|
||||
$reflection = new ReflectionClass($classNamespace);
|
||||
|
||||
/*
|
||||
* Name of method provided only?
|
||||
* Let's find instance of the method (based on reflection)
|
||||
*/
|
||||
// Name of method provided only?
|
||||
// Let's find instance of the method (based on reflection)
|
||||
if (!$method instanceof ReflectionMethod) {
|
||||
$method = $reflection->getMethod($method);
|
||||
}
|
||||
@@ -203,14 +199,15 @@ trait BaseTestCaseTrait
|
||||
switch ($visibilityType) {
|
||||
case OopVisibilityType::IS_PUBLIC:
|
||||
static::assertTrue($method->isPublic());
|
||||
break;
|
||||
|
||||
break;
|
||||
case OopVisibilityType::IS_PROTECTED:
|
||||
static::assertTrue($method->isProtected());
|
||||
break;
|
||||
|
||||
break;
|
||||
case OopVisibilityType::IS_PRIVATE:
|
||||
static::assertTrue($method->isPrivate());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -234,9 +231,6 @@ trait BaseTestCaseTrait
|
||||
$argumentsCount = 0,
|
||||
$requiredArgumentsCount = 0
|
||||
) {
|
||||
/*
|
||||
* Let's grab the constructor
|
||||
*/
|
||||
$reflection = new ReflectionClass($classNamespace);
|
||||
$method = $reflection->getConstructor();
|
||||
|
||||
@@ -256,9 +250,6 @@ trait BaseTestCaseTrait
|
||||
*/
|
||||
protected static function assertHasNoConstructor($classNamespace)
|
||||
{
|
||||
/*
|
||||
* Let's grab the constructor
|
||||
*/
|
||||
$reflection = new ReflectionClass($classNamespace);
|
||||
$constructor = $reflection->getConstructor();
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ trait HumanTrait
|
||||
/**
|
||||
* Returns email address
|
||||
*
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
@@ -109,7 +109,7 @@ trait HumanTrait
|
||||
/**
|
||||
* Returns birth date
|
||||
*
|
||||
* @return \DateTime|null
|
||||
* @return null|\DateTime
|
||||
*/
|
||||
public function getBirthDate()
|
||||
{
|
||||
|
||||
@@ -23,40 +23,40 @@ class DatePartType extends BaseType
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DAY = 'day';
|
||||
public const DAY = 'day';
|
||||
|
||||
/**
|
||||
* The "hour" date part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const HOUR = 'hour';
|
||||
public const HOUR = 'hour';
|
||||
|
||||
/**
|
||||
* The "minute" date part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const MINUTE = 'minute';
|
||||
public const MINUTE = 'minute';
|
||||
|
||||
/**
|
||||
* The "month" date part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const MONTH = 'month';
|
||||
public const MONTH = 'month';
|
||||
|
||||
/**
|
||||
* The "second" date part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SECOND = 'second';
|
||||
public const SECOND = 'second';
|
||||
|
||||
/**
|
||||
* The "year" date part
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const YEAR = 'year';
|
||||
public const YEAR = 'year';
|
||||
}
|
||||
|
||||
@@ -26,63 +26,63 @@ class DatePeriod extends BaseType
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const LAST_MONTH = 4;
|
||||
public const LAST_MONTH = 4;
|
||||
|
||||
/**
|
||||
* The period constant: last week
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const LAST_WEEK = 1;
|
||||
public const LAST_WEEK = 1;
|
||||
|
||||
/**
|
||||
* The period constant: last year
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const LAST_YEAR = 7;
|
||||
public const LAST_YEAR = 7;
|
||||
|
||||
/**
|
||||
* The period constant: next month
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const NEXT_MONTH = 6;
|
||||
public const NEXT_MONTH = 6;
|
||||
|
||||
/**
|
||||
* The period constant: next week
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const NEXT_WEEK = 3;
|
||||
public const NEXT_WEEK = 3;
|
||||
|
||||
/**
|
||||
* The period constant: next year
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const NEXT_YEAR = 9;
|
||||
public const NEXT_YEAR = 9;
|
||||
|
||||
/**
|
||||
* The period constant: this month
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const THIS_MONTH = 5;
|
||||
public const THIS_MONTH = 5;
|
||||
|
||||
/**
|
||||
* The period constant: this week
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const THIS_WEEK = 2;
|
||||
public const THIS_WEEK = 2;
|
||||
|
||||
/**
|
||||
* The period constant: this year
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const THIS_YEAR = 8;
|
||||
public const THIS_YEAR = 8;
|
||||
|
||||
/**
|
||||
* The start date of period
|
||||
@@ -114,23 +114,20 @@ class DatePeriod extends BaseType
|
||||
* Returns formatted one of the period's date: start date or end date
|
||||
*
|
||||
* @param string $format Format used to format the date
|
||||
* @param bool $startDate (optional) If is set to true, start date is formatted. Otherwise - end date.
|
||||
* @param bool $startDate (optional) If is set to true, start date will be formatted. Otherwise - end date.
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedDate($format, $startDate = true)
|
||||
{
|
||||
$date = $this->getEndDate();
|
||||
|
||||
/*
|
||||
* Start date should be formatted?
|
||||
*/
|
||||
// Start date should be formatted?
|
||||
if ($startDate) {
|
||||
$date = $this->getStartDate();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unknown date or format is invalid?
|
||||
*/
|
||||
// Unknown date or format is invalid?
|
||||
// Nothing to do
|
||||
if (null === $date || !Date::isValidDateFormat($format)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -19,19 +19,19 @@ class OopVisibilityType extends BaseType
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const IS_PRIVATE = 3;
|
||||
public const IS_PRIVATE = 3;
|
||||
|
||||
/**
|
||||
* The "protected" visibility of OOP
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const IS_PROTECTED = 2;
|
||||
public const IS_PROTECTED = 2;
|
||||
|
||||
/**
|
||||
* The "public" visibility of OOP
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const IS_PUBLIC = 1;
|
||||
public const IS_PUBLIC = 1;
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@ class Arrays
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const POSITION_KEY_NAME = 'position';
|
||||
public const POSITION_KEY_NAME = 'position';
|
||||
|
||||
/**
|
||||
* Converts given array's column to string.
|
||||
* Recursive call is made for multi-dimensional arrays.
|
||||
*
|
||||
* @param array $array Data to be converted
|
||||
* @param string|int $arrayColumnKey (optional) Column name. Default: "".
|
||||
* @param int|string $arrayColumnKey (optional) Column name. Default: "".
|
||||
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function values2string(array $array, $arrayColumnKey = '', $separator = ',')
|
||||
{
|
||||
@@ -85,7 +85,7 @@ class Arrays
|
||||
* @param string $valuesKeysSeparator (optional) Separator used between name and value. Default: "=".
|
||||
* @param string $valuesWrapper (optional) Wrapper used to wrap values, e.g. double-quote: key="value".
|
||||
* Default: "".
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function valuesKeys2string(
|
||||
array $array,
|
||||
@@ -123,7 +123,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array Data to be converted. It have to be an array that represents database table.
|
||||
* @param string $separator (optional) Separator used between values. Default: ",".
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function values2csv(array $array, $separator = ',')
|
||||
{
|
||||
@@ -279,7 +279,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array Data to get the breadcrumb
|
||||
* @param string $separator (optional) Separator used to stick the elements. Default: "/".
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getLastElementBreadCrumb(array $array, $separator = '/')
|
||||
{
|
||||
@@ -328,9 +328,7 @@ class Arrays
|
||||
$last = end($array);
|
||||
|
||||
if (is_array($last)) {
|
||||
/*
|
||||
* We've got an array, so looking for the last row of array will be done recursively
|
||||
*/
|
||||
// We've got an array, so looking for the last row of array will be done recursively
|
||||
$effect = self::getLastRow($last);
|
||||
|
||||
/*
|
||||
@@ -381,7 +379,7 @@ class Arrays
|
||||
* @param string $jsVariableName (optional) Name of the variable that will be in generated JavaScript code
|
||||
* @param bool $preserveIndexes (optional) If is set to true and $jsVariableName isn't empty, indexes also
|
||||
* will be added to the JavaScript code. Otherwise not.
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function array2JavaScript(array $array, $jsVariableName = '', $preserveIndexes = false)
|
||||
{
|
||||
@@ -477,7 +475,7 @@ class Arrays
|
||||
* Quotes (adds quotes) to elements that are strings and returns new array (with quoted elements)
|
||||
*
|
||||
* @param array $array The array to check for string values
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function quoteStrings(array $array)
|
||||
{
|
||||
@@ -509,9 +507,9 @@ class Arrays
|
||||
/**
|
||||
* Removes marginal element (first or last)
|
||||
*
|
||||
* @param string|array $item The item which should be shortened
|
||||
* @param array|string $item The item which should be shortened
|
||||
* @param bool $last (optional) If is set to true, last element is removed. Otherwise - first.
|
||||
* @return string|array
|
||||
* @return array|string
|
||||
*/
|
||||
public static function removeMarginalElement($item, $last = true)
|
||||
{
|
||||
@@ -560,7 +558,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array that contains element / item which should be removed
|
||||
* @param mixed $item The element / item which should be removed
|
||||
* @return bool|array
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function removeElement(array $array, $item)
|
||||
{
|
||||
@@ -572,19 +570,13 @@ class Arrays
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flip the array to make it looks like: value => key
|
||||
*/
|
||||
// Flip the array to make it looks like: value => key
|
||||
$arrayFlipped = array_flip($array);
|
||||
|
||||
/*
|
||||
* Take the key of element / item that should be removed
|
||||
*/
|
||||
// Take the key of element / item that should be removed
|
||||
$key = $arrayFlipped[$item];
|
||||
|
||||
/*
|
||||
* ...and remove the element / item
|
||||
*/
|
||||
// ...and remove the element / item
|
||||
unset($array[$key]);
|
||||
|
||||
return $array;
|
||||
@@ -642,7 +634,7 @@ class Arrays
|
||||
* value will be used with it's key, because other will be overridden.
|
||||
* Otherwise - values are preserved and keys assigned to that values are
|
||||
* returned as an array.
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*
|
||||
* Example of $ignoreDuplicatedValues = false:
|
||||
* - provided array
|
||||
@@ -680,13 +672,12 @@ class Arrays
|
||||
*/
|
||||
if (is_array($value)) {
|
||||
$replaced[$key] = self::setKeysAsValues($value, $ignoreDuplicatedValues);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicated values shouldn't be ignored and processed value is used as key already?
|
||||
* Let's use an array and that will contain all values (to avoid ignoring / overriding duplicated values)
|
||||
*/
|
||||
// Duplicated values shouldn't be ignored and processed value is used as key already?
|
||||
// Let's use an array and that will contain all values (to avoid ignoring / overriding duplicated values)
|
||||
if (!$ignoreDuplicatedValues && isset($replaced[$value])) {
|
||||
$existing = self::makeArray($replaced[$value]);
|
||||
|
||||
@@ -697,9 +688,7 @@ class Arrays
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Standard behaviour
|
||||
*/
|
||||
// Standard behaviour
|
||||
$replaced[$value] = $key;
|
||||
}
|
||||
|
||||
@@ -711,7 +700,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array to sort
|
||||
* @param int $sortFlags (optional) Options of ksort() function
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function ksortRecursive(array &$array, $sortFlags = SORT_REGULAR)
|
||||
{
|
||||
@@ -739,7 +728,7 @@ class Arrays
|
||||
* Returns count / amount of elements that are not array
|
||||
*
|
||||
* @param array $array The array to count
|
||||
* @return int|null
|
||||
* @return null|int
|
||||
*/
|
||||
public static function getNonArrayElementsCount(array $array)
|
||||
{
|
||||
@@ -756,6 +745,7 @@ class Arrays
|
||||
foreach ($array as &$value) {
|
||||
if (is_array($value)) {
|
||||
$count += self::getNonArrayElementsCount($value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -857,10 +847,10 @@ class Arrays
|
||||
* @param array $array The array with elements
|
||||
* @param string $separator (optional) Separator used between elements. Default: ".".
|
||||
* @param string $parentPath (optional) Path of the parent element. Default: "".
|
||||
* @param string|array $stopIfMatchedBy (optional) Patterns of keys or paths that matched will stop the process
|
||||
* @param array|string $stopIfMatchedBy (optional) Patterns of keys or paths that matched will stop the process
|
||||
* of path building and including children of those keys or paths (recursive
|
||||
* will not be used for keys in lower level of given array). Default: "".
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*
|
||||
* Examples - $stopIfMatchedBy argument:
|
||||
* a) "\d+"
|
||||
@@ -910,6 +900,7 @@ class Arrays
|
||||
|
||||
if (preg_match($pattern, $key) || preg_match($pattern, $path)) {
|
||||
$stopRecursion = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -923,12 +914,11 @@ class Arrays
|
||||
*/
|
||||
if (!$valueIsArray || ($valueIsArray && empty($value)) || $stopRecursion) {
|
||||
$paths[$path] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Let's iterate through the next level, using recursive
|
||||
*/
|
||||
// Let's iterate through the next level, using recursive
|
||||
if ($valueIsArray) {
|
||||
$recursivePaths = self::getLastElementsPaths($value, $separator, $path, $stopIfMatchedBy);
|
||||
$paths += $recursivePaths;
|
||||
@@ -978,9 +968,7 @@ class Arrays
|
||||
*/
|
||||
$areMatched = true;
|
||||
|
||||
/*
|
||||
* Building the pattern
|
||||
*/
|
||||
// Building the pattern
|
||||
$rawPattern = $pattern;
|
||||
$pattern = sprintf('|%s|', $rawPattern);
|
||||
|
||||
@@ -991,6 +979,7 @@ class Arrays
|
||||
*/
|
||||
if (!preg_match($pattern, $key)) {
|
||||
$areMatched = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1141,7 +1130,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array which should contain values of the key
|
||||
* @param string $key The key
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function getAllValuesOfKey(array $array, $key)
|
||||
{
|
||||
@@ -1158,6 +1147,7 @@ class Arrays
|
||||
foreach ($array as $index => $value) {
|
||||
if ($index === $key) {
|
||||
$values[] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1184,7 +1174,7 @@ class Arrays
|
||||
* @param string $keyName (optional) Name of key which will contain the position value
|
||||
* @param int $startPosition (optional) Default, start value of the position for main / given array, not the
|
||||
* children
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function setPositions(array $array, $keyName = self::POSITION_KEY_NAME, $startPosition = null)
|
||||
{
|
||||
@@ -1233,6 +1223,7 @@ class Arrays
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$result[$key] = self::trimRecursive($value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1287,7 +1278,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array An array to sort
|
||||
* @param array $keysOrder An array with keys of the 1st argument in proper / required order
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function sortByCustomKeysOrder(array $array, array $keysOrder)
|
||||
{
|
||||
@@ -1336,7 +1327,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array with elements to implode
|
||||
* @param string $separator Separator used to stick together elements of given array
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function implodeSmart(array $array, $separator)
|
||||
{
|
||||
@@ -1437,9 +1428,7 @@ class Arrays
|
||||
foreach ($array1 as $key => $value) {
|
||||
$array2HasKey = array_key_exists($key, $array2);
|
||||
|
||||
/*
|
||||
* Values should be compared only?
|
||||
*/
|
||||
// Values should be compared only?
|
||||
if ($valuesOnly) {
|
||||
$difference = null;
|
||||
|
||||
@@ -1461,20 +1450,14 @@ class Arrays
|
||||
$effect[] = $difference;
|
||||
}
|
||||
|
||||
/*
|
||||
* The key exists in 2nd array?
|
||||
*/
|
||||
// The key exists in 2nd array?
|
||||
} elseif ($array2HasKey) {
|
||||
/*
|
||||
* The value it's an array (it's a nested array)?
|
||||
*/
|
||||
// The value it's an array (it's a nested array)?
|
||||
if (is_array($value)) {
|
||||
$diff = [];
|
||||
|
||||
if (is_array($array2[$key])) {
|
||||
/*
|
||||
* Let's verify the nested array
|
||||
*/
|
||||
// Let's verify the nested array
|
||||
$diff = self::arrayDiffRecursive($value, $array2[$key], $valuesOnly);
|
||||
}
|
||||
|
||||
@@ -1484,16 +1467,12 @@ class Arrays
|
||||
|
||||
$effect[$key] = $diff;
|
||||
} elseif ($value !== $array2[$key]) {
|
||||
/*
|
||||
* Value is different than in 2nd array?
|
||||
* OKay, I've got difference
|
||||
*/
|
||||
// Value is different than in 2nd array?
|
||||
// OKay, I've got difference
|
||||
$effect[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* OKay, I've got difference
|
||||
*/
|
||||
// OKay, I've got difference
|
||||
$effect[$key] = $value;
|
||||
}
|
||||
}
|
||||
@@ -1506,14 +1485,12 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array to verify
|
||||
* @param mixed $element The element who index / key is needed
|
||||
* @return bool|mixed|null
|
||||
* @return null|bool|mixed
|
||||
*/
|
||||
public static function getIndexOf(array $array, $element)
|
||||
{
|
||||
/*
|
||||
* No elements?
|
||||
* Nothing to do
|
||||
*/
|
||||
// No elements?
|
||||
// Nothing to do
|
||||
if (empty($array)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1531,10 +1508,10 @@ class Arrays
|
||||
* Returns an array with incremented indexes / keys
|
||||
*
|
||||
* @param array $array The array which indexes / keys should be incremented
|
||||
* @param int|null $startIndex (optional) Index from which incrementation should be started. If not provided,
|
||||
* @param null|int $startIndex (optional) Index from which incrementation should be started. If not provided,
|
||||
* the first index / key will be used.
|
||||
* @param int $incrementStep (optional) Value used for incrementation. The step of incrementation.
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function incrementIndexes(array $array, $startIndex = null, $incrementStep = 1)
|
||||
{
|
||||
@@ -1594,7 +1571,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array with elements
|
||||
* @param mixed $element Element for who next element should be returned
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
public static function getNextElement(array $array, $element)
|
||||
{
|
||||
@@ -1606,7 +1583,7 @@ class Arrays
|
||||
*
|
||||
* @param array $array The array with elements
|
||||
* @param mixed $element Element for who previous element should be returned
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
public static function getPreviousElement(array $array, $element)
|
||||
{
|
||||
@@ -1617,7 +1594,7 @@ class Arrays
|
||||
* Returns information if given array is a multi dimensional array
|
||||
*
|
||||
* @param array $array The array to verify
|
||||
* @return bool|null
|
||||
* @return null|bool
|
||||
*/
|
||||
public static function isMultiDimensional(array $array)
|
||||
{
|
||||
@@ -1671,7 +1648,7 @@ class Arrays
|
||||
* Returns non-empty values, e.g. without "" (empty string), null or []
|
||||
*
|
||||
* @param array $values The values to filter
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function getNonEmptyValues(array $values)
|
||||
{
|
||||
@@ -1696,7 +1673,7 @@ class Arrays
|
||||
*
|
||||
* @param array $values The values to filter
|
||||
* @param string $separator (optional) Separator used to implode the values. Default: ", ".
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getNonEmptyValuesAsString(array $values, $separator = ', ')
|
||||
{
|
||||
@@ -1727,7 +1704,7 @@ class Arrays
|
||||
* @param array $array The array with elements
|
||||
* @param mixed $element Element for who next element should be returned
|
||||
* @param bool $next (optional) If is set to true, returns next neighbour. Otherwise - previous.
|
||||
* @return mixed|null
|
||||
* @return null|mixed
|
||||
*/
|
||||
private static function getNeighbour(array $array, $element, $next = true)
|
||||
{
|
||||
@@ -1770,9 +1747,7 @@ class Arrays
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Looking for key of the neighbour (next or previous element)
|
||||
*/
|
||||
// Looking for key of the neighbour (next or previous element)
|
||||
if ($next) {
|
||||
++$indexOfKey;
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,7 @@ class Bundle
|
||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @param string $extension (optional) Extension of the view / template (default: "html.twig")
|
||||
* @throws IncorrectBundleNameException
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getBundleViewPath($viewPath, $bundleName, $extension = 'html.twig')
|
||||
{
|
||||
@@ -37,23 +37,17 @@ class Bundle
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given name of bundle is invalid?
|
||||
*/
|
||||
// Oops, given name of bundle is invalid
|
||||
if (!Regex::isValidBundleName($bundleName)) {
|
||||
throw IncorrectBundleNameException::create($bundleName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Path of the view / template doesn't end with given extension?
|
||||
*/
|
||||
// Make sure that path of the view / template ends with given extension
|
||||
if (!Regex::endsWith($viewPath, $extension)) {
|
||||
$viewPath = sprintf('%s.%s', $viewPath, $extension);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare short name of bundle and path of view / template with "/" (instead of ":")
|
||||
*/
|
||||
// Prepare short name of bundle and path of view / template with "/" (instead of ":")
|
||||
$shortBundleName = static::getShortBundleName($bundleName);
|
||||
$viewPath = str_replace(':', '/', $viewPath);
|
||||
|
||||
@@ -65,13 +59,11 @@ class Bundle
|
||||
*
|
||||
* @param string $fullBundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||
* @throws IncorrectBundleNameException
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getShortBundleName($fullBundleName)
|
||||
{
|
||||
/*
|
||||
* Given name of bundle is invalid?
|
||||
*/
|
||||
// Oops, given name of bundle is invalid
|
||||
if (!Regex::isValidBundleName($fullBundleName)) {
|
||||
if (!is_string($fullBundleName)) {
|
||||
$fullBundleName = gettype($fullBundleName);
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
namespace Meritoo\Common\Utilities;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Useful Composer-related methods (only static functions)
|
||||
*
|
||||
@@ -23,14 +21,14 @@ class Composer
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const FILE_NAME_MAIN = 'composer.json';
|
||||
public const FILE_NAME_MAIN = 'composer.json';
|
||||
|
||||
/**
|
||||
* Returns value from composer.json file
|
||||
*
|
||||
* @param string $composerJsonPath Path of composer.json file
|
||||
* @param string $nodeName Name of node who value should be returned
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getValue($composerJsonPath, $nodeName)
|
||||
{
|
||||
@@ -63,7 +61,6 @@ class Composer
|
||||
return null;
|
||||
}
|
||||
|
||||
/* @var stdClass $data */
|
||||
return $data->{$nodeName};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DATE_DIFFERENCE_UNIT_DAYS = 'days';
|
||||
public const DATE_DIFFERENCE_UNIT_DAYS = 'days';
|
||||
|
||||
/**
|
||||
* The 'hours' unit of date difference.
|
||||
@@ -37,7 +37,7 @@ class Date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DATE_DIFFERENCE_UNIT_HOURS = 'hours';
|
||||
public const DATE_DIFFERENCE_UNIT_HOURS = 'hours';
|
||||
|
||||
/**
|
||||
* The 'minutes' unit of date difference.
|
||||
@@ -45,7 +45,7 @@ class Date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DATE_DIFFERENCE_UNIT_MINUTES = 'minutes';
|
||||
public const DATE_DIFFERENCE_UNIT_MINUTES = 'minutes';
|
||||
|
||||
/**
|
||||
* The 'months' unit of date difference.
|
||||
@@ -53,7 +53,7 @@ class Date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DATE_DIFFERENCE_UNIT_MONTHS = 'months';
|
||||
public const DATE_DIFFERENCE_UNIT_MONTHS = 'months';
|
||||
|
||||
/**
|
||||
* The 'years' unit of date difference.
|
||||
@@ -61,14 +61,14 @@ class Date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DATE_DIFFERENCE_UNIT_YEARS = 'years';
|
||||
public const DATE_DIFFERENCE_UNIT_YEARS = 'years';
|
||||
|
||||
/**
|
||||
* Returns date's period (that contains start and end date) for given period
|
||||
*
|
||||
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
|
||||
* @throws Exception
|
||||
* @return DatePeriod|null
|
||||
* @return null|DatePeriod
|
||||
*/
|
||||
public static function getDatesForPeriod($period)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ class Date
|
||||
*
|
||||
* @param string $format (optional) Format of returned value. A string acceptable by the DateTime::format()
|
||||
* method.
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function generateRandomTime($format = 'H:i:s')
|
||||
{
|
||||
@@ -213,9 +213,7 @@ class Date
|
||||
$seconds[] = $i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare random time (hour, minute and second)
|
||||
*/
|
||||
// Prepare random time (hour, minute and second)
|
||||
$hour = $hours[array_rand($hours)];
|
||||
$minute = $minutes[array_rand($minutes)];
|
||||
$second = $seconds[array_rand($seconds)];
|
||||
@@ -259,23 +257,17 @@ class Date
|
||||
$month = (int)$month;
|
||||
$day = (int)$day;
|
||||
|
||||
/*
|
||||
* Oops, incorrect year
|
||||
*/
|
||||
// Oops, given year is incorrect
|
||||
if ($year <= 0) {
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::YEAR, $year);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, incorrect month
|
||||
*/
|
||||
// Oops, given month is incorrect
|
||||
if ($month < 1 || $month > 12) {
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::MONTH, $month);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, incorrect day
|
||||
*/
|
||||
// Oops, given day is incorrect
|
||||
if ($day < 1 || $day > 31) {
|
||||
throw UnknownDatePartTypeException::createException(DatePartType::DAY, $day);
|
||||
}
|
||||
@@ -353,8 +345,8 @@ class Date
|
||||
* If the unit of date difference is null, all units are returned in array (units are keys of the array).
|
||||
* Otherwise - one, integer value is returned.
|
||||
*
|
||||
* @param string|DateTime $dateStart The start date
|
||||
* @param string|DateTime $dateEnd The end date
|
||||
* @param DateTime|string $dateStart The start date
|
||||
* @param DateTime|string $dateEnd The end date
|
||||
* @param string $differenceUnit (optional) Unit of date difference. One of this class
|
||||
* DATE_DIFFERENCE_UNIT_* constants. If is set to null all units are
|
||||
* returned in the array.
|
||||
@@ -401,9 +393,7 @@ class Date
|
||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
|
||||
$diff = $end->diff($start);
|
||||
|
||||
/*
|
||||
* Difference between dates in years should be returned only?
|
||||
*/
|
||||
// Difference between dates in years should be returned only?
|
||||
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
|
||||
return $diff->y;
|
||||
}
|
||||
@@ -414,9 +404,7 @@ class Date
|
||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
|
||||
$diff = $end->diff($start);
|
||||
|
||||
/*
|
||||
* Difference between dates in months should be returned only?
|
||||
*/
|
||||
// Difference between dates in months should be returned only?
|
||||
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
|
||||
return $diff->m;
|
||||
}
|
||||
@@ -427,55 +415,41 @@ class Date
|
||||
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
|
||||
$days = (int)floor($dateDiff / $daySeconds);
|
||||
|
||||
/*
|
||||
* Difference between dates in days should be returned only?
|
||||
*/
|
||||
// Difference between dates in days should be returned only?
|
||||
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
|
||||
return $days;
|
||||
}
|
||||
|
||||
/*
|
||||
* All units should be returned?
|
||||
*/
|
||||
// All units should be returned?
|
||||
if (null === $differenceUnit) {
|
||||
$difference[self::DATE_DIFFERENCE_UNIT_DAYS] = $days;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculation for later usage
|
||||
*/
|
||||
// Calculation for later usage
|
||||
$daysInSeconds = $days * $daySeconds;
|
||||
}
|
||||
|
||||
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
|
||||
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
|
||||
|
||||
/*
|
||||
* Difference between dates in hours should be returned only?
|
||||
*/
|
||||
// Difference between dates in hours should be returned only?
|
||||
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
|
||||
return $hours;
|
||||
}
|
||||
|
||||
/*
|
||||
* All units should be returned?
|
||||
*/
|
||||
// All units should be returned?
|
||||
if (null === $differenceUnit) {
|
||||
$difference[self::DATE_DIFFERENCE_UNIT_HOURS] = $hours;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculation for later usage
|
||||
*/
|
||||
// Calculation for later usage
|
||||
$hoursInSeconds = $hours * $hourSeconds;
|
||||
}
|
||||
|
||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
|
||||
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
|
||||
|
||||
/*
|
||||
* Difference between dates in minutes should be returned only?
|
||||
*/
|
||||
// Difference between dates in minutes should be returned only?
|
||||
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
|
||||
return $minutes;
|
||||
}
|
||||
@@ -583,7 +557,7 @@ class Date
|
||||
* @param string $dateFormat (optional) Format of date used to verify if given value is actually a date.
|
||||
* It should be format matched to the given value, e.g. "Y-m-d H:i" for
|
||||
* "2015-01-01 10:00" value. Default: "Y-m-d".
|
||||
* @return DateTime|bool
|
||||
* @return bool|DateTime
|
||||
*/
|
||||
public static function getDateTime($value, $allowCompoundFormats = false, $dateFormat = 'Y-m-d')
|
||||
{
|
||||
@@ -710,28 +684,19 @@ class Date
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Datetime to string
|
||||
*/
|
||||
$formatted = (new DateTime())->format($format);
|
||||
|
||||
/*
|
||||
* Formatted date it's the format who is validated?
|
||||
* The format is invalid
|
||||
*/
|
||||
// Formatted date it's the format who is validated?
|
||||
// The format is invalid
|
||||
if ($formatted === $format) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate the format used to create the datetime
|
||||
*/
|
||||
// Validate the format used to create the datetime
|
||||
$fromFormat = DateTime::createFromFormat($format, $formatted);
|
||||
|
||||
/*
|
||||
* It's instance of DateTime?
|
||||
* The format is valid
|
||||
*/
|
||||
// It's instance of DateTime?
|
||||
// The format is valid
|
||||
if ($fromFormat instanceof DateTime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -706,9 +706,6 @@ class MimeTypes
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extensions should be returned as upper case?
|
||||
*/
|
||||
if ($asUpperCase) {
|
||||
if (is_array($extension)) {
|
||||
array_walk($extension, function (&$value) {
|
||||
@@ -729,7 +726,7 @@ class MimeTypes
|
||||
* Returns extension for given mime type
|
||||
*
|
||||
* @param string $mimeType The mime type, e.g. "video/mpeg"
|
||||
* @return string|array
|
||||
* @return array|string
|
||||
*/
|
||||
public static function getExtension($mimeType)
|
||||
{
|
||||
@@ -772,29 +769,24 @@ class MimeTypes
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* 1st possibility: the finfo class
|
||||
*/
|
||||
// 1st possibility: the finfo class
|
||||
if (class_exists('finfo')) {
|
||||
$finfo = new \finfo();
|
||||
|
||||
return $finfo->file($filePath, FILEINFO_MIME_TYPE);
|
||||
}
|
||||
|
||||
/*
|
||||
* 2nd possibility: the mime_content_type function
|
||||
*/
|
||||
// 2nd possibility: the mime_content_type function
|
||||
if (function_exists('mime_content_type')) {
|
||||
return mime_content_type($filePath);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, there is no possibility to read the mime type
|
||||
*/
|
||||
// Oops, there is no possibility to read the mime type
|
||||
$template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
|
||||
. ' mime type of file \'%s\'.';
|
||||
|
||||
$message = sprintf($template, $filePath);
|
||||
|
||||
throw new \RuntimeException($message);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class Miscellaneous
|
||||
* Otherwise - only content of given directory is returned.
|
||||
* @param int $maxFilesCount (optional) Maximum files that will be returned. If it's null, all files are
|
||||
* returned.
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function getDirectoryContent($directoryPath, $recursive = false, $maxFilesCount = null)
|
||||
{
|
||||
@@ -222,11 +222,6 @@ class Miscellaneous
|
||||
*/
|
||||
public static function getUniqueFileName($originalFileName, $objectId = 0)
|
||||
{
|
||||
/*
|
||||
* Get parts of the file name:
|
||||
* - without extension
|
||||
* - and... the extension
|
||||
*/
|
||||
$withoutExtension = self::getFileNameWithoutExtension($originalFileName);
|
||||
$extension = self::getFileExtension($originalFileName, true);
|
||||
|
||||
@@ -238,20 +233,13 @@ class Miscellaneous
|
||||
*/
|
||||
$withoutExtension = Urlizer::urlize($withoutExtension);
|
||||
|
||||
/*
|
||||
* Now I have to complete the template used to build / generate unique name
|
||||
*/
|
||||
// Now I have to complete the template used to build / generate unique name
|
||||
$template = '%s-%s.%s'; // [file's name]-[unique key].[file's extension]
|
||||
|
||||
/*
|
||||
* Add some uniqueness
|
||||
*/
|
||||
// Add some uniqueness
|
||||
$unique = self::getUniqueString(mt_rand());
|
||||
|
||||
/*
|
||||
* Finally build and return the unique name
|
||||
*/
|
||||
|
||||
// Finally build and return the unique name
|
||||
if ($objectId > 0) {
|
||||
$template = '%s-%s-%s.%s'; // [file's name]-[unique key]-[object ID].[file's extension]
|
||||
|
||||
@@ -345,9 +333,7 @@ class Miscellaneous
|
||||
|
||||
$converted = $converter->transliterate($string);
|
||||
|
||||
/*
|
||||
* Make the string lowercase and human-readable
|
||||
*/
|
||||
// Make the string lowercase and human-readable
|
||||
if ($lowerCaseHuman) {
|
||||
$matches = [];
|
||||
$matchCount = preg_match_all('|[A-Z]{1}[^A-Z]*|', $converted, $matches);
|
||||
@@ -390,10 +376,10 @@ class Miscellaneous
|
||||
* Replaces part of string with other string or strings.
|
||||
* There is a few combination of what should be searched and with what it should be replaced.
|
||||
*
|
||||
* @param string|array $subject The string or an array of strings to search and replace
|
||||
* @param string|array $search String or pattern or array of patterns to find. It may be: string, an array
|
||||
* @param array|string $subject The string or an array of strings to search and replace
|
||||
* @param array|string $search String or pattern or array of patterns to find. It may be: string, an array
|
||||
* of strings or an array of patterns.
|
||||
* @param string|array $replacement The string or an array of strings to replace. It may be: string or an array
|
||||
* @param array|string $replacement The string or an array of strings to replace. It may be: string or an array
|
||||
* of strings.
|
||||
* @param bool $quoteStrings (optional) If is set to true, strings are surrounded with single quote sign
|
||||
* @return string
|
||||
@@ -466,9 +452,7 @@ class Miscellaneous
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 1st step: replace strings, simple operation with strings
|
||||
*/
|
||||
// 1st step: replace strings, simple operation with strings
|
||||
if ($bothAreStrings) {
|
||||
$effect = str_replace($search, $replacement, $subject);
|
||||
}
|
||||
@@ -503,15 +487,10 @@ class Miscellaneous
|
||||
$effect = [];
|
||||
}
|
||||
|
||||
/*
|
||||
* I have to make the subject an array...
|
||||
*/
|
||||
$subject = Arrays::makeArray($subject);
|
||||
|
||||
/*
|
||||
* ...and use iterate through the subjects,
|
||||
* because explode() function expects strings as both arguments (1st and 2nd)
|
||||
*/
|
||||
// I have to iterate through the subjects, because explode() function expects strings as both arguments
|
||||
// (1st and 2nd)
|
||||
foreach ($subject as $subSubject) {
|
||||
$subEffect = '';
|
||||
|
||||
@@ -521,9 +500,7 @@ class Miscellaneous
|
||||
foreach ($exploded as $key => $item) {
|
||||
$subEffect .= $item;
|
||||
|
||||
/*
|
||||
* The replacement shouldn't be included when the searched string was not found
|
||||
*/
|
||||
// The replacement shouldn't be included when the searched string was not found
|
||||
if ($explodedCount > 1 && $key < $explodedCount - 1 && isset($replacement[$key])) {
|
||||
$subEffect .= $replacement[$key];
|
||||
}
|
||||
@@ -531,6 +508,7 @@ class Miscellaneous
|
||||
|
||||
if ($subjectIsArray) {
|
||||
$effect[] = $subEffect;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -571,7 +549,6 @@ class Miscellaneous
|
||||
public static function getOperatingSystemNameServer()
|
||||
{
|
||||
return PHP_OS;
|
||||
|
||||
/*
|
||||
* Previous version:
|
||||
* return php_uname('s');
|
||||
@@ -668,7 +645,7 @@ class Miscellaneous
|
||||
$spacePosition = mb_strrpos($lineWithAberration, ' ', 0, $encoding);
|
||||
|
||||
if (false !== $spacePosition && 0 < $spacePosition) {
|
||||
/* @var int $spacePosition */
|
||||
/** @var int $spacePosition */
|
||||
$perLine = $spacePosition;
|
||||
$insertSeparator = true;
|
||||
}
|
||||
@@ -705,7 +682,7 @@ class Miscellaneous
|
||||
* @param string $directoryPath Directory path
|
||||
* @param bool $contentOnly (optional) If is set to true, only content of the directory is removed, not
|
||||
* directory itself. Otherwise - directory is removed too (default behaviour).
|
||||
* @return bool|null
|
||||
* @return null|bool
|
||||
*/
|
||||
public static function removeDirectory($directoryPath, $contentOnly = false)
|
||||
{
|
||||
@@ -735,9 +712,7 @@ class Miscellaneous
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Directory should be removed too?
|
||||
*/
|
||||
// Directory should be removed too?
|
||||
if (!$contentOnly) {
|
||||
return rmdir($directoryPath);
|
||||
}
|
||||
@@ -789,7 +764,7 @@ class Miscellaneous
|
||||
* Make a string's first character lowercase
|
||||
*
|
||||
* @param string $text The text to get first character lowercase
|
||||
* @param bool|null $restLowercase (optional) Information that to do with rest of given string
|
||||
* @param null|bool $restLowercase (optional) Information that to do with rest of given string
|
||||
* @return string
|
||||
*
|
||||
* Values of the $restLowercase argument:
|
||||
@@ -818,7 +793,7 @@ class Miscellaneous
|
||||
* Make a string's first character uppercase
|
||||
*
|
||||
* @param string $text The text to get uppercase
|
||||
* @param bool|null $restLowercase (optional) Information that to do with rest of given string
|
||||
* @param null|bool $restLowercase (optional) Information that to do with rest of given string
|
||||
* @return string
|
||||
*
|
||||
* Values of the $restLowercase argument:
|
||||
@@ -932,7 +907,7 @@ class Miscellaneous
|
||||
*
|
||||
* @param string $string The string to check
|
||||
* @param string $separator The separator which divides elements of string
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getLastElementOfString($string, $separator)
|
||||
{
|
||||
@@ -980,30 +955,23 @@ class Miscellaneous
|
||||
* - concatenatePaths(['path/first', 'path/second', 'path/third']);
|
||||
* - concatenatePaths('path/first', 'path/second', 'path/third');
|
||||
*
|
||||
* @param string|array $paths Paths co concatenate. As described above: an array of paths / strings or strings
|
||||
* @param array|string $paths Paths co concatenate. As described above: an array of paths / strings or strings
|
||||
* passed as following arguments.
|
||||
* @return string
|
||||
*/
|
||||
public static function concatenatePaths($paths)
|
||||
{
|
||||
/*
|
||||
* If paths are not provided as array, get the paths from methods' arguments
|
||||
*/
|
||||
// If paths are not provided as array, get the paths from methods' arguments
|
||||
if (!is_array($paths)) {
|
||||
$paths = func_get_args();
|
||||
}
|
||||
|
||||
/*
|
||||
* No paths provided?
|
||||
* Nothing to do
|
||||
*/
|
||||
// No paths provided?
|
||||
// Nothing to do
|
||||
if (empty($paths)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* Some useful variables
|
||||
*/
|
||||
$concatenated = '';
|
||||
$firstWindowsBased = false;
|
||||
$separator = DIRECTORY_SEPARATOR;
|
||||
@@ -1011,16 +979,12 @@ class Miscellaneous
|
||||
foreach ($paths as $path) {
|
||||
$path = trim($path);
|
||||
|
||||
/*
|
||||
* Empty paths are useless
|
||||
*/
|
||||
// Empty paths are useless
|
||||
if (empty($path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the first path is a Windows-based path?
|
||||
*/
|
||||
// Does the first path is a Windows-based path?
|
||||
if (Arrays::isFirstElement($paths, $path)) {
|
||||
$firstWindowsBased = Regex::isWindowsBasedPath($path);
|
||||
|
||||
@@ -1029,14 +993,10 @@ class Miscellaneous
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the starting / beginning directory's separator
|
||||
*/
|
||||
// Remove the starting / beginning directory's separator
|
||||
$path = self::removeStartingDirectorySeparator($path, $separator);
|
||||
|
||||
/*
|
||||
* Removes the ending directory's separator
|
||||
*/
|
||||
// Removes the ending directory's separator
|
||||
$path = self::removeEndingDirectorySeparator($path, $separator);
|
||||
|
||||
/*
|
||||
@@ -1046,12 +1006,11 @@ class Miscellaneous
|
||||
*/
|
||||
if ($firstWindowsBased && empty($concatenated)) {
|
||||
$concatenated = $path;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Concatenate the paths / strings with OS-related directory separator between them (slash or backslash)
|
||||
*/
|
||||
// Concatenate the paths / strings with OS-related directory separator between them (slash or backslash)
|
||||
$concatenated = sprintf('%s%s%s', $concatenated, $separator, $path);
|
||||
}
|
||||
|
||||
@@ -1138,22 +1097,23 @@ class Miscellaneous
|
||||
switch ($globalSourceType) {
|
||||
case INPUT_GET:
|
||||
$globalSource = $_GET;
|
||||
break;
|
||||
|
||||
break;
|
||||
case INPUT_POST:
|
||||
$globalSource = $_POST;
|
||||
break;
|
||||
|
||||
break;
|
||||
case INPUT_COOKIE:
|
||||
$globalSource = $_COOKIE;
|
||||
break;
|
||||
|
||||
break;
|
||||
case INPUT_SERVER:
|
||||
$globalSource = $_SERVER;
|
||||
break;
|
||||
|
||||
break;
|
||||
case INPUT_ENV:
|
||||
$globalSource = $_ENV;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1201,6 +1161,7 @@ class Miscellaneous
|
||||
for ($i = ($length - $textLength); 0 < $i; --$i) {
|
||||
if ($before) {
|
||||
$text = '0' . $text;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1213,9 +1174,9 @@ class Miscellaneous
|
||||
/**
|
||||
* Returns information if given value is located in interval between given utmost left and right values
|
||||
*
|
||||
* @param int|float $value Value to verify
|
||||
* @param int|float $left Left utmost value of interval
|
||||
* @param int|float $right Right utmost value of interval
|
||||
* @param float|int $value Value to verify
|
||||
* @param float|int $left Left utmost value of interval
|
||||
* @param float|int $right Right utmost value of interval
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBetween($value, $left, $right)
|
||||
@@ -1277,9 +1238,7 @@ class Miscellaneous
|
||||
*/
|
||||
public static function getInvertedColor($color)
|
||||
{
|
||||
/*
|
||||
* Prepare the color for later usage
|
||||
*/
|
||||
// Prepare the color for later usage
|
||||
$color = trim($color);
|
||||
$withHash = Regex::startsWith($color, '#');
|
||||
|
||||
@@ -1289,23 +1248,17 @@ class Miscellaneous
|
||||
*/
|
||||
$validColor = Regex::getValidColorHexValue($color);
|
||||
|
||||
/*
|
||||
* Grab color's components
|
||||
*/
|
||||
// Grab color's components
|
||||
$red = hexdec(substr($validColor, 0, 2));
|
||||
$green = hexdec(substr($validColor, 2, 2));
|
||||
$blue = hexdec(substr($validColor, 4, 2));
|
||||
|
||||
/*
|
||||
* Calculate inverted color's components
|
||||
*/
|
||||
// Calculate inverted color's components
|
||||
$redInverted = self::getValidColorComponent(255 - $red);
|
||||
$greenInverted = self::getValidColorComponent(255 - $green);
|
||||
$blueInverted = self::getValidColorComponent(255 - $blue);
|
||||
|
||||
/*
|
||||
* Voila, here is the inverted color
|
||||
*/
|
||||
// Voila, here is the inverted color
|
||||
$invertedColor = sprintf('%s%s%s', $redInverted, $greenInverted, $blueInverted);
|
||||
|
||||
if ($withHash) {
|
||||
@@ -1328,9 +1281,7 @@ class Miscellaneous
|
||||
$fileName = 'composer.json';
|
||||
$directoryPath = __DIR__;
|
||||
|
||||
/*
|
||||
* Path of directory it's not the path of last directory?
|
||||
*/
|
||||
// Path of directory it's not the path of last directory?
|
||||
while (DIRECTORY_SEPARATOR !== $directoryPath) {
|
||||
$filePath = static::concatenatePaths($directoryPath, $fileName);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class QueryBuilderUtility
|
||||
* If null is returned, alias was not found.
|
||||
*
|
||||
* @param QueryBuilder $queryBuilder The query builder to retrieve root alias
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getRootAlias(QueryBuilder $queryBuilder)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class QueryBuilderUtility
|
||||
*
|
||||
* @param QueryBuilder $queryBuilder The query builder to verify
|
||||
* @param string $property Name of property that maybe is joined
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getJoinedPropertyAlias(QueryBuilder $queryBuilder, $property)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class QueryBuilderUtility
|
||||
$pattern = sprintf($patternTemplate, $property);
|
||||
|
||||
foreach ($joins as $joinExpressions) {
|
||||
/* @var $expression Join */
|
||||
/** @var Join $expression */
|
||||
foreach ($joinExpressions as $expression) {
|
||||
$joinedProperty = $expression->getJoin();
|
||||
|
||||
@@ -90,7 +90,7 @@ class QueryBuilderUtility
|
||||
* @param array $criteria (optional) The criteria used in WHERE clause. It may simple array with pairs
|
||||
* key-value or an array of arrays where second element of sub-array is the
|
||||
* comparison operator. Example below.
|
||||
* @param string|null $alias (optional) Alias used in the query
|
||||
* @param null|string $alias (optional) Alias used in the query
|
||||
* @return QueryBuilder
|
||||
*
|
||||
* Example of the $criteria argument:
|
||||
@@ -173,9 +173,7 @@ class QueryBuilderUtility
|
||||
$entityManager->remove($entity);
|
||||
}
|
||||
|
||||
/*
|
||||
* The deleted objects should be flushed?
|
||||
*/
|
||||
// The deleted objects should be flushed?
|
||||
if ($flushDeleted) {
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Reflection
|
||||
* Constants whose values are integers are considered only.
|
||||
*
|
||||
* @param object|string $class The object or name of object's class
|
||||
* @return int|null
|
||||
* @return null|int
|
||||
*/
|
||||
public static function getMaxNumberConstant($class)
|
||||
{
|
||||
@@ -249,6 +249,7 @@ class Reflection
|
||||
|
||||
$value = $object->{$getterName}();
|
||||
$valueFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -275,7 +276,7 @@ class Reflection
|
||||
* Returns values of given property for given objects.
|
||||
* Looks for proper getter for the property.
|
||||
*
|
||||
* @param Collection|object|array $objects The objects that should contain given property. It may be also one
|
||||
* @param array|Collection|object $objects The objects that should contain given property. It may be also one
|
||||
* object.
|
||||
* @param string $property Name of the property that contains a value
|
||||
* @param bool $force (optional) If is set to true, try to retrieve value even if the
|
||||
@@ -316,7 +317,7 @@ class Reflection
|
||||
* @param array|object|string $source An array of objects, namespaces, object or namespace
|
||||
* @param bool $withoutNamespace (optional) If is set to true, namespace is omitted. Otherwise -
|
||||
* not, full name of class is returned, with namespace.
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getClassName($source, $withoutNamespace = false)
|
||||
{
|
||||
@@ -338,9 +339,7 @@ class Reflection
|
||||
$source = Arrays::getFirstElement($source);
|
||||
}
|
||||
|
||||
/*
|
||||
* Let's prepare name of class
|
||||
*/
|
||||
// Let's prepare name of class
|
||||
if (is_object($source)) {
|
||||
$name = get_class($source);
|
||||
} elseif (is_string($source) && (class_exists($source) || trait_exists($source))) {
|
||||
@@ -472,7 +471,7 @@ class Reflection
|
||||
* Returns a parent class or false if there is no parent class
|
||||
*
|
||||
* @param array|object|string $source An array of objects, namespaces, object or namespace
|
||||
* @return \ReflectionClass|bool
|
||||
* @return bool|\ReflectionClass
|
||||
*/
|
||||
public static function getParentClass($source)
|
||||
{
|
||||
@@ -489,7 +488,7 @@ class Reflection
|
||||
* @param array|object|string $class Class who child classes should be returned. An array of objects, strings,
|
||||
* object or string.
|
||||
* @throws CannotResolveClassNameException
|
||||
* @return array|null
|
||||
* @return null|array
|
||||
*/
|
||||
public static function getChildClasses($class)
|
||||
{
|
||||
@@ -505,9 +504,7 @@ class Reflection
|
||||
|
||||
$className = self::getClassName($class);
|
||||
|
||||
/*
|
||||
* Oops, cannot resolve class
|
||||
*/
|
||||
// Oops, cannot resolve class
|
||||
if (null === $className) {
|
||||
throw CannotResolveClassNameException::create($class);
|
||||
}
|
||||
@@ -577,7 +574,7 @@ class Reflection
|
||||
* @param string $property Name of the property
|
||||
* @param int $filter (optional) Filter of properties. Uses \ReflectionProperty class constants.
|
||||
* By default all properties are allowed / processed.
|
||||
* @return \ReflectionProperty|null
|
||||
* @return null|\ReflectionProperty
|
||||
*/
|
||||
public static function getProperty($class, $property, $filter = null)
|
||||
{
|
||||
@@ -585,7 +582,7 @@ class Reflection
|
||||
$properties = self::getProperties($className, $filter);
|
||||
|
||||
if (!empty($properties)) {
|
||||
/* @var $reflectionProperty \ReflectionProperty */
|
||||
/** @var \ReflectionProperty $reflectionProperty */
|
||||
foreach ($properties as $reflectionProperty) {
|
||||
if ($reflectionProperty->getName() === $property) {
|
||||
return $reflectionProperty;
|
||||
@@ -604,23 +601,19 @@ class Reflection
|
||||
* @param bool $verifyParents If is set to true, parent classes are verified if they use given
|
||||
* trait. Otherwise - not.
|
||||
* @throws CannotResolveClassNameException
|
||||
* @return bool|null
|
||||
* @return null|bool
|
||||
*/
|
||||
public static function usesTrait($class, $trait, $verifyParents = false)
|
||||
{
|
||||
$className = self::getClassName($class);
|
||||
$traitName = self::getClassName($trait);
|
||||
|
||||
/*
|
||||
* Oops, cannot resolve class
|
||||
*/
|
||||
// Oops, cannot resolve class
|
||||
if (null === $className || '' === $className) {
|
||||
throw CannotResolveClassNameException::create($class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Oops, cannot resolve trait
|
||||
*/
|
||||
// Oops, cannot resolve trait
|
||||
if (null === $traitName || '' === $traitName) {
|
||||
throw new CannotResolveClassNameException($class, false);
|
||||
}
|
||||
@@ -646,7 +639,7 @@ class Reflection
|
||||
* If given class does not extend another, returns null.
|
||||
*
|
||||
* @param array|object|string $class An array of objects, namespaces, object or namespace
|
||||
* @return string|null
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getParentClassName($class)
|
||||
{
|
||||
@@ -673,9 +666,7 @@ class Reflection
|
||||
{
|
||||
$reflectionProperty = self::getProperty($object, $property);
|
||||
|
||||
/*
|
||||
* Oops, property does not exist
|
||||
*/
|
||||
// Oops, property does not exist
|
||||
if (null === $reflectionProperty) {
|
||||
throw NotExistingPropertyException::create($object, $property);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ class Regex
|
||||
|
||||
eval(sprintf('$isEqual = %s%s;', $value, $filterExpression));
|
||||
|
||||
/* @var bool $isEqual */
|
||||
/** @var bool $isEqual */
|
||||
$remove = !$isEqual;
|
||||
}
|
||||
|
||||
@@ -317,6 +317,7 @@ class Regex
|
||||
$effect = $effect && $matched;
|
||||
} elseif ($matched) {
|
||||
$effect = $matched;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -458,14 +459,10 @@ class Regex
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* I have to escape all slashes (directory separators): "/" -> "\/"
|
||||
*/
|
||||
// I have to escape all slashes (directory separators): "/" -> "\/"
|
||||
$prepared = preg_quote($path, '/');
|
||||
|
||||
/*
|
||||
* Slash at the ending is optional
|
||||
*/
|
||||
// Slash at the ending is optional
|
||||
if (self::endsWith($path, '/')) {
|
||||
$prepared .= '?';
|
||||
}
|
||||
@@ -775,7 +772,7 @@ class Regex
|
||||
* (default behaviour). Otherwise - not.
|
||||
* @throws IncorrectColorHexLengthException
|
||||
* @throws InvalidColorHexValueException
|
||||
* @return string|bool
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function getValidColorHexValue($color, $throwException = true)
|
||||
{
|
||||
@@ -986,7 +983,7 @@ class Regex
|
||||
* Returns slug for given value
|
||||
*
|
||||
* @param string $value Value that should be transformed to slug
|
||||
* @return string|bool
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function createSlug($value)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class Repository
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const POSITION_KEY = 'position';
|
||||
public const POSITION_KEY = 'position';
|
||||
|
||||
/**
|
||||
* Replenishes positions of given items
|
||||
@@ -57,24 +57,17 @@ class Repository
|
||||
}
|
||||
|
||||
foreach ($items as &$item) {
|
||||
/*
|
||||
* The item is not sortable?
|
||||
*/
|
||||
// Not sortable?
|
||||
if (!self::isSortable($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Position has been set?
|
||||
* Nothing to do
|
||||
*/
|
||||
// Sorted already (position has been set)?
|
||||
if (self::isSorted($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate position
|
||||
*/
|
||||
// Calculate position
|
||||
if ($asLast) {
|
||||
++$position;
|
||||
} else {
|
||||
@@ -87,6 +80,7 @@ class Repository
|
||||
*/
|
||||
if (is_object($item)) {
|
||||
$item->setPosition($position);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -118,31 +112,23 @@ class Repository
|
||||
$extreme = null;
|
||||
|
||||
foreach ($items as $item) {
|
||||
/*
|
||||
* The item is not sortable?
|
||||
*/
|
||||
// Not sortable?
|
||||
if (!self::isSortable($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$position = null;
|
||||
|
||||
/*
|
||||
* Let's grab the position
|
||||
*/
|
||||
// Let's grab the position
|
||||
if (is_object($item)) {
|
||||
$position = $item->getPosition();
|
||||
} elseif (array_key_exists(static::POSITION_KEY, $item)) {
|
||||
$position = $item[static::POSITION_KEY];
|
||||
}
|
||||
|
||||
/*
|
||||
* Maximum value is expected?
|
||||
*/
|
||||
// Maximum value is expected?
|
||||
if ($max) {
|
||||
/*
|
||||
* Position was found and it's larger than previously found position (the extreme position)?
|
||||
*/
|
||||
// Position was found and it's larger than previously found position (the extreme position)?
|
||||
if (null === $extreme || (null !== $position && $position > $extreme)) {
|
||||
$extreme = $position;
|
||||
}
|
||||
@@ -218,17 +204,12 @@ class Repository
|
||||
*/
|
||||
private static function isSorted($item)
|
||||
{
|
||||
/*
|
||||
* Given item is not sortable?
|
||||
*/
|
||||
// Not sortable?
|
||||
if (!self::isSortable($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* It's an object or it's an array
|
||||
* and position has been set?
|
||||
*/
|
||||
// It's an object or it's an array and position has been set?
|
||||
|
||||
return
|
||||
(is_object($item) && null !== $item->getPosition())
|
||||
|
||||
@@ -90,9 +90,7 @@ class Uri
|
||||
* $matches[2] - protocol version, e.g. 1.1
|
||||
*/
|
||||
|
||||
/*
|
||||
* Oops, cannot match protocol
|
||||
*/
|
||||
// Oops, cannot match protocol
|
||||
if (0 === $matchCount) {
|
||||
return '';
|
||||
}
|
||||
@@ -244,9 +242,7 @@ class Uri
|
||||
$currentUrl = self::getServerNameOrIp(true);
|
||||
$url = self::replenishProtocol($url);
|
||||
|
||||
/*
|
||||
* Let's prepare pattern of current url
|
||||
*/
|
||||
// Let's prepare pattern of current url
|
||||
$search = [
|
||||
':',
|
||||
'/',
|
||||
@@ -274,9 +270,7 @@ class Uri
|
||||
*/
|
||||
public static function replenishProtocol($url, $protocol = '')
|
||||
{
|
||||
/*
|
||||
* Let's trim the url
|
||||
*/
|
||||
// Let's trim the url
|
||||
if (is_string($url)) {
|
||||
$url = trim($url);
|
||||
}
|
||||
@@ -297,9 +291,7 @@ class Uri
|
||||
return $url;
|
||||
}
|
||||
|
||||
/*
|
||||
* Protocol is not provided?
|
||||
*/
|
||||
// Protocol is not provided?
|
||||
if (empty($protocol)) {
|
||||
$protocol = self::getProtocolName();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Company
|
||||
*
|
||||
* @param string $name Name of company
|
||||
* @param Address $address Address of company
|
||||
* @param BankAccount|null $bankAccount (optional) Bank account of company
|
||||
* @param null|BankAccount $bankAccount (optional) Bank account of company
|
||||
*/
|
||||
public function __construct($name, Address $address, BankAccount $bankAccount = null)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ class Company
|
||||
/**
|
||||
* Returns bank account of company
|
||||
*
|
||||
* @return BankAccount|null
|
||||
* @return null|BankAccount
|
||||
*/
|
||||
public function getBankAccount()
|
||||
{
|
||||
|
||||
@@ -195,7 +195,7 @@ class Size
|
||||
* @param string $size The size represented as string (width and height separated by given separator)
|
||||
* @param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px".
|
||||
* @param string $separator (optional) Separator used to split width and height. Default: " x ".
|
||||
* @return Size|null
|
||||
* @return null|Size
|
||||
*/
|
||||
public static function fromString($size, $unit = 'px', $separator = ' x ')
|
||||
{
|
||||
@@ -223,7 +223,7 @@ class Size
|
||||
*
|
||||
* @param array $array The size represented as array
|
||||
* @param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px".
|
||||
* @return Size|null
|
||||
* @return null|Size
|
||||
*/
|
||||
public static function fromArray(array $array, $unit = 'px')
|
||||
{
|
||||
|
||||
@@ -54,6 +54,16 @@ class Version
|
||||
$this->patchPart = $patchPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns representation of object as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%d.%d.%d', $this->getMajorPart(), $this->getMinorPart(), $this->getPatchPart());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the "major" part.
|
||||
* Incremented when you make incompatible API changes.
|
||||
@@ -87,16 +97,6 @@ class Version
|
||||
return $this->patchPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns representation of object as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%d.%d.%d', $this->getMajorPart(), $this->getMinorPart(), $this->getPatchPart());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new instance based on given version as string.
|
||||
* Given version should contain 3 dot-separated integers, 1 per each part ("major", "minor" and "patch").
|
||||
@@ -106,7 +106,7 @@ class Version
|
||||
* "10.4.0";
|
||||
*
|
||||
* @param string $version The version
|
||||
* @return Version|null
|
||||
* @return null|Version
|
||||
*/
|
||||
public static function fromString(string $version)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ class Version
|
||||
* [10, 4, 0];
|
||||
*
|
||||
* @param array $version The version
|
||||
* @return Version|null
|
||||
* @return null|Version
|
||||
*/
|
||||
public static function fromArray(array $version)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user