forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
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
18 changed files
with
116 additions
and
291 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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
* Normalizes a composite identifier. | ||
* | ||
* @author Antoine Bluchet <[email protected]> | ||
* @deprecated | ||
*/ | ||
final class CompositeIdentifierParser | ||
{ | ||
|
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
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 |
---|---|---|
|
@@ -13,15 +13,11 @@ | |
|
||
namespace ApiPlatform\Exception; | ||
|
||
use ApiPlatform\Metadata\Exception\InvalidArgumentException as MetadataInvalidArgumentException; | ||
|
||
/** | ||
* Invalid argument exception. | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
* | ||
* @deprecated use \ApiPlatform\Metadata\Exception\InvalidArgumentException | ||
*/ | ||
class InvalidArgumentException extends MetadataInvalidArgumentException | ||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface | ||
{ | ||
} |
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 |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
* | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
final class InvalidIdentifierException extends \Exception implements ExceptionInterface | ||
class InvalidIdentifierException extends \Exception implements ExceptionInterface | ||
{ | ||
} |
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 |
---|---|---|
|
@@ -17,8 +17,6 @@ | |
* Identifier is not valid exception. | ||
* | ||
* @author Antoine Bluchet <[email protected]> | ||
* | ||
* @final | ||
*/ | ||
class InvalidUriVariableException extends \Exception implements ExceptionInterface | ||
{ | ||
|
This file was deleted.
Oops, something went wrong.
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
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,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Metadata\Exception; | ||
|
||
use ApiPlatform\Exception\InvalidIdentifierException as LegacyInvalidIdentifierException; | ||
|
||
if (class_exists(LegacyInvalidIdentifierException::class)) { | ||
class InvalidIdentifierException extends LegacyInvalidIdentifierException | ||
{ | ||
} | ||
} else { | ||
/** | ||
* Identifier is not valid exception. | ||
* | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
final class InvalidIdentifierException extends \Exception implements ExceptionInterface | ||
{ | ||
} | ||
} |
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
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
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,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Metadata\Util; | ||
|
||
/** | ||
* Normalizes a composite identifier. | ||
* | ||
* @internal | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
final class CompositeIdentifierParser | ||
{ | ||
public const COMPOSITE_IDENTIFIER_REGEXP = '/(\w+)=(?<=\w=)(.*?)(?=;\w+=)|(\w+)=([^;]*);?$/'; | ||
|
||
private function __construct() | ||
{ | ||
} | ||
|
||
/* | ||
* Normalize takes a string and gives back an array of identifiers. | ||
* | ||
* For example: foo=0;bar=2 returns ['foo' => 0, 'bar' => 2]. | ||
*/ | ||
public static function parse(string $identifier): array | ||
{ | ||
$matches = []; | ||
$identifiers = []; | ||
$num = preg_match_all(self::COMPOSITE_IDENTIFIER_REGEXP, $identifier, $matches, \PREG_SET_ORDER); | ||
|
||
foreach ($matches as $i => $match) { | ||
if ($i === $num - 1) { | ||
$identifiers[$match[3]] = $match[4]; | ||
continue; | ||
} | ||
$identifiers[$match[1]] = $match[2]; | ||
} | ||
|
||
return $identifiers; | ||
} | ||
|
||
/** | ||
* Renders composite identifiers to string using: key=value;key2=value2. | ||
*/ | ||
public static function stringify(array $identifiers): string | ||
{ | ||
$composite = []; | ||
foreach ($identifiers as $name => $value) { | ||
$composite[] = sprintf('%s=%s', $name, $value); | ||
} | ||
|
||
return implode(';', $composite); | ||
} | ||
} |
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
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
Oops, something went wrong.