TSetter::__set()   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 2
1
<?php
2
3
namespace Htsl\Helper;
4
5
////////////////////////////////////////////////////////////////
6
7 View Code Duplication
trait TSetter
8
{
9
	/**
10
	 * Allow setting fooBar setter with setFooBar().
11
	 *
12
	 * @access public
13
	 *
14
	 * @param  string $attribute
15
	 * @param  mixed  $value
16
	 */
17
	public function __set( $attribute, $value )
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
	{
19
		if( is_callable([static::class, $setter= 'set'.implode('',array_map('ucfirst',explode('_',$attribute))),]) ){
20
			return static::$setter($value);
21
		}else{
22
			throw new \Exception(static::class.' has no attribute named '.$attribute);
23
		}
24
	}
25
}
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...
26