HEX
Server: Apache/2.4.66 (Debian)
System: Linux 6dfabc3b2241 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User: (1000)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wp-migrate-db/class/Common/DryRun/DiffInterpreter.php
<?php

namespace DeliciousBrains\WPMDB\Common\DryRun;

class DiffInterpreter
{

    /**
     * @var DiffGroup
     */
    private $group;


    /**
     * @param DiffGroup $group
     */
    public function __construct(DiffGroup $group)
    {
        $this->group = $group;
    }


    /**
     * Computes string difference and adds the entity to the group if diff exists.
     *
     * @param DiffEntity $entity
     */
    public function compute(DiffEntity $entity)
    {
        if (0 !== strcmp($entity->getOriginalExpression(), $entity->getReplaceExpression())) {
            $this->group->addEntity($entity);
        }
    }


    /**
     * post-find/replace procedures.
     */
    public function finalize() {
        $this->group->finalize();
    }


    /**
     * Returns array of diff entities with unmatching strings.
     *
     * @return DiffEntity[]
     */
    public function results() {
        return $this->group->getEntities();
    }

    /**
     * @return DiffGroup
     */
    public function getGroup()
    {
        return $this->group;
    }
}