mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 06:48:41 +00:00
Add and improve docblocks
This commit is contained in:
parent
09d4f67f62
commit
185933a721
|
|
@ -94,6 +94,13 @@ class AccountManager implements \Countable
|
||||||
return $this->accounts[$id] ?? new NullAccount();
|
return $this->accounts[$id] ?? new NullAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the authentication manager
|
||||||
|
*
|
||||||
|
* @return Auth
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getAuth() : Auth
|
public function getAuth() : Auth
|
||||||
{
|
{
|
||||||
return $this->auth;
|
return $this->auth;
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ class MarketShareEstimation {
|
||||||
*
|
*
|
||||||
* @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}}
|
* @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}}
|
||||||
*
|
*
|
||||||
* @param int $participants (N)
|
* @param int $participants The amount of existing participants in the market or compentitors (N)
|
||||||
* @param float $marketShare (m)
|
* @param float $marketShare The absolute own market share (m)
|
||||||
* @param float $modifier (s)
|
* @param float $modifier Distribution modifier (s)
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int Returns the rank
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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}}}}
|
* @latex m = \frac{\frac{1}{r^{s}}}{\sum_{n=1}^N{\frac{1}{n^{s}}}}
|
||||||
*
|
*
|
||||||
* @param int $participants (N)
|
* @param int $participants The amount of existing participants in the market or compentitors (N)
|
||||||
* @param int $rank (r)
|
* @param int $rank The absolute own rank in the market (r)
|
||||||
* @param float $modifier (s)
|
* @param float $modifier Distribution modifier (s)
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float Returns the Market share
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ use phpOMS\System\File\Local\LocalStorage;
|
||||||
use phpOMS\Utils\IO\Zip\Zip;
|
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
|
* @category Framework
|
||||||
* @package phpOMS\Account
|
* @package phpOMS\Account
|
||||||
|
|
@ -66,10 +68,10 @@ class PackageManager
|
||||||
private $info = [];
|
private $info = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $path Package path
|
* @param string $path Package source path e.g. path after download.
|
||||||
* @param string $basePath Base Path of the application
|
* @param string basePath Path of the application
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -79,6 +81,15 @@ class PackageManager
|
||||||
$this->basePath = $basePath;
|
$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
|
public function extract(string $path) : bool
|
||||||
{
|
{
|
||||||
$this->extractPath = $path;
|
$this->extractPath = $path;
|
||||||
|
|
@ -103,11 +114,27 @@ class PackageManager
|
||||||
$this->info = json_decode(file_get_contents($this->extractPath . '/info.json'), true);
|
$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
|
public function isValid() : bool
|
||||||
{
|
{
|
||||||
return $this->authenticate(file_get_contents($this->extractPath . '/package.cert'), $this->hashFiles());
|
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
|
private function hashFiles(array $files) : string
|
||||||
{
|
{
|
||||||
$files = Directory::list($this->extractPath . '/package');
|
$files = Directory::list($this->extractPath . '/package');
|
||||||
|
|
@ -124,6 +151,13 @@ class PackageManager
|
||||||
return \sodium_crypto_generichash_final();
|
return \sodium_crypto_generichash_final();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install package
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function install() /* : void */
|
public function install() /* : void */
|
||||||
{
|
{
|
||||||
if(!$this->isValid()) {
|
if(!$this->isValid()) {
|
||||||
|
|
@ -137,6 +171,13 @@ class PackageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move files
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function move($components)
|
private function move($components)
|
||||||
{
|
{
|
||||||
foreach($components as $component) {
|
foreach($components as $component) {
|
||||||
|
|
@ -144,6 +185,13 @@ class PackageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy files
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function copy($components)
|
private function copy($components)
|
||||||
{
|
{
|
||||||
foreach($components as $component) {
|
foreach($components as $component) {
|
||||||
|
|
@ -155,6 +203,13 @@ class PackageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete files
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function delete($components)
|
private function delete($components)
|
||||||
{
|
{
|
||||||
foreach($components as $component) {
|
foreach($components as $component) {
|
||||||
|
|
@ -162,6 +217,13 @@ class PackageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute commands
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function execute($components)
|
private function execute($components)
|
||||||
{
|
{
|
||||||
foreach($components as $component) {
|
foreach($components as $component) {
|
||||||
|
|
@ -169,13 +231,27 @@ class PackageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup after installation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function cleanup()
|
public function cleanup()
|
||||||
{
|
{
|
||||||
File::delete($this->path);
|
File::delete($this->path);
|
||||||
Directory::delete($this->extractPath);
|
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
|
// https://3v4l.org/PN9Xl
|
||||||
$publicKey = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjr73rerPRq3ZwWmrUKsN
|
$publicKey = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjr73rerPRq3ZwWmrUKsN
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,15 @@ class StringCompare
|
||||||
$this->dictionary = $dictionary;
|
$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 */
|
public function add(string $word) /* : void */
|
||||||
{
|
{
|
||||||
$this->dictionary[] = $word;
|
$this->dictionary[] = $word;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user