diff --git a/Account/AccountManager.php b/Account/AccountManager.php index 7c25d8b9b..8457c5e02 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -94,6 +94,13 @@ class AccountManager implements \Countable return $this->accounts[$id] ?? new NullAccount(); } + /** + * Returns the authentication manager + * + * @return Auth + * + * @since 1.0.0 + */ public function getAuth() : Auth { return $this->auth; diff --git a/Business/Sales/MarketShareEstimation.php b/Business/Sales/MarketShareEstimation.php index 2e8eef0d9..b2b03079a 100644 --- a/Business/Sales/MarketShareEstimation.php +++ b/Business/Sales/MarketShareEstimation.php @@ -33,11 +33,11 @@ class MarketShareEstimation { * * @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}} * - * @param int $participants (N) - * @param float $marketShare (m) - * @param float $modifier (s) + * @param int $participants The amount of existing participants in the market or compentitors (N) + * @param float $marketShare The absolute own market share (m) + * @param float $modifier Distribution modifier (s) * - * @return int + * @return int Returns the rank * * @since 1.0.0 */ @@ -56,11 +56,11 @@ class MarketShareEstimation { * * @latex m = \frac{\frac{1}{r^{s}}}{\sum_{n=1}^N{\frac{1}{n^{s}}}} * - * @param int $participants (N) - * @param int $rank (r) - * @param float $modifier (s) + * @param int $participants The amount of existing participants in the market or compentitors (N) + * @param int $rank The absolute own rank in the market (r) + * @param float $modifier Distribution modifier (s) * - * @return float + * @return float Returns the Market share * * @since 1.0.0 */ diff --git a/Module/PackageManager.php b/Module/PackageManager.php index 5e8117233..d743e1fcf 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -23,7 +23,9 @@ use phpOMS\System\File\Local\LocalStorage; use phpOMS\Utils\IO\Zip\Zip; /** - * Account group class. + * Package Manager model. + * + * The package manager is responsible for handling installation and update packages for modules, frameworks and resources. * * @category Framework * @package phpOMS\Account @@ -66,10 +68,10 @@ class PackageManager private $info = []; /** - * Object constructor. - * - * @param string $path Package path - * @param string $basePath Base Path of the application + * Constructor. + * + * @param string $path Package source path e.g. path after download. + * @param string basePath Path of the application * * @since 1.0.0 */ @@ -79,6 +81,15 @@ class PackageManager $this->basePath = $basePath; } + /** + * Extract package to temporary destination + * + * @param string $path Temporary extract path + * + * @return bool + * + * @since 1.0.0 + */ public function extract(string $path) : bool { $this->extractPath = $path; @@ -103,11 +114,27 @@ class PackageManager $this->info = json_decode(file_get_contents($this->extractPath . '/info.json'), true); } + /** + * Validate package integrity + * + * @return bool Returns true if the package is authentic, false otherwise + * + * @since 1.0.0 + */ public function isValid() : bool { return $this->authenticate(file_get_contents($this->extractPath . '/package.cert'), $this->hashFiles()); } + /** + * Hash array of files + * + * @param array $files Files to hash + * + * @return string Hash value of files + * + * @since 1.0.0 + */ private function hashFiles(array $files) : string { $files = Directory::list($this->extractPath . '/package'); @@ -124,6 +151,13 @@ class PackageManager return \sodium_crypto_generichash_final(); } + /** + * Install package + * + * @return void + * + * @since 1.0.0 + */ public function install() /* : void */ { if(!$this->isValid()) { @@ -137,6 +171,13 @@ class PackageManager } } + /** + * Move files + * + * @return void + * + * @since 1.0.0 + */ private function move($components) { foreach($components as $component) { @@ -144,6 +185,13 @@ class PackageManager } } + /** + * Copy files + * + * @return void + * + * @since 1.0.0 + */ private function copy($components) { foreach($components as $component) { @@ -155,6 +203,13 @@ class PackageManager } } + /** + * Delete files + * + * @return void + * + * @since 1.0.0 + */ private function delete($components) { foreach($components as $component) { @@ -162,6 +217,13 @@ class PackageManager } } + /** + * Execute commands + * + * @return void + * + * @since 1.0.0 + */ private function execute($components) { foreach($components as $component) { @@ -169,13 +231,27 @@ class PackageManager } } + /** + * Cleanup after installation + * + * @return void + * + * @since 1.0.0 + */ public function cleanup() { File::delete($this->path); Directory::delete($this->extractPath); } - private function authenticate(string $signedHash, string $rawHash) + /** + * Authenticate package + * + * @return bool + * + * @since 1.0.0 + */ + private function authenticate(string $signedHash, string $rawHash) : bool { // https://3v4l.org/PN9Xl $publicKey = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjr73rerPRq3ZwWmrUKsN diff --git a/Utils/StringCompare.php b/Utils/StringCompare.php index 0cf24641d..4d471d751 100644 --- a/Utils/StringCompare.php +++ b/Utils/StringCompare.php @@ -48,6 +48,15 @@ class StringCompare $this->dictionary = $dictionary; } + /** + * Adds word to dictionary + * + * @param string $word Word to add to dictionary + * + * @return void + * + * @since 1.0.0 + */ public function add(string $word) /* : void */ { $this->dictionary[] = $word;