summaryrefslogtreecommitdiff
path: root/src/Script/Output.php
blob: e61cff81702155639806a366c98bb0b4bbf1cddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace App\Script;

use App\Model\Collection;
use Exception;

class Output
{
    public function printCollection(Collection $collection)
    {
        if (count($collection) === 0) {
            echo "No results found\n";
            return;
        }

        $out = [];
        foreach ($collection as $vendor) {
            $out[] = implode("\n", $vendor->toString());
        }

        echo implode("\n\n", $out) . "\n";
    }

    public function printException(Exception $e)
    {
        echo "An unexpected exception occured:\n" . $e->getMessage() . "\n";
    }
}