acelot/search-schema

View on GitHub
src/Rule/Like.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php declare(strict_types=1);

namespace Acelot\SearchSchema\Rule;

final class Like extends AbstractSimpleRule
{
    /**
     * @var bool
     */
    private $caseSensitive = false;

    /**
     * @return Like
     */
    public function caseInsensitive(): Like
    {
        $clone = clone $this;
        $clone->caseSensitive = false;
        return $clone;
    }

    /**
     * @return Like
     */
    public function caseSensitive(): Like
    {
        $clone = clone $this;
        $clone->caseSensitive = true;
        return $clone;
    }

    protected function getOperator(): string
    {
        return $this->caseSensitive ? 'LIKE' : 'ILIKE';
    }
}