Completed
Push — master ( bc3c0c...8086a8 )
by Aimeos
01:52
created
controller/frontend/src/Controller/Frontend/Product/Factory.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string|null $name Name of the controller implementaton (default: "Standard")
29 29
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Controller object
30 30
 	 */
31
-	public static function create( \Aimeos\MShop\Context\Item\Iface $context, $name = null )
31
+	public static function create(\Aimeos\MShop\Context\Item\Iface $context, $name = null)
32 32
 	{
33 33
 		/** controller/frontend/product/name
34 34
 		 * Class name of the used product frontend controller implementation
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 		 * @since 2017.03
64 64
 		 * @category Developer
65 65
 		 */
66
-		if( $name === null ) {
67
-			$name = $context->getConfig()->get( 'controller/frontend/product/name', 'Standard' );
66
+		if ($name === null) {
67
+			$name = $context->getConfig()->get('controller/frontend/product/name', 'Standard');
68 68
 		}
69 69
 
70
-		if( ctype_alnum( $name ) === false )
70
+		if (ctype_alnum($name) === false)
71 71
 		{
72
-			$classname = is_string( $name ) ? '\\Aimeos\\Controller\\Frontend\\Product\\' . $name : '<not a string>';
73
-			throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
72
+			$classname = is_string($name) ? '\\Aimeos\\Controller\\Frontend\\Product\\' . $name : '<not a string>';
73
+			throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
74 74
 		}
75 75
 
76 76
 		$iface = '\\Aimeos\\Controller\\Frontend\\Product\\Iface';
77 77
 		$classname = '\\Aimeos\\Controller\\Frontend\\Product\\' . $name;
78 78
 
79
-		$controller = self::createController( $context, $classname, $iface );
79
+		$controller = self::createController($context, $classname, $iface);
80 80
 
81 81
 		/** controller/frontend/product/decorators/excludes
82 82
 		 * Excludes decorators added by the "common" option from the product frontend controllers
@@ -152,6 +152,6 @@  discard block
 block discarded – undo
152 152
 		 * @see controller/frontend/product/decorators/excludes
153 153
 		 * @see controller/frontend/product/decorators/global
154 154
 		 */
155
-		return self::addControllerDecorators( $context, $controller, 'product' );
155
+		return self::addControllerDecorators($context, $controller, 'product');
156 156
 	}
157 157
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param boolean $value True to enable caching, false to disable it.
28 28
 	 * @return boolean Previous cache setting
29 29
 	 */
30
-	static public function cache( $value )
30
+	static public function cache($value)
31 31
 	{
32 32
 		self::$cache = (boolean) $value;
33 33
 		self::$objects = [];
@@ -49,26 +49,26 @@  discard block
 block discarded – undo
49 49
 	 * @return \Aimeos\Controller\Frontend\Iface New frontend controller
50 50
 	 * @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found
51 51
 	 */
52
-	static public function create( \Aimeos\MShop\Context\Item\Iface $context, $path )
52
+	static public function create(\Aimeos\MShop\Context\Item\Iface $context, $path)
53 53
 	{
54
-		if( empty( $path ) ) {
55
-			throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) );
54
+		if (empty($path)) {
55
+			throw new \Aimeos\Controller\Frontend\Exception(sprintf('Controller path is empty'));
56 56
 		}
57 57
 
58
-		if( self::$cache === false || !isset( self::$objects[$path] ) )
58
+		if (self::$cache === false || !isset(self::$objects[$path]))
59 59
 		{
60
-			if( ctype_alnum( $path ) === false ) {
61
-				throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s"', $path ) );
60
+			if (ctype_alnum($path) === false) {
61
+				throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in controller name "%1$s"', $path));
62 62
 			}
63 63
 
64
-			$factory = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $path ) . '\\Factory';
64
+			$factory = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($path) . '\\Factory';
65 65
 
66
-			if( class_exists( $factory ) === false ) {
67
-				throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) );
66
+			if (class_exists($factory) === false) {
67
+				throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $factory));
68 68
 			}
69 69
 
70
-			if( ( $controller = call_user_func_array( [$factory, 'create'], [$context] ) ) === false ) {
71
-				throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) );
70
+			if (($controller = call_user_func_array([$factory, 'create'], [$context])) === false) {
71
+				throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid factory "%1$s"', $factory));
72 72
 			}
73 73
 
74 74
 			self::$objects[$path] = $controller;
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/FrontendTest.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@
 block discarded – undo
13 13
 {
14 14
 	public function testCreateController()
15 15
 	{
16
-		$controller = \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'basket' );
17
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Frontend\\Iface', $controller );
16
+		$controller = \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'basket');
17
+		$this->assertInstanceOf('\\Aimeos\\Controller\\Frontend\\Iface', $controller);
18 18
 	}
