public static function create($code, $message = null, $category = null)
    {
        return new class($message, $code, $category) extends ControlledError
        {
            /**
             * @var string
             */
            protected $category;

            /**
             * @param string $message
             * @param string $code
             * @param null   $category
             */
            public function __construct($message, $code, $category = null)
            {
                if ($category) {
                    $this->category = $category;
                }
                parent:: __construct($message, $code);
            }

            /**
             * @return string
             */
            public function getCategory(): string
            {
                return $this->category ?? parent::getCategory();
            }
        };
    }
public static function create($code, $message = null, $category = null)
    {
        return new class($message, $code, $category) extends ControlledError
        {
            /**
             * @var string
             */
            protected $category;

            /**
             * @param string $message
             * @param string $code
             * @param null   $category
             */
            public function __construct($message, $code, $category = null)
            {
                if ($category) {
                    $this->category = $category;
                }
                parent:: __construct($message, $code);
            }

            /**
             * @return string
             */
            public function getCategory(): string
            {
                return $this->category ?? parent::getCategory();
            }
        };
    }
public static function create ( $ code , $ message = null , $ category = null ) { return new class ( $ message , $ code , $ category ) extends ControlledError { /**
             * @var string
             */ protected $ category ; /**
             * @param string $message
             * @param string $code
             * @param null   $category
             */ public function __construct ( $ message , $ code , $ category = null ) { if ( $ category ) { $ this -> category = $ category ; } parent :: __construct ( $ message , $ code ) ; } /**
             * @return string
             */ public function getCategory ( ) : string { return $ this -> category ?? parent :: getCategory ( ) ; } } ; }
Throw a controlled error dynamically

@param int|string  $code
@param string      $message
@param string|null $category

@return ControlledError
Throw a controlled error dynamically