You are here

public function MobileDetectPlatform::evaluate in Mobile Detect 8.2

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

src/Plugin/Condition/MobileDetectPlatform.php, line 95

Class

MobileDetectPlatform
Provides the 'Device platform' condition.

Namespace

Drupal\mobile_detect\Plugin\Condition

Code

public function evaluate() {
  $platform = $this->configuration['platform'];
  if (empty($platform) && !$this
    ->isNegated()) {
    return true;
  }
  $detect = $this->mobileDetect;
  foreach ($platform as $value) {
    if ($value === 'android' && $detect
      ->isAndroidOS() || $value === 'ios' && $detect
      ->isIOS()) {
      return true;
    }
  }
  return false;
}