Completed
Push — master ( 2b6933...74f0c0 )
by Aimeos
02:02
created
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.
admin/jsonadm/src/Admin/JsonAdm.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  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
-		if( empty( $path ) ) {
41
-			return self::createRoot( $context, $aimeos, $path, $name );
40
+		if (empty($path)) {
41
+			return self::createRoot($context, $aimeos, $path, $name);
42 42
 		} else {
43
-			return self::createNew( $context, $aimeos, $path, $name );
43
+			return self::createNew($context, $aimeos, $path, $name);
44 44
 		}
45 45
 	}
46 46
 
@@ -55,53 +55,53 @@  discard block
 block discarded – undo
55 55
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
56 56
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid
57 57
 	 */
58
-	protected static function createNew( \Aimeos\MShop\Context\Item\Iface $context,
59
-		\Aimeos\Bootstrap $aimeos, $path, $name )
58
+	protected static function createNew(\Aimeos\MShop\Context\Item\Iface $context,
59
+		\Aimeos\Bootstrap $aimeos, $path, $name)
60 60
 	{
61 61
 		$pname = $name;
62
-		$parts = explode( '/', $path );
62
+		$parts = explode('/', $path);
63 63
 
64
-		foreach( $parts as $key => $part )
64
+		foreach ($parts as $key => $part)
65 65
 		{
66
-			if( ctype_alnum( $part ) === false )
66
+			if (ctype_alnum($part) === false)
67 67
 			{
68
-				$msg = sprintf( 'Invalid client "%1$s"', $path );
69
-				throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 );
68
+				$msg = sprintf('Invalid client "%1$s"', $path);
69
+				throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400);
70 70
 			}
71 71
 
72
-			$parts[$key] = ucwords( $part );
72
+			$parts[$key] = ucwords($part);
73 73
 		}
74 74
 
75
-		if( $pname === null ) {
76
-			$pname = $context->getConfig()->get( 'admin/jsonadm/' . $path . '/name', 'Standard' );
75
+		if ($pname === null) {
76
+			$pname = $context->getConfig()->get('admin/jsonadm/' . $path . '/name', 'Standard');
77 77
 		}
78 78
 
79 79
 		$view = $context->getView();
80 80
 		$config = $context->getConfig();
81 81
 
82
-		if( $view->access( $config->get( 'admin/jsonadm/resource/' . $path . '/groups', [] ) ) !== true ) {
83
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Not allowed to access JsonAdm "%1$s" client', $path ) );
82
+		if ($view->access($config->get('admin/jsonadm/resource/' . $path . '/groups', [])) !== true) {
83
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Not allowed to access JsonAdm "%1$s" client', $path));
84 84
 		}
85 85
 
86 86
 
87 87
 		$view = $context->getView();
88 88
 		$iface = \Aimeos\Admin\JsonAdm\Iface::class;
89
-		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname;
89
+		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname;
90 90
 
91
-		if( ctype_alnum( $pname ) === false )
91
+		if (ctype_alnum($pname) === false)
92 92
 		{
93
-			$classname = is_string( $pname ) ? $classname : '<not a string>';
94
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
93
+			$classname = is_string($pname) ? $classname : '<not a string>';
94
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
95 95
 		}
96 96
 
97
-		if( class_exists( $classname ) === false ) {
98
-			return self::createRoot( $context, $aimeos, $path, $name );
97
+		if (class_exists($classname) === false) {
98
+			return self::createRoot($context, $aimeos, $path, $name);
99 99
 		}
100 100
 
101
-		$client = self::createAdmin( $classname, $iface, $context, $path );
102
-		$client = self::addClientDecorators( $client, $context, $path );
101
+		$client = self::createAdmin($classname, $iface, $context, $path);
102
+		$client = self::addClientDecorators($client, $context, $path);
103 103
 
104
-		return $client->setAimeos( $aimeos )->setView( $view );
104
+		return $client->setAimeos($aimeos)->setView($view);
105 105
 	}
106 106
 
107 107
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
116 116
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created
117 117
 	 */
118
-	protected static function createRoot( \Aimeos\MShop\Context\Item\Iface $context,
119
-		\Aimeos\Bootstrap $aimeos, $path, $name = null )
118
+	protected static function createRoot(\Aimeos\MShop\Context\Item\Iface $context,
119
+		\Aimeos\Bootstrap $aimeos, $path, $name = null)
120 120
 	{
121 121
 		/** admin/jsonadm/name
122 122
 		 * Class name of the used JSON API client implementation
@@ -151,21 +151,21 @@  discard block
 block discarded – undo
151 151
 		 * @since 2015.12
152 152
 		 * @category Developer
153 153
 		 */
154
-		if( $name === null ) {
155
-			$name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' );
154
+		if ($name === null) {
155
+			$name = $context->getConfig()->get('admin/jsonadm/name', 'Standard');
156 156
 		}
157 157
 
158
-		if( ctype_alnum( $name ) === false )
158
+		if (ctype_alnum($name) === false)
159 159
 		{
160
-			$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
161
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
160
+			$classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
161
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
162 162
 		}
163 163
 
164 164
 		$view = $context->getView();
165 165
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
166 166
 		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;
167 167
 
168
-		$client = self::createAdmin( $classname, $iface, $context, $path );
168
+		$client = self::createAdmin($classname, $iface, $context, $path);
169 169
 
170 170
 		/** admin/jsonadm/decorators/excludes
171 171
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 		 * @see admin/jsonadm/decorators/global
246 246
 		 */
247 247
 
248
-		$client = self::addClientDecorators( $client, $context, $path );
248
+		$client = self::addClientDecorators($client, $context, $path);
249 249
 
250
-		return $client->setAimeos( $aimeos )->setView( $view );
250
+		return $client->setAimeos($aimeos)->setView($view);
251 251
 	}
252 252
 }
Please login to merge, or discard this patch.