<?php

namespace Amp\Optimizer\Error;

/**
 * Default set of properties and methods to use for errors.
 *
 * @package Amp\Optimizer
 */
trait ErrorProperties
{

    /**
     * Instantiate an Error object.
     *
     * @param string $message Message for the error.
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Message of the error.
     *
     * @var string
     */
    protected $message;

    /**
     * Get the code of the error.
     *
     * @return string Code of the error.
     */
    public function getCode()
    {
        return basename(get_class($this));
    }

    /**
     * Get the message of the error.
     *
     * @return string Message of the error.
     */
    public function getMessage()
    {
        return $this->message;
    }
}

<?php

namespace Amp\Optimizer\Error;

/**
 * Default set of properties and methods to use for errors.
 *
 * @package Amp\Optimizer
 */
trait ErrorProperties
{

    /**
     * Instantiate an Error object.
     *
     * @param string $message Message for the error.
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Message of the error.
     *
     * @var string
     */
    protected $message;

    /**
     * Get the code of the error.
     *
     * @return string Code of the error.
     */
    public function getCode()
    {
        return preg_replace('/^.+\\\\/', '', get_class($this));
    }

    /**
     * Get the message of the error.
     *
     * @return string Message of the error.
     */
    public function getMessage()
    {
        return $this->message;
    }
}

Fix removal of namespace when deriving error code from class name
Fix removal of namespace when deriving error code from class name