CountTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
c 1
b 1
f 0
lcom 0
cbo 0
dl 0
loc 12
rs 10
ccs 2
cts 2
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A count() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Model\Traits\Tag;
13
14
/**
15
 * CountTrait is trait class containing the methods for counting database records for the Tag model.
16
 *
17
 * @author Mohamed Alsharaf <[email protected]>
18
 *
19
 * @property static $this
20
 */
21
trait CountTrait
22
{
23
    /**
24
     * Count number of tags.
25
     *
26
     * @return int
27
     */
28 2
    public function count()
29
    {
30 2
        return $this->where('group', '=', false)->count();
0 ignored issues
show
Bug introduced by
It seems like where() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
31
    }
32
}
33