From b5ddbab61f6c88912c7a904be188b88f54098402 Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Wed, 11 Oct 2023 13:31:20 +0200 Subject: [PATCH] Adhere to PSR-12 coding styles --- src/Traits/Getter.php | 22 +++++++++------------- src/Traits/Setter.php | 20 ++++++++------------ src/Traits/Singleton.php | 28 ++++++---------------------- 3 files changed, 23 insertions(+), 47 deletions(-) diff --git a/src/Traits/Getter.php b/src/Traits/Getter.php index f7bdd0b..ca65baf 100644 --- a/src/Traits/Getter.php +++ b/src/Traits/Getter.php @@ -1,4 +1,5 @@ - @@ -17,6 +18,8 @@ * along with this program. If not, see . */ +declare(strict_types=1); + namespace OCC\Traits; /** @@ -24,25 +27,21 @@ namespace OCC\Traits; * * @author Sebastian Meyer * @package opencultureconsulting/traits - * @access public */ trait Getter { /** * Read data from an inaccessible property. * - * @access public - * @final + * @param string $property The class property to get * - * @param string $property - * - * @return mixed + * @return mixed The class property's current value * * @throws \InvalidArgumentException */ final public function __get(string $property): mixed { - $method = 'get' . ucfirst($property); + $method = '_get' . ucfirst($property); if ( property_exists(__CLASS__, $property) && method_exists(__CLASS__, $method) @@ -56,12 +55,9 @@ trait Getter /** * Check if an inaccessible property is set and not empty. * - * @access public - * @final + * @param string $property The class property to check * - * @param string $property - * - * @return bool + * @return bool Whether the class property is set and not empty */ final public function __isset(string $property): bool { diff --git a/src/Traits/Setter.php b/src/Traits/Setter.php index 246f262..3da6171 100644 --- a/src/Traits/Setter.php +++ b/src/Traits/Setter.php @@ -1,4 +1,5 @@ - @@ -17,6 +18,8 @@ * along with this program. If not, see . */ +declare(strict_types=1); + namespace OCC\Traits; /** @@ -24,18 +27,14 @@ namespace OCC\Traits; * * @author Sebastian Meyer * @package opencultureconsulting/traits - * @access public */ trait Setter { /** * Write data to an inaccessible property. * - * @access public - * @final - * - * @param string $property - * @param mixed $value + * @param string $property The class property to set + * @param mixed $value The new value of the property * * @return void * @@ -43,7 +42,7 @@ trait Setter */ final public function __set(string $property, mixed $value): void { - $method = 'set' . ucfirst($property); + $method = '_set' . ucfirst($property); if ( property_exists(__CLASS__, $property) && method_exists(__CLASS__, $method) @@ -57,10 +56,7 @@ trait Setter /** * Unset an inaccessible property. * - * @access public - * @final - * - * @param string $property + * @param string $property The class property to unset * * @return void * diff --git a/src/Traits/Singleton.php b/src/Traits/Singleton.php index 6a489be..0c4a6b9 100644 --- a/src/Traits/Singleton.php +++ b/src/Traits/Singleton.php @@ -1,4 +1,5 @@ - @@ -17,35 +18,25 @@ * along with this program. If not, see . */ +declare(strict_types=1); + namespace OCC\Traits; /** - * Allows just a single instance of a class. + * Allows just a single instance of the class using this trait. * * @author Sebastian Meyer * @package opencultureconsulting/traits - * @access public */ trait Singleton { /** - * Holds the singleton instance. - * - * @access private - * @static - * - * @var self + * Holds the singleton instances. */ private static ?self $singleton; /** * Get a singleton instance of this class. - * - * @access public - * @final - * @static - * - * @return self */ final public static function getInstance(): self { @@ -59,18 +50,11 @@ trait Singleton /** * This is a singleton class, thus the constructor is private. * (Get an instance of this class by calling self::getInstance()) - * - * @access private - * @abstract */ abstract private function __construct(); /** * This is a singleton class, thus cloning is prohibited. - * - * @access private - * - * @return void */ final private function __clone(): void {