Code Duplication    Length = 38-39 lines in 2 locations

src/Xhgui/Searcher/PdoSearcher.php 2 locations

@@ 34-72 (lines=39) @@
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function latest()
35
    {
36
        $stmt = $this->pdo->query("
37
          SELECT
38
            id,
39
            profile,
40
            url,
41
            SERVER,
42
            GET,
43
            ENV,
44
            simple_url,
45
            request_ts,
46
            request_ts_micro,
47
            request_date
48
          FROM {$this->table}
49
          ORDER BY request_date ASC
50
          LIMIT 1
51
        ");
52
53
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
54
        if (false === $row) {
55
            throw new Exception('No profile available yet.');
56
        }
57
58
        return new Profile([
59
            '_id' => $row['id'],
60
            'meta' => [
61
                'url' => $row['url'],
62
                'SERVER' => json_decode($row['SERVER'], true),
63
                'get' => json_decode($row['GET'], true),
64
                'env' => json_decode($row['ENV'], true),
65
                'simple_url' => $row['simple_url'],
66
                'request_ts' => (int) $row['request_ts'],
67
                'request_ts_micro' => $row['request_ts_micro'],
68
                'request_date' => $row['request_date'],
69
            ],
70
            'profile' => json_decode($row['profile'], true),
71
        ]);
72
    }
73
74
    /**
75
     * {@inheritdoc}
@@ 85-122 (lines=38) @@
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function get($id)
86
    {
87
        $stmt = $this->pdo->prepare("
88
          SELECT
89
            profile,
90
            url,
91
            SERVER,
92
            GET,
93
            ENV,
94
            simple_url,
95
            request_ts,
96
            request_ts_micro,
97
            request_date
98
          FROM {$this->table}
99
          WHERE id = :id
100
        ");
101
102
        $stmt->execute(['id' => $id]);
103
104
        if (false === $row = $stmt->fetch(PDO::FETCH_ASSOC)) {
105
            throw new Exception('No profile data found.');
106
        }
107
108
        return new Profile([
109
            '_id' => $id,
110
            'meta' => [
111
                'url' => $row['url'],
112
                'SERVER' => json_decode($row['SERVER'], true),
113
                'get' => json_decode($row['GET'], true),
114
                'env' => json_decode($row['ENV'], true),
115
                'simple_url' => $row['simple_url'],
116
                'request_ts' => (int) $row['request_ts'],
117
                'request_ts_micro' => $row['request_ts_micro'],
118
                'request_date' => $row['request_date'],
119
            ],
120
            'profile' => json_decode($row['profile'], true),
121
        ]);
122
    }
123
124
    /**
125
     * {@inheritdoc}