PluginProbe
Boxzilla – WordPress Popup Builder / 3.2
Boxzilla – WordPress Popup Builder v3.2
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
← All changes | src/admin/class-migrations.php +22 -25 3.4.53.2 View file →
@@ -6,10 +6,10 @@
6 6
7 7 /**
8 8 *
9 9 */
10 -class Migrations
11 -{
10 +class Migrations {
11 +
12 12 /**
13 13 * @var float
14 14 */
15 15 protected $version_from = 0;
@@ -28,12 +28,11 @@
28 28 * @param float $from
29 29 * @param float $to
30 30 * @param string $migrations_dir
31 31 */
32 - public function __construct($from, $to, $migrations_dir)
33 - {
34 - $this->version_from = $from;
35 - $this->version_to = $to;
32 + public function __construct( $from, $to, $migrations_dir ) {
33 + $this->version_from = $from;
34 + $this->version_to = $to;
36 35 $this->migrations_dir = $migrations_dir;
37 36 }
38 37
39 38 /**
@@ -38,40 +37,38 @@
38 37
39 38 /**
40 39 * Run the various upgrade routines, all the way up to the latest version
41 40 */
42 - public function run()
43 - {
41 + public function run() {
44 42 $migrations = $this->find_migrations();
45 43 // run in sub-function for scope
46 - array_map([ $this, 'run_migration' ], $migrations);
44 + array_map( array( $this, 'run_migration' ), $migrations );
47 45 }
48 46
49 47 /**
50 48 * @return array
51 49 */
52 - public function find_migrations()
53 - {
54 - $files = glob(rtrim($this->migrations_dir, '/') . '/*.php');
55 - $migrations = [];
50 + public function find_migrations() {
51 + $files = glob( rtrim( $this->migrations_dir, '/' ) . '/*.php' );
52 + $migrations = array();
56 53
57 54 // return empty array when glob returns non-array value.
58 - if (! is_array($files)) {
55 + if( ! is_array( $files ) ) {
59 56 return $migrations;
60 57 }
61 58
62 - foreach ($files as $file) {
63 - $migration = basename($file);
64 - $parts = explode('-', $migration);
65 - $version = $parts[0];
59 + foreach( $files as $file ) {
60 + $migration = basename( $file );
61 + $parts = explode( '-', $migration );
62 + $version = $parts[0];
66 63
67 64 // check if migration file is not for an even higher version
68 - if (version_compare($version, $this->version_to, '>')) {
65 + if( version_compare( $version, $this->version_to, '>' ) ) {
69 66 continue;
70 67 }
71 68
72 69 // check if we ran migration file before.
73 - if (version_compare($this->version_from, $version, '>=')) {
70 + if( version_compare( $this->version_from, $version, '>=' ) ) {
74 71 continue;
75 72 }
76 73
77 74 // schedule migration file for running
@@ -87,13 +84,13 @@
87 84 * @param string $file
88 85 *
89 86 * @throws Exception
90 87 */
91 - protected function run_migration($file)
92 - {
93 - if (! file_exists($file)) {
94 - throw new Exception("Migration file $file does not exist.");
88 + protected function run_migration( $file ) {
89 +
90 + if( ! file_exists( $file ) ) {
91 + throw new Exception( "Migration file $file does not exist.");
95 92 }
96 93
97 94 include $file;
98 95 }
99 -}
96 +}