JuliaStrelkova/project-lvl2-s427

View on GitHub
src/Renderer/RendererFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php


namespace Gendiff\Renderer;


use RuntimeException;

class RendererFactory
{
    public static function getRenderer(string $format): Renderer
    {
        switch ($format) {
            case 'pretty':
                return new RendererPretty();

            case 'plain':
                return new RendererPlain();

            case 'json':
                return new RendererJson();
        }

        throw new RuntimeException('Unexpected data format');
    }
}