BlogCategory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 26
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A _getArticleCountFormat() 0 4 1
1
<?php
2
namespace App\Model\Entity;
3
4
use App\Model\Behavior\AppTranslateTrait;
5
use Cake\I18n\Number;
6
use Cake\ORM\Behavior\Translate\TranslateTrait;
7
use Cake\ORM\Entity;
8
9
class BlogCategory extends Entity
10
{
11
12
    use AppTranslateTrait;
13
    use TranslateTrait;
14
15
    /**
16
     * Fields that can be mass assigned using newEntity() or patchEntity().
17
     *
18
     * @var array
19
     */
20
    protected $_accessible = [
21
        '*' => true,
22
        'id' => false,
23
    ];
24
25
    /**
26
     * Get the number of articles formatted.
27
     *
28
     * @return string
29
     */
30
    protected function _getArticleCountFormat()
31
    {
32
        return Number::format($this->article_count);
0 ignored issues
show
Documentation introduced by
The property article_count does not exist on object<App\Model\Entity\BlogCategory>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
33
    }
34
}
35