Completed
Push — master ( 060b04...657701 )
by
unknown
04:35
created

Folder::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Db;
15
16
use \OCP\AppFramework\Db\Entity;
17
18
/**
19
 * @method integer getId()
20
 * @method void setId(integer $value)
21
 * @method string getUserId()
22
 * @method void setUserId(string $value)
23
 * @method string getName()
24
 * @method void setName(string $value)
25
 * @method integer getParentId()
26
 * @method void setParentId(integer $value)
27
 * @method boolean getOpened()
28
 * @method void setOpened(boolean $value)
29
 * @method integer getDeletedAt()
30
 * @method void setDeletedAt(integer $value)
31
 * @method integer getLastModified()
32
 * @method void setLastModified(integer $value)
33
34
 */
35
class Folder extends Entity implements IAPI, \JsonSerializable {
36
37
    use EntityJSONSerializer;
38
39
    protected $parentId;
40
    protected $name;
41
    protected $userId;
42
    protected $opened;
43
    protected $deletedAt;
44
    protected $lastModified;
45
46 11
    public function __construct(){
47 11
        $this->addType('parentId', 'integer');
48 11
        $this->addType('opened', 'boolean');
49 11
        $this->addType('deletedAt', 'integer');
50 11
        $this->addType('lastModified', 'integer');
51 11
    }
52
53
    /**
54
     * Turns entitie attributes into an array
55
     */
56
    public function jsonSerialize() {
57
        return $this->serializeFields([
58
            'id',
59
            'parentId',
60
            'name',
61
            'userId',
62
            'opened',
63
            'deletedAt',
64
        ]);
65
    }
66
67
    public function toAPI() {
68
        return $this->serializeFields([
69
            'id',
70
            'name'
71
        ]);
72
    }
73
}