. */ declare(strict_types=1); namespace FireflyIII\Services\Spectre\Object; use Carbon\Carbon; /** * @codeCoverageIgnore * Class Account */ class Account extends SpectreObject { /** @var float */ private $balance; /** @var Carbon */ private $createdAt; /** @var string */ private $currencyCode; /** @var array */ private $extra = []; /** @var int */ private $id; /** @var int */ private $loginId; /** @var string */ private $name; /** @var string */ private $nature; /** @var Carbon */ private $updatedAt; /** * Account constructor. * * @param array $data */ public function __construct(array $data) { $this->id = (int)$data['id']; $this->loginId = $data['login_id']; $this->currencyCode = $data['currency_code']; $this->balance = $data['balance']; $this->name = $data['name']; $this->nature = $data['nature']; $this->createdAt = new Carbon($data['created_at']); $this->updatedAt = new Carbon($data['updated_at']); foreach ($data['extra'] as $key => $value) { $this->extra[$key] = $value; } } /** * @return float */ public function getBalance(): float { return $this->balance; } /** * @return string */ public function getCurrencyCode(): string { return $this->currencyCode; } /** * @return array */ public function getExtra(): array { return $this->extra; } /** * @return int */ public function getId(): int { return $this->id; } /** * @return string */ public function getName(): string { return $this->name; } /** * @return string */ public function getNature(): string { return $this->nature; } /** * @return array */ public function toArray(): array { $array = [ 'balance' => $this->balance, 'created_at' => $this->createdAt->toIso8601String(), 'currency_code' => $this->currencyCode, 'extra' => $this->extra, 'id' => $this->id, 'login_id' => $this->loginId, 'name' => $this->name, 'nature' => $this->nature, 'updated_at' => $this->updatedAt->toIso8601String(), ]; return $array; } }