Code Duplication    Length = 36-36 lines in 2 locations

src/RobotsTxtParser/Directives/CacheDelay.php 1 location

@@ 9-44 (lines=36) @@
6
 *
7
 * @package vipnytt\RobotsTxtParser\Directives
8
 */
9
class CacheDelay implements DirectiveInterface
10
{
11
    /**
12
     * Directive
13
     */
14
    const DIRECTIVE = 'Cache-delay';
15
16
    protected $array = [];
17
    protected $parent;
18
19
20
    public function __construct($array, $parent = null)
21
    {
22
        $this->array = $array;
23
    }
24
25
    /**
26
     * Add
27
     *
28
     * @param string $line
29
     * @return bool
30
     */
31
    public function add($line)
32
    {
33
        if (empty(($float = floatval($this->array)))) {
34
            return false;
35
        }
36
        $this->array = [$float];
37
        return true;
38
    }
39
40
    public function export()
41
    {
42
        return empty($this->array) ? [] : [self::DIRECTIVE => $this->array];
43
    }
44
}
45

src/RobotsTxtParser/Directives/CrawlDelay.php 1 location

@@ 9-44 (lines=36) @@
6
 *
7
 * @package vipnytt\RobotsTxtParser\Directives
8
 */
9
class CrawlDelay implements DirectiveInterface
10
{
11
    /**
12
     * Directive
13
     */
14
    const DIRECTIVE = 'Crawl-delay';
15
16
    protected $array = [];
17
    protected $parent;
18
19
20
    public function __construct($array, $parent = null)
21
    {
22
        $this->array = $array;
23
    }
24
25
    /**
26
     * Add
27
     *
28
     * @param string $line
29
     * @return bool
30
     */
31
    public function add($line)
32
    {
33
        if (empty(($float = floatval($this->array)))) {
34
            return false;
35
        }
36
        $this->array = [$float];
37
        return true;
38
    }
39
40
    public function export()
41
    {
42
        return empty($this->array) ? [] : [self::DIRECTIVE => $this->array];
43
    }
44
}
45