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

ReadonlyAnnotation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 17
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A __toString() 0 4 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