firefly-iii/app/Helpers/Collection/Balance.php

96 lines
2.1 KiB
PHP
Raw Normal View History

2015-05-16 07:51:23 -05:00
<?php
/**
* Balance.php
2017-10-21 01:40:00 -05:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
2017-10-21 01:40:00 -05:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:41:58 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
2015-05-16 07:51:23 -05:00
namespace FireflyIII\Helpers\Collection;
2015-05-20 12:55:53 -05:00
2015-05-16 07:51:23 -05:00
use Illuminate\Support\Collection;
/**
2017-11-15 05:25:49 -06:00
* Class Balance.
2015-05-16 07:51:23 -05:00
*/
class Balance
{
/** @var BalanceHeader Header row. */
2015-05-16 07:51:23 -05:00
protected $balanceHeader;
/** @var Collection Collection of lines. */
2015-05-16 07:51:23 -05:00
protected $balanceLines;
/**
* Balance constructor.
2015-05-16 07:51:23 -05:00
*/
public function __construct()
{
$this->balanceLines = new Collection;
}
/**
* Add a line.
*
2015-05-16 07:51:23 -05:00
* @param BalanceLine $line
*/
2018-07-07 14:17:46 -05:00
public function addBalanceLine(BalanceLine $line): void
2015-05-16 07:51:23 -05:00
{
$this->balanceLines->push($line);
}
/**
* Get the header.
*
2015-05-16 07:51:23 -05:00
* @return BalanceHeader
*/
2016-02-18 00:21:48 -06:00
public function getBalanceHeader(): BalanceHeader
2015-05-16 07:51:23 -05:00
{
2016-03-02 06:13:33 -06:00
return $this->balanceHeader ?? new BalanceHeader;
2015-05-16 07:51:23 -05:00
}
/**
* Set the header.
*
2015-05-16 07:51:23 -05:00
* @param BalanceHeader $balanceHeader
*/
2018-07-07 14:17:46 -05:00
public function setBalanceHeader(BalanceHeader $balanceHeader): void
2015-05-16 07:51:23 -05:00
{
$this->balanceHeader = $balanceHeader;
}
2015-05-16 08:43:58 -05:00
/**
* Get all lines.
*
2016-02-18 00:21:48 -06:00
* @return Collection
2015-05-16 08:43:58 -05:00
*/
2016-02-18 00:21:48 -06:00
public function getBalanceLines(): Collection
2015-05-16 08:43:58 -05:00
{
return $this->balanceLines;
}
2016-04-29 04:05:52 -05:00
/**
* Set all lines.
*
2016-04-29 04:05:52 -05:00
* @param Collection $balanceLines
*/
2018-07-07 14:17:46 -05:00
public function setBalanceLines(Collection $balanceLines): void
2016-04-29 04:05:52 -05:00
{
$this->balanceLines = $balanceLines;
}
2015-05-20 12:56:14 -05:00
}