Created shortcode creation rest endpoint

This commit is contained in:
Alejandro Celaya
2016-06-12 17:51:30 +02:00
parent 8a7d5a499e
commit 1fbefbbd15
4 changed files with 135 additions and 2 deletions

26
src/Util/RestUtils.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
namespace Acelaya\UrlShortener\Util;
use Acelaya\UrlShortener\Exception\ExceptionInterface;
use Acelaya\UrlShortener\Exception\InvalidShortCodeException;
use Acelaya\UrlShortener\Exception\InvalidUrlException;
class RestUtils
{
const INVALID_SHORTCODE_ERROR = 'INVALID_SHORTCODE';
const INVALID_URL_ERROR = 'INVALID_URL';
const INVALID_ARGUMENT_ERROR = 'INVALID_ARGUMEN';
const UNKNOWN_ERROR = 'UNKNOWN_ERROR';
public static function getRestErrorCodeFromException(ExceptionInterface $e)
{
switch (true) {
case $e instanceof InvalidShortCodeException:
return self::INVALID_SHORTCODE_ERROR;
case $e instanceof InvalidUrlException:
return self::INVALID_URL_ERROR;
default:
return self::UNKNOWN_ERROR;
}
}
}