PHP code example of chalcedonyt / laravel-specification
1. Go to this page and download the library: Download chalcedonyt/laravel-specification 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/ */
chalcedonyt / laravel-specification example snippets
class NewSpecification extends AbstractSpecification
{
/**
* @var \App\User
*/
protected $user;
/**
* @var
*/
protected $myValue;
/**
*
* @param \App\User $user
* @param $myValue
*
*/
public function __construct(\App\User $user, $my_value)
{
$this->user = $user;
$this->myValue = $my_value;
}
/**
* Tests an object and returns a boolean value
*
* @var mixed
*/
public function isSatisfiedBy($candidate)
{
//return a boolean value
}
}
class MalePersonSpecification extends \Chalcedonyt\Specification\AbstractSpecification
{
const GENDER_MALE = 1;
const GENDER_FEMALE = 2;
/**
* Tests an object and returns a boolean value
*
* @var Array candidate
*/
public function isSatisfiedBy($candidate)
{
return $candidate['gender'] == self::GENDER_MALE;
}
}
php
class AgeOfPersonSpecification extends \Chalcedonyt\Specification\AbstractSpecification
{
protected $minAge;
protected $maxAge;
/**
* Set properties here for a parameterized specification.
*
*/
public function __construct($min_age, $max_age)
{
$this->minAge = $min_age;
$this->maxAge = $max_age;
}
/**
* Tests an object and returns a boolean value
*
* @var Array $candidate
*/
public function isSatisfiedBy($candidate)
{
return $this->minAge <= $candidate['age'] && $this->maxAge >= $candidate['age'];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.