$27 GRAYBYTE WORDPRESS FILE MANAGER $35

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.216.51
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravetechrwanda/itiministry.org/plugins/give/src/MigrationLog/Helpers/

HOME
Current File : /home/bravetechrwanda/itiministry.org/plugins/give/src/MigrationLog/Helpers//MigrationHelper.php
<?php

namespace Give\MigrationLog\Helpers;

use Give\Framework\Migrations\Contracts\Migration;
use Give\Framework\Migrations\MigrationsRegister;
use Give\MigrationLog\MigrationLogModel;
use Give\MigrationLog\MigrationLogRepository;

/**
 * Class MigrationOrder
 * @package Give\MigrationLog\Helpers
 *
 * Helper class used to get migration data
 *
 * @since   2.10.0
 */
class MigrationHelper
{

    /**
     * @var MigrationsRegister
     */
    private $migrationRegister;

    /**
     * @var MigrationLogRepository
     */
    private $migrationRepository;

    /**
     * @var MigrationLogModel[]
     */
    private $migrationsInDatabase;

    /**
     * MigrationOrder constructor.
     *
     * @param MigrationsRegister     $migrationRegister
     * @param MigrationLogRepository $migrationRepository
     */
    public function __construct(
        MigrationsRegister $migrationRegister,
        MigrationLogRepository $migrationRepository
    ) {
        $this->migrationRegister = $migrationRegister;
        $this->migrationRepository = $migrationRepository;
    }

    /**
     * Get migrations sorted by run order
     *
     * @since 2.10.0
     *
     * @return array
     */
    private function getMigrationsSorted()
    {
        static $migrations = [];

        if (empty($migrations)) {
            /* @var Migration $migrationClass */
            foreach ($this->migrationRegister->getMigrations() as $migrationClass) {
                $migrations[$migrationClass::id()] = $migrationClass::timestamp();
            }

            asort($migrations);
        }

        return $migrations;
    }

    /**
     * Get pending migrations
     *
     * @since 2.10.0
     *
     * @return string[]
     */
    public function getPendingMigrations()
    {
        return array_filter(
            $this->migrationRegister->getMigrations(),
            function ($migrationClass) {
                /* @var Migration $migrationClass */
                foreach ($this->getMigrationsInDatabase() as $migration) {
                    if ($migration->getId() === $migrationClass::id()) {
                        return false;
                    }
                }

                return true;
            }
        );
    }

    /**
     * Get migration run order
     *
     * @since 2.10.0
     *
     * @param string $migrationId
     *
     * @return int
     */
    public function getRunOrderForMigration($migrationId)
    {
        return array_search($migrationId, array_keys($this->getMigrationsSorted())) + 1;
    }

    /**
     * Retrieves the migrations from the database, caching the results for future retrieval
     *
     * @since 2.10.1
     *
     * @return MigrationLogModel[]
     */
    private function getMigrationsInDatabase()
    {
        if ($this->migrationsInDatabase === null) {
            $this->migrationsInDatabase = $this->migrationRepository->getMigrations();
        }

        return $this->migrationsInDatabase;
    }
}


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 May 2026 4.20 PM
bravetechrwanda / bravetechrwanda
0755
Assets.php
0.678 KB
31 Mar 2025 11.17 PM
bravetechrwanda / bravetechrwanda
0644
Environment.php
0.637 KB
24 Nov 2021 4.55 AM
bravetechrwanda / bravetechrwanda
0644
MigrationHelper.php
2.906 KB
31 Mar 2025 11.17 PM
bravetechrwanda / bravetechrwanda
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF