PluginProbe
Datafeedr API / 1.0.124
Datafeedr API v1.0.124
1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 All 181 releases
datafeedr-api / src / Migrations / Migration.php

Migration.php in Datafeedr API 1.0.124, at src/Migrations/Migration.php

47 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace Datafeedr\Api\Migrations;
2
3 /**
4 * Class Migration
5 * @package Datafeedr\Api\Migrations
6 *
7 * @since 2.0.0
8 *
9 * Contains the version() method for extracting the version number from the
10 * Migration class name.
11 */
12 abstract class Migration {
13
14 /**
15 * Returns the migration version by extracting it from the Migration class name.
16 *
17 * For example, if the class is named Migration_20180118151744_Create_New_Option()
18 *
19 * Then this function will return 20180118151744.
20 *
21 * If the version was not found in this class name, this function will return a very high number
22 * which should never be considered a proper DB version number because I don't expect there will
23 * still be WordPress websites in the year 3000. ;)
24 *
25 * @since 2.0.0
26 *
27 * @return string
28 */
29 public function version() {
30 $called_class = get_called_class();
31 $class_parts = explode( '_', $called_class );
32 foreach ( $class_parts as $part ) {
33 if ( is_numeric( $part ) ) {
34 return $part;
35 }
36 }
37
38 /**
39 * Return a high version number because one was not found in the called class name.
40 *
41 * This will prevent the migration script from rerunning the same migration over and over
42 * because no version was returned.
43 */
44 return '30000111111111';
45 }
46 }
47