Completed
Push — master ( 2ced0e...c16d2b )
by Aimeos
03:27
created
src/Bootstrap.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param \Slim\App $app Slim application
28 28
 	 * @param array $settings Multi-dimensional array of configuration settings
29 29
 	 */
30
-	public function __construct( \Slim\App $app, array $settings )
30
+	public function __construct(\Slim\App $app, array $settings)
31 31
 	{
32 32
 		$this->app = $app;
33 33
 		$this->settings = $settings;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 * @param string $path Absolute or relative path to the Aimeos route file
41 41
 	 * @return \Aimeos\Slim\Bootstrap Self instance
42 42
 	 */
43
-	public function routes( $path )
43
+	public function routes($path)
44 44
 	{
45 45
 		$app = $this->app;
46 46
 		$settings = $this->settings;
47 47
 
48
-		$config = function( $key, $default ) use ( $settings )
48
+		$config = function($key, $default) use ($settings)
49 49
 		{
50
-			foreach( explode( '/', trim( $key, '/' ) ) as $part )
50
+			foreach (explode('/', trim($key, '/')) as $part)
51 51
 			{
52
-				if( isset( $settings[$part] ) ) {
52
+				if (isset($settings[$part])) {
53 53
 					$settings = $settings[$part];
54 54
 				} else {
55 55
 					return $default;
@@ -71,52 +71,52 @@  discard block
 block discarded – undo
71 71
 	 * @param string $extdir Absolute or relative path to the Aimeos extension directory
72 72
 	 * @return \Aimeos\Slim\Bootstrap Self instance
73 73
 	 */
74
-	public function setup( $extdir = '../ext' )
74
+	public function setup($extdir = '../ext')
75 75
 	{
76 76
 		$container = $this->app->getContainer();
77 77
 
78
-		$container['router'] = function( $c ) {
78
+		$container['router'] = function($c) {
79 79
 			return new \Aimeos\Slim\Router();
80 80
 		};
81 81
 
82
-		$container['aimeos'] = function( $c ) use ( $extdir ) {
83
-			return new \Aimeos\Bootstrap( (array) $extdir, false );
82
+		$container['aimeos'] = function($c) use ($extdir) {
83
+			return new \Aimeos\Bootstrap((array) $extdir, false);
84 84
 		};
85 85
 
86
-		$container['aimeos_context'] = function( $c ) {
87
-			return new \Aimeos\Slim\Base\Context( $c );
86
+		$container['aimeos_context'] = function($c) {
87
+			return new \Aimeos\Slim\Base\Context($c);
88 88
 		};
89 89
 
90
-		$container['aimeos_i18n'] = function( $c ) {
91
-			return new \Aimeos\Slim\Base\I18n( $c );
90
+		$container['aimeos_i18n'] = function($c) {
91
+			return new \Aimeos\Slim\Base\I18n($c);
92 92
 		};
93 93
 
94
-		$container['aimeos_page'] = function( $c ) {
95
-			return new \Aimeos\Slim\Base\Page( $c );
94
+		$container['aimeos_page'] = function($c) {
95
+			return new \Aimeos\Slim\Base\Page($c);
96 96
 		};
97 97
 
98
-		$container['aimeos_view'] = function( $c ) {
99
-			return new \Aimeos\Slim\Base\View( $c );
98
+		$container['aimeos_view'] = function($c) {
99
+			return new \Aimeos\Slim\Base\View($c);
100 100
 		};
101 101
 
102 102
 
103
-		$default = require __DIR__ . DIRECTORY_SEPARATOR . 'aimeos-default.php';
104
-		$settings = array_replace_recursive( $default, $this->settings );
103
+		$default = require __DIR__.DIRECTORY_SEPARATOR.'aimeos-default.php';
104
+		$settings = array_replace_recursive($default, $this->settings);
105 105
 
106
-		$container['aimeos_config'] = function( $c ) use ( $settings ) {
106
+		$container['aimeos_config'] = function($c) use ($settings) {
107 107
 
108
-			$config = new \Aimeos\MW\Config\PHPArray( $settings, $c['aimeos']->getConfigPaths() );
108
+			$config = new \Aimeos\MW\Config\PHPArray($settings, $c['aimeos']->getConfigPaths());
109 109
 
110
-			if( function_exists( 'apc_store' ) === true && $config->get( 'apc_enabled', false ) == true ) {
111
-				$config = new \Aimeos\MW\Config\Decorator\APC( $config, $config->get( 'apc_prefix', 'slim:' ) );
110
+			if (function_exists('apc_store') === true && $config->get('apc_enabled', false) == true) {
111
+				$config = new \Aimeos\MW\Config\Decorator\APC($config, $config->get('apc_prefix', 'slim:'));
112 112
 			}
113 113
 
114 114
 			return $config;
115 115
 		};
116 116
 
117 117
 
118
-		$container['mailer'] = function( $c ) {
119
-			return \Swift_Mailer::newInstance( \Swift_SendmailTransport::newInstance() );
118
+		$container['mailer'] = function($c) {
119
+			return \Swift_Mailer::newInstance(\Swift_SendmailTransport::newInstance());
120 120
 		};
121 121
 
122 122
 		return $this;
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public static function getVersion()
132 132
 	{
133
-		$basedir = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . DIRECTORY_SEPARATOR;
133
+		$basedir = dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR;
134 134
 
135
-		if( ( $content = @file_get_contents( $basedir . 'composer.lock' ) ) !== false
136
-			&& ( $content = json_decode( $content, true ) ) !== null && isset( $content['packages'] )
135
+		if (($content = @file_get_contents($basedir.'composer.lock')) !== false
136
+			&& ($content = json_decode($content, true)) !== null && isset($content['packages'])
137 137
 		) {
138
-			foreach( (array) $content['packages'] as $item )
138
+			foreach ((array) $content['packages'] as $item)
139 139
 			{
140
-				if( $item['name'] === 'aimeos/aimeos-slim' ) {
140
+				if ($item['name'] === 'aimeos/aimeos-slim') {
141 141
 					return $item['version'];
142 142
 				}
143 143
 			}
Please login to merge, or discard this patch.
src/Router.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -22,68 +22,68 @@
 block discarded – undo
22 22
  */
23 23
 class Router extends \Slim\Router
24 24
 {
25
-    /**
26
-     * Build the path for a named route excluding the base path
27
-     *
28
-     * @param string $name        Route name
29
-     * @param array  $data        Named argument replacement data
30
-     * @param array  $queryParams Optional query string parameters
31
-     *
32
-     * @return string
33
-     *
34
-     * @throws RuntimeException         If named route does not exist
35
-     * @throws InvalidArgumentException If required data not provided
36
-     */
37
-    public function relativePathFor($name, array $data = [], array $queryParams = [])
38
-    {
39
-        $route = $this->getNamedRoute($name);
40
-        $pattern = $route->getPattern();
25
+	/**
26
+	 * Build the path for a named route excluding the base path
27
+	 *
28
+	 * @param string $name        Route name
29
+	 * @param array  $data        Named argument replacement data
30
+	 * @param array  $queryParams Optional query string parameters
31
+	 *
32
+	 * @return string
33
+	 *
34
+	 * @throws RuntimeException         If named route does not exist
35
+	 * @throws InvalidArgumentException If required data not provided
36
+	 */
37
+	public function relativePathFor($name, array $data = [], array $queryParams = [])
38
+	{
39
+		$route = $this->getNamedRoute($name);
40
+		$pattern = $route->getPattern();
41 41
 
42
-        $routeDatas = $this->routeParser->parse($pattern);
43
-        // $routeDatas is an array of all possible routes that can be made. There is
44
-        // one routedata for each optional parameter plus one for no optional parameters.
45
-        //
46
-        // The most specific is last, so we look for that first.
47
-        $routeDatas = array_reverse($routeDatas);
42
+		$routeDatas = $this->routeParser->parse($pattern);
43
+		// $routeDatas is an array of all possible routes that can be made. There is
44
+		// one routedata for each optional parameter plus one for no optional parameters.
45
+		//
46
+		// The most specific is last, so we look for that first.
47
+		$routeDatas = array_reverse($routeDatas);
48 48
 
49
-        $segments = $segmentKeys = [];
50
-        foreach ($routeDatas as $routeData) {
51
-            foreach ($routeData as $item) {
52
-                if (is_string($item)) {
53
-                    // this segment is a static string
54
-                    $segments[] = $item;
55
-                    continue;
56
-                }
49
+		$segments = $segmentKeys = [];
50
+		foreach ($routeDatas as $routeData) {
51
+			foreach ($routeData as $item) {
52
+				if (is_string($item)) {
53
+					// this segment is a static string
54
+					$segments[] = $item;
55
+					continue;
56
+				}
57 57
 
58
-                // This segment has a parameter: first element is the name
59
-                if (!array_key_exists($item[0], $data)) {
60
-                    // we don't have a data element for this segment: cancel
61
-                    // testing this routeData item, so that we can try a less
62
-                    // specific routeData item.
63
-                    $segments = [];
64
-                    $segmentName = $item[0];
65
-                    break;
66
-                }
67
-                $segments[] = $data[$item[0]];
68
-                $segmentKeys[$item[0]] = true;
69
-            }
70
-            if (!empty($segments)) {
71
-                // we found all the parameters for this route data, no need to check
72
-                // less specific ones
73
-                break;
74
-            }
75
-        }
58
+				// This segment has a parameter: first element is the name
59
+				if (!array_key_exists($item[0], $data)) {
60
+					// we don't have a data element for this segment: cancel
61
+					// testing this routeData item, so that we can try a less
62
+					// specific routeData item.
63
+					$segments = [];
64
+					$segmentName = $item[0];
65
+					break;
66
+				}
67
+				$segments[] = $data[$item[0]];
68
+				$segmentKeys[$item[0]] = true;
69
+			}
70
+			if (!empty($segments)) {
71
+				// we found all the parameters for this route data, no need to check
72
+				// less specific ones
73
+				break;
74
+			}
75
+		}
76 76
 
77
-        if (empty($segments)) {
78
-            throw new InvalidArgumentException('Missing data for URL segment: ' . $segmentName);
79
-        }
80
-        $url = implode('', $segments);
77
+		if (empty($segments)) {
78
+			throw new InvalidArgumentException('Missing data for URL segment: ' . $segmentName);
79
+		}
80
+		$url = implode('', $segments);
81 81
 
82
-        $params = array_merge(array_diff_key($data, $segmentKeys), $queryParams);
83
-        if ($params) {
84
-            $url .= '?' . http_build_query($params);
85
-        }
82
+		$params = array_merge(array_diff_key($data, $segmentKeys), $queryParams);
83
+		if ($params) {
84
+			$url .= '?' . http_build_query($params);
85
+		}
86 86
 
87
-        return $url;
88
-    }
87
+		return $url;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,13 +75,13 @@
 block discarded – undo
75 75
         }
76 76
 
77 77
         if (empty($segments)) {
78
-            throw new InvalidArgumentException('Missing data for URL segment: ' . $segmentName);
78
+            throw new InvalidArgumentException('Missing data for URL segment: '.$segmentName);
79 79
         }
80 80
         $url = implode('', $segments);
81 81
 
82 82
         $params = array_merge(array_diff_key($data, $segmentKeys), $queryParams);
83 83
         if ($params) {
84
-            $url .= '?' . http_build_query($params);
84
+            $url .= '?'.http_build_query($params);
85 85
         }
86 86
 
87 87
         return $url;
Please login to merge, or discard this patch.