Passed
Push — master ( 765295...2b592d )
by Stephen
03:03 queued 12s
created

PublicStatusTrait::isPrivate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sfneal\Models\Traits;
4
5
/**
6
 * Trait PublicStatus.
7
 *
8
 * @property $public_status
9
 */
10
trait PublicStatusTrait
11
{
12
    /**
13
     * Determine if a Model's 'public_status' is true.
14
     *
15
     * @return bool
16
     */
17
    public function isPublic(): bool
18
    {
19
        return $this->public_status == 1;
20
    }
21
22
    /**
23
     * Determine if a Model's 'public_status' is false.
24
     *
25
     * @return bool
26
     */
27
    public function isPrivate(): bool
28
    {
29
        return ! $this->isPublic();
30
    }
31
32
    /**
33
     * Update a Model's 'public_status' attribute.
34
     *
35
     *  - if a $status is not provided, the $status_id is automatically changed
36
     *
37
     * @param int|null $status
38
     * @return bool
39
     */
40
    public function updatePublicStatus(int $status = null): bool
41
    {
42
        return $this->update([
0 ignored issues
show
Bug introduced by
The method update() does not exist on Sfneal\Models\Traits\PublicStatusTrait. Did you maybe mean updatePublicStatus()? ( Ignorable by Annotation )

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

42
        return $this->/** @scrutinizer ignore-call */ update([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
            'public_status' => $status ?? ($this->public_status == 1 ? 0 : 1),
44
        ]);
45
    }
46
}
47