LoveCount   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A lovesCount() 0 3 1
A lovesCountDigital() 0 3 1
1
<?php
2
3
namespace CSlant\LaravelLike\Traits\Love;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\MorphMany;
7
8
/**
9
 * Trait LoveScopes
10
 *
11
 * @package CSlant\LaravelLike\Traits\Love
12
 * @mixin Model
13
 *
14
 * @method MorphMany<self, *> lovesTo()
15
 */
16
trait LoveCount
17
{
18
    /**
19
     * Get the count of loves.
20
     *
21
     * @return int
22
     */
23
    public function lovesCount(): int
24
    {
25
        return $this->lovesTo()->count();
26
    }
27
28
    /**
29
     * Get the count of loves in digital format.
30
     *
31
     * @return string
32
     */
33
    public function lovesCountDigital(): string
34
    {
35
        return count_digital($this->lovesCount());
36
    }
37
}
38