RoomItem   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 59
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A store() 0 20 2
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class RoomItem.
7
 */
8
class RoomItem extends ChocolateyModel
9
{
10
    /**
11
     * Disable Timestamps.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'items';
23
24
    /**
25
     * Primary Key of the Table.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'id';
30
31
    /**
32
     * Store a RoomItem.
33
     *
34
     * @param int    $userId
35
     * @param int    $roomId
36
     * @param int    $itemId
37
     * @param int    $xPosition
38
     * @param int    $yPosition
39
     * @param string $zPosition
40
     * @param int    $rotation
41
     * @param string $extraData
42
     * @param string $wallPosition
43
     *
44
     * @return RoomItem
45
     */
46
    public function store(int $userId, int $roomId, int $itemId, int $xPosition, int $yPosition, string $zPosition, int $rotation, string $extraData, string $wallPosition = ''): RoomItem
47
    {
48
        $this->attributes['user_id'] = $userId;
49
        $this->attributes['room_id'] = $roomId;
50
        $this->attributes['item_id'] = $itemId;
51
        $this->attributes['x'] = $xPosition;
52
        $this->attributes['y'] = $yPosition;
53
        $this->attributes['z'] = $zPosition;
54
        $this->attributes['rot'] = $rotation;
55
        $this->attributes['extra_data'] = $extraData;
56
        $this->timestamps = false;
57
58
        if (!empty($wallPosition)) {
59
            $this->attributes['wall_pos'] = $wallPosition;
60
        }
61
62
        $this->save();
63
64
        return $this;
65
    }
66
}
67