Compare commits

..

5 Commits

Author SHA1 Message Date
jay 85887e02ff implement ResourceAwareInterface 2026-07-10 16:11:54 -04:00
jay 87df263393 create ResourceAwareInterface 2026-07-10 16:11:39 -04:00
jay 06b1ea046e add composer.lock 2026-07-10 16:10:54 -04:00
jay 16851ec519 composer init 2026-07-10 16:10:39 -04:00
jay 00e605ec9e created the project in netbeans 2026-07-10 16:09:14 -04:00
4 changed files with 73 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
composer.lock
/nbproject/
/vendor/
+20
View File
@@ -0,0 +1,20 @@
{
"name": "potter/resource",
"type": "library",
"require": {
"php": "^8.5"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Potter\\Resource\\": "src/Potter/Resource/"
}
},
"authors": [
{
"name": "Jay Potter",
"email": "j@ypotter.ca"
}
],
"minimum-stability": "stable"
}
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Potter\Resource;
interface ResourceAwareInterface
{
public function detachResource();
public function getResource();
public function getResourceId(): int;
public function getResourceType(): string;
}
@@ -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;
}
}