Completed
Push — master ( 74f0c0...5d0abf )
by Aimeos
02:39
created
admin/jsonadm/src/Admin/JsonAdm.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
35 35
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid
36 36
 	 */
37
-	static public function create( \Aimeos\MShop\Context\Item\Iface $context,
38
-		\Aimeos\Bootstrap $aimeos, $path, $name = null )
37
+	static public function create(\Aimeos\MShop\Context\Item\Iface $context,
38
+		\Aimeos\Bootstrap $aimeos, $path, $name = null)
39 39
 	{
40
-		$path = trim( $path, '/' );
40
+		$path = trim($path, '/');
41 41
 
42
-		if( empty( $path ) ) {
43
-			return self::createRoot( $context, $aimeos, $path, $name );
42
+		if (empty($path)) {
43
+			return self::createRoot($context, $aimeos, $path, $name);
44 44
 		} else {
45
-			return self::createNew( $context, $aimeos, $path, $name );
45
+			return self::createNew($context, $aimeos, $path, $name);
46 46
 		}
47 47
 	}
48 48
 
@@ -57,53 +57,53 @@  discard block
 block discarded – undo
57 57
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
58 58
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid
59 59
 	 */
60
-	protected static function createNew( \Aimeos\MShop\Context\Item\Iface $context,
61
-		\Aimeos\Bootstrap $aimeos, $path, $name )
60
+	protected static function createNew(\Aimeos\MShop\Context\Item\Iface $context,
61
+		\Aimeos\Bootstrap $aimeos, $path, $name)
62 62
 	{
63 63
 		$pname = $name;
64
-		$parts = explode( '/', $path );
64
+		$parts = explode('/', $path);
65 65
 
66
-		foreach( $parts as $key => $part )
66
+		foreach ($parts as $key => $part)
67 67
 		{
68
-			if( ctype_alnum( $part ) === false )
68
+			if (ctype_alnum($part) === false)
69 69
 			{
70
-				$msg = sprintf( 'Invalid client "%1$s"', $path );
71
-				throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 );
70
+				$msg = sprintf('Invalid client "%1$s"', $path);
71
+				throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400);
72 72
 			}
73 73
 
74
-			$parts[$key] = ucwords( $part );
74
+			$parts[$key] = ucwords($part);
75 75
 		}
76 76
 
