function grammar($number, $forms)
{
assert(count($forms) === 3);
$nn = abs((abs($number % 100) < 21) ? ($number % 100) : ($number % 10));
return (($nn == 1) ? $forms[0] : (($nn > 1 && $nn < 5) ? $forms[1] : $forms[2]));
}
echo $years . grammar($years, [' год', ' года', ' лет']);
$fields = [
'clientName' => 'name',
'clientPhone' => 'phone',
'clientEmail' => 'email'
];
$where = [];
$resultArr = [];
foreach($fields as $key => $field) {
if($arr[$key]) {
$where[] = "`$field` LIKE ?";
$resultArr[] = '%' . $arr['clientName'] . '%';
}
}
if(count($where) > 0) {
$sql .= ' WHERE ' . implode(' AND ', $where);
}
static public function method($parameter1, $parameter2 = null) {
if($parameter2 === null) {
// your first method code
} else {
// your second method code
}
}
abstract class Widget
{
protected $template;
public function __construct()
{ }
public function setTemplate(string $template)
{
if (!file_exists($template)) {
throw new \Exception('Widget template "' . $template . '" was not found.');
}
$this->template = $template;
return $this;
}
abstract public function render(TemplateService $templateService, Client $client) : string;
}