From 8eed212cb0e5cfcbcb7a4bb5cb4f04d7e0fc3b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lajos=20M=C3=A9sz=C3=A1ros?= Date: Thu, 22 Apr 2021 14:35:56 +0200 Subject: [PATCH] Moved TODOs in code to tickets and credited sources in readme --- README.md | 8 ++++++++ src/A.php | 7 ++----- src/S.php | 4 ---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2a00aa0..8ab3b18 100644 --- a/README.md +++ b/README.md @@ -357,3 +357,11 @@ Plus, sometimes the function name I would like to use is already taken by PHP, l ## Misc information - ÁSÓ in hungarian means shovel + +## Credits + +https://www.geeksforgeeks.org/php-startswith-and-endswith-functions/ - used for S::startsWith() and S::endsWith() + +https://stackoverflow.com/a/173479/1806628 - used for A::isAssoc() + +https://www.php.net/manual/en/function.array-unique.php#116302 - used for A::uniqByKey() diff --git a/src/A.php b/src/A.php index a088e53..3cfd51e 100644 --- a/src/A.php +++ b/src/A.php @@ -19,7 +19,6 @@ public static function isArray($data): bool } // A::isAssoc(['a' => 12]) -> true - // https://stackoverflow.com/a/173479/1806628 public static function isAssoc(array $data): bool { if (self::isEmpty($data)) { @@ -131,7 +130,6 @@ public static function uniq(array $data): array } // A::uniqByKey('color', [['color' => 'red', ...], ['color' => 'red', ...]]) -> [['color => 'red', ...]] - // https://www.php.net/manual/en/function.array-unique.php#116302 public static function uniqByKey($key, array $data): array { $i = 0; @@ -204,8 +202,8 @@ public static function sortByKey( // A::unnest([[1, 2, 3], [3, 4, [5]]]) -> [1, 2, 3, 3, 4, [5]] public static function unnest($data, int $levels = 1): array { - // TODO: implementálni azt, hogy több level-re legyen jó - // talán elég csak annyi, hogy rekurzívan meghívjuk az unnest-et, amíg $levels-- > 0 + // TODO: implement this to work with any $levels + // it might be enought just to do a recursion until --$levels === 0 return self::reduce( function ($acc, $x) { return self::append($x, $acc); @@ -296,7 +294,6 @@ public static function includes($value, array $data): bool // A::slice(2, 4, [1, 2, 3, 4, 5]) -> [3, 4, 5] public static function slice(int $fromIndex, int $toIndex, array $data): array { - // TODO: make it work with negative numbers return array_slice($data, $fromIndex, $toIndex); } diff --git a/src/S.php b/src/S.php index 10dd1d1..d21b0eb 100644 --- a/src/S.php +++ b/src/S.php @@ -59,8 +59,6 @@ public static function includes( // S::split(' ', "aab bbc ccd") -> ['aab', 'bbc', 'ccd'] public static function split(string $separator, string $data): array { - // TODO: ez nem biztos, hogy UTF-8 kompatibilis - // https://www.php.net/manual/en/function.mb-strtolower.php#118378 return explode($separator, $data); } @@ -93,7 +91,6 @@ public static function slice(int $startPos, int $endPos, string $data): string } // S::startsWith("ab", "abcd") -> true - // https://www.geeksforgeeks.org/php-startswith-and-endswith-functions/ public static function startsWith( string $startString, string $data, @@ -107,7 +104,6 @@ public static function startsWith( } // S::endsWith("ab", "abcd") -> false - // https://www.geeksforgeeks.org/php-startswith-and-endswith-functions/ public static function endsWith( string $endString, string $data,