HEX
Server: Apache/2
System: Linux nexus-01 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: aglcoke (1118)
PHP: 8.2.31
Disabled: mail,exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/self/cwd/wp-content/plugins/duplicator-pro/src/Utils/IncrementalStatusMessage.php
<?php

/**
 * @package   Duplicator
 * @copyright (c) 2022, Snapcreek LLC
 */

namespace Duplicator\Utils;

/**
 * This class is for accumulation of messages. It implements __toString method, so objects
 * of this class can be passed to strval or be used in other contexts where string is expected.
 */
class IncrementalStatusMessage
{
    /** @var string Prepend to each line in __toString method */
    private $prepend = "-> ";
    /** @var string Append to each line in __toString method */
    private $append = "\n";
    /** @var string[] */
    protected $messages = [];

    /**
     * Constructor of the class
     */
    public function __construct()
    {
    }

    /**
     * @param mixed $message Message to add to container. It will be converted to string.
     *
     * @return void
     */
    public function addMessage($message)
    {
        $this->messages[] = (string) $message;
    }

    /**
     * Resets/empties messages container
     *
     * @return void
     */
    public function reset()
    {
        $this->messages = [];
    }

    /**
     * Converts/combines logged messages into one string.
     * Takes into account attributes $append and $prepend for each line.
     *
     * @return string
     */
    public function __toString()
    {
        $finalString = "";
        foreach ($this->messages as $message) {
            $finalString .= $this->prepend . $message . $this->append;
        }
        return $finalString;
    }

    /**
     * Setter method
     *
     * @param string $prepend Prepend to each line
     *
     * @return void
     */
    public function setPrepend($prepend = "->")
    {
        $this->prepend = (string) $prepend;
    }

    /**
     * Setter method
     *
     * @param string $append Append to each line
     *
     * @return void
     */
    public function setAppend($append = "\n")
    {
        $this->append = (string) $append;
    }

    /**
     * Getter method
     *
     * @return string prepend
     */
    public function getPrepend()
    {
        return $this->prepend;
    }

    /**
     * Getter method
     *
     * @return string append
     */
    public function getAppend()
    {
        return $this->append;
    }
}