1. Go to this page and download the library: Download sikessem/capsule library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sikessem / capsule example snippets
namespace Sikessem\Capsule\Sample;
use Sikessem\Capsule\Core\IsEncapsulated;
interface CustomInterface extends IsEncapsulated
{
public function getName(): string;
public function setName(string $name): void;
}
namespace Sikessem\Capsule\Sample;
final class CustomClass implements CustomInterface
{
use CustomTrait;
public function __construct(string $name = 'World')
{
$this->setName($name);
}
}
namespace Sikessem\Capsule\Sample;
use Sikessem\Capsule\Core\HasEncapsulator;
trait CustomTrait
{
use HasEncapsulator;
protected string $name;
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
}
use Sikessem\Capsule\Sample\CustomClass;
$capsule = new CustomClass('Sikessem');
isset($capsule->name); // Returns true
echo $capsule->name; // Prints "Sikessem"
unset($capsule->name); // Does nothing
isset($capsule->name); // Returns true
$capsule->value = 'value'; // Throws an exception
$capsule->name = 'value'; // Set name to "value"
echo $capsule->name; // Prints "value"
$capsule->on('hello', function (?string $name = null) {
return 'Hello '.($name ?? 'Sikessem').'!';
});
echo $capsule->hello(); //Prints "Hello Sikessem!"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.