Translatable   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 42
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __get() 0 22 5
A __call() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Zenify
7
 * Copyright (c) 2012 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Zenify\DoctrineBehaviors\Entities\Attributes;
11
12
13
/**
14
 * @method Translatable proxyCurrentLocaleTranslation($method, $args = [])
15
 */
16
trait Translatable
17
{
18
19
	/**
20
	 * @param string
21
	 * @return mixed
22
	 */
23 2
	public function &__get($name) // "&" intentionally due to compatibility with Nette\Object
24
	{
25 2
		$prefix = 'get';
26 2
		if (preg_match('/^(is|has|should)/i', $name)) {
27
			$prefix = '';
28
		}
29
30 2
		$methodName = $prefix . ucfirst($name);
31
32 2
		if (property_exists($this, $name) === FALSE && method_exists($this, $methodName) === FALSE) {
33 2
			$value = $this->proxyCurrentLocaleTranslation($methodName);
34
			// variable $value intentionally, due to & compatibility
35 2
			return $value;
36
		}
37
38
		if (method_exists($this, $methodName)) {
39
			$value = $this->$methodName();
40
			return $value;
41
		}
42
43
		return $this->$name;
44
	}
45
46
47
	/**
48
	 * @param string
49
	 * @param array
50
	 * @return mixed
51
	 */
52 6
	public function __call($method, $arguments)
53
	{
54 6
		return $this->proxyCurrentLocaleTranslation($method, $arguments);
55
	}
56
57
}
58