Elgg  Version 4.3
TimeHelpers.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Traits\Seeding;
4 
5 use Elgg\Values;
6 
13 trait TimeHelpers {
14 
18  protected $create_since;
19 
23  protected $create_until;
24 
33  public function setCreateSince($since = 'now') {
34  $this->create_since = Values::normalizeTimestamp($since);
35  }
36 
45  public function setCreateUntil($until = 'now') {
46  $this->create_until = Values::normalizeTimestamp($until);
47  }
48 
54  public function getRandomCreationTimestamp() : int {
55  $since = $this->create_since ?: time();
56  $until = $this->create_until ?: time();
57 
58  return $this->faker()->numberBetween($since, $until);
59  }
60 }
Saves user notification settings.
getRandomCreationTimestamp()
Get a random timestamp between a lower and upper time.
Definition: TimeHelpers.php:54
setCreateUntil($until= 'now')
Set a time for entities to be created until.
Definition: TimeHelpers.php:45
static normalizeTimestamp($time)
Returns timestamp value of the time representation.
Definition: Values.php:64
setCreateSince($since= 'now')
Set a time for entities to be created after.
Definition: TimeHelpers.php:33
faker($locale= 'en_US')
Returns an instance of faker.
Definition: Seeding.php:48