Completed
Push — master ( 6f46dc...2c5f1b )
by Peter
08:02 queued 11s
created

ReadonlyAnnotation::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Annotations;
15
16
use Maslosoft\Mangan\Meta\ManganPropertyAnnotation;
17
18
/**
19
 * Readonly indicator for mongo documents
20
 * @Target('property')
21
 * @template Readonly
22
 */
23
class ReadonlyAnnotation extends ManganPropertyAnnotation
24
{
25
26
	public $value = true;
27
28 1
	public function init()
29
	{
30 1
		$this->getEntity()->direct = false;
31 1
		$this->getEntity()->readonly = (bool) $this->value;
32 1
	}
33
34
	public function __toString()
35
	{
36
		return $this->value;
37
	}
38
39
}
40