<?php /** * Dto for fid address data * * Copyright (C) 2019 Leipzig University Library * * PHP version 7 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program 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 along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * @category VuFind * @package Service * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; /** * FID address dto class * * @category VuFind * @package Service * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ class Address { /** * Address identifier * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:update:request", * "user:update:response", * }) */ protected $id; /* @var User|null */ protected $user; /** * First address line * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:creation:request", * "user:update:request", * "user:update:response" * }) */ protected $line1; /** * Second address line * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:creation:request", * "user:update:request", * "user:update:response" * }) */ protected $line2; /** * Postal * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:creation:request", * "user:update:request", * "user:update:response" * }) */ protected $zip; /** * Town * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:creation:request", * "user:update:request", * "user:update:response" * }) */ protected $city; /** * Country * * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", * "user:creation:request", * "user:update:request", * "user:update:response" * }) */ protected $country; /** * Get address identifier * * @return string|null */ public function getId(): ?string { return $this->id; } /** * Get address identifier * * @param string|null $id identifier * * @return void */ public function setId(?string $id): void { $this->id = $id; } /** * Set user * * @param User|null $user User * * @return void */ public function setUser(?User $user): void { $this->user = $user; } /** * Get user * * @return User|null */ public function getUser(): ?User { return $this->user; } /** * Get first line * * @return string|null */ public function getLine1(): ?string { return $this->line1; } /** * Set first line * * @param string|null $line1 first line * * @return void */ public function setLine1(?string $line1): void { $this->line1 = $line1; } /** * Get second line * * @return string|null */ public function getLine2(): ?string { return $this->line2; } /** * Set second line * * @param string|null $line2 second line * * @return void */ public function setLine2(?string $line2): void { $this->line2 = $line2; } /** * Get postal * * @return string|null */ public function getZip(): ?string { return $this->zip; } /** * Set postal * * @param string|null $zip postal * * @return void */ public function setZip(?string $zip): void { $this->zip = $zip; } /** * Get town * * @return string|null town */ public function getCity(): ?string { return $this->city; } /** * Set town * * @param string|null $city town * * @return void */ public function setCity(?string $city): void { $this->city = $city; } /** * Get country * * @return string|null */ public function getCountry(): ?string { return $this->country; } /** * Set country * * @param string|null $country country * * @return void */ public function setCountry(?string $country): void { $this->country = $country; } /** * Represent object as a string * * @return string */ public function __toString() { return $this->id . ': ' . $this->line1 . ' ' . $this->line2 . '; ' . $this->zip . ' ' . $this->city . '; ' . $this->country; } /** * Check if line1, zip and city is set * * @return bool */ public function isCompleteAddress() : bool { return strlen($this->line1) > 0 && strlen($this->zip) > 0 && strlen($this->city) > 0; } }