News::getImageDimensions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace FaithGen\News\Models;
4
5
use FaithGen\SDK\Models\UuidModel;
6
use FaithGen\SDK\Traits\Relationships\Belongs\BelongsToMinistryTrait;
7
use FaithGen\SDK\Traits\Relationships\Morphs\CommentableTrait;
8
use FaithGen\SDK\Traits\Relationships\Morphs\ImageableTrait;
9
use FaithGen\SDK\Traits\StorageTrait;
10
use FaithGen\SDK\Traits\TitleTrait;
11
12
class News extends UuidModel
13
{
14
    use ImageableTrait, CommentableTrait, BelongsToMinistryTrait, StorageTrait, TitleTrait;
15
16
    protected $table = 'fg_news';
17
18
    //****************************************************************************//
19
    //***************************** MODEL ATTRIBUTES *****************************//
20
    //****************************************************************************//
21
    public function getTitleAttribute($val)
22
    {
23
        return ucfirst($val);
24
    }
25
26
    //****************************************************************************//
27
    //***************************** MODEL RELATIONSHIPS *****************************//
28
    //****************************************************************************//
29
30
    /**
31
     * The name of the directory in storage that has files for this model.
32
     * @return mixed
33
     */
34
    public function filesDir()
35
    {
36
        return 'news';
37
    }
38
39
    /**
40
     * The file name fo this model.
41
     * @return mixed
42
     */
43
    public function getFileName()
44
    {
45
        return $this->image->name;
0 ignored issues
show
Documentation introduced by
The property image does not exist on object<FaithGen\News\Models\News>. 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...
46
    }
47
48
    public function getImageDimensions()
49
    {
50
        return [0, 100];
51
    }
52
}
53