Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrick Peter committed Sep 25, 2023
1 parent a01e22d commit 89c819e
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions Slugify.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

namespace Tamedevelopers\Support;

use Exception;
use Cocur\Slugify\Slugify as CocurSlugify;
use Tamedevelopers\Support\Capsule\Manager;
use Tamedevelopers\Support\Capsule\CustomException;


/**
* Cocur\Slugify\Slugify Wrapper
Expand All @@ -22,7 +20,6 @@ class Slugify{
* @var string
*/
static private $language;


/**
* slug
Expand All @@ -35,8 +32,6 @@ class Slugify{
*/
static public function slug($word, $language = null, $separator = "-", $case = true)
{
self::isSlugifyInstalled();

// get language
$language = self::switchLanguage($language);

Expand Down Expand Up @@ -65,7 +60,7 @@ static public function slug($word, $language = null, $separator = "-", $case = t
* @param string|null $language
* @return string
*/
static protected function switchLanguage($language = null)
static private function switchLanguage($language = null)
{
return [
'ar' => 'arabic',
Expand Down Expand Up @@ -156,35 +151,4 @@ static private function supportedLanguage()
];
}

/**
* Check If DOM PDF has been installed
*
* @return mixed
*/
static private function isSlugifyInstalled()
{
try {
if (class_exists('Cocur\Slugify\Slugify')) {
return true;
} else {
throw new CustomException(
"Class Cocur\Slugify\Slugify not found: \nRequire the package by running: `composer require cocur/slugify`\n" .
(new Exception)->getTraceAsString()
);
}
} catch (CustomException $e) {
// Handle the exception silently (turn off error reporting)
error_reporting(0);

Manager::setHeaders(404, function() use($e){

// create error logger
Env::bootLogger();

// Trigger a custom error
trigger_error($e->getMessage(), E_USER_ERROR);
});
}
}

}

0 comments on commit 89c819e

Please sign in to comment.