19 19
 
20 20
 
21 21
 	public function testCreateControllerEmpty()
22 22
 	{
23
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
24
-		\Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), '' );
23
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
24
+		\Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), '');
25 25
 	}
26 26
 
27 27
 
28 28
 	public function testCreateControllerInvalidName()
29 29
 	{
30
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
31
-		\Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), '%^' );
30
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
31
+		\Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), '%^');
32 32
 	}
33 33
 
34 34
 
35 35
 	public function testCreateControllerNotExisting()
36 36
 	{
37
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
38
-		\Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'notexist' );
37
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
38
+		\Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'notexist');
39 39
 	}
40 40
 
41 41
 
42 42
 	public function testCreateSubControllerNotExisting()
43 43
 	{
44
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
45
-		\Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'basket/notexist' );
44
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
45
+		\Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'basket/notexist');
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testCache()
50 50
 	{
51 51
 		$context = \TestHelperFrontend::getContext();
52
-		\Aimeos\Controller\Frontend::cache( true );
52
+		\Aimeos\Controller\Frontend::cache(true);
53 53
 
54
-		$controller1 = \Aimeos\Controller\Frontend::create( $context, 'basket' );
55
-		$controller2 = \Aimeos\Controller\Frontend::create( $context, 'basket' );
54
+		$controller1 = \Aimeos\Controller\Frontend::create($context, 'basket');
55
+		$controller2 = \Aimeos\Controller\Frontend::create($context, 'basket');
56 56
 
57
-		\Aimeos\Controller\Frontend::cache( false );
58
-		$this->assertNotSame( $controller1, $controller2 );
57
+		\Aimeos\Controller\Frontend::cache(false);
58
+		$this->assertNotSame($controller1, $controller2);
59 59
 	}
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
controller/frontend/tests/TestHelperFrontend.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 
21
-	public static function getContext( $site = 'unittest' )
21
+	public static function getContext($site = 'unittest')
22 22
 	{
23
-		if( !isset( self::$context[$site] ) ) {
24
-			self::$context[$site] = self::createContext( $site );
23
+		if (!isset(self::$context[$site])) {
24
+			self::$context[$site] = self::createContext($site);
25 25
 		}
26 26
 
27 27
 		return clone self::$context[$site];
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 	private static function getAimeos()
32 32
 	{
33
-		if( !isset( self::$aimeos ) )
33
+		if (!isset(self::$aimeos))
34 34
 		{
35 35
 			require_once 'Bootstrap.php';
36
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
36
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
37 37
 
38
-			$extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
39
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true );
38
+			$extdir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
39
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true);
40 40
 		}
41 41
 
42 42
 		return self::$aimeos;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * @param string $site
48 48
 	 */
49
-	private static function createContext( $site )
49
+	private static function createContext($site)
50 50
 	{
51 51
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
52 52
 		$aimeos = self::getAimeos();
@@ -56,38 +56,38 @@  discard block
 block discarded – undo
56 56
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
57 57
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
58 58
 
59
-		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
60
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
61
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
62
-		$ctx->setConfig( $conf );
59
+		$conf = new \Aimeos\MW\Config\PHPArray([], $paths);
60
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
61
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
62
+		$ctx->setConfig($conf);
63 63
 
64 64
 
65
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
66
-		$ctx->setDatabaseManager( $dbm );
65
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
66
+		$ctx->setDatabaseManager($dbm);
67 67
 
68 68
 
69
-		$mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf );
70
-		$ctx->setMessageQueueManager( $mq );
69
+		$mq = new \Aimeos\MW\MQueue\Manager\Standard($conf);
70
+		$ctx->setMessageQueueManager($mq);
71 71
 
72 72
 
73
-		$logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG );
74
-		$ctx->setLogger( $logger );
73
+		$logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG);
74
+		$ctx->setLogger($logger);
75 75
 
76 76
 
77
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
78
-		$ctx->setI18n( array( 'de' => $i18n ) );
77
+		$i18n = new \Aimeos\MW\Translation\None('de');
78
+		$ctx->setI18n(array('de' => $i18n));
79 79
 
80 80
 
81 81
 		$session = new \Aimeos\MW\Session\None();
82
-		$ctx->setSession( $session );
82
+		$ctx->setSession($session);
83 83
 
84 84
 
85
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx );
86
-		$locale = $localeManager->bootstrap( $site, '', '', false );
87
-		$ctx->setLocale( $locale );
85
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx);
86
+		$locale = $localeManager->bootstrap($site, '', '', false);
87
+		$ctx->setLocale($locale);
88 88
 
89 89
 
90
-		$ctx->setEditor( 'core:controller/frontend' );
90
+		$ctx->setEditor('core:controller/frontend');
91 91
 
92 92
 		return $ctx;
93 93
 	}
Please login to merge, or discard this patch.