Code Duplication    Length = 39-39 lines in 2 locations

src/Xhgui/Searcher/Pdo.php 2 locations

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