PHP code example of sikessem / type
1. Go to this page and download the library: Download sikessem/type 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 / type example snippets
namespace App\Types;
use Sikessem\Type\Statement;
class MyType implements Statement {
public function __construct(protected string $value) {
$this->setValue($value);
}
protected string $value;
public function setValue(string $value): self {
$this->value = $value;
return $this;
}
public function getValue(): string {
return $this->value;
}
public function dump(): void {
exit($this->value);
}
// The method to define to parse a value
public static function parse(mixed $value): self {
return new self((string)$value);
}
}
use App\Types\MyType;
$myVar = let(MyType::class, 'Hello');
$myVar->dump(); // Exit with the string 'Hello'