Skip to content

Commit

Permalink
Allow extensibility of protected properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
serbanghita committed Aug 11, 2023
1 parent e7d78f9 commit d4279b3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/MobileDetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public function getHttpHeader(string $header): ?string

public function getMobileHeaders(): array
{
return self::$mobileHeaders;
return static::$mobileHeaders;
}

/**
Expand All @@ -930,7 +930,7 @@ public function getMobileHeaders(): array
*/
public function getUaHttpHeaders(): array
{
return self::$uaHttpHeaders;
return static::$uaHttpHeaders;
}


Expand Down Expand Up @@ -1046,7 +1046,7 @@ public function getMatchesArray(): ?array
*/
public static function getPhoneDevices(): array
{
return self::$phoneDevices;
return static::$phoneDevices;
}

/**
Expand All @@ -1056,7 +1056,7 @@ public static function getPhoneDevices(): array
*/
public static function getTabletDevices(): array
{
return self::$tabletDevices;
return static::$tabletDevices;
}

/**
Expand All @@ -1066,7 +1066,7 @@ public static function getTabletDevices(): array
*/
public static function getUserAgents(): array
{
return self::getBrowsers();
return static::getBrowsers();
}

/**
Expand All @@ -1076,7 +1076,7 @@ public static function getUserAgents(): array
*/
public static function getBrowsers(): array
{
return self::$browsers;
return static::$browsers;
}

/**
Expand All @@ -1091,10 +1091,10 @@ public function getRules(): array

if (!$rules) {
$rules = array_merge(
self::$phoneDevices,
self::$tabletDevices,
self::$operatingSystems,
self::$browsers
static::$phoneDevices,

This comment has been minimized.

Copy link
@pquerner

pquerner Aug 11, 2023

getter here aswell

static::$tabletDevices,
static::$operatingSystems,
static::$browsers
);
}

Expand All @@ -1108,7 +1108,7 @@ public function getRules(): array
*/
public static function getOperatingSystems(): array
{
return self::$operatingSystems;
return static::$operatingSystems;
}

/**
Expand Down Expand Up @@ -1267,7 +1267,7 @@ public function isTablet(string $userAgent = null, array $httpHeaders = null): b
}
}

foreach (self::$tabletDevices as $_regex) {
foreach (static::$tabletDevices as $_regex) {

This comment has been minimized.

Copy link
@pquerner

pquerner Aug 11, 2023

Should've used the getter. Overwriting the function is easier than to carry over the full big array.
In the function you can use array_merge and whatnot. While only allowing overwriting the property are more annoying..

if ($this->match($_regex, $userAgent)) {
return true;
}
Expand Down Expand Up @@ -1342,7 +1342,7 @@ public function match(string $regex, string $userAgent = null): bool
*/
public static function getProperties(): array
{
return self::$properties;
return static::$properties;
}

/**
Expand Down

0 comments on commit d4279b3

Please sign in to comment.