Passed
Push — feature/rebusify ( 816514...289185 )
by Paul
07:17
created

RebusifyController::canProceed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Controllers;
4
5
use GeminiLabs\SiteReviews\Database\OptionManager;
6
use GeminiLabs\SiteReviews\Modules\Rebusify;
7
use GeminiLabs\SiteReviews\Review;
8
9
class RebusifyController extends Controller
10
{
11
    /**
12
     * Triggered when a review is created
13
     * @return void
14
     * @action site-reviews/review/created
15
     */
16 1
    public function onCreated(Review $review)
17
    {
18 1
        if ($this->canProceed($review) && 'publish' === $review->status) {
19
            $result = glsr(Rebusify::class)->sendReview($review);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
20
            // @todo
21
        }
22 1
    }
23
24
    /**
25
     * Triggered when a review is reverted to its original title/content/date_timestamp
26
     * @return void
27
     * @action site-reviews/review/reverted
28
     */
29
    public function onReverted(Review $review)
30
    {
31
        if ($this->canProceed($review) && 'publish' === $review->status) {
32
            $result = glsr(Rebusify::class)->sendReview($review);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
33
            // @todo
34
        }
35
    }
36
37
    /**
38
     * Triggered when an existing review is updated
39
     * @return void
40
     * @action site-reviews/review/saved
41
     */
42 1
    public function onSaved(Review $review)
43
    {
44 1
        if ($this->canProceed($review) && 'publish' === $review->status) {
45
            $result = glsr(Rebusify::class)->sendReview($review);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
46
            // @todo
47
        }
48 1
    }
49
50
    /**
51
     * Triggered when a review's response is added or updated
52
     * @param int $metaId
53
     * @param int $postId
54
     * @param string $metaKey
55
     * @param mixed $metaValue
56
     * @return void
57
     * @action updated_postmeta
58
     */
59
    public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue)
0 ignored issues
show
Unused Code introduced by
The parameter $metaValue is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

59
    public function onUpdatedMeta($metaId, $postId, $metaKey, /** @scrutinizer ignore-unused */ $metaValue)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        if (!$this->isReviewPostId($postId) 
62
            || $this->canProceed($review) 
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $review seems to be never defined.
Loading history...
63
            || '_response' !== $metaKey) {
64
            return;
65
        }
66
        $review = glsr_get_review($postId);
67
        $result = glsr(Rebusify::class)->sendReviewResponse($review);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
68
        // @todo
69
    }
70
71
    /**
72
     * @return bool
73
     */
74 1
    protected function canProceed(Review $review)
0 ignored issues
show
Unused Code introduced by
The parameter $review is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    protected function canProceed(/** @scrutinizer ignore-unused */ Review $review)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76 1
        return glsr(OptionManager::class)->getBool('settings.general.support.rebusify');
77
    }
78
}
79