@@ -88,7 +88,8 @@ |
||
88 | 88 | return array_pop( $this->connections[$name] ); |
89 | 89 | |
90 | 90 | } |
91 | - catch( \Exception $e ) { |
|
91 | + catch( \Exception $e ) |
|
92 | + { |
|
92 | 93 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode() ); |
93 | 94 | } |
94 | 95 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | try |
67 | 67 | { |
68 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
68 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
69 | 69 | |
70 | 70 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
71 | 71 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->count[$name] = 0; |
74 | 74 | } |
75 | 75 | |
76 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
76 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
77 | 77 | |
78 | 78 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
79 | 79 | { |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function createConnection( $name, $adapter ) |
121 | 121 | { |
122 | - $params = $this->config->get( 'resource/' . $name ); |
|
122 | + $params = $this->config->get( 'resource/'.$name ); |
|
123 | 123 | |
124 | - $params['user'] = $this->config->get( 'resource/' . $name . '/username' ); |
|
125 | - $params['dbname'] = $this->config->get( 'resource/' . $name . '/database' ); |
|
124 | + $params['user'] = $this->config->get( 'resource/'.$name.'/username' ); |
|
125 | + $params['dbname'] = $this->config->get( 'resource/'.$name.'/database' ); |
|
126 | 126 | |
127 | - if( ( $socket = $this->config->get( 'resource/' . $name . '/socket' ) ) != null ) { |
|
127 | + if( ( $socket = $this->config->get( 'resource/'.$name.'/socket' ) ) != null ) { |
|
128 | 128 | $params['unix_socket'] = $socket; |
129 | 129 | } |
130 | 130 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $conn = \Doctrine\DBAL\DriverManager::getConnection( $params ); |
141 | 141 | $dbc = new \Aimeos\MW\DB\Connection\DBAL( $conn ); |
142 | 142 | |
143 | - foreach( $this->config->get( 'resource/' . $name . '/stmt', [] ) as $stmt ) { |
|
143 | + foreach( $this->config->get( 'resource/'.$name.'/stmt', [] ) as $stmt ) { |
|
144 | 144 | $dbc->create( $stmt )->execute()->finish(); |
145 | 145 | } |
146 | 146 |
@@ -88,7 +88,8 @@ discard block |
||
88 | 88 | return array_pop( $this->connections[$name] ); |
89 | 89 | |
90 | 90 | } |
91 | - catch( \PDOException $e ) { |
|
91 | + catch( \PDOException $e ) |
|
92 | + { |
|
92 | 93 | throw new \Aimeos\MW\DB\Exception( $e->getMessage(), $e->getCode(), $e->errorInfo ); |
93 | 94 | } |
94 | 95 | } |
@@ -131,8 +132,7 @@ discard block |
||
131 | 132 | { |
132 | 133 | $dsn .= isset( $host ) ? ';host=' . $host : ''; |
133 | 134 | $dsn .= isset( $port ) ? ';port=' . $port : ''; |
134 | - } |
|
135 | - else |
|
135 | + } else |
|
136 | 136 | { |
137 | 137 | $dsn .= ';unix_socket=' . $sock; |
138 | 138 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | try |
57 | 57 | { |
58 | - $adapter = $this->config->get( 'resource/' . $name . '/adapter', 'mysql' ); |
|
58 | + $adapter = $this->config->get( 'resource/'.$name.'/adapter', 'mysql' ); |
|
59 | 59 | |
60 | 60 | if( !isset( $this->connections[$name] ) || empty( $this->connections[$name] ) ) |
61 | 61 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->count[$name] = 0; |
64 | 64 | } |
65 | 65 | |
66 | - $limit = $this->config->get( 'resource/' . $name . '/limit', -1 ); |
|
66 | + $limit = $this->config->get( 'resource/'.$name.'/limit', -1 ); |
|
67 | 67 | |
68 | 68 | if( $limit >= 0 && $this->count[$name] >= $limit ) |
69 | 69 | { |
@@ -109,33 +109,33 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected function createConnection( $name, $adapter ) |
111 | 111 | { |
112 | - $host = $this->config->get( 'resource/' . $name . '/host' ); |
|
113 | - $port = $this->config->get( 'resource/' . $name . '/port' ); |
|
114 | - $user = $this->config->get( 'resource/' . $name . '/username' ); |
|
115 | - $pass = $this->config->get( 'resource/' . $name . '/password' ); |
|
116 | - $sock = $this->config->get( 'resource/' . $name . '/socket' ); |
|
117 | - $dbase = $this->config->get( 'resource/' . $name . '/database' ); |
|
118 | - |
|
119 | - $dsn = $adapter . ':dbname=' . $dbase; |
|
112 | + $host = $this->config->get( 'resource/'.$name.'/host' ); |
|
113 | + $port = $this->config->get( 'resource/'.$name.'/port' ); |
|
114 | + $user = $this->config->get( 'resource/'.$name.'/username' ); |
|
115 | + $pass = $this->config->get( 'resource/'.$name.'/password' ); |
|
116 | + $sock = $this->config->get( 'resource/'.$name.'/socket' ); |
|
117 | + $dbase = $this->config->get( 'resource/'.$name.'/database' ); |
|
118 | + |
|
119 | + $dsn = $adapter.':dbname='.$dbase; |
|
120 | 120 | if( $sock == null ) |
121 | 121 | { |
122 | - $dsn .= isset( $host ) ? ';host=' . $host : ''; |
|
123 | - $dsn .= isset( $port ) ? ';port=' . $port : ''; |
|
122 | + $dsn .= isset( $host ) ? ';host='.$host : ''; |
|
123 | + $dsn .= isset( $port ) ? ';port='.$port : ''; |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | - $dsn .= ';unix_socket=' . $sock; |
|
127 | + $dsn .= ';unix_socket='.$sock; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $attr = array( |
131 | - \PDO::ATTR_PERSISTENT => $this->config->get( 'resource/' . $name . '/opt-persistent', false ), |
|
131 | + \PDO::ATTR_PERSISTENT => $this->config->get( 'resource/'.$name.'/opt-persistent', false ), |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | $pdo = new \PDO( $dsn, $user, $pass, $attr ); |
135 | 135 | $pdo->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION ); |
136 | 136 | $dbc = new \Aimeos\MW\DB\Connection\PDO( $pdo ); |
137 | 137 | |
138 | - foreach( $this->config->get( 'resource/' . $name . '/stmt', [] ) as $stmt ) { |
|
138 | + foreach( $this->config->get( 'resource/'.$name.'/stmt', [] ) as $stmt ) { |
|
139 | 139 | $dbc->create( $stmt )->execute()->finish(); |
140 | 140 | } |
141 | 141 |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $message = json_encode( $message ); |
72 | 72 | } |
73 | 73 | |
74 | - if( error_log( '<' . $facility . '> ' . $level . ' ' . $message ) === false ) { |
|
74 | + if( error_log( '<'.$facility.'> '.$level.' '.$message ) === false ) { |
|
75 | 75 | throw new \Aimeos\MW\Logger\Exception( sprintf( |
76 | 76 | 'Unable to log message with priority "%1$d": %2$s', $priority, $message ) ); |
77 | 77 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Log messages to a database table. |
17 | - * |
|
17 | + * |
|
18 | 18 | * @package MW |
19 | 19 | * @subpackage Logger |
20 | 20 | */ |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $this->facilities = $facilities; |
46 | 46 | |
47 | 47 | if( $requestid === null ) { |
48 | - $requestid = md5( php_uname('n') . getmypid() . date( 'Y-m-d H:i:s' ) ); |
|
48 | + $requestid = md5( php_uname( 'n' ).getmypid().date( 'Y-m-d H:i:s' ) ); |
|
49 | 49 | } |
50 | 50 | $this->requestid = $requestid; |
51 | 51 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct( $filename, $priority = \Aimeos\MW\Logger\Base::ERR, array $facilities = null ) |
36 | 36 | { |
37 | - if ( !$this->stream = fopen( $filename, 'a', false ) ) { |
|
37 | + if( !$this->stream = fopen( $filename, 'a', false ) ) { |
|
38 | 38 | throw new \Aimeos\MW\Logger\Exception( sprintf( 'Unable to open file "%1$s" for appending' ), $filename ); |
39 | 39 | } |
40 | 40 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $message = json_encode( $message ); |
64 | 64 | } |
65 | 65 | |
66 | - $message = '<' . $facility . '> ' . date( 'Y-m-d H:i:s' ) . ' ' . $priority . ' ' . $message; |
|
66 | + $message = '<'.$facility.'> '.date( 'Y-m-d H:i:s' ).' '.$priority.' '.$message; |
|
67 | 67 | |
68 | - if ( false === fwrite( $this->stream, $message ) ) { |
|
68 | + if( false === fwrite( $this->stream, $message ) ) { |
|
69 | 69 | throw new \Aimeos\MW\Logger\Exception( 'Unable to write to stream' ); |
70 | 70 | } |
71 | 71 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function checkClass( $name, $object ) |
31 | 31 | { |
32 | - if( ($object instanceof $name) === false ) { |
|
32 | + if( ( $object instanceof $name ) === false ) { |
|
33 | 33 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Object doesn\'t implement "%1$s"', $name ) ); |
34 | 34 | } |
35 | 35 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public static function checkClassList( $name, array $list ) |
46 | 46 | { |
47 | 47 | foreach( $list as $object ) { |
48 | - if( ($object instanceof $name) === false ) { |
|
48 | + if( ( $object instanceof $name ) === false ) { |
|
49 | 49 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Object doesn\'t implement "%1$s"', $name ) ); |
50 | 50 | } |
51 | 51 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | foreach( $attributes as $key => $item ) |
99 | 99 | { |
100 | 100 | if( $item instanceof $iface ) { |
101 | - $translations[ $item->getCode() ] = $item->getInternalCode(); |
|
101 | + $translations[$item->getCode()] = $item->getInternalCode(); |
|
102 | 102 | } else if( isset( $item['code'] ) ) { |
103 | - $translations[ $item['code'] ] = $item['internalcode']; |
|
103 | + $translations[$item['code']] = $item['internalcode']; |
|
104 | 104 | } else { |
105 | 105 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
106 | 106 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | foreach( $attributes as $key => $item ) |
127 | 127 | { |
128 | 128 | if( $item instanceof $iface ) { |
129 | - $types[ $item->getCode() ] = $item->getInternalType(); |
|
129 | + $types[$item->getCode()] = $item->getInternalType(); |
|
130 | 130 | } else if( isset( $item['code'] ) ) { |
131 | - $types[ $item['code'] ] = $item['internaltype']; |
|
131 | + $types[$item['code']] = $item['internaltype']; |
|
132 | 132 | } else { |
133 | 133 | throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
134 | 134 | } |
@@ -311,6 +311,9 @@ |
||
311 | 311 | |
312 | 312 | class TestBase extends \Aimeos\MShop\Service\Provider\Base |
313 | 313 | { |
314 | + /** |
|
315 | + * @param integer $ts |
|
316 | + */ |
|
314 | 317 | public function calcDateLimitPublic( $ts, $days = 0, $bd = false, $hd = '' ) |
315 | 318 | { |
316 | 319 | return $this->calcDateLimit( $ts, $days, $bd, $hd ); |
@@ -335,6 +335,9 @@ |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | + /** |
|
339 | + * @param string $name |
|
340 | + */ |
|
338 | 341 | protected function access( $name ) |
339 | 342 | { |
340 | 343 | $class = new \ReflectionClass( '\Aimeos\Controller\Common\Media\Standard' ); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $file = $this->getMockBuilder( '\Psr\Http\Message\UploadedFileInterface' )->getMock(); |
42 | 42 | $file->expects( $this->once() )->method( 'getStream' ) |
43 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.gif' ) ) ); |
|
43 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.gif' ) ) ); |
|
44 | 44 | |
45 | 45 | $item = \Aimeos\MShop\Factory::createManager( $this->context, 'media' )->createItem(); |
46 | 46 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $file = $this->getMockBuilder( '\Psr\Http\Message\UploadedFileInterface' )->getMock(); |
62 | 62 | $file->expects( $this->once() )->method( 'getStream' ) |
63 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.pdf' ) ) ); |
|
63 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.pdf' ) ) ); |
|
64 | 64 | |
65 | 65 | $item = \Aimeos\MShop\Factory::createManager( $this->context, 'media' )->createItem(); |
66 | 66 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ->getMock(); |
109 | 109 | |
110 | 110 | $object->expects( $this->once() )->method( 'getFileContent' ) |
111 | - ->will( $this->returnValue( file_get_contents( __DIR__ . '/testfiles/test.png' ) ) ); |
|
111 | + ->will( $this->returnValue( file_get_contents( __DIR__.'/testfiles/test.png' ) ) ); |
|
112 | 112 | |
113 | 113 | $object->expects( $this->exactly( 2 ) )->method( 'storeFile' ); |
114 | 114 | |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | public function testGetFileContent() |
206 | 206 | { |
207 | - $dest = dirname( dirname( dirname( __DIR__ ) ) ) . '/tmp/'; |
|
207 | + $dest = dirname( dirname( dirname( __DIR__ ) ) ).'/tmp/'; |
|
208 | 208 | if( !is_dir( $dest ) ) { mkdir( $dest, 0755, true ); } |
209 | - copy( __DIR__ . '/testfiles/test.gif', $dest . 'test.gif' ); |
|
209 | + copy( __DIR__.'/testfiles/test.gif', $dest.'test.gif' ); |
|
210 | 210 | |
211 | 211 | $result = $this->access( 'getFileContent' )->invokeArgs( $this->object, array( 'test.gif', 'fs-media' ) ); |
212 | 212 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | public function testGetMimeType() |
298 | 298 | { |
299 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.png' ); |
|
299 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.png' ); |
|
300 | 300 | |
301 | 301 | $result = $this->access( 'getMimeType' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
302 | 302 | $this->assertEquals( 'image/png', $result ); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function testGetMimeTypeNotAllowed() |
307 | 307 | { |
308 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
308 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
309 | 309 | $this->context->getConfig()->set( 'controller/common/media/standard/files/allowedtypes', array( 'image/jpeg' ) ); |
310 | 310 | |
311 | 311 | $result = $this->access( 'getMimeType' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | public function testGetMimeTypeNoTypes() |
317 | 317 | { |
318 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
318 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
319 | 319 | $this->context->getConfig()->set( 'controller/common/media/standard/files/allowedtypes', [] ); |
320 | 320 | |
321 | 321 | $this->setExpectedException( '\Aimeos\Controller\Common\Exception' ); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | public function testScaleImage() |
327 | 327 | { |
328 | - $file = \Aimeos\MW\Media\Factory::get( __DIR__ . '/testfiles/test.gif' ); |
|
328 | + $file = \Aimeos\MW\Media\Factory::get( __DIR__.'/testfiles/test.gif' ); |
|
329 | 329 | |
330 | 330 | $this->access( 'scaleImage' )->invokeArgs( $this->object, array( $file, 'files' ) ); |
331 | 331 | } |
@@ -333,18 +333,18 @@ discard block |
||
333 | 333 | |
334 | 334 | public function testStoreFile() |
335 | 335 | { |
336 | - $content = file_get_contents( __DIR__ . '/testfiles/test.gif' ); |
|
336 | + $content = file_get_contents( __DIR__.'/testfiles/test.gif' ); |
|
337 | 337 | |
338 | - $dest = dirname( dirname( dirname( __DIR__ ) ) ) . '/tmp/'; |
|
338 | + $dest = dirname( dirname( dirname( __DIR__ ) ) ).'/tmp/'; |
|
339 | 339 | if( !is_dir( $dest ) ) { mkdir( $dest, 0755, true ); } |
340 | - copy( __DIR__ . '/testfiles/test.gif', $dest . 'test2.gif' ); |
|
340 | + copy( __DIR__.'/testfiles/test.gif', $dest.'test2.gif' ); |
|
341 | 341 | |
342 | 342 | $this->access( 'storeFile' )->invokeArgs( $this->object, array( $content, 'fs-media', 'test.gif', 'test2.gif' ) ); |
343 | 343 | |
344 | - $this->assertFalse( file_exists( $dest . 'test2.gif' ) ); |
|
345 | - $this->assertTrue( file_exists( $dest . 'test.gif' ) ); |
|
344 | + $this->assertFalse( file_exists( $dest.'test2.gif' ) ); |
|
345 | + $this->assertTrue( file_exists( $dest.'test.gif' ) ); |
|
346 | 346 | |
347 | - unlink( $dest . 'test.gif' ); |
|
347 | + unlink( $dest.'test.gif' ); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 |