Does our comparison need a container? EG: "[* TO *]"? If so, return the opening container brace.

@param string $comparison
@return string
@throws InvalidArgumentException
997
protected function getOpenComparisonContainer($comparison)
    {
        switch ($comparison) {
            case SearchCriterion::GREATER_EQUAL:
            case SearchCriterion::LESS_EQUAL:
            case SearchCriterion::ISNULL:
            case SearchCriterion::ISNOTNULL:
                return '[';
            case SearchCriterion::GREATER_THAN:
            case SearchCriterion::LESS_THAN:
                return '{';
            default:
                throw new InvalidArgumentException('Invalid comparison for RangeCriterion');
        }
    }
446973
protected static function matchCase($value, $comparison)
    {
        $functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords'];

        foreach ($functions as $function) {
            if (call_user_func($function, $comparison) === $comparison) {
                return call_user_func($function, $value);
            }
        }

        return $value;
    }
120653
public function startsWith(self $str, MStringComparison $cmp = null){
		
		if($str->isNullOrEmpty()){
			throw new \InvalidArgumentException('$str is empty');
		}
		
		if($str->count() > $this->count()){
			throw new \InvalidArgumentException('$str is longer than $this');
		}
		
		if($cmp === null || $cmp->getValue() === MStringComparison::CASE_SENSITIVE){
			return $this->substring(0, $str->count())->_Value === $str->_Value;
		}
		else{
			return $this->substring(0, $str->count())->toLower()
					->_Value === $str->toLower()->_Value;
		}
		
	}
531305
public function getDifferenceInDays($compare = null)
	{
		if ( ! $compare)
		{
			$compare = new ExpressiveDate(null, $this->getTimezone());
		}

		return $this->diff($compare)->format('%r%a');
	}
1121675
protected function equality($comparison, $operand)
    {
        return $this->expr->addCondition(new Operator\Equality(
            $this,
            $comparison,
            $this->expr->value($operand)
        ));
    }
