-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea/ | ||
.code/ | ||
vendor/ | ||
|
||
.env | ||
.DS_Store | ||
|
||
composer.lock | ||
index.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "ninetynine/url", | ||
"description": "A package which offers a helper to build URLs", | ||
"minimum-stability": "dev", | ||
"type": "library", | ||
"license": "LGPL-3.0", | ||
"keywords": [ | ||
"helpers", | ||
"php" | ||
], | ||
"homepage": "https://github.com/ninetynine/url", | ||
"support": { | ||
"issues": "https://github.com/ninetynine/url/issues", | ||
"source": "https://github.com/ninetynine/url" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Dexter Marks-Barber", | ||
"email": "dexter@marks-barber.co.uk", | ||
"role": "Maintainer" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.0.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"NinetyNine\\Url\\": "src/NinetyNine/Url" | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "0.x-dev" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/NinetyNine/Url/Exceptions/InvalidArrayElementException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace NinetyNine\Url\Exceptions; | ||
|
||
class InvalidArrayElementException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace NinetyNine\Url\Exceptions; | ||
|
||
class InvalidArrayException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace NinetyNine\Url\Exceptions; | ||
|
||
class InvalidProtocolException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
namespace NinetyNine\Url\Helpers; | ||
|
||
use NinetyNine\Url\Exceptions\InvalidArrayException; | ||
|
||
class Methods | ||
{ | ||
/** | ||
* Check if an array is associative or not | ||
* | ||
* @param array $array | ||
* @return bool | ||
*/ | ||
public static function isAssociative(array $array) | ||
{ | ||
return !empty($array) && array_keys($array) !== range(0, count($array) - 1); | ||
} | ||
|
||
/** | ||
* Check if an array is associative or not and throw | ||
* | ||
* @param array $array | ||
* @throws InvalidArrayException | ||
* @return void | ||
*/ | ||
public static function isAssociativeVolatile(array $array) | ||
{ | ||
if (!static::isAssociative($array)) { | ||
throw new InvalidArrayException; | ||
} | ||
} | ||
|
||
/** | ||
* Flattern an array | ||
* | ||
* @param array $array | ||
* @param array $tmp | ||
* @return array | ||
*/ | ||
public static function flattern(array $array, &$tmp = []) | ||
{ | ||
foreach ($array as $element) { | ||
if (!is_array($element)) { | ||
$tmp[] = $element; | ||
|
||
continue; | ||
} | ||
|
||
$tmp = static::flattern($element, $tmp); | ||
} | ||
|
||
return $tmp; | ||
} | ||
|
||
/** | ||
* Remove an array element | ||
* | ||
* @param string|int $key | ||
* @param array $array | ||
* @return array | ||
*/ | ||
public static function remove($key, array &$array) | ||
{ | ||
unset($array[ $key ]); | ||
|
||
return $array; | ||
} | ||
} |
Oops, something went wrong.