TGetter::__get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 7
Ratio 87.5 %

Importance

Changes 0
Metric Value
dl 7
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Htsl\Helper;
4
5
////////////////////////////////////////////////////////////////
6
7 View Code Duplication
trait TGetter
8
{
9
	/**
10
	 * Allow setting fooBar getter with getFooBar().
11
	 *
12
	 * @access public
13
	 *
14
	 * @param  string $attribute
15
	 *
16
	 * @return mixed
17
	 */
18
	public function __get( $attribute )
19
	{
20
		if( is_callable([static::class, $getter= 'get'.implode('',array_map('ucfirst',explode('_',$attribute))),]) ){
21
			return static::$getter();
22
		}else{
23
			throw new \Exception(static::class.' has no attribute named '.$attribute);
24
		}
25
	}
26
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
27