FolderPermission   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 5 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
/*
5
 * This file is part of the package typo3/cms-digital-asset-management.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE file that was distributed with this source code.
9
 */
10
11
namespace TYPO3\CMS\DigitalAssetManagement\Entity;
12
13
use TYPO3\CMS\Core\Resource\Folder;
14
15
/**
16
 * Immutable permission object, used by FolderItemFolder
17
 * entity to represent permissions of folders.
18
 */
19
class FolderPermission implements \JsonSerializable
20
{
21
    /**
22
     * @var bool True if entity is readable
23
     */
24
    protected $isReadable;
25
26
    /**
27
     * @var bool True if entity is writable
28
     */
29
    protected $isWritable;
30
31
    /**
32
     * @param Folder $folder
33
     */
34
    public function __construct(Folder $folder)
35
    {
36
        $this->isReadable = $folder->checkActionPermission('read');
37
        $this->isWritable = $folder->checkActionPermission('write');
38
    }
39
40
    public function jsonSerialize()
41
    {
42
        return [
43
            'isReadable' => $this->isReadable,
44
            'isWritable' => $this->isWritable,
45
        ];
46
    }
47
}
48