Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Sep 21, 2023
1 parent 5babc18 commit 1775636
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Algorithm/Rating/Glicko2.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function rating(

// Step 0:
$rdOld /= self::Q;
$elo = ($elo - $this->DEFAULT_ELO) / self::Q;
$elo = ($elo - $this->DEFAULT_ELO) / self::Q;

foreach ($oElo as $idx => $value) {
$oElo[$idx] = ($value - $this->DEFAULT_ELO) / self::Q;
Expand Down
2 changes: 1 addition & 1 deletion DataStorage/Database/Mapper/DeleteMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function deleteHasMany(\ReflectionClass $refClass, object $obj, mixed $o

$objIds = [];
$refProp = $refClass->getProperty($member);
$values = $refProp->isPublic() ? $obj->{$member} : $refProp->getValue($obj);
$values = $refProp->isPublic() ? $obj->{$member} : $refProp->getValue($obj);

if (!\is_array($values)) {
// conditionals
Expand Down
2 changes: 1 addition & 1 deletion DataStorage/Database/Mapper/WriteMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private function createHasMany(\ReflectionClass $refClass, object $obj, mixed $o
}

$property = $refClass->getProperty($propertyName);
$values = $property->isPublic() ? $obj->{$propertyName} : $property->getValue($obj);
$values = $property->isPublic() ? $obj->{$propertyName} : $property->getValue($obj);

/** @var class-string<DataMapperFactory> $mapper */
$mapper = $this->mapper::HAS_MANY[$propertyName]['mapper'];
Expand Down
8 changes: 7 additions & 1 deletion Message/Cli/CliHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ public function has(string $key) : bool
*/
public function generate(int $code) : void
{
$this->generate500();
switch ($code) {
default:
$this->generate500();
}
}

/**
* {@inheritdoc}
*/
public function getRequestTime() : int
{
return $this->timestamp;
Expand Down
7 changes: 7 additions & 0 deletions Message/HeaderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ abstract public function get(string $key = null) : array;
*/
abstract public function has(string $key) : bool;

/**
* Get time of the request
*
* @return int
*
* @since 1.0.0
*/
abstract public function getRequestTime() : int;

/**
Expand Down
27 changes: 26 additions & 1 deletion Message/Http/HttpHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,47 @@ public function getProtocolVersion() : string
return $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1';
}

/**
* Get the referer link
*
* @return string
*
* @since 1.0.0
*/
public function getReferer() : string
{
return $_SERVER['HTTP_REFERER'] ?? '';
}

/**
* {@inheritdoc}
*/
public function getRequestTime() : int
{
return (int) ($_SERVER['REQUEST_TIME'] ?? $this->timestamp);
}

/**
* Get the ip of the requester
*
* @return string
*
* @since 1.0.0
*/
public function getRequestIp() : string
{
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '';
}

public function getBrowserName(): string {
/**
* Get the browser/agent name of the request
*
* @return string
*
* @since 1.0.0
*/
public function getBrowserName(): string
{
$userAgent = $_SERVER['HTTP_USER_AGENT'];

if (\strpos($userAgent, 'Opera') !== false || \strpos($userAgent, 'OPR/') !== false) {
Expand Down
74 changes: 74 additions & 0 deletions Message/Http/ImpressionStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,93 @@
*/
class ImpressionStat
{
/**
* Request ip
*
* @var string
* @since 1.0.0
*/
public string $address = '';

/**
* Request language
*
* @var string
* @since 1.0.0
*/
public string $language = ISO639x1Enum::_EN;

/**
* Request country
*
* @var string
* @since 1.0.0
*/
public string $country = ISO3166TwoEnum::_XXX;

/**
* Request time
*
* @var \DateTime
* @since 1.0.0
*/
public \DateTime $datetime;

/**
* Request host/domain
*
* @var string
* @since 1.0.0
*/
public string $host = '';

/**
* Request path
*
* @var string
* @since 1.0.0
*/
public string $path = '';

/**
* Request full uri
*
* @var string
* @since 1.0.0
*/
public string $uri = '';

/**
* Request referer link
*
* @var string
* @since 1.0.0
*/
public string $referer = '';

/**
* Request browser/agent
*
* @var string
* @since 1.0.0
*/
public string $userAgent = '';

/**
* Additional custom meta data to be stored
*
* @var string
* @since 1.0.0
*/
public array $meta = [];

/**
* Constructor.
*
* @param HttpRequest $request Http request object
*
* @since 1.0.0
*/
public function __construct(HttpRequest $request)
{
$this->language = $request->header->l11n->language;
Expand All @@ -60,6 +127,13 @@ public function __construct(HttpRequest $request)
$this->userAgent = $request->header->getBrowserName();
}

/**
* Turn object to array
*
* @return array
*
* @since 1.0.0
*/
public function toArray() : array
{
return [
Expand Down

0 comments on commit 1775636

Please sign in to comment.