implement ResourceAwareInterface

This commit is contained in:
2026-07-10 16:11:54 -04:00
parent 87df263393
commit 85887e02ff
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Potter\Resource;
trait ResourceAwareTrait
{
private $resource;
final public function detachResource()
{
$resource = $this->resource;
$this->resource = null;
return $resource;
}
final public function getResource()
{
return $this->resource;
}
final public function getResourceId(): int
{
return get_resource_id($this->resource);
}
final public function getResourceType(): string
{
return get_resource_type($this->resource);
}
final protected function setResource($resource)
{
$this->resource = $resource;
}
}