Passed
Branch master (007b29)
by smiley
03:08
created
src/TraitException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits;
14 14
 
15
-class TraitException extends \Exception{}
15
+class TraitException extends \Exception {}
Please login to merge, or discard this patch.
src/ClassLoader.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use Exception, ReflectionClass;
16 16
 
17
-trait ClassLoader{
17
+trait ClassLoader {
18 18
 
19 19
 	/**
20 20
 	 * Instances an object of $class/$type with an arbitrary number of $params
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
 	 * @return object of type $type
28 28
 	 * @throws \Exception
29 29
 	 */
30
-	public function loadClass(string $class, string $type = null, ...$params){
30
+	public function loadClass(string $class, string $type = null, ...$params) {
31 31
 		$type = $type === null ? $class : $type;
32 32
 
33
-		try{
33
+		try {
34 34
 			$reflectionClass = new ReflectionClass($class);
35 35
 			$reflectionType  = new ReflectionClass($type);
36 36
 
37
-			if($reflectionType->isTrait()){
37
+			if ($reflectionType->isTrait()) {
38 38
 				trigger_error($class.' cannot be an instance of trait '.$type);
39 39
 			}
40 40
 
41
-			if($reflectionClass->isAbstract()){
41
+			if ($reflectionClass->isAbstract()) {
42 42
 				trigger_error('cannot instance abstract class '.$class);
43 43
 			}
44 44
 
45
-			if($reflectionClass->isTrait()){
45
+			if ($reflectionClass->isTrait()) {
46 46
 				trigger_error('cannot instance trait '.$class);
47 47
 			}
48 48
 
49
-			if($class !== $type){
49
+			if ($class !== $type) {
50 50
 
51
-				if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){
51
+				if ($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)) {
52 52
 					trigger_error($class.' does not implement '.$type);
53 53
 				}
54
-				elseif(!$reflectionClass->isSubclassOf($type)) {
54
+				elseif (!$reflectionClass->isSubclassOf($type)) {
55 55
 					trigger_error($class.' does not inherit '.$type);
56 56
 				}
57 57
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 
60 60
 			$object = $reflectionClass->newInstanceArgs($params);
61 61
 
62
-			if(!$object instanceof $type){
62
+			if (!$object instanceof $type) {
63 63
 				trigger_error('how did u even get here?'); // @codeCoverageIgnore
64 64
 			}
65 65
 
66 66
 			return $object;
67 67
 		}
68
-		catch(Exception $e){
68
+		catch (Exception $e) {
69 69
 			throw new TraitException('ClassLoader: '.$e->getMessage());
70 70
 		}
71 71
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 				if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){
52 52
 					trigger_error($class.' does not implement '.$type);
53
-				}
54
-				elseif(!$reflectionClass->isSubclassOf($type)) {
53
+				} elseif(!$reflectionClass->isSubclassOf($type)) {
55 54
 					trigger_error($class.' does not inherit '.$type);
56 55
 				}
57 56
 
@@ -64,8 +63,7 @@  discard block
 block discarded – undo
64 63
 			}
65 64
 
66 65
 			return $object;
67
-		}
68
-		catch(Exception $e){
66
+		} catch(Exception $e){
69 67
 			throw new TraitException('ClassLoader: '.$e->getMessage());
70 68
 		}
71 69
 
Please login to merge, or discard this patch.
src/Magic.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * A Container that turns methods into magic properties
17 17
  */
18
-trait Magic{
18
+trait Magic {
19 19
 
20 20
 	/**
21 21
 	 * @param string $name
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	private function set(string $name, $value) {
57 57
 		$method = 'magic_set_'.$name;
58 58
 
59
-		if(method_exists($this, $method)){
59
+		if (method_exists($this, $method)) {
60 60
 			$this->$method($value);
61 61
 		}
62 62
 
Please login to merge, or discard this patch.
src/Container.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * a generic container with magic getter and setter
17 17
  */
18
-trait Container{
18
+trait Container {
19 19
 
20 20
 	/**
21 21
 	 * @param array $properties
22 22
 	 */
23
-	public function __construct(array $properties = []){
23
+	public function __construct(array $properties = []) {
24 24
 
25
-		foreach($properties as $key => $value){
25
+		foreach ($properties as $key => $value) {
26 26
 			$this->__set($key, $value);
27 27
 		}
28 28
 
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return mixed
35 35
 	 */
36
-	public function __get(string $property){
36
+	public function __get(string $property) {
37 37
 
38
-		if(property_exists($this, $property)){
38
+		if (property_exists($this, $property)) {
39 39
 			return $this->{$property};
40 40
 		}
41 41
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return void
50 50
 	 */
51
-	public function __set(string $property, $value){
51
+	public function __set(string $property, $value) {
52 52
 
53
-		if(property_exists($this, $property)){
53
+		if (property_exists($this, $property)) {
54 54
 			$this->{$property} = $value;
55 55
 		}
56 56
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function __toArray():array {
63 63
 		$data = [];
64 64
 
65
-		foreach($this as $key => $value){
65
+		foreach ($this as $key => $value) {
66 66
 			$data[$key] = $value;
67 67
 		}
68 68
 
Please login to merge, or discard this patch.