4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Argument\Token;
15 * Approximate value token
17 * @author Daniel Leech <daniel@dantleech.com>
19 class ApproximateValueToken implements TokenInterface
24 public function __construct($value, $precision = 0)
26 $this->value = $value;
27 $this->precision = $precision;
33 public function scoreArgument($argument)
35 return round($argument, $this->precision) === round($this->value, $this->precision) ? 10 : false;
41 public function isLast()
47 * Returns string representation for token.
51 public function __toString()
53 return sprintf('≅%s', round($this->value, $this->precision));