Completed
Push — master ( 4a8c3d...7eaefb )
by
unknown
03:53
created

Translatable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 60%

Importance

Changes 10
Bugs 2 Features 2
Metric Value
wmc 6
c 10
b 2
f 2
lcom 0
cbo 0
dl 0
loc 42
ccs 9
cts 15
cp 0.6
rs 10

2 Methods

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