Completed
Push — develop ( 1c3d8e...dc7d05 )
by Mohamed
07:44
created

Activity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dataCollection() 0 4 1
A dataValue() 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\User;
13
14
use Illuminate\Database\Eloquent\Model;
15
use Illuminate\Support\Collection;
16
use Tinyissue\Model\Traits\User\Activity\RelationTrait;
17
18
/**
19
 * Activity is model class for user activities.
20
 *
21
 * @author Mohamed Alsharaf <[email protected]>
22
 *
23
 * @property int    $id
24
 * @property string $data
25
 * @property int    $type_id
26
 * @property int    $parent_id
27
 * @property int    $user_id
28
 * @property int    $item_id
29
 * @property int    $action_id
30
 */
31
class Activity extends Model
32
{
33
    use RelationTrait;
34
35
    /**
36
     * Timestamp enabled.
37
     *
38
     * @var bool
39
     */
40
    public $timestamps = true;
41
42
    /**
43
     * Name of database table.
44
     *
45
     * @var string
46
     */
47
    protected $table = 'users_activity';
48
49
    /**
50
     * List of allowed columns to be used in $this->fill().
51
     *
52
     * @var array
53
     */
54
    protected $fillable = ['type_id', 'parent_id', 'user_id', 'item_id', 'action_id', 'data'];
55
56
    /**
57
     * List of columns and their cast data-type.
58
     *
59
     * @var array
60
     */
61
    protected $casts = [
62
        'data' => 'array',
63
    ];
64
65
    /**
66
     * Get a value from the data field using "dot" notation.
67
     *
68
     * @param string $name
69
     *
70
     * @return Collection
71
     */
72
    public function dataCollection($name)
73
    {
74
        return new Collection($this->dataValue($name));
75
    }
76
77
    /**
78
     * Get a value from the data field using "dot" notation.
79
     *
80
     * @param string $name
81
     *
82
     * @return mixed
83
     */
84
    public function dataValue($name)
85
    {
86
        return array_get($this->data, $name);
0 ignored issues
show
Documentation introduced by
$this->data is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
87
    }
88
}
89