77
-		if( $pname === null ) {
78
-			$pname = $context->getConfig()->get( 'admin/jsonadm/' . $path . '/name', 'Standard' );
77
+		if ($pname === null) {
78
+			$pname = $context->getConfig()->get('admin/jsonadm/' . $path . '/name', 'Standard');
79 79
 		}
80 80
 
81 81
 		$view = $context->getView();
82 82
 		$config = $context->getConfig();
83 83
 
84
-		if( $view->access( $config->get( 'admin/jsonadm/resource/' . $path . '/groups', [] ) ) !== true ) {
85
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Not allowed to access JsonAdm "%1$s" client', $path ) );
84
+		if ($view->access($config->get('admin/jsonadm/resource/' . $path . '/groups', [])) !== true) {
85
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Not allowed to access JsonAdm "%1$s" client', $path));
86 86
 		}
87 87
 
88 88
 
89 89
 		$view = $context->getView();
90 90
 		$iface = \Aimeos\Admin\JsonAdm\Iface::class;
91
-		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname;
91
+		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname;
92 92
 
93
-		if( ctype_alnum( $pname ) === false )
93
+		if (ctype_alnum($pname) === false)
94 94
 		{
95
-			$classname = is_string( $pname ) ? $classname : '<not a string>';
96
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
95
+			$classname = is_string($pname) ? $classname : '<not a string>';
96
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
97 97
 		}
98 98
 
99
-		if( class_exists( $classname ) === false ) {
100
-			return self::createRoot( $context, $aimeos, $path, $name );
99
+		if (class_exists($classname) === false) {
100
+			return self::createRoot($context, $aimeos, $path, $name);
101 101
 		}
102 102
 
103
-		$client = self::createAdmin( $classname, $iface, $context, $path );
104
-		$client = self::addClientDecorators( $client, $context, $path );
103
+		$client = self::createAdmin($classname, $iface, $context, $path);
104
+		$client = self::addClientDecorators($client, $context, $path);
105 105
 
106
-		return $client->setAimeos( $aimeos )->setView( $view );
106
+		return $client->setAimeos($aimeos)->setView($view);
107 107
 	}
108 108
 
109 109
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
118 118
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created
119 119
 	 */
120
-	protected static function createRoot( \Aimeos\MShop\Context\Item\Iface $context,
121
-		\Aimeos\Bootstrap $aimeos, $path, $name = null )
120
+	protected static function createRoot(\Aimeos\MShop\Context\Item\Iface $context,
121
+		\Aimeos\Bootstrap $aimeos, $path, $name = null)
122 122
 	{
123 123
 		/** admin/jsonadm/name
124 124
 		 * Class name of the used JSON API client implementation
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 		 * @since 2015.12
154 154
 		 * @category Developer
155 155
 		 */
156
-		if( $name === null ) {
157
-			$name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' );
156
+		if ($name === null) {
157
+			$name = $context->getConfig()->get('admin/jsonadm/name', 'Standard');
158 158
 		}
159 159
 
160
-		if( ctype_alnum( $name ) === false )
160
+		if (ctype_alnum($name) === false)
161 161
 		{
162
-			$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
163
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
162
+			$classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
163
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
164 164
 		}
165 165
 
166 166
 		$view = $context->getView();
167 167
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
168 168
 		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;
169 169
 
170
-		$client = self::createAdmin( $classname, $iface, $context, $path );
170
+		$client = self::createAdmin($classname, $iface, $context, $path);
171 171
 
172 172
 		/** admin/jsonadm/decorators/excludes
173 173
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 		 * @see admin/jsonadm/decorators/global
248 248
 		 */
249 249
 
250
-		$client = self::addClientDecorators( $client, $context, $path );
250
+		$client = self::addClientDecorators($client, $context, $path);
251 251
 
252
-		return $client->setAimeos( $aimeos )->setView( $view );
252
+		return $client->setAimeos($aimeos)->setView($view);
253 253
 	}
254 254
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdmTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 		$context = \TestHelperJadm::getContext();
17 17
 		$aimeos = \TestHelperJadm::getAimeos();
18 18
 
19
-		$client = \Aimeos\Admin\JsonAdm::create( $context, $aimeos, 'order' );
20
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
21
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client );
19
+		$client = \Aimeos\Admin\JsonAdm::create($context, $aimeos, 'order');
20
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
21
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client);
22 22
 	}
23 23
 
24 24
 
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 		$context = \TestHelperJadm::getContext();
28 28
 		$aimeos = \TestHelperJadm::getAimeos();
29 29
 
30
-		$client = \Aimeos\Admin\JsonAdm::create( $context, $aimeos, 'order/base' );
31
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
32
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client );
30
+		$client = \Aimeos\Admin\JsonAdm::create($context, $aimeos, 'order/base');
31
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
32
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client);
33 33
 	}
34 34
 
35 35
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 		$context = \TestHelperJadm::getContext();
39 39
 		$aimeos = \TestHelperJadm::getAimeos();
40 40
 
41
-		$client = \Aimeos\Admin\JsonAdm::create( $context, $aimeos, 'stock/type' );
42
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
43
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client );
41
+		$client = \Aimeos\Admin\JsonAdm::create($context, $aimeos, 'stock/type');
42
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
43
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client);
44 44
 	}
45 45
 
46 46
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 		$context = \TestHelperJadm::getContext();
50 50
 		$aimeos = \TestHelperJadm::getAimeos();
51 51
 
52
-		$client = \Aimeos\Admin\JsonAdm::create( $context, $aimeos, '/' );
53
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
54
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client );
52
+		$client = \Aimeos\Admin\JsonAdm::create($context, $aimeos, '/');
53
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
54
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client);
55 55
 	}
56 56
 
57 57
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 		$context = \TestHelperJadm::getContext();
61 61
 		$aimeos = \TestHelperJadm::getAimeos();
62 62
 
63
-		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
64
-		\Aimeos\Admin\JsonAdm::create( $context, $aimeos, '%^' );
63
+		$this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception');
64
+		\Aimeos\Admin\JsonAdm::create($context, $aimeos, '%^');
65 65
 	}
66 66
 
67 67
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		$context = \TestHelperJadm::getContext();
71 71
 		$aimeos = \TestHelperJadm::getAimeos();
72 72
 
73
-		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
74
-		\Aimeos\Admin\JsonAdm::create( $context, $aimeos, '', '%^' );
73
+		$this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception');
74
+		\Aimeos\Admin\JsonAdm::create($context, $aimeos, '', '%^');
75 75
 	}
76 76
 }
77 77
\ No newline at end of file
Please login to merge, or discard this patch.