You are here

public function ScalarComparator::accepts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/sebastian/comparator/src/ScalarComparator.php \SebastianBergmann\Comparator\ScalarComparator::accepts()

Returns whether the comparator can compare two values.

@since Method available since Release 3.6.0

Parameters

mixed $expected The first value to compare:

mixed $actual The second value to compare:

Return value

bool

Overrides Comparator::accepts

1 method overrides ScalarComparator::accepts()
NumericComparator::accepts in vendor/sebastian/comparator/src/NumericComparator.php
Returns whether the comparator can compare two values.

File

vendor/sebastian/comparator/src/ScalarComparator.php, line 26

Class

ScalarComparator
Compares scalar or NULL values for equality.

Namespace

SebastianBergmann\Comparator

Code

public function accepts($expected, $actual) {
  return (is_scalar($expected) xor null === $expected) && (is_scalar($actual) xor null === $actual) || is_string($expected) && is_object($actual) && method_exists($actual, '__toString') || is_object($expected) && method_exists($expected, '__toString') && is_string($actual);
}