UnsupportedTrait
Trait UnsupportedTrait
Provides a standardized way to signal that a specific method or operation is not supported in the current class or context.
This trait is useful for abstract base classes, partial implementations, or stubs, where certain methods should intentionally throw an exception when invoked.
Features:
- Throws a consistent
UnsupportedOperationExceptionwhen calling theunsupported()method. - Allows optional method name labeling for clarity in the exception message.
Dependencies:
oihana\enums\Charfor optional formatting (e.g., empty string).oihana\exceptions\UnsupportedOperationExceptionto indicate the operation is disallowed.
Example usage:
use oihana\traits\UnsupportedTrait;
class ReadOnlyRepository
{
use UnsupportedTrait;
public function save($item)
{
$this->unsupported(__FUNCTION__); // Will throw exception
}
}
Table of Contents
Methods
- unsupported() : void
- Updates an item in the model.
Methods
unsupported()
Updates an item in the model.
protected
unsupported([string $method = Char::EMPTY ]) : void
Parameters
- $method : string = Char::EMPTY