Cms   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 9
c 0
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 13 4
A before() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Creates all CMS tables.
14
 */
15
class Cms extends Base
16
{
17
	/**
18
	 * Returns the list of task names which depends on this task.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function before() : array
23
	{
24
		return ['Locale'];
25
	}
26
27
28
	/**
29
	 * Creates the CMS tables
30
	 */
31
	public function up()
32
	{
33
		$this->info( 'Creating CMS tables', 'vv' );
34
		$db = $this->db( 'db-cms' );
35
36
		foreach( $this->paths( 'default/schema/cms.php' ) as $filepath )
37
		{
38
			if( ( $list = include( $filepath ) ) === false ) {
39
				throw new \RuntimeException( sprintf( 'Unable to get schema from file "%1$s"', $filepath ) );
40
			}
41
42
			foreach( $list['table'] ?? [] as $name => $fcn ) {
43
				$db->table( $name, $fcn );
44
			}
45
		}
46
	}
47
}
48