1<?php 2 3namespace ComboStrap\Web; 4 5use ComboStrap\ExceptionBadArgument; 6use ComboStrap\ExceptionBadSyntax; 7use ComboStrap\LogUtility; 8use ComboStrap\Site; 9use ComboStrap\Web\Url; 10 11class UrlEndpoint 12{ 13 14 const LIB_EXE_FETCH_PHP = '/lib/exe/fetch.php'; 15 const LIB_EXE_DETAIL_PHP = '/lib/exe/detail.php'; 16 const LIB_EXE_RUNNER_PHP = '/lib/exe/taskrunner.php'; 17 const LIB_EXE_CSS_PHP = '/lib/exe/css.php'; 18 const DOKU_PHP = '/doku.php'; 19 const LIB_EXE_AJAX_PHP = "/lib/exe/ajax.php"; 20 const DOKU_ENDPOINTS = [ 21 self::DOKU_PHP, 22 self::LIB_EXE_FETCH_PHP, 23 self::LIB_EXE_DETAIL_PHP, 24 self::LIB_EXE_RUNNER_PHP, 25 self::LIB_EXE_AJAX_PHP, 26 self::LIB_EXE_CSS_PHP 27 ]; 28 29 30 public static function createFetchUrl(): Url 31 { 32 return Url::createEmpty()->setPath(self::LIB_EXE_FETCH_PHP); 33 } 34 35 public static function createDetailUrl(): Url 36 { 37 return Url::createEmpty()->setPath(self::LIB_EXE_DETAIL_PHP); 38 } 39 40 41 public static function createComboStrapUrl(): Url 42 { 43 return Url::createEmpty() 44 ->setScheme("https") 45 ->setHost("combostrap.com"); 46 } 47 48 public static function createSupportUrl(): Url 49 { 50 51 return self::createComboStrapUrl() 52 ->setPath("support"); 53 54 } 55 56 public static function createDokuUrl(): Url 57 { 58 59 return Url::createEmpty()->setPath(self::DOKU_PHP); 60 61 } 62 63 64 /** 65 * 66 */ 67 public static function createBaseUrl(): Url 68 { 69 $url = Site::getBaseUrl(); 70 try { 71 return Url::createFromString($url); 72 } catch (ExceptionBadArgument|ExceptionBadSyntax $e) { 73 LogUtility::error("The base Url ($url) is not a valid url. Empty URL returned. Error: {$e->getMessage()}", "urlendpoint",$e); 74 return Url::createEmpty(); 75 } 76 } 77 78 public static function createTaskRunnerUrl(): Url 79 { 80 return Url::createEmpty()->setPath(self::LIB_EXE_RUNNER_PHP); 81 } 82 83 public static function createAjaxUrl(): Url 84 { 85 return Url::createEmpty()->setPath(self::LIB_EXE_AJAX_PHP); 86 } 87 88 public static function createCssUrl(): Url 89 { 90 return Url::createEmpty()->setPath(self::LIB_EXE_CSS_PHP); 91 } 92 93 94} 95