Completed
Push — master ( ac109f...19c432 )
by Aimeos
05:47
created
client/jsonapi/src/Client/JsonApi/Common/Factory/Base.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $classname Full name of the class for which the object should be returned
32 32
 	 * @param \Aimeos\Client\JsonApi\Iface|null $client JSON API client object
33 33
 	 */
34
-	public static function injectClient( $classname, \Aimeos\Client\JsonApi\Iface $client = null )
34
+	public static function injectClient($classname, \Aimeos\Client\JsonApi\Iface $client = null)
35 35
 	{
36 36
 		self::$objects[$classname] = $client;
37 37
 	}
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param string $path Name of the client, e.g "product"
48 48
 	 * @return \Aimeos\Client\JsonApi\Iface Client object
49 49
 	 */
50
-	protected static function addClientDecorators( \Aimeos\Client\JsonApi\Iface $client,
51
-		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path )
50
+	protected static function addClientDecorators(\Aimeos\Client\JsonApi\Iface $client,
51
+		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path)
52 52
 	{
53 53
 		$config = $context->getConfig();
54 54
 
@@ -74,38 +74,38 @@  discard block
 block discarded – undo
74 74
 		 * @since 2015.12
75 75
 		 * @category Developer
76 76
 		 */
77
-		$decorators = $config->get( 'client/jsonapi/common/decorators/default', array() );
77
+		$decorators = $config->get('client/jsonapi/common/decorators/default', array());
78 78
 
79
-		if( $path !== null && is_string( $path ) )
79
+		if ($path !== null && is_string($path))
80 80
 		{
81
-			$dpath = trim( $path, '/' );
82
-			$dpath = ( $dpath !== '' ? $dpath . '/' : $dpath );
81
+			$dpath = trim($path, '/');
82
+			$dpath = ($dpath !== '' ? $dpath . '/' : $dpath);
83 83
 
84
-			$excludes = $config->get( 'client/jsonapi/' . $dpath . 'decorators/excludes', array() );
85
-			$localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) );
84
+			$excludes = $config->get('client/jsonapi/' . $dpath . 'decorators/excludes', array());
85
+			$localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path)));
86 86
 
87
-			foreach( $decorators as $key => $name )
87
+			foreach ($decorators as $key => $name)
88 88
 			{
89
-				if( in_array( $name, $excludes ) ) {
90
-					unset( $decorators[$key] );
89
+				if (in_array($name, $excludes)) {
90
+					unset($decorators[$key]);
91 91
 				}
92 92
 			}
93 93
 
94 94
 			$classprefix = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\';
95
-			$decorators = $config->get( 'client/jsonapi/' . $dpath . 'decorators/global', array() );
96
-			$client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path );
95
+			$decorators = $config->get('client/jsonapi/' . $dpath . 'decorators/global', array());
96
+			$client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path);
97 97
 
98
-			if( !empty( $path ) )
98
+			if (!empty($path))
99 99
 			{
100
-				$classprefix = '\\Aimeos\\Client\\JsonApi\\' . ucfirst( $localClass ) . '\\Decorator\\';
101
-				$decorators = $config->get( 'client/jsonapi/' . $dpath . 'decorators/local', array() );
102
-				$client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path );
100
+				$classprefix = '\\Aimeos\\Client\\JsonApi\\' . ucfirst($localClass) . '\\Decorator\\';
101
+				$decorators = $config->get('client/jsonapi/' . $dpath . 'decorators/local', array());
102
+				$client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path);
103 103
 			}
104 104
 		}
105 105
 		else
106 106
 		{
107 107
 			$classprefix = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\';
108
-			$client = self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path );
108
+			$client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path);
109 109
 		}
110 110
 
111 111
 		return $client;
@@ -124,29 +124,29 @@  discard block
 block discarded – undo
124 124
 	 * @param string $path Name of the client, e.g "product"
125 125
 	 * @return \Aimeos\Client\JsonApi\Iface Client object
126 126
 	 */
127
-	protected static function addDecorators( \Aimeos\Client\JsonApi\Iface $client, array $decorators, $classprefix,
128
-			\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path )
127
+	protected static function addDecorators(\Aimeos\Client\JsonApi\Iface $client, array $decorators, $classprefix,
128
+			\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path)
129 129
 	{
130 130
 		$iface = '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\\Iface';
131 131
 
132
-		foreach( $decorators as $name )
132
+		foreach ($decorators as $name)
133 133
 		{
134
-			if( ctype_alnum( $name ) === false )
134
+			if (ctype_alnum($name) === false)
135 135
 			{
136
-				$classname = is_string( $name ) ? $classprefix . $name : '<not a string>';
137
-				throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid class name "%1$s"', $classname ), 404 );
136
+				$classname = is_string($name) ? $classprefix . $name : '<not a string>';
137
+				throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid class name "%1$s"', $classname), 404);
138 138
 			}
139 139
 
140 140
 			$classname = $classprefix . $name;
141 141
 
142
-			if( class_exists( $classname ) === false ) {
143
-				throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 );
142
+			if (class_exists($classname) === false) {
143
+				throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" not found', $classname), 404);
144 144
 			}
145 145
 
146
-			$client = new $classname( $client, $context, $view, $templatePaths, $path );
146
+			$client = new $classname($client, $context, $view, $templatePaths, $path);
147 147
 
148
-			if( !( $client instanceof $iface ) ) {
149
-				throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $iface ), 404 );
148
+			if (!($client instanceof $iface)) {
149
+				throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" does not implement "%2$s"', $classname, $iface), 404);
150 150
 			}
151 151
 		}
152 152
 
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 	 * @param string $path Name of the client, e.g "product"
166 166
 	 * @return \Aimeos\Client\JsonApi\Iface Client object
167 167
 	 */
168
-	protected static function createClientBase( $classname, $interface, \Aimeos\MShop\Context\Item\Iface $context,
169
-		\Aimeos\MW\View\Iface $view, array $templatePaths, $path )
168
+	protected static function createClientBase($classname, $interface, \Aimeos\MShop\Context\Item\Iface $context,
169
+		\Aimeos\MW\View\Iface $view, array $templatePaths, $path)
170 170
 	{
171
-		if( isset( self::$objects[$classname] ) ) {
171
+		if (isset(self::$objects[$classname])) {
172 172
 			return self::$objects[$classname];
173 173
 		}
174 174
 
175
-		if( class_exists( $classname ) === false ) {
176
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 );
175
+		if (class_exists($classname) === false) {
176
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" not found', $classname), 404);
177 177
 		}
178 178
 
179
-		$client = new $classname( $context, $view, $templatePaths, $path );
179
+		$client = new $classname($context, $view, $templatePaths, $path);
180 180
 
181
-		if( !( $client instanceof $interface ) ) {
182
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $interface ), 500 );
181
+		if (!($client instanceof $interface)) {
182
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Class "%1$s" does not implement "%2$s"', $classname, $interface), 500);
183 183
 		}
184 184
 
185 185
 		return $client;
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Common/Factory/Iface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
 	 * @param string|null $name Name of the client implementation ("Standard" if null)
29 29
 	 * @return \Aimeos\Client\JsonApi\Iface Client Interface
30 30
 	 */
31
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null );
31
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null);
32 32
 }
Please login to merge, or discard this patch.