Completed
Push — master ( 902e66...0cbd7a )
by Jan-Petter
02:44
created

InlineHostParser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 23.68 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 9
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A client() 0 4 1
A render() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace vipnytt\RobotsTxtParser\Parser\Directives;
3
4
use vipnytt\RobotsTxtParser\Client\Directives\InlineHostClient;
5
6
/**
7
 * Class InlineHostParser
8
 *
9
 * @package vipnytt\RobotsTxtParser\Parser\Directives
10
 */
11
class InlineHostParser extends HostParserCore
12
{
13
    /**
14
     * InlineHostParser constructor.
15
     *
16
     * @param string $base
17
     * @param string $effective
18
     */
19
    public function __construct($base, $effective)
20
    {
21
        parent::__construct($base, $effective);
22
    }
23
24
    /**
25
     * Client
26
     *
27
     * @return InlineHostClient
28
     */
29
    public function client()
30
    {
31
        return new InlineHostClient($this->base, $this->effective, $this->host);
32
    }
33
34
    /**
35
     * Render
36
     *
37
     * @return string[]
38
     */
39 View Code Duplication
    public function render()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $result = [];
42
        foreach ($this->host as $host) {
43
            $result[] = self::DIRECTIVE_HOST . ':' . $host;
44
        }
45
        sort($result);
46
        return $result;
47
    }
48
}
49