mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Tests > refactoring & minor improvements
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
Common and useful classes, methods, exceptions etc.
|
Common and useful classes, methods, exceptions etc.
|
||||||
|
|
||||||
|
# 0.1.3
|
||||||
|
|
||||||
|
1. Tests > refactoring & minor improvements
|
||||||
|
|
||||||
# 0.1.2
|
# 0.1.2
|
||||||
|
|
||||||
1. Documentation > Value Objects
|
1. Documentation > Value Objects
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6",
|
"php": ">=5.6",
|
||||||
|
"ext-intl": "*",
|
||||||
"ext-pcre": "*",
|
"ext-pcre": "*",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5",
|
||||||
"gedmo/doctrine-extensions": "^2.4"
|
"gedmo/doctrine-extensions": "^2.4"
|
||||||
|
|||||||
@@ -119,11 +119,15 @@ class Date
|
|||||||
$lastMonth = self::getDatesForPeriod(DatePeriod::LAST_MONTH);
|
$lastMonth = self::getDatesForPeriod(DatePeriod::LAST_MONTH);
|
||||||
$nextMonth = self::getDatesForPeriod(DatePeriod::NEXT_MONTH);
|
$nextMonth = self::getDatesForPeriod(DatePeriod::NEXT_MONTH);
|
||||||
|
|
||||||
$dateStart = $lastMonth->getEndDate();
|
if (null !== $lastMonth) {
|
||||||
$dateStart->add(new DateInterval('P1D'));
|
$dateStart = $lastMonth->getEndDate();
|
||||||
|
$dateStart->add(new DateInterval('P1D'));
|
||||||
|
}
|
||||||
|
|
||||||
$dateEnd = $nextMonth->getStartDate();
|
if (null !== $nextMonth) {
|
||||||
$dateEnd->sub(new DateInterval('P1D'));
|
$dateEnd = $nextMonth->getStartDate();
|
||||||
|
$dateEnd->sub(new DateInterval('P1D'));
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DatePeriod::NEXT_MONTH:
|
case DatePeriod::NEXT_MONTH:
|
||||||
@@ -137,10 +141,10 @@ class Date
|
|||||||
$dateStart = new DateTime();
|
$dateStart = new DateTime();
|
||||||
$dateEnd = new DateTime();
|
$dateEnd = new DateTime();
|
||||||
|
|
||||||
if (DatePeriod::LAST_YEAR == $period || DatePeriod::NEXT_YEAR == $period) {
|
if (DatePeriod::LAST_YEAR === $period || DatePeriod::NEXT_YEAR === $period) {
|
||||||
$yearDifference = 1;
|
$yearDifference = 1;
|
||||||
|
|
||||||
if (DatePeriod::LAST_YEAR == $period) {
|
if (DatePeriod::LAST_YEAR === $period) {
|
||||||
$yearDifference *= -1;
|
$yearDifference *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +224,6 @@ class Date
|
|||||||
/**
|
/**
|
||||||
* Returns current day of week
|
* Returns current day of week
|
||||||
*
|
*
|
||||||
* @throws UnknownDatePartTypeException
|
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getCurrentDayOfWeek()
|
public static function getCurrentDayOfWeek()
|
||||||
@@ -368,11 +371,11 @@ class Date
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dateStart = self::getDateTime($dateStart, true);
|
$start = self::getDateTime($dateStart, true);
|
||||||
$dateEnd = self::getDateTime($dateEnd, true);
|
$end = self::getDateTime($dateEnd, true);
|
||||||
|
|
||||||
$difference = [];
|
$difference = [];
|
||||||
$dateDiff = $dateEnd->getTimestamp() - $dateStart->getTimestamp();
|
$dateDiff = $end->getTimestamp() - $start->getTimestamp();
|
||||||
|
|
||||||
$daysInSeconds = 0;
|
$daysInSeconds = 0;
|
||||||
$hoursInSeconds = 0;
|
$hoursInSeconds = 0;
|
||||||
@@ -390,39 +393,39 @@ class Date
|
|||||||
self::DATE_DIFFERENCE_UNIT_MINUTES,
|
self::DATE_DIFFERENCE_UNIT_MINUTES,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS == $differenceUnit) {
|
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
|
||||||
$diff = $dateEnd->diff($dateStart);
|
$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) {
|
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
|
||||||
return $diff->y;
|
return $diff->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
|
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS == $differenceUnit) {
|
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
|
||||||
$diff = $dateEnd->diff($dateStart);
|
$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) {
|
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
|
||||||
return $diff->m;
|
return $diff->m;
|
||||||
}
|
}
|
||||||
|
|
||||||
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
|
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits)) {
|
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
|
||||||
$days = (int)floor($dateDiff / $daySeconds);
|
$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) {
|
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
|
||||||
return $days;
|
return $days;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,13 +442,13 @@ class Date
|
|||||||
$daysInSeconds = $days * $daySeconds;
|
$daysInSeconds = $days * $daySeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits)) {
|
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
|
||||||
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
|
$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) {
|
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
|
||||||
return $hours;
|
return $hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,13 +465,13 @@ class Date
|
|||||||
$hoursInSeconds = $hours * $hourSeconds;
|
$hoursInSeconds = $hours * $hourSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES == $differenceUnit) {
|
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
|
||||||
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
|
$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) {
|
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
|
||||||
return $minutes;
|
return $minutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,7 +557,7 @@ class Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
$randomDate = clone $startDate;
|
$randomDate = clone $startDate;
|
||||||
$randomInterval = new DateInterval(sprintf($intervalTemplate, rand($start, $end)));
|
$randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));
|
||||||
|
|
||||||
return $randomDate->add($randomInterval);
|
return $randomDate->add($randomInterval);
|
||||||
}
|
}
|
||||||
@@ -637,7 +640,7 @@ class Date
|
|||||||
* So, I have to refuse those special compound formats if they are not explicitly declared as
|
* So, I have to refuse those special compound formats if they are not explicitly declared as
|
||||||
* compound (2nd argument of this method, set to false by default)
|
* compound (2nd argument of this method, set to false by default)
|
||||||
*/
|
*/
|
||||||
if (in_array($value, $specialFormats)) {
|
if (in_array($value, $specialFormats, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,7 +665,7 @@ class Date
|
|||||||
*/
|
*/
|
||||||
$dateString = (new DateTime())->format($value);
|
$dateString = (new DateTime())->format($value);
|
||||||
|
|
||||||
if ($dateString != $value) {
|
if ($dateString !== (string)$value) {
|
||||||
return new DateTime($dateString);
|
return new DateTime($dateString);
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
@@ -706,7 +709,7 @@ class Date
|
|||||||
* Formatted date it's the format who is validated?
|
* Formatted date it's the format who is validated?
|
||||||
* The format is invalid
|
* The format is invalid
|
||||||
*/
|
*/
|
||||||
if ($formatted == $format) {
|
if ($formatted === $format) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
namespace Meritoo\Common\Utilities;
|
namespace Meritoo\Common\Utilities;
|
||||||
|
|
||||||
use Gedmo\Sluggable\Util\Urlizer;
|
use Gedmo\Sluggable\Util\Urlizer;
|
||||||
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
|
||||||
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
|
||||||
use Transliterator;
|
use Transliterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,15 +60,15 @@ class Miscellaneous
|
|||||||
$startFileName = mb_substr($startFileName, 1);
|
$startFileName = mb_substr($startFileName, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$directoryContent = scandir($directoryPath);
|
$directoryContent = scandir($directoryPath, SCANDIR_SORT_ASCENDING);
|
||||||
|
|
||||||
if (!empty($directoryContent)) {
|
if (!empty($directoryContent)) {
|
||||||
foreach ($directoryContent as $fileName) {
|
foreach ($directoryContent as $fileName) {
|
||||||
if ('.' != $fileName && '..' != $fileName) {
|
if ('.' !== $fileName && '..' !== $fileName) {
|
||||||
$content = null;
|
$content = null;
|
||||||
|
|
||||||
if (!empty($startFileName) && !$startFileFound) {
|
if (!empty($startFileName) && !$startFileFound) {
|
||||||
if ($fileName == $startFileName) {
|
if ($fileName === $startFileName) {
|
||||||
$startFileFound = true;
|
$startFileFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,18 +82,18 @@ class Miscellaneous
|
|||||||
if (null !== $content) {
|
if (null !== $content) {
|
||||||
$files[$fileName] = $content;
|
$files[$fileName] = $content;
|
||||||
|
|
||||||
if (!empty($maxFilesCount)) {
|
if (null !== $maxFilesCount) {
|
||||||
$count += Arrays::getNonArrayElementsCount($content);
|
$count += Arrays::getNonArrayElementsCount($content);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$files[] = $fileName;
|
$files[] = $fileName;
|
||||||
|
|
||||||
if (!empty($maxFilesCount)) {
|
if (null !== $maxFilesCount) {
|
||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($maxFilesCount) && $count >= $maxFilesCount) {
|
if (null !== $maxFilesCount && $count >= $maxFilesCount) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,11 +158,17 @@ class Miscellaneous
|
|||||||
*/
|
*/
|
||||||
public static function includeFileExtension($fileName, $extension)
|
public static function includeFileExtension($fileName, $extension)
|
||||||
{
|
{
|
||||||
if (self::getFileExtension($fileName, true) != strtolower($extension)) {
|
$fileExtension = self::getFileExtension($fileName, true);
|
||||||
return sprintf('%s.%s', $fileName, $extension);
|
|
||||||
|
/*
|
||||||
|
* File has given extension?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if ($fileExtension === strtolower($extension)) {
|
||||||
|
return $fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fileName;
|
return sprintf('%s.%s', $fileName, $extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,31 +233,28 @@ class Miscellaneous
|
|||||||
/*
|
/*
|
||||||
* Let's clear name of file
|
* Let's clear name of file
|
||||||
*
|
*
|
||||||
* Attention. The name without extension may be cleared / urlized only
|
* Attention.
|
||||||
* to avoid incorrect name by replacing "." with "-".
|
* The name without extension may be cleared / urlized only to avoid incorrect name by replacing "." with "-".
|
||||||
*/
|
*/
|
||||||
$withoutExtension = Urlizer::urlize($withoutExtension);
|
$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'; // file's name and unique key
|
$template = '%s-%s.%s'; // [file's name]-[unique key].[file's extension]
|
||||||
|
|
||||||
if ($objectId > 0) {
|
|
||||||
$template .= '-%s'; // object ID
|
|
||||||
}
|
|
||||||
|
|
||||||
$template .= '.%s'; // file's extension
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add some uniqueness
|
* Add some uniqueness
|
||||||
*/
|
*/
|
||||||
$unique = uniqid(mt_rand(), true);
|
$unique = self::getUniqueString(mt_rand());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finally build and return the unique name
|
* Finally build and return the unique name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($objectId > 0) {
|
if ($objectId > 0) {
|
||||||
|
$template = '%s-%s-%s.%s'; // [file's name]-[unique key]-[object ID].[file's extension]
|
||||||
|
|
||||||
return sprintf($template, $withoutExtension, $unique, $objectId, $extension);
|
return sprintf($template, $withoutExtension, $unique, $objectId, $extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +334,7 @@ class Miscellaneous
|
|||||||
{
|
{
|
||||||
$phpModulesArray = get_loaded_extensions();
|
$phpModulesArray = get_loaded_extensions();
|
||||||
|
|
||||||
return in_array($phpModuleName, $phpModulesArray);
|
return in_array($phpModuleName, $phpModulesArray, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -461,7 +462,7 @@ class Miscellaneous
|
|||||||
* Value to find is neither a string nor an array OR it's an empty string?
|
* Value to find is neither a string nor an array OR it's an empty string?
|
||||||
* Nothing to do
|
* Nothing to do
|
||||||
*/
|
*/
|
||||||
if ((!$searchIsString && !$searchIsArray) || ($searchIsString && 0 == strlen($search))) {
|
if ((!$searchIsString && !$searchIsArray) || ($searchIsString && '' === $search)) {
|
||||||
return $effect;
|
return $effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +487,7 @@ class Miscellaneous
|
|||||||
* Second step: replace with regular expressions.
|
* Second step: replace with regular expressions.
|
||||||
* Attention. Searched and replacement value should be the same type: strings or arrays.
|
* Attention. Searched and replacement value should be the same type: strings or arrays.
|
||||||
*/
|
*/
|
||||||
if ($effect == $subject && ($bothAreStrings || $bothAreArrays)) {
|
if ($effect === $subject && ($bothAreStrings || $bothAreArrays)) {
|
||||||
if ($quoteStrings && $replacementIsString) {
|
if ($quoteStrings && $replacementIsString) {
|
||||||
$replacement = '\'' . $replacement . '\'';
|
$replacement = '\'' . $replacement . '\'';
|
||||||
}
|
}
|
||||||
@@ -504,7 +505,7 @@ class Miscellaneous
|
|||||||
* Third step: complex replace of the replacement defined as an array.
|
* Third step: complex replace of the replacement defined as an array.
|
||||||
* It may be useful when you want to search for a one string and replace the string with multiple values.
|
* It may be useful when you want to search for a one string and replace the string with multiple values.
|
||||||
*/
|
*/
|
||||||
if ($effect == $subject && $searchIsString && $replacementIsArray) {
|
if ($effect === $subject && $searchIsString && $replacementIsArray) {
|
||||||
$subjectIsArray = is_array($subject);
|
$subjectIsArray = is_array($subject);
|
||||||
$effect = '';
|
$effect = '';
|
||||||
|
|
||||||
@@ -589,7 +590,12 @@ class Miscellaneous
|
|||||||
*/
|
*/
|
||||||
public static function getOperatingSystemNameServer()
|
public static function getOperatingSystemNameServer()
|
||||||
{
|
{
|
||||||
return php_uname('s');
|
return PHP_OS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Previous version:
|
||||||
|
* return php_uname('s');
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -681,7 +687,8 @@ class Miscellaneous
|
|||||||
|
|
||||||
$spacePosition = mb_strrpos($lineWithAberration, ' ', 0, $encoding);
|
$spacePosition = mb_strrpos($lineWithAberration, ' ', 0, $encoding);
|
||||||
|
|
||||||
if ($spacePosition > 0) {
|
if (false !== $spacePosition && 0 < $spacePosition) {
|
||||||
|
/* @var int $spacePosition */
|
||||||
$perLine = $spacePosition;
|
$perLine = $spacePosition;
|
||||||
$insertSeparator = true;
|
$insertSeparator = true;
|
||||||
}
|
}
|
||||||
@@ -738,8 +745,8 @@ class Miscellaneous
|
|||||||
return unlink($directoryPath);
|
return unlink($directoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (scandir($directoryPath) as $item) {
|
foreach (scandir($directoryPath, SCANDIR_SORT_ASCENDING) as $item) {
|
||||||
if ('.' == $item || '..' == $item) {
|
if ('.' === $item || '..' === $item) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,7 +795,7 @@ class Miscellaneous
|
|||||||
foreach ($members as $key => $value) {
|
foreach ($members as $key => $value) {
|
||||||
$value = mb_strtolower($value);
|
$value = mb_strtolower($value);
|
||||||
|
|
||||||
if (0 == $key) {
|
if (0 === $key) {
|
||||||
$effect .= self::lowercaseFirst($value);
|
$effect .= self::lowercaseFirst($value);
|
||||||
} else {
|
} else {
|
||||||
$effect .= self::uppercaseFirst($value);
|
$effect .= self::uppercaseFirst($value);
|
||||||
@@ -809,10 +816,6 @@ class Miscellaneous
|
|||||||
* - null (default): nothing is done with the string
|
* - null (default): nothing is done with the string
|
||||||
* - true: the rest of string is lowercased
|
* - true: the rest of string is lowercased
|
||||||
* - false: the rest of string is uppercased
|
* - false: the rest of string is uppercased
|
||||||
*
|
|
||||||
* Some explanation:
|
|
||||||
* Function lcfirst() is available for PHP >= 5.30, so I wrote my own function that lowercases first character of
|
|
||||||
* the string.
|
|
||||||
*/
|
*/
|
||||||
public static function lowercaseFirst($text, $restLowercase = null)
|
public static function lowercaseFirst($text, $restLowercase = null)
|
||||||
{
|
{
|
||||||
@@ -828,16 +831,7 @@ class Miscellaneous
|
|||||||
$effect = mb_strtoupper($effect);
|
$effect = mb_strtoupper($effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('lcfirst')) {
|
return lcfirst($effect);
|
||||||
$effect = lcfirst($effect);
|
|
||||||
} else {
|
|
||||||
$first = mb_strtolower($effect[0]);
|
|
||||||
$rest = mb_substr($effect, 1);
|
|
||||||
|
|
||||||
$effect = $first . $rest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -866,16 +860,7 @@ class Miscellaneous
|
|||||||
$effect = mb_strtoupper($effect);
|
$effect = mb_strtoupper($effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('ucfirst')) {
|
return ucfirst($effect);
|
||||||
$effect = ucfirst($effect);
|
|
||||||
} else {
|
|
||||||
$first = mb_strtoupper($effect[0]);
|
|
||||||
$rest = mb_substr($effect, 1);
|
|
||||||
|
|
||||||
$effect = $first . $rest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -916,9 +901,9 @@ class Miscellaneous
|
|||||||
'TB',
|
'TB',
|
||||||
'PB',
|
'PB',
|
||||||
];
|
];
|
||||||
$index = floor(log($sizeInBytes, 1024));
|
|
||||||
|
|
||||||
$size = round($sizeInBytes / pow(1024, $index), 2);
|
$index = floor(log($sizeInBytes, 1024));
|
||||||
|
$size = round($sizeInBytes / (1024 ** $index), 2);
|
||||||
$unit = $units[(int)$index];
|
$unit = $units[(int)$index];
|
||||||
|
|
||||||
return sprintf('%s %s', $size, $unit);
|
return sprintf('%s %s', $size, $unit);
|
||||||
@@ -1194,10 +1179,6 @@ class Miscellaneous
|
|||||||
|
|
||||||
if (null !== $globalSource && isset($globalSource[$variableName])) {
|
if (null !== $globalSource && isset($globalSource[$variableName])) {
|
||||||
$value = $globalSource[$variableName];
|
$value = $globalSource[$variableName];
|
||||||
|
|
||||||
if (!ini_get('magic_quotes_gpc')) {
|
|
||||||
$value = addslashes($value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1243,7 +1224,7 @@ class Miscellaneous
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = $text . '0';
|
$text .= '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
@@ -1298,8 +1279,8 @@ class Miscellaneous
|
|||||||
if ($asHexadecimal) {
|
if ($asHexadecimal) {
|
||||||
$hexadecimal = dechex($colorComponent);
|
$hexadecimal = dechex($colorComponent);
|
||||||
|
|
||||||
if (1 == strlen($hexadecimal)) {
|
if (1 === strlen($hexadecimal)) {
|
||||||
return sprintf('0%s', $hexadecimal, $hexadecimal);
|
return sprintf('0%s', $hexadecimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hexadecimal;
|
return $hexadecimal;
|
||||||
@@ -1312,8 +1293,6 @@ class Miscellaneous
|
|||||||
* Returns inverted value of color for given color
|
* Returns inverted value of color for given color
|
||||||
*
|
*
|
||||||
* @param string $color Hexadecimal value of color to invert (with or without hash), e.g. "dd244c" or "#22a5fe"
|
* @param string $color Hexadecimal value of color to invert (with or without hash), e.g. "dd244c" or "#22a5fe"
|
||||||
* @throws IncorrectColorHexLengthException
|
|
||||||
* @throws InvalidColorHexValueException
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getInvertedColor($color)
|
public static function getInvertedColor($color)
|
||||||
@@ -1328,14 +1307,14 @@ class Miscellaneous
|
|||||||
* Verify and get valid value of color.
|
* Verify and get valid value of color.
|
||||||
* An exception will be thrown if the value is not a color.
|
* An exception will be thrown if the value is not a color.
|
||||||
*/
|
*/
|
||||||
$color = Regex::getValidColorHexValue($color);
|
$validColor = Regex::getValidColorHexValue($color);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab color's components
|
* Grab color's components
|
||||||
*/
|
*/
|
||||||
$red = hexdec(substr($color, 0, 2));
|
$red = hexdec(substr($validColor, 0, 2));
|
||||||
$green = hexdec(substr($color, 2, 2));
|
$green = hexdec(substr($validColor, 2, 2));
|
||||||
$blue = hexdec(substr($color, 4, 2));
|
$blue = hexdec(substr($validColor, 4, 2));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate inverted color's components
|
* Calculate inverted color's components
|
||||||
|
|||||||
@@ -517,7 +517,12 @@ letsTest[2] = value_2;';
|
|||||||
self::assertTrue(Arrays::areKeysInArray($keys17, $this->complexArray, false));
|
self::assertTrue(Arrays::areKeysInArray($keys17, $this->complexArray, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLastElementsPaths()
|
public function testGetLastElementsPathsUsingEmptyArray()
|
||||||
|
{
|
||||||
|
self::assertSame([], Arrays::getLastElementsPaths([]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLastElementsPathsUsingDefaults()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Using default separator and other default arguments
|
* Using default separator and other default arguments
|
||||||
@@ -536,7 +541,10 @@ letsTest[2] = value_2;';
|
|||||||
];
|
];
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray));
|
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLastElementsPathsUsingCustomSeparator()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Using custom separator
|
* Using custom separator
|
||||||
*/
|
*/
|
||||||
@@ -555,204 +563,20 @@ letsTest[2] = value_2;';
|
|||||||
];
|
];
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray, $separator));
|
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray, $separator));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Special exception: do not use, stop recursive on the "diam" key
|
* @param string|array $stopIfMatchedBy Patterns of keys or paths that matched will stop the process of path
|
||||||
*/
|
* building and including children of those keys or paths (recursive will
|
||||||
$expected = [
|
* not be used for keys in lower level of given array)
|
||||||
'lorem.ipsum.dolor' => 'sit',
|
* @param string $separator Separator used in resultant strings. Default: ".".
|
||||||
'consectetur' => 'adipiscing',
|
* @param array $expected Expected array
|
||||||
'mollis' => 1234,
|
*
|
||||||
2 => [],
|
* @dataProvider provideStopIfMatchedByForGetLastElementsPaths
|
||||||
'sit.nullam' => 'donec',
|
*/
|
||||||
'sit.aliquet.vitae.ligula' => 'quis',
|
public function testGetLastElementsPathsUsingStopIfMatchedBy($stopIfMatchedBy, $separator, array $expected)
|
||||||
'sit.0' => 'elit',
|
{
|
||||||
'amet.0' => 'iaculis',
|
self::assertEquals($expected, Arrays::getLastElementsPaths($this->superComplexArray, $separator, '', $stopIfMatchedBy));
|
||||||
'amet.1' => 'primis',
|
|
||||||
'lorem.ipsum.diam' => [
|
|
||||||
'non' => 'egestas',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$stopIfMatchedBy = 'diam';
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray, '.', '', $stopIfMatchedBy));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop building of paths on these keys:
|
|
||||||
* - "diam"
|
|
||||||
* - "aliquet"
|
|
||||||
*/
|
|
||||||
$expected = [
|
|
||||||
'lorem . ipsum . dolor' => 'sit',
|
|
||||||
'consectetur' => 'adipiscing',
|
|
||||||
'mollis' => 1234,
|
|
||||||
2 => [],
|
|
||||||
'sit . nullam' => 'donec',
|
|
||||||
'sit . 0' => 'elit',
|
|
||||||
'amet . 0' => 'iaculis',
|
|
||||||
'amet . 1' => 'primis',
|
|
||||||
'lorem . ipsum . diam' => [
|
|
||||||
'non' => 'egestas',
|
|
||||||
],
|
|
||||||
'sit . aliquet' => [
|
|
||||||
'vitae' => [
|
|
||||||
'ligula' => 'quis',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$stopIfMatchedBy = [
|
|
||||||
'diam',
|
|
||||||
'aliquet',
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray, ' . ', '', $stopIfMatchedBy));
|
|
||||||
|
|
||||||
$expected = [
|
|
||||||
'ipsum > quis > vestibulum > porta-1' => [
|
|
||||||
'turpis',
|
|
||||||
'urna',
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-2' => [
|
|
||||||
'tortor' => [
|
|
||||||
'in' => [
|
|
||||||
'dui',
|
|
||||||
'dolor' => [
|
|
||||||
'aliquam',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-3' => [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
],
|
|
||||||
'primis > 0' => [
|
|
||||||
'in',
|
|
||||||
'faucibus',
|
|
||||||
'orci',
|
|
||||||
],
|
|
||||||
'primis > 1' => [
|
|
||||||
'luctus',
|
|
||||||
'et',
|
|
||||||
'ultrices',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop building of paths on more sophisticated keys
|
|
||||||
*/
|
|
||||||
$stopIfMatchedBy = [
|
|
||||||
'porta\-\d+',
|
|
||||||
'^\d+$',
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->superComplexArray, ' > ', '', $stopIfMatchedBy));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop building of paths on these:
|
|
||||||
* - keys
|
|
||||||
* and
|
|
||||||
* - paths (verify paths too)
|
|
||||||
*/
|
|
||||||
$expected = [
|
|
||||||
'lorem > ipsum > dolor' => 'sit',
|
|
||||||
'consectetur' => 'adipiscing',
|
|
||||||
'mollis' => 1234,
|
|
||||||
2 => [],
|
|
||||||
'sit > nullam' => 'donec',
|
|
||||||
'sit > 0' => 'elit',
|
|
||||||
'amet > 0' => 'iaculis',
|
|
||||||
'amet > 1' => 'primis',
|
|
||||||
'lorem > ipsum > diam' => [
|
|
||||||
'non' => 'egestas',
|
|
||||||
],
|
|
||||||
'sit > aliquet > vitae' => [
|
|
||||||
'ligula' => 'quis',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$stopIfMatchedBy = [
|
|
||||||
'diam',
|
|
||||||
'sit > aliquet > vitae',
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->complexArray, ' > ', '', $stopIfMatchedBy));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop building of paths on these paths (verify paths only)
|
|
||||||
*/
|
|
||||||
$expected = [
|
|
||||||
'ipsum > quis > vestibulum > porta-1' => [
|
|
||||||
'turpis',
|
|
||||||
'urna',
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-2 > tortor' => [
|
|
||||||
'in' => [
|
|
||||||
'dui',
|
|
||||||
'dolor' => [
|
|
||||||
'aliquam',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 0' => 1,
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 1' => 2,
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 2' => 3,
|
|
||||||
'primis > 0 > 0' => 'in',
|
|
||||||
'primis > 0 > 1' => 'faucibus',
|
|
||||||
'primis > 0 > 2' => 'orci',
|
|
||||||
'primis > 1' => [
|
|
||||||
'luctus',
|
|
||||||
'et',
|
|
||||||
'ultrices',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$stopIfMatchedBy = [
|
|
||||||
'ipsum > quis > vestibulum > porta-1',
|
|
||||||
'ipsum > quis > vestibulum > porta-2 > tortor',
|
|
||||||
'primis > 1',
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->superComplexArray, ' > ', '', $stopIfMatchedBy));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stop building of paths if path contains any of these part (verify part of paths only)
|
|
||||||
*/
|
|
||||||
$expected = [
|
|
||||||
'ipsum > quis > vestibulum > porta-1' => [
|
|
||||||
'turpis',
|
|
||||||
'urna',
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-2 > tortor > in' => [
|
|
||||||
'dui',
|
|
||||||
'dolor' => [
|
|
||||||
'aliquam',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 0' => 1,
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 1' => 2,
|
|
||||||
'ipsum > quis > vestibulum > porta-3 > 2' => 3,
|
|
||||||
'primis > 0' => [
|
|
||||||
'in',
|
|
||||||
'faucibus',
|
|
||||||
'orci',
|
|
||||||
],
|
|
||||||
'primis > 1' => [
|
|
||||||
'luctus',
|
|
||||||
'et',
|
|
||||||
'ultrices',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$stopIfMatchedBy = [
|
|
||||||
'vestibulum > porta-1',
|
|
||||||
'tortor > in',
|
|
||||||
'[a-z]+ > \d+',
|
|
||||||
];
|
|
||||||
|
|
||||||
self::assertEquals($expected, Arrays::getLastElementsPaths($this->superComplexArray, ' > ', '', $stopIfMatchedBy));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAreAllKeysMatchedByPattern()
|
public function testAreAllKeysMatchedByPattern()
|
||||||
@@ -1760,6 +1584,229 @@ letsTest[2] = value_2;';
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides patterns of keys or paths that matched will stop the process and the expected array for the
|
||||||
|
* getLastElementsPaths() method
|
||||||
|
*
|
||||||
|
* @return \Generator
|
||||||
|
*/
|
||||||
|
public function provideStopIfMatchedByForGetLastElementsPaths()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Special exception: do not use, stop recursive on the "diam" key
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
'diam',
|
||||||
|
'.',
|
||||||
|
[
|
||||||
|
'ipsum.quis.vestibulum.porta-1.0' => 'turpis',
|
||||||
|
'ipsum.quis.vestibulum.porta-1.1' => 'urna',
|
||||||
|
'ipsum.quis.vestibulum.porta-2.tortor.in.0' => 'dui',
|
||||||
|
'ipsum.quis.vestibulum.porta-2.tortor.in.dolor.0' => 'aliquam',
|
||||||
|
'ipsum.quis.vestibulum.porta-3.0' => 1,
|
||||||
|
'ipsum.quis.vestibulum.porta-3.1' => 2,
|
||||||
|
'ipsum.quis.vestibulum.porta-3.2' => 3,
|
||||||
|
'primis.0.0' => 'in',
|
||||||
|
'primis.0.1' => 'faucibus',
|
||||||
|
'primis.0.2' => 'orci',
|
||||||
|
'primis.1.0' => 'luctus',
|
||||||
|
'primis.1.1' => 'et',
|
||||||
|
'primis.1.2' => 'ultrices',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop building of paths on these keys:
|
||||||
|
* - "tortor"
|
||||||
|
* - "primis"
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
[
|
||||||
|
'tortor',
|
||||||
|
'primis',
|
||||||
|
],
|
||||||
|
' . ',
|
||||||
|
[
|
||||||
|
'ipsum . quis . vestibulum . porta-1 . 0' => 'turpis',
|
||||||
|
'ipsum . quis . vestibulum . porta-1 . 1' => 'urna',
|
||||||
|
'ipsum . quis . vestibulum . porta-2 . tortor' => [
|
||||||
|
'in' => [
|
||||||
|
'dui',
|
||||||
|
'dolor' => [
|
||||||
|
'aliquam',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ipsum . quis . vestibulum . porta-3 . 0' => 1,
|
||||||
|
'ipsum . quis . vestibulum . porta-3 . 1' => 2,
|
||||||
|
'ipsum . quis . vestibulum . porta-3 . 2' => 3,
|
||||||
|
'primis' => [
|
||||||
|
[
|
||||||
|
'in',
|
||||||
|
'faucibus',
|
||||||
|
'orci',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'luctus',
|
||||||
|
'et',
|
||||||
|
'ultrices',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop building of paths on more sophisticated keys
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
[
|
||||||
|
'porta\-\d+',
|
||||||
|
'^\d+$',
|
||||||
|
],
|
||||||
|
' > ',
|
||||||
|
[
|
||||||
|
'ipsum > quis > vestibulum > porta-1' => [
|
||||||
|
'turpis',
|
||||||
|
'urna',
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-2' => [
|
||||||
|
'tortor' => [
|
||||||
|
'in' => [
|
||||||
|
'dui',
|
||||||
|
'dolor' => [
|
||||||
|
'aliquam',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-3' => [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
],
|
||||||
|
'primis > 0' => [
|
||||||
|
'in',
|
||||||
|
'faucibus',
|
||||||
|
'orci',
|
||||||
|
],
|
||||||
|
'primis > 1' => [
|
||||||
|
'luctus',
|
||||||
|
'et',
|
||||||
|
'ultrices',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop building of paths on these:
|
||||||
|
* - keys
|
||||||
|
* and
|
||||||
|
* - paths (verify paths too)
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
[
|
||||||
|
'porta-1',
|
||||||
|
'porta-2 > tortor > in',
|
||||||
|
],
|
||||||
|
' > ',
|
||||||
|
[
|
||||||
|
'ipsum > quis > vestibulum > porta-1' => [
|
||||||
|
'turpis',
|
||||||
|
'urna',
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-2 > tortor > in' => [
|
||||||
|
'dui',
|
||||||
|
'dolor' => [
|
||||||
|
'aliquam',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 0' => 1,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 1' => 2,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 2' => 3,
|
||||||
|
'primis > 0 > 0' => 'in',
|
||||||
|
'primis > 0 > 1' => 'faucibus',
|
||||||
|
'primis > 0 > 2' => 'orci',
|
||||||
|
'primis > 1 > 0' => 'luctus',
|
||||||
|
'primis > 1 > 1' => 'et',
|
||||||
|
'primis > 1 > 2' => 'ultrices',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop building of paths on these paths (verify paths only)
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
[
|
||||||
|
'ipsum > quis > vestibulum > porta-1',
|
||||||
|
'ipsum > quis > vestibulum > porta-2 > tortor',
|
||||||
|
'primis > 1',
|
||||||
|
],
|
||||||
|
' > ',
|
||||||
|
[
|
||||||
|
'ipsum > quis > vestibulum > porta-1' => [
|
||||||
|
'turpis',
|
||||||
|
'urna',
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-2 > tortor' => [
|
||||||
|
'in' => [
|
||||||
|
'dui',
|
||||||
|
'dolor' => [
|
||||||
|
'aliquam',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 0' => 1,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 1' => 2,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 2' => 3,
|
||||||
|
'primis > 0 > 0' => 'in',
|
||||||
|
'primis > 0 > 1' => 'faucibus',
|
||||||
|
'primis > 0 > 2' => 'orci',
|
||||||
|
'primis > 1' => [
|
||||||
|
'luctus',
|
||||||
|
'et',
|
||||||
|
'ultrices',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop building of paths if path contains any of these part (verify part of paths only)
|
||||||
|
*/
|
||||||
|
yield[
|
||||||
|
[
|
||||||
|
'vestibulum > porta-1',
|
||||||
|
'tortor > in',
|
||||||
|
'[a-z]+ > \d+',
|
||||||
|
],
|
||||||
|
' > ',
|
||||||
|
[
|
||||||
|
'ipsum > quis > vestibulum > porta-1' => [
|
||||||
|
'turpis',
|
||||||
|
'urna',
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-2 > tortor > in' => [
|
||||||
|
'dui',
|
||||||
|
'dolor' => [
|
||||||
|
'aliquam',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 0' => 1,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 1' => 2,
|
||||||
|
'ipsum > quis > vestibulum > porta-3 > 2' => 3,
|
||||||
|
'primis > 0' => [
|
||||||
|
'in',
|
||||||
|
'faucibus',
|
||||||
|
'orci',
|
||||||
|
],
|
||||||
|
'primis > 1' => [
|
||||||
|
'luctus',
|
||||||
|
'et',
|
||||||
|
'ultrices',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -1877,10 +1924,12 @@ letsTest[2] = value_2;';
|
|||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
unset($this->simpleArray);
|
unset(
|
||||||
unset($this->simpleArrayWithKeys);
|
$this->simpleArray,
|
||||||
unset($this->twoDimensionsArray);
|
$this->simpleArrayWithKeys,
|
||||||
unset($this->complexArray);
|
$this->twoDimensionsArray,
|
||||||
unset($this->superComplexArray);
|
$this->complexArray,
|
||||||
|
$this->superComplexArray
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
$expected = "int(123)\n";
|
$expected = "int(123)\n";
|
||||||
|
|
||||||
if ($xdebugLoaded) {
|
if ($xdebugLoaded) {
|
||||||
$libraryPath = realpath(sprintf('%s%s', dirname(__FILE__), '/../..'));
|
$libraryPath = realpath(sprintf('%s%s', __DIR__, '/../..'));
|
||||||
$filePath = sprintf('%s%s', $libraryPath, '/src/Utilities/Miscellaneous.php:');
|
$filePath = sprintf('%s%s', $libraryPath, '/src/Utilities/Miscellaneous.php:');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -348,7 +348,10 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testGetOperatingSystemNameServer()
|
public function testGetOperatingSystemNameServer()
|
||||||
{
|
{
|
||||||
self::assertEquals(php_uname('s'), Miscellaneous::getOperatingSystemNameServer());
|
/*
|
||||||
|
* While running Docker OS is a Linux
|
||||||
|
*/
|
||||||
|
self::assertEquals('Linux', Miscellaneous::getOperatingSystemNameServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubstringToWord()
|
public function testSubstringToWord()
|
||||||
|
|||||||
Reference in New Issue
Block a user