<?php

namespace FireflyIII\Helpers\Collection;

use Illuminate\Support\Collection;

/**
 * @codeCoverageIgnore
 *
 * Class Budget
 *
 * @package FireflyIII\Helpers\Collection
 */
class Budget
{
    /** @var  Collection */
    protected $budgetLines;
    /** @var string */
    protected $budgeted = '0';
    /** @var string */
    protected $left = '0';
    /** @var string */
    protected $overspent = '0';
    /** @var string */
    protected $spent = '0';

    /**
     *
     */
    public function __construct()
    {
        $this->budgetLines = new Collection;
    }

    /**
     * @param BudgetLine $budgetLine
     */
    public function addBudgetLine(BudgetLine $budgetLine)
    {
        $this->budgetLines->push($budgetLine);
    }

    /**
     * @param float $add
     */
    public function addBudgeted($add)
    {
        $add = strval(round($add, 2));
        bcscale(2);
        $this->budgeted = bcadd($this->budgeted, $add);
    }

    /**
     * @param float $add
     */
    public function addLeft($add)
    {
        $add = strval(round($add, 2));
        bcscale(2);
        $this->left = bcadd($this->left, $add);
    }

    /**
     * @param float $add
     */
    public function addOverspent($add)
    {
        $add = strval(round($add, 2));
        bcscale(2);
        $this->overspent = bcadd($this->overspent, $add);
    }

    /**
     * @param float $add
     */
    public function addSpent($add)
    {
        $add = strval(round($add, 2));
        bcscale(2);
        $this->spent = bcadd($this->spent, $add);
    }

    /**
     * @return \Illuminate\Support\Collection
     */
    public function getBudgetLines()
    {
        return $this->budgetLines;
    }

    /**
     * @return string
     */
    public function getBudgeted()
    {
        return $this->budgeted;
    }

    /**
     * @param string $budgeted
     */
    public function setBudgeted($budgeted)
    {
        $this->budgeted = $budgeted;
    }

    /**
     * @return string
     */
    public function getLeft()
    {
        return $this->left;
    }

    /**
     * @param string $left
     */
    public function setLeft($left)
    {
        $this->left = $left;
    }

    /**
     * @return string
     */
    public function getOverspent()
    {
        return $this->overspent;
    }

    /**
     * @param string $overspent
     */
    public function setOverspent($overspent)
    {
        $this->overspent = strval(round($overspent, 2));
    }

    /**
     * @return string
     */
    public function getSpent()
    {
        return $this->spent;
    }

    /**
     * @param string $spent
     */
    public function setSpent($spent)
    {
        $this->spent = strval(round($spent, 2));
    }


}
