You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

51 lines
1.1 KiB

<?php
/**
* Copyright (c) Vincent Klaiber.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @see https://github.com/wordplate/extended-acf
*/
declare(strict_types=1);
namespace WordPlate\Acf;
class Location
{
protected $rules = [];
public function __construct(string $param, string $operator, ?string $value = null)
{
$this->rules[] = compact('param', 'operator', 'value');
}
public static function if(string $param, string $operator, ?string $value = null): self
{
if (func_num_args() === 2) {
$value = $operator;
$operator = '==';
}
return new self($param, $operator, $value);
}
public function and(string $param, string $operator, ?string $value = null): self
{
if (func_num_args() === 2) {
$value = $operator;
$operator = '==';
}
$this->rules[] = compact('param', 'operator', 'value');
return $this;
}
public function toArray(): array
{
return $this->rules;
}
}