1. Go to this page and download the library: Download zeus/anti-guard-clause 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/ */
zeus / anti-guard-clause example snippets
use Zues\Less\IfInterface;
readonly class Age implements IfInterface
{
public function __construct(private int $age)
{
}
/**
* @return mixed
*/
public function make(): mixed
{
return 'age must be greater than 18';
}
/**
* @return bool
*/
public function isTrue(): bool
{
return 18<=$this->age;
}
}
use Zues\Less\IfInterface;
readonly class Man implements IfInterface
{
public function __construct(private string $gender)
{
}
public function make(): string
{
return 'gender must be a man';
}
/**
* @return bool
*/
public function isTrue(): bool
{
return $this->gender === 'man';
}
}
use Zues\Less\ElseInterface;
readonly class ElseGender implements ElseInterface
{
/**
* @return mixed
*/
public function make(): string
{
return 'else condition';
}
}