You are here

public function GranularityService::includeGranularityElement in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x src/Service/GranularityService.php \Drupal\duration_field\Service\GranularityService::includeGranularityElement()

Test if the given granularity element should be included.

Inclusion is determined based on the given granularity string.

Parameters

string $granularityElement: The granularity element to test for. Values can be:

  • y (years)
  • m (months)
  • d (days)
  • h (hours)
  • i (minutes)
  • s (seconds)

string $granularityString: The granularity string to test against.

Return value

bool TRUE if the given granularity should be inclued, FALSE otherwise.

Overrides GranularityServiceInterface::includeGranularityElement

File

src/Service/GranularityService.php, line 57

Class

GranularityService

Namespace

Drupal\duration_field\Service

Code

public function includeGranularityElement($granularityElement, $granularityString) {
  $granularities = $this
    ->convertGranularityStringToGranularityArray($granularityString);
  return $granularities[$granularityElement];
}