Compare commits

...

7 Commits

Author SHA1 Message Date
ee67a82f64 Add clone() Method 2025-10-25 11:52:31 -04:00
577b2d3eeb Create CloneableTrait 2025-10-25 11:50:27 -04:00
9d669625bb Create Cloneable 2025-10-25 11:49:48 -04:00
a558567ba9 Create AbstractCloneable 2025-10-25 11:49:38 -04:00
59e0f3eb5b Create CloneableInterface 2025-10-25 11:49:23 -04:00
42a0e9b97d composer init 2025-10-25 11:47:20 -04:00
79909e0877 Add first name to Copyright 2025-10-25 11:46:31 -04:00
6 changed files with 64 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2025 Potter
Copyright (c) 2025 Jay Potter
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including

20
composer.json Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "potter/cloneable",
"type": "library",
"require": {
"php": "^8.4"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Potter\\Cloneable\\": "src/Potter/Cloneable/"
}
},
"authors": [
{
"name": "Jay Potter",
"email": "j@ypotter.ca"
}
],
"minimum-stability": "dev"
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Cloneable;
abstract class AbstractCloneable implements CloneableInterface
{
abstract public function clone(): CloneableInterface;
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Cloneable;
abstract class Cloneable extends AbstractCloneable
{
use CloneableTrait;
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Cloneable;
interface CloneableInterface
{
public function clone(): self;
}

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Potter\Cloneable;
trait CloneableTrait
{
final public function clone(): CloneableInterface
{
return clone $this;
}
}