<?php

namespace Modules\Shared\Helpers\Excel;

class SheetStylesManager
{
    private $sheet;
    private $styles;

    public function __construct($sheet, $styles)
    {
        $this->sheet  = $sheet;
        $this->styles = $styles;
    }

    public function autoSum($row, $columns, $start_row, $end_row)
    {
        foreach ($columns as $column) {
            $this->sheet->setCellValue("{$column}{$row}", "=SUM({$column}{$start_row}:{$column}{$end_row})");
        }
    }

    public function border($start_row, $end_row)
    {
        $border = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN;

        for ($i = $start_row; $i <= $end_row; $i++) {
            $this->styles[$i] = [
                'borders' => [
                    'allBorders' => [
                        'borderStyle' => $border,
                        'color' => ['argb' => '171719'],
                    ],
                ]
            ];
        }

        return $this->styles;
    }
}
