Code Duplication    Length = 12-14 lines in 3 locations

src/Modules/Extractors/PublishDateExtractor.php 3 locations

@@ 109-120 (lines=12) @@
106
        $nodes = $this->article()->getRawDoc()->find('script[type="application/ld+json"]');
107
108
        /* @var $node Element */
109
        foreach ($nodes as $node) {
110
            try {
111
                $json = json_decode($node->text());
112
                if (isset($json->datePublished)) {
113
                    $dt = new \DateTime($json->datePublished);
114
                    break;
115
                }
116
            }
117
            catch (\Exception $e) {
118
                // Do nothing here in case the node has unrecognizable date information.
119
            }
120
        }
121
122
        return $dt;
123
    }
@@ 203-214 (lines=12) @@
200
        $nodes = $this->article()->getRawDoc()->find('script[type="application/ld+json"]');
201
202
        /* @var $node Element */
203
        foreach ($nodes as $node) {
204
            try {
205
                $json = json_decode($node->text());
206
                if (isset($json->dateCreated)) {
207
                    $dt = new \DateTime($json->dateCreated);
208
                    break;
209
                }
210
            }
211
            catch (\Exception $e) {
212
                // Do nothing here in case the node has unrecognizable date information.
213
            }
214
        }
215
216
        if (!is_null($dt)) {
217
            return $dt;
@@ 244-257 (lines=14) @@
241
        $nodes = $this->article()->getRawDoc()->find('meta[name="parsely-page"]');
242
243
        /* @var $node Element */
244
        foreach ($nodes as $node) {
245
            try {
246
                if ($node->hasAttribute('content')) {
247
                    $json = json_decode($node->getAttribute('content'));
248
                    if (isset($json->pub_date)) {
249
                        $dt = new \DateTime($json->pub_date);
250
                        break;
251
                    }
252
                }
253
            }
254
            catch (\Exception $e) {
255
                // Do nothing here in case the node has unrecognizable date information.
256
            }
257
        }
258
259
        return $dt;
260
    }