<?php
namespace Incoviba\Common\Ideal\Cartola;

use Incoviba\Common\Define;
use Incoviba\Common\Ideal\Service;
use Psr\Http\Message\UploadedFileInterface;

abstract class Banco extends Service implements Define\Cartola\Banco
{
    public function process(UploadedFileInterface $file): array
    {
        $data = $this->parseFile($file);
        $temp = [];
        $columns = $this->columnMap();
        foreach ($data as $row) {
            $r = [];
            foreach ($columns as $old => $new) {
                if (!isset($row[$old])) {
                    continue;
                }
                $r[$new] = $row[$old];
            }
            $temp []= $r;
        }
        return $temp;
    }
    public function processMovimientosDiarios(array $movimientos): array
    {
        return $movimientos;
    }

    abstract protected function columnMap(): array;
    abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
}
