SAREhub/PHP_Client

View on GitHub
src/SAREhub/Client/Processor/ExchangeCatcherProcessor.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace SAREhub\Client\Processor;

use SAREhub\Client\Message\Exchange;
use SAREhub\Client\Message\Message;

class ExchangeCatcherProcessor implements Processor
{
    /**
     * @var Exchange[]
     */
    private $caughtHistory = [];

    public function process(Exchange $exchange)
    {
        $this->caughtHistory[] = $exchange->copy();
    }

    /**
     * @return Exchange[]
     */
    public function getCaughtHistory(): array
    {
        return $this->caughtHistory;
    }

    /**
     * @return Message[]
     */
    public function getCaughtInMessages(): array
    {
        $history = [];
        foreach ($this->getCaughtHistory() as $exchange) {
            $history[] = $exchange->getIn();
        }
        return $history;
    }
}