diff --git a/composer.json b/composer.json index 4e42f2cb..b69306cf 100644 --- a/composer.json +++ b/composer.json @@ -83,6 +83,7 @@ "Shlinkio\\Shlink\\Core\\": "module/Core/src" }, "files": [ + "config/constants.php", "module/Core/functions/functions.php" ] }, diff --git a/config/autoload/delete_short_urls.global.php b/config/autoload/delete_short_urls.global.php index 986b33ac..7f64abd7 100644 --- a/config/autoload/delete_short_urls.global.php +++ b/config/autoload/delete_short_urls.global.php @@ -6,7 +6,7 @@ namespace Shlinkio\Shlink; use function Shlinkio\Shlink\Common\env; -use const Shlinkio\Shlink\Core\DEFAULT_DELETE_SHORT_URL_THRESHOLD; +use const Shlinkio\Shlink\DEFAULT_DELETE_SHORT_URL_THRESHOLD; return [ diff --git a/config/autoload/locks.global.php b/config/autoload/locks.global.php index 35f4e90c..60054147 100644 --- a/config/autoload/locks.global.php +++ b/config/autoload/locks.global.php @@ -9,7 +9,7 @@ use Symfony\Component\Lock; use function Shlinkio\Shlink\Common\env; -use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY; +use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY; return [ diff --git a/config/autoload/url-shortener.global.php b/config/autoload/url-shortener.global.php index 5193ee1b..432c63e1 100644 --- a/config/autoload/url-shortener.global.php +++ b/config/autoload/url-shortener.global.php @@ -4,10 +4,10 @@ declare(strict_types=1); use function Shlinkio\Shlink\Common\env; -use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_CACHE_LIFETIME; -use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_STATUS_CODE; -use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH; -use const Shlinkio\Shlink\Core\MIN_SHORT_CODES_LENGTH; +use const Shlinkio\Shlink\DEFAULT_REDIRECT_CACHE_LIFETIME; +use const Shlinkio\Shlink\DEFAULT_REDIRECT_STATUS_CODE; +use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH; +use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH; return (static function (): array { $webhooks = env('VISITS_WEBHOOKS'); diff --git a/config/constants.php b/config/constants.php new file mode 100644 index 00000000..5a270e3c --- /dev/null +++ b/config/constants.php @@ -0,0 +1,16 @@ +]*>(.*?)<\/title>/i'; // Matches the value inside an html title tag diff --git a/config/container.php b/config/container.php index 7b6f0b08..56fb345d 100644 --- a/config/container.php +++ b/config/container.php @@ -5,7 +5,7 @@ declare(strict_types=1); use Laminas\ServiceManager\ServiceManager; use Symfony\Component\Lock; -use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY; +use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY; chdir(dirname(__DIR__)); diff --git a/module/CLI/config/dependencies.config.php b/module/CLI/config/dependencies.config.php index 95ea1bbc..d89a8af2 100644 --- a/module/CLI/config/dependencies.config.php +++ b/module/CLI/config/dependencies.config.php @@ -24,7 +24,7 @@ use Symfony\Component\Console as SymfonyCli; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Process\PhpExecutableFinder; -use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY; +use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY; return [ diff --git a/module/Core/functions/functions.php b/module/Core/functions/functions.php index 9ba4bdcc..bba0c17b 100644 --- a/module/Core/functions/functions.php +++ b/module/Core/functions/functions.php @@ -6,7 +6,6 @@ namespace Shlinkio\Shlink\Core; use Cake\Chronos\Chronos; use DateTimeInterface; -use Fig\Http\Message\StatusCodeInterface; use Jaybizzle\CrawlerDetect\CrawlerDetect; use Laminas\InputFilter\InputFilter; use PUGX\Shortid\Factory as ShortIdFactory; @@ -22,15 +21,6 @@ use function str_repeat; use function str_replace; use function ucwords; -const DEFAULT_DELETE_SHORT_URL_THRESHOLD = 15; -const DEFAULT_SHORT_CODES_LENGTH = 5; -const MIN_SHORT_CODES_LENGTH = 4; -const DEFAULT_REDIRECT_STATUS_CODE = StatusCodeInterface::STATUS_FOUND; -const DEFAULT_REDIRECT_CACHE_LIFETIME = 30; -const LOCAL_LOCK_FACTORY = 'Shlinkio\Shlink\LocalLockFactory'; -const CUSTOM_SLUGS_REGEXP = '/[^\pL\pN._~]/u'; // Any unicode letter or number, plus ".", "_" and "~" chars -const TITLE_TAG_VALUE = '/]*>(.*?)<\/title>/i'; // Matches the value inside an html title tag - function generateRandomShortCode(int $length): string { static $shortIdFactory; diff --git a/module/Core/src/Model/ShortUrlMeta.php b/module/Core/src/Model/ShortUrlMeta.php index 06e0eee7..0c982f17 100644 --- a/module/Core/src/Model/ShortUrlMeta.php +++ b/module/Core/src/Model/ShortUrlMeta.php @@ -14,7 +14,7 @@ use function Shlinkio\Shlink\Core\getOptionalBoolFromInputFilter; use function Shlinkio\Shlink\Core\getOptionalIntFromInputFilter; use function Shlinkio\Shlink\Core\parseDateField; -use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH; +use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH; final class ShortUrlMeta implements TitleResolutionModelInterface { diff --git a/module/Core/src/Options/DeleteShortUrlsOptions.php b/module/Core/src/Options/DeleteShortUrlsOptions.php index 9fa7fcf0..ff1c356a 100644 --- a/module/Core/src/Options/DeleteShortUrlsOptions.php +++ b/module/Core/src/Options/DeleteShortUrlsOptions.php @@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\Core\Options; use Laminas\Stdlib\AbstractOptions; -use const Shlinkio\Shlink\Core\DEFAULT_DELETE_SHORT_URL_THRESHOLD; +use const Shlinkio\Shlink\DEFAULT_DELETE_SHORT_URL_THRESHOLD; class DeleteShortUrlsOptions extends AbstractOptions { diff --git a/module/Core/src/Options/UrlShortenerOptions.php b/module/Core/src/Options/UrlShortenerOptions.php index 31ecc137..f760220e 100644 --- a/module/Core/src/Options/UrlShortenerOptions.php +++ b/module/Core/src/Options/UrlShortenerOptions.php @@ -8,8 +8,8 @@ use Laminas\Stdlib\AbstractOptions; use function Functional\contains; -use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_CACHE_LIFETIME; -use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_STATUS_CODE; +use const Shlinkio\Shlink\DEFAULT_REDIRECT_CACHE_LIFETIME; +use const Shlinkio\Shlink\DEFAULT_REDIRECT_STATUS_CODE; class UrlShortenerOptions extends AbstractOptions { diff --git a/module/Core/src/Util/UrlValidator.php b/module/Core/src/Util/UrlValidator.php index 0756f55e..5b84c5f8 100644 --- a/module/Core/src/Util/UrlValidator.php +++ b/module/Core/src/Util/UrlValidator.php @@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Options\UrlShortenerOptions; use function preg_match; use function trim; -use const Shlinkio\Shlink\Core\TITLE_TAG_VALUE; +use const Shlinkio\Shlink\TITLE_TAG_VALUE; class UrlValidator implements UrlValidatorInterface, RequestMethodInterface { diff --git a/module/Core/src/Validation/ShortUrlInputFilter.php b/module/Core/src/Validation/ShortUrlInputFilter.php index b969d95e..fd5a92e7 100644 --- a/module/Core/src/Validation/ShortUrlInputFilter.php +++ b/module/Core/src/Validation/ShortUrlInputFilter.php @@ -13,8 +13,8 @@ use Shlinkio\Shlink\Common\Validation; use Shlinkio\Shlink\Core\Util\CocurSymfonySluggerBridge; use Shlinkio\Shlink\Rest\Entity\ApiKey; -use const Shlinkio\Shlink\Core\CUSTOM_SLUGS_REGEXP; -use const Shlinkio\Shlink\Core\MIN_SHORT_CODES_LENGTH; +use const Shlinkio\Shlink\CUSTOM_SLUGS_REGEXP; +use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH; class ShortUrlInputFilter extends InputFilter { diff --git a/module/Core/test/Entity/ShortUrlTest.php b/module/Core/test/Entity/ShortUrlTest.php index 89ccc805..d41357cd 100644 --- a/module/Core/test/Entity/ShortUrlTest.php +++ b/module/Core/test/Entity/ShortUrlTest.php @@ -16,7 +16,7 @@ use function Functional\map; use function range; use function strlen; -use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH; +use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH; class ShortUrlTest extends TestCase {