Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
8 / 8
Range
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
8 / 8
 handle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
8 / 8
1<?php
2
3namespace Qmp\Laravel\MongoJsExecutor\Replacers;
4
5
6class Range extends MongoJsParserReplacer
7{
8    /**
9     * Undocumented variable
10     *
11     * @var string
12     */
13    protected $search = "/[\"']@RANGE(.*)[\"']/";
14
15    /**
16     * Undocumented function
17     *
18     * @param [type] $json
19     * @return void
20     */
21    protected $replace = '{$gte: "@START", $lt: "@END"}';
22
23    /**
24     * Undocumented function
25     *
26     * @return void
27     */
28    public function handle($json)
29    {
30        return $this->prc($this->search, function ($date) {
31            $str = explode(',', $this->r(['[', ']'], '', $date[1]));
32            return $this->r(
33                [
34                    '"@START"',
35                    '"@END"'
36                ],
37                [
38                    trim($str[0]),
39                    trim($str[1])
40                ],
41                $this->replace
42            );
43        }, $json);
44    }
45}