From 41189c82738018584130dca44604f2f1c113841e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 22 Sep 2018 16:23:56 +0200 Subject: [PATCH] Static analysis fixes --- Admin/Install/Navigation.php | 12 +++- Controller/ApiController.php | 6 -- Controller/BackendController.php | 10 +-- Controller/Controller.php | 11 --- Models/AddressMapper.php | 10 ++- Models/Profile.php | 115 ++++++++++++++++++++++++++++++- Models/ProfileMapper.php | 10 ++- 7 files changed, 144 insertions(+), 30 deletions(-) diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index e7a7371..be96fe9 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -38,7 +38,17 @@ class Navigation */ public static function install(string $path = null, DatabasePool $dbPool = null) : void { - $navData = \json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); + $navFile = \file_get_contents(__DIR__ . '/Navigation.install.json'); + + if ($navFile === false) { + throw new \Exception(); + } + + $navData = \json_decode($navFile, true); + + if ($navData === false) { + throw new \Exception(); + } $class = '\\Modules\\Navigation\\Admin\\Installer'; /** @var $class \Modules\Navigation\Admin\Installer */ diff --git a/Controller/ApiController.php b/Controller/ApiController.php index c7c7c16..0ff42b8 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -16,17 +16,11 @@ namespace Modules\Profile\Controller; use Modules\Profile\Models\Profile; use Modules\Profile\Models\ProfileMapper; -use Modules\Profile\Models\PermissionState; use Modules\Admin\Models\AccountMapper; -use phpOMS\Account\PermissionType; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Message\NotificationLevel; -use phpOMS\Module\ModuleAbstract; -use phpOMS\Module\WebInterface; -use phpOMS\Views\View; -use phpOMS\Asset\AssetType; /** * Profile class. diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 9d14d1f..28c603b 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -16,15 +16,9 @@ namespace Modules\Profile\Controller; use Modules\Profile\Models\Profile; use Modules\Profile\Models\ProfileMapper; -use Modules\Profile\Models\PermissionState; -use Modules\Admin\Models\AccountMapper; -use phpOMS\Account\PermissionType; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; -use phpOMS\Message\NotificationLevel; -use phpOMS\Module\ModuleAbstract; -use phpOMS\Module\WebInterface; use phpOMS\Views\View; use phpOMS\Asset\AssetType; @@ -50,7 +44,7 @@ class BackendController extends Controller */ public function setupProfileStyles(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { - /** @var Head $head */ + /** @var \phpOMS\Model\Html\Head $head */ $head = $response->get('Content')->getData('head'); $head->addAsset(AssetType::CSS, '/Modules/Profile/Theme/Backend/css/styles.css'); } @@ -90,7 +84,7 @@ class BackendController extends Controller { $view = new View($this->app, $request, $response); - /** @var Head $head */ + /** @var \phpOMS\Model\Html\Head $head */ $head = $response->get('Content')->getData('head'); $head->addAsset(AssetType::CSS, '/Modules/Calendar/Theme/Backend/css/styles.css'); diff --git a/Controller/Controller.php b/Controller/Controller.php index 0903af9..cda510a 100644 --- a/Controller/Controller.php +++ b/Controller/Controller.php @@ -14,19 +14,8 @@ declare(strict_types=1); namespace Modules\Profile\Controller; -use Modules\Profile\Models\Profile; -use Modules\Profile\Models\ProfileMapper; -use Modules\Profile\Models\PermissionState; -use Modules\Admin\Models\AccountMapper; - -use phpOMS\Account\PermissionType; -use phpOMS\Message\RequestAbstract; -use phpOMS\Message\ResponseAbstract; -use phpOMS\Message\NotificationLevel; use phpOMS\Module\ModuleAbstract; use phpOMS\Module\WebInterface; -use phpOMS\Views\View; -use phpOMS\Asset\AssetType; /** * Profile class. diff --git a/Models/AddressMapper.php b/Models/AddressMapper.php index 4e491b7..95c89c6 100644 --- a/Models/AddressMapper.php +++ b/Models/AddressMapper.php @@ -4,7 +4,7 @@ * * PHP Version 7.2 * - * @package TBD + * @package Modules\Profile * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -21,6 +21,14 @@ use phpOMS\DataStorage\Database\Query\Column; use phpOMS\DataStorage\Database\RelationType; use phpOMS\Stdlib\Base\Location; +/** + * Address mapper. + * + * @package Modules\Profile + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class AddressMapper extends DataMapperAbstract { /** diff --git a/Models/Profile.php b/Models/Profile.php index e1ccac6..d10ba1f 100644 --- a/Models/Profile.php +++ b/Models/Profile.php @@ -22,7 +22,7 @@ use Modules\Media\Models\NullMedia; use phpOMS\Stdlib\Base\Location; /** - * Account class. + * Profile class. * * @package Modules\Profile\Models * @license OMS License 1.0 @@ -31,16 +31,53 @@ use phpOMS\Stdlib\Base\Location; */ class Profile { + /** + * Id. + * + * @var int + * @since 1.0.0 + */ private $id = 0; + /** + * Profile image. + * + * @var Media + * @since 1.0.0 + */ private $image = null; + /** + * Birthday. + * + * @var \DateTime + * @since 1.0.0 + */ private $birthday = null; + /** + * Account. + * + * @var Account + * @since 1.0.0 + */ private $account = null; + /** + * Location data. + * + * @var array + * @since 1.0.0 + */ private $location = []; + /** + * Constructor. + * + * @param Account|null $account Account to initialize this profile with + * + * @since 1.0.0 + */ public function __construct(Account $account = null) { $this->image = new NullMedia(); @@ -48,51 +85,125 @@ class Profile $this->account = $account ?? new Account(); } + /** + * Get account id. + * + * @return int Account id + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } + /** + * Get account locations. + * + * @return array + * + * @since 1.0.0 + */ public function getLocation() : array { return $this->location; } - public function addLocation(Location $location) + /** + * Add location. + * + * @param Location $location Location + * + * @return void + * + * @since 1.0.0 + */ + public function addLocation(Location $location) : void { $this->location[] = $location; } + /** + * Get account image. + * + * @return Media + * + * @since 1.0.0 + */ public function getImage() : Media { return $this->image; } + /** + * Set account image. + * + * @param Media $image Profile image + * + * @return void + * + * @since 1.0.0 + */ public function setImage(Media $image) : void { $this->image = $image; } + /** + * Set account. + * + * @param Account $account Profile account + * + * @return void + * + * @since 1.0.0 + */ public function setAccount(Account $account) : void { $this->account = $account; } + /** + * Get account. + * + * @return Account + * + * @since 1.0.0 + */ public function getAccount() : Account { return $this->account ?? new NullAccount(); } + /** + * Set birthday. + * + * @param \DateTime $birthday Birthday + * + * @return void + * + * @since 1.0.0 + */ public function setBirthday(\DateTime $birthday) : void { $this->birthday = $birthday; } + /** + * Get birthday. + * + * @return \DateTime + * + * @since 1.0.0 + */ public function getBirthday() : \DateTime { return $this->birthday; } + /** + * {@inheritdoc} + */ public function jsonSerialize() { return [ diff --git a/Models/ProfileMapper.php b/Models/ProfileMapper.php index bf95b78..4764a2c 100644 --- a/Models/ProfileMapper.php +++ b/Models/ProfileMapper.php @@ -4,7 +4,7 @@ * * PHP Version 7.2 * - * @package TBD + * @package Modules\Profile\Models * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -23,6 +23,14 @@ use Modules\Admin\Models\Account; use Modules\Admin\Models\AccountMapper; use Modules\Calendar\Models\CalendarMapper; +/** + * Profile mapper. + * + * @package Modules\Profile + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class ProfileMapper extends DataMapperAbstract { /**