1340344
public function greaterEqual($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->greaterEqualMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->greaterEqualColumnVector($b);
                break;

            case $b instanceof Vector:
                $c = $this->greaterEqualVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->greaterEqualScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot compare matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
1209465
public function initContainer($container, $key = '')
    {
        if ($container instanceof Container) {
            $this->setContainer($container);
            $this->setLogger(
                $this->getContainer()->offsetGet(LoggerService::SERVICE_ID)->getLogger()
            );

            // @TODO: implemented because of the legacy, we will don't need it when we're using the container in every case.
            if (!empty($key)) {
                try {
                    return $this->getContainer()->offsetGet($key);
                } catch (\InvalidArgumentException $e) {
                }
            }

            return null;
        }

        return $container;
    }
946116
public function equals($compare): bool
    {
        if ($compare instanceof self) {
            return ($this->name() === $compare->name());
        }

        return false;
    }
288105
public function setMaxComparison(ComparisonExpression $maxComparison)
    {
        if($maxComparison->getField() != $this->getField()) {
            throw new \InvalidArgumentException('Field of Minimum Comparison is not equal to field of Range.');
        } else if($maxComparison->getValue()->isNull() && !(ComparisonExpression::LT & $maxComparison->getOperator())) {
            throw new \InvalidArgumentException('Range.max has to be an Any or a Less Comparison.');
        }

        $this->maxComparison = $maxComparison;
        return $this;
    }
705380
public function getDifferenceInDays($compare = null)
        {
            if (!$compare) {
                $compare = new Date(null, $this->getTimezone());
            }

            return $this->diff($compare)->format('%r%a');
        }
1078373
public function setMinComparison(ComparisonExpression $minComparison)
    {
        if($minComparison->getField() != $this->getField()) {
            throw new \InvalidArgumentException('Field of Minimum Comparison is not equal to field of Range.');
        } else if(($minComparison->getValue()->isNull()) &&  !(ComparisonExpression::GT & $minComparison->getOperator())) {
            throw new \InvalidArgumentException('Range.min has to be an Any or a Greater Comparison.');
        }

        $this->minComparison = $minComparison;
        return $this;
    }
68473
public function common(DatePeriodDateTime $comparison) : ?self
    {
        $start = $this;
        $end = $this->getEndDate();

        $comparisonStart = $comparison;
        $comparisonEnd = $comparison->getEndDate();

        /*
         *            L     H
         * C :        |_____|
         * 1 :      __|__   |
         * 2 :     ___|     |
         * 3 :        |   __|___
         * 4 :        |     |___
         * 5 :      __|_____|__
         * 6 :        |_____|___
         * 7 :      __|_____|
         * 8 :        |_____|
         * 9 :   __   |     |
         * 10:        |     | __
         * 11:        |  __ |
         */

        // case 1
        if ($start->lt($comparisonStart) && $comparisonStart->gt($start) && $end->lt($comparisonEnd) && $end->gt($comparisonStart)) {
            return new static($comparisonStart, $end);
        }

        // case 2
        if ($end->eq($comparisonStart)) {
            return null;
        }

        // case 3
        if ($start->gt($comparisonStart) && $start->lt($comparisonEnd) && $end->gt($comparisonEnd)) {
            return new static($start, $comparisonEnd);
        }

        // case 4
        if ($start->eq($comparisonEnd)) {
            return null;
        }

        // case 5
        if ($start->lt($comparisonStart) && $end->gt($comparisonEnd)) {
            return new static($comparisonStart, $comparisonEnd);
        }

        // case 6
        if ($start->eq($comparisonStart) && $end->gt($comparisonEnd)) {
            return new static($comparisonStart, $comparisonEnd);
        }

        // case 7
        if ($start->lt($comparisonStart) && $end->eq($comparisonEnd)) {
            return new static($comparisonStart, $comparisonEnd);
        }

        // case 8
        if ($start->eq($comparisonStart) && $end->eq($comparisonEnd)) {
            return new static($comparisonStart, $comparisonEnd);
        }

        // case 9
        if ($end->lte($comparisonStart)) {
            return null;
        }

        // case 10
        if ($start->gte($comparisonEnd)) {
            return null;
        }

        // case 11
        if ($start->gt($comparisonStart) && $end->lt($comparisonEnd)) {
            return new static($start, $end);
        }

        return null;
    }
1057908
public static function instanceOf(string $comparison) : Validator\Any
    {
        return self::any()
            ->must('is_object', 'not an object')
            ->must(
                function ($value) use ($comparison) : bool {
                    return $value instanceof $comparison;
                },
                "not an instance of $comparison"
            );
    }
1184926
public function sortByKey(ComparerInterface $comparer = null)
    {
        if ($comparer === null) {
            $comparer = $this->getDefaultComparer();
        }
        uksort($this->container, array($comparer, 'compare'));

        return $this;
    }
990934
public function compareTo($other)
    {
        if ($other === null) {
            return false;
        }
        if (!($other instanceof ConstantNode)) {
            return false;
        }

        return $this->getName() == $other->getName();
    }
1073935
protected function processComparison($query, Comparison $comparison)
    {
        $subject = self::translateColumnName($query, $comparison);
        $value = self::translateParameter($query, $comparison->getValue());
        $operator = $comparison->getOperator();

        switch ($operator) {
            case Operator::SEARCH:
                $value = '%' . $value . '%';
                $operator = 'LIKE';
                break;
        }

        $query->where($subject, $operator, $value);
    }
1048965
public function substract(DatePeriodDateTime $comparison) : array
    {
        $start = $this;
        $end = $this->getEndDate();

        $comparisonStart = $comparison;
        $comparisonEnd = $comparison->getEndDate();

        /*
         *            L     H
         * C :        |_____|
         * 1 :      __|__   |
         * 2 :     ___|     |
         * 3 :        |   __|___
         * 4 :        |     |___
         * 5 :      __|_____|__
         * 6 :        |_____|___
         * 7 :      __|_____|
         * 8 :        |_____|
         * 9 :   __   |     |
         * 10:        |     | __
         * 11:        |  __ |
         */

        // case 1
        if ($start->lt($comparisonStart) && $comparisonStart->gt($start) && $end->lt($comparisonEnd) && $end->gt($comparisonStart)) {
            return [new static($start, $comparisonStart)];
        }

        // case 2
        if ($end->eq($comparisonStart)) {
            return [$this];
        }

        // case 3
        if ($start->gt($comparisonStart) && $start->lt($comparisonEnd) && $end->gt($comparisonEnd)) {
            return [new static($comparisonEnd, $end)];
        }

        // case 4
        if ($start->eq($comparisonEnd)) {
            return [$this];
        }

        // case 5
        if ($start->lt($comparisonStart) && $end->gt($comparisonEnd)) {
            return [new static($start, $comparisonStart), new static($comparisonEnd, $end)];
        }

        // case 6
        if ($start->eq($comparisonStart) && $end->gt($comparisonEnd)) {
            return [new static($comparisonEnd, $end)];
        }

        // case 7
        if ($start->lt($comparisonStart) && $end->eq($comparisonEnd)) {
            return [new static($start, $comparisonStart)];
        }

        // case 8
        if ($start->eq($comparisonStart) && $end->eq($comparisonEnd)) {
            return [];
        }

        // case 11
        if ($start->gt($comparisonStart) && $end->lt($comparisonEnd)) {
            return [];
        }

        return [$this];
    }