Test Failed
Push — develop ( ad6b70...42909d )
by Paul
09:48
created

GeolocationController::geolocateReview()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Controllers;
4
5
use GeminiLabs\SiteReviews\Helper;
6
use GeminiLabs\SiteReviews\Modules\Html\ReviewHtml;
7
use GeminiLabs\SiteReviews\Modules\Queue;
8
use GeminiLabs\SiteReviews\Review;
9
10
class GeolocationController extends AbstractController
11
{
12
    /**
13
     * @filter site-reviews/review/build/after
14
     */
15
    public function filterReviewTemplateTags(array $tags, Review $review, ReviewHtml $html): array
16
    {
17
        $tags['location'] = $html->buildTemplateTag($review, 'location', '');
18
        return $tags;
19
    }
20
21
    /**
22
     * @action site-reviews/review/created
23
     */
24
    public function geolocateReview(Review $review): void
25
    {
26
        if (defined('WP_IMPORTING')) {
27
            return;
28
        }
29
        if (Helper::isLocalIpAddress($review->ip_address)) {
30
            return;
31
        }
32
        glsr(Queue::class)->once(time(), 'queue/geolocation', ['review_id' => $review->ID], true);
33
    }
34
}
35