Code Duplication    Length = 27-33 lines in 2 locations

generated/src/xKerman_Restricted_FloatHandler.php 1 location

@@ 6-32 (lines=27) @@
3
/**
4
 * Handler for PHP serialized float number
5
 */
6
class xKerman_Restricted_FloatHandler implements xKerman_Restricted_HandlerInterface
7
{
8
    /** @var array $mapping parser result mapping */
9
    private $mapping;
10
    /**
11
     * constructor
12
     */
13
    public function __construct()
14
    {
15
        $this->mapping = array('INF' => INF, '-INF' => -INF, 'NAN' => NAN);
16
    }
17
    /**
18
     * parse given `$source` as PHP serialized float number
19
     *
20
     * @param Source $source parser input
21
     * @param string $args   float value
22
     * @return array
23
     * @throws UnserializeFailedException
24
     */
25
    public function handle(xKerman_Restricted_Source $source, $args)
26
    {
27
        if (array_key_exists($args, $this->mapping)) {
28
            return array($this->mapping[$args], $source);
29
        }
30
        return array(floatval($args), $source);
31
    }
32
}

src/FloatHandler.php 1 location

@@ 10-42 (lines=33) @@
7
/**
8
 * Handler for PHP serialized float number
9
 */
10
class FloatHandler implements HandlerInterface
11
{
12
    /** @var array $mapping parser result mapping */
13
    private $mapping;
14
15
    /**
16
     * constructor
17
     */
18
    public function __construct()
19
    {
20
        $this->mapping = array(
21
            'INF'  => INF,
22
            '-INF' => -INF,
23
            'NAN'  => NAN,
24
        );
25
    }
26
27
    /**
28
     * parse given `$source` as PHP serialized float number
29
     *
30
     * @param Source $source parser input
31
     * @param string $args   float value
32
     * @return array
33
     * @throws UnserializeFailedException
34
     */
35
    public function handle(Source $source, $args)
36
    {
37
        if (array_key_exists($args, $this->mapping)) {
38
            return array($this->mapping[$args], $source);
39
        }
40
        return array(floatval($args), $source);
41
    }
42
}
43