TSetter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 89.47 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 17
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __set() 7 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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