HasLikes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLikesCount() 0 3 1
A getLikesSum() 0 3 1
A isLiked() 0 3 1
1
<?php
2
3
namespace Osnova\Services\Timeline\Traits;
4
5
trait HasLikes
6
{
7
    /**
8
     * Determines whether the entity was liked by the current user.
9
     *
10
     * @return bool
11
     */
12
    public function isLiked()
13
    {
14
        return $this->getData('likes.is_liked', false) === true;
0 ignored issues
show
Bug introduced by
It seems like getData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

14
        return $this->/** @scrutinizer ignore-call */ getData('likes.is_liked', false) === true;
Loading history...
15
    }
16
17
    /**
18
     * Get the entity likes count.
19
     *
20
     * @return int
21
     */
22
    public function getLikesCount()
23
    {
24
        return intval($this->getData('likes.count'));
25
    }
26
27
    /**
28
     * Get the entity likes sum.
29
     *
30
     * @return int
31
     */
32
    public function getLikesSum()
33
    {
34
        return intval($this->getData('likes.summ'));
35
    }
36
}
37