<?php
// Copyright 1999-2017. Plesk International GmbH. All rights reserved.

namespace Plesk\MigrationLibV8\MailImport\Entity\Status;

/**
 * Whole import status of a session - all mail address pairs ever migrated within the session.
 *
 * @package Plesk\MigrationLibV8\MailImport\Entity\Status
 */
class Import
{
    /**
     * @var \Plesk\MigrationLibV8\MailImport\Entity\Status\Import\MailAddressPair[]
     */
    private $_mailAddressPairsStatus;

    /**
     * Import constructor.
     *
     * @param $mailAddressPairsStatus \Plesk\MigrationLibV8\MailImport\Entity\Status\Import\MailAddressPair[]
     */
    public function __construct($mailAddressPairsStatus) {
        $this->_mailAddressPairsStatus = $mailAddressPairsStatus;
    }

    /**
     * @return \Plesk\MigrationLibV8\MailImport\Entity\Status\Import\MailAddressPair[]
     */
    public function getMailAddressPairsStatus()
    {
        return $this->_mailAddressPairsStatus;
    }

    /**
     * Get whole import status as array (useful for integration with JavaScript code).
     *
     * @return array
     */
    public function asArray()
    {
        $mailAddressPairsStatus = [];
        foreach ($this->getMailAddressPairsStatus() as $mailAddressPairStatus) {
            $mailAddressPairsStatus[] = $mailAddressPairStatus->asArray();
        }

        return [
            'mail_address_pairs' => $mailAddressPairsStatus,
        ];
    }
}
