class SmsTestTime in SMS Framework 2.x
Same name and namespace in other branches
- 2.1.x tests/modules/sms_test_time/src/SmsTestTime.php \Drupal\sms_test_time\SmsTestTime
Time service with a predictable time.
Hierarchy
- class \Drupal\sms_test_time\SmsTestTime implements TimeInterface
Expanded class hierarchy of SmsTestTime
1 string reference to 'SmsTestTime'
- sms_test_time.services.yml in tests/
modules/ sms_test_time/ sms_test_time.services.yml - tests/modules/sms_test_time/sms_test_time.services.yml
1 service uses SmsTestTime
- sms_test_time.time in tests/
modules/ sms_test_time/ sms_test_time.services.yml - Drupal\sms_test_time\SmsTestTime
File
- tests/
modules/ sms_test_time/ src/ SmsTestTime.php, line 12
Namespace
Drupal\sms_test_timeView source
class SmsTestTime implements TimeInterface {
/**
* Original time service.
*
* @var \Drupal\Component\Datetime\TimeInterface
*/
protected $original;
/**
* Date for testing.
*
* @var \DateTime
*/
protected $date;
/**
* SmsTestTime constructor.
*
* @param \Drupal\Component\Datetime\TimeInterface $original
* Original time service.
*/
public function __construct(TimeInterface $original) {
$this->original = $original;
$this->date = new \DateTimeImmutable('2:30pm 17 October 1997', new \DateTimeZone('UTC'));
}
/**
* {@inheritdoc}
*/
public function getRequestTime() {
return $this->date
->format('U');
}
/**
* {@inheritdoc}
*/
public function getRequestMicroTime() {
return $this->date
->format('U.u');
}
/**
* {@inheritdoc}
*/
public function getCurrentTime() {
return $this->date
->format('U');
}
/**
* {@inheritdoc}
*/
public function getCurrentMicroTime() {
return $this->date
->format('U.u');
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SmsTestTime:: |
protected | property | Date for testing. | |
SmsTestTime:: |
protected | property | Original time service. | |
SmsTestTime:: |
public | function |
Returns the current system time with microsecond precision. Overrides TimeInterface:: |
|
SmsTestTime:: |
public | function |
Returns the current system time as an integer. Overrides TimeInterface:: |
|
SmsTestTime:: |
public | function |
Returns the timestamp for the current request with microsecond precision. Overrides TimeInterface:: |
|
SmsTestTime:: |
public | function |
Returns the timestamp for the current request. Overrides TimeInterface:: |
|
SmsTestTime:: |
public | function | SmsTestTime constructor. |