repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
brick/date-time
src/LocalDateTime.php
LocalDateTime.withTime
public function withTime(LocalTime $time) : LocalDateTime { if ($time->isEqualTo($this->time)) { return $this; } return new LocalDateTime($this->date, $time); }
php
public function withTime(LocalTime $time) : LocalDateTime { if ($time->isEqualTo($this->time)) { return $this; } return new LocalDateTime($this->date, $time); }
[ "public", "function", "withTime", "(", "LocalTime", "$", "time", ")", ":", "LocalDateTime", "{", "if", "(", "$", "time", "->", "isEqualTo", "(", "$", "this", "->", "time", ")", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime"...
Returns a copy of this LocalDateTime with the time altered. @param LocalTime $time @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "time", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L312-L319
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withYear
public function withYear(int $year) : LocalDateTime { $date = $this->date->withYear($year); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
php
public function withYear(int $year) : LocalDateTime { $date = $this->date->withYear($year); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
[ "public", "function", "withYear", "(", "int", "$", "year", ")", ":", "LocalDateTime", "{", "$", "date", "=", "$", "this", "->", "date", "->", "withYear", "(", "$", "year", ")", ";", "if", "(", "$", "date", "===", "$", "this", "->", "date", ")", "...
Returns a copy of this LocalDateTime with the year altered. If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. @param int $year @return LocalDateTime @throws DateTimeException If the year is outside the valid range.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "year", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L332-L341
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withMonth
public function withMonth(int $month) : LocalDateTime { $date = $this->date->withMonth($month); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
php
public function withMonth(int $month) : LocalDateTime { $date = $this->date->withMonth($month); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
[ "public", "function", "withMonth", "(", "int", "$", "month", ")", ":", "LocalDateTime", "{", "$", "date", "=", "$", "this", "->", "date", "->", "withMonth", "(", "$", "month", ")", ";", "if", "(", "$", "date", "===", "$", "this", "->", "date", ")",...
Returns a copy of this LocalDateTime with the month-of-year altered. If the day-of-month is invalid for the month and year, it will be changed to the last valid day of the month. @param int $month @return LocalDateTime @throws DateTimeException If the month is invalid.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "month", "-", "of", "-", "year", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L354-L363
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withDay
public function withDay(int $day) : LocalDateTime { $date = $this->date->withDay($day); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
php
public function withDay(int $day) : LocalDateTime { $date = $this->date->withDay($day); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
[ "public", "function", "withDay", "(", "int", "$", "day", ")", ":", "LocalDateTime", "{", "$", "date", "=", "$", "this", "->", "date", "->", "withDay", "(", "$", "day", ")", ";", "if", "(", "$", "date", "===", "$", "this", "->", "date", ")", "{", ...
Returns a copy of this LocalDateTime with the day-of-month altered. If the resulting date is invalid, an exception is thrown. @param int $day @return LocalDateTime @throws DateTimeException If the day is invalid for the current year and month.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "day", "-", "of", "-", "month", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L376-L385
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withHour
public function withHour(int $hour) : LocalDateTime { $time = $this->time->withHour($hour); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
php
public function withHour(int $hour) : LocalDateTime { $time = $this->time->withHour($hour); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
[ "public", "function", "withHour", "(", "int", "$", "hour", ")", ":", "LocalDateTime", "{", "$", "time", "=", "$", "this", "->", "time", "->", "withHour", "(", "$", "hour", ")", ";", "if", "(", "$", "time", "===", "$", "this", "->", "time", ")", "...
Returns a copy of this LocalDateTime with the hour-of-day altered. @param int $hour @return LocalDateTime @throws DateTimeException If the hour is invalid.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "hour", "-", "of", "-", "day", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L396-L405
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withMinute
public function withMinute(int $minute) : LocalDateTime { $time = $this->time->withMinute($minute); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
php
public function withMinute(int $minute) : LocalDateTime { $time = $this->time->withMinute($minute); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
[ "public", "function", "withMinute", "(", "int", "$", "minute", ")", ":", "LocalDateTime", "{", "$", "time", "=", "$", "this", "->", "time", "->", "withMinute", "(", "$", "minute", ")", ";", "if", "(", "$", "time", "===", "$", "this", "->", "time", ...
Returns a copy of this LocalDateTime with the minute-of-hour altered. @param int $minute @return LocalDateTime @throws DateTimeException If the minute-of-hour if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "minute", "-", "of", "-", "hour", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L416-L425
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withSecond
public function withSecond(int $second) : LocalDateTime { $time = $this->time->withSecond($second); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
php
public function withSecond(int $second) : LocalDateTime { $time = $this->time->withSecond($second); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
[ "public", "function", "withSecond", "(", "int", "$", "second", ")", ":", "LocalDateTime", "{", "$", "time", "=", "$", "this", "->", "time", "->", "withSecond", "(", "$", "second", ")", ";", "if", "(", "$", "time", "===", "$", "this", "->", "time", ...
Returns a copy of this LocalDateTime with the second-of-minute altered. @param int $second @return LocalDateTime @throws DateTimeException If the second-of-minute if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "second", "-", "of", "-", "minute", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L436-L445
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.withNano
public function withNano(int $nano) : LocalDateTime { $time = $this->time->withNano($nano); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
php
public function withNano(int $nano) : LocalDateTime { $time = $this->time->withNano($nano); if ($time === $this->time) { return $this; } return new LocalDateTime($this->date, $time); }
[ "public", "function", "withNano", "(", "int", "$", "nano", ")", ":", "LocalDateTime", "{", "$", "time", "=", "$", "this", "->", "time", "->", "withNano", "(", "$", "nano", ")", ";", "if", "(", "$", "time", "===", "$", "this", "->", "time", ")", "...
Returns a copy of this LocalDateTime with the nano-of-second altered. @param int $nano @return LocalDateTime @throws DateTimeException If the nano-of-second if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "nano", "-", "of", "-", "second", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L456-L465
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusPeriod
public function plusPeriod(Period $period) : LocalDateTime { $date = $this->date->plusPeriod($period); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
php
public function plusPeriod(Period $period) : LocalDateTime { $date = $this->date->plusPeriod($period); if ($date === $this->date) { return $this; } return new LocalDateTime($date, $this->time); }
[ "public", "function", "plusPeriod", "(", "Period", "$", "period", ")", ":", "LocalDateTime", "{", "$", "date", "=", "$", "this", "->", "date", "->", "plusPeriod", "(", "$", "period", ")", ";", "if", "(", "$", "date", "===", "$", "this", "->", "date",...
Returns a copy of this LocalDateTime with the specified Period added. @param Period $period @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "Period", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L486-L495
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusDuration
public function plusDuration(Duration $duration) : LocalDateTime { if ($duration->isZero()) { return $this; } $days = Math::floorDiv($duration->getSeconds(), LocalTime::SECONDS_PER_DAY); return new LocalDateTime($this->date->plusDays($days), $this->time->plusDuration($duration)); }
php
public function plusDuration(Duration $duration) : LocalDateTime { if ($duration->isZero()) { return $this; } $days = Math::floorDiv($duration->getSeconds(), LocalTime::SECONDS_PER_DAY); return new LocalDateTime($this->date->plusDays($days), $this->time->plusDuration($duration)); }
[ "public", "function", "plusDuration", "(", "Duration", "$", "duration", ")", ":", "LocalDateTime", "{", "if", "(", "$", "duration", "->", "isZero", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "days", "=", "Math", "::", "floorDiv", "(", ...
Returns a copy of this LocalDateTime with the specific Duration added. @param Duration $duration @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specific", "Duration", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L504-L513
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusYears
public function plusYears(int $years) : LocalDateTime { if ($years === 0) { return $this; } return new LocalDateTime($this->date->plusYears($years), $this->time); }
php
public function plusYears(int $years) : LocalDateTime { if ($years === 0) { return $this; } return new LocalDateTime($this->date->plusYears($years), $this->time); }
[ "public", "function", "plusYears", "(", "int", "$", "years", ")", ":", "LocalDateTime", "{", "if", "(", "$", "years", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "plus...
Returns a copy of this LocalDateTime with the specified period in years added. @param int $years @return LocalDateTime @throws DateTimeException If the resulting year is out of range.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "years", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L524-L531
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusMonths
public function plusMonths(int $months) : LocalDateTime { if ($months === 0) { return $this; } return new LocalDateTime($this->date->plusMonths($months), $this->time); }
php
public function plusMonths(int $months) : LocalDateTime { if ($months === 0) { return $this; } return new LocalDateTime($this->date->plusMonths($months), $this->time); }
[ "public", "function", "plusMonths", "(", "int", "$", "months", ")", ":", "LocalDateTime", "{", "if", "(", "$", "months", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "p...
Returns a copy of this LocalDateTime with the specified period in months added. @param int $months @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "months", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L540-L547
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusWeeks
public function plusWeeks(int $weeks) : LocalDateTime { if ($weeks === 0) { return $this; } return new LocalDateTime($this->date->plusWeeks($weeks), $this->time); }
php
public function plusWeeks(int $weeks) : LocalDateTime { if ($weeks === 0) { return $this; } return new LocalDateTime($this->date->plusWeeks($weeks), $this->time); }
[ "public", "function", "plusWeeks", "(", "int", "$", "weeks", ")", ":", "LocalDateTime", "{", "if", "(", "$", "weeks", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "plus...
Returns a copy of this LocalDateTime with the specified period in weeks added. @param int $weeks @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "weeks", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L556-L563
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusDays
public function plusDays(int $days) : LocalDateTime { if ($days === 0) { return $this; } return new LocalDateTime($this->date->plusDays($days), $this->time); }
php
public function plusDays(int $days) : LocalDateTime { if ($days === 0) { return $this; } return new LocalDateTime($this->date->plusDays($days), $this->time); }
[ "public", "function", "plusDays", "(", "int", "$", "days", ")", ":", "LocalDateTime", "{", "if", "(", "$", "days", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "plusDay...
Returns a copy of this LocalDateTime with the specified period in days added. @param int $days @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "days", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L572-L579
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.minusYears
public function minusYears(int $years) : LocalDateTime { if ($years === 0) { return $this; } return new LocalDateTime($this->date->minusYears($years), $this->time); }
php
public function minusYears(int $years) : LocalDateTime { if ($years === 0) { return $this; } return new LocalDateTime($this->date->minusYears($years), $this->time); }
[ "public", "function", "minusYears", "(", "int", "$", "years", ")", ":", "LocalDateTime", "{", "if", "(", "$", "years", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "min...
Returns a copy of this LocalDateTime with the specified period in years subtracted. @param int $years @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "years", "subtracted", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L676-L683
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.minusMonths
public function minusMonths(int $months) : LocalDateTime { if ($months === 0) { return $this; } return new LocalDateTime($this->date->minusMonths($months), $this->time); }
php
public function minusMonths(int $months) : LocalDateTime { if ($months === 0) { return $this; } return new LocalDateTime($this->date->minusMonths($months), $this->time); }
[ "public", "function", "minusMonths", "(", "int", "$", "months", ")", ":", "LocalDateTime", "{", "if", "(", "$", "months", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "...
Returns a copy of this LocalDateTime with the specified period in months subtracted. @param int $months @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "months", "subtracted", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L692-L699
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.minusWeeks
public function minusWeeks(int $weeks) : LocalDateTime { if ($weeks === 0) { return $this; } return new LocalDateTime($this->date->minusWeeks($weeks), $this->time); }
php
public function minusWeeks(int $weeks) : LocalDateTime { if ($weeks === 0) { return $this; } return new LocalDateTime($this->date->minusWeeks($weeks), $this->time); }
[ "public", "function", "minusWeeks", "(", "int", "$", "weeks", ")", ":", "LocalDateTime", "{", "if", "(", "$", "weeks", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "min...
Returns a copy of this LocalDateTime with the specified period in weeks subtracted. @param int $weeks @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "weeks", "subtracted", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L708-L715
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.minusDays
public function minusDays(int $days) : LocalDateTime { if ($days === 0) { return $this; } return new LocalDateTime($this->date->minusDays($days), $this->time); }
php
public function minusDays(int $days) : LocalDateTime { if ($days === 0) { return $this; } return new LocalDateTime($this->date->minusDays($days), $this->time); }
[ "public", "function", "minusDays", "(", "int", "$", "days", ")", ":", "LocalDateTime", "{", "if", "(", "$", "days", "===", "0", ")", "{", "return", "$", "this", ";", "}", "return", "new", "LocalDateTime", "(", "$", "this", "->", "date", "->", "minusD...
Returns a copy of this LocalDateTime with the specified period in days subtracted. @param int $days @return LocalDateTime
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "in", "days", "subtracted", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L724-L731
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.plusWithOverflow
private function plusWithOverflow(int $hours, int $minutes, int $seconds, int $nanos, int $sign) : LocalDateTime { $totDays = \intdiv($hours, LocalTime::HOURS_PER_DAY) + \intdiv($minutes, LocalTime::MINUTES_PER_DAY) + \intdiv($seconds, LocalTime::SECONDS_PER_DAY); $totDays *= $sign; $totSeconds = ($seconds % LocalTime::SECONDS_PER_DAY) + ($minutes % LocalTime::MINUTES_PER_DAY) * LocalTime::SECONDS_PER_MINUTE + ($hours % LocalTime::HOURS_PER_DAY) * LocalTime::SECONDS_PER_HOUR; $curSoD = $this->time->toSecondOfDay(); $totSeconds = $totSeconds * $sign + $curSoD; $totNanos = $nanos * $sign + $this->time->getNano(); $totSeconds += Math::floorDiv($totNanos, LocalTime::NANOS_PER_SECOND); $newNano = Math::floorMod($totNanos, LocalTime::NANOS_PER_SECOND); $totDays += Math::floorDiv($totSeconds, LocalTime::SECONDS_PER_DAY); $newSoD = Math::floorMod($totSeconds, LocalTime::SECONDS_PER_DAY); $newDate = $this->date->plusDays($totDays); $newTime = ($newSoD === $curSoD ? $this->time : LocalTime::ofSecondOfDay($newSoD, $newNano)); return new LocalDateTime($newDate, $newTime); }
php
private function plusWithOverflow(int $hours, int $minutes, int $seconds, int $nanos, int $sign) : LocalDateTime { $totDays = \intdiv($hours, LocalTime::HOURS_PER_DAY) + \intdiv($minutes, LocalTime::MINUTES_PER_DAY) + \intdiv($seconds, LocalTime::SECONDS_PER_DAY); $totDays *= $sign; $totSeconds = ($seconds % LocalTime::SECONDS_PER_DAY) + ($minutes % LocalTime::MINUTES_PER_DAY) * LocalTime::SECONDS_PER_MINUTE + ($hours % LocalTime::HOURS_PER_DAY) * LocalTime::SECONDS_PER_HOUR; $curSoD = $this->time->toSecondOfDay(); $totSeconds = $totSeconds * $sign + $curSoD; $totNanos = $nanos * $sign + $this->time->getNano(); $totSeconds += Math::floorDiv($totNanos, LocalTime::NANOS_PER_SECOND); $newNano = Math::floorMod($totNanos, LocalTime::NANOS_PER_SECOND); $totDays += Math::floorDiv($totSeconds, LocalTime::SECONDS_PER_DAY); $newSoD = Math::floorMod($totSeconds, LocalTime::SECONDS_PER_DAY); $newDate = $this->date->plusDays($totDays); $newTime = ($newSoD === $curSoD ? $this->time : LocalTime::ofSecondOfDay($newSoD, $newNano)); return new LocalDateTime($newDate, $newTime); }
[ "private", "function", "plusWithOverflow", "(", "int", "$", "hours", ",", "int", "$", "minutes", ",", "int", "$", "seconds", ",", "int", "$", "nanos", ",", "int", "$", "sign", ")", ":", "LocalDateTime", "{", "$", "totDays", "=", "\\", "intdiv", "(", ...
Returns a copy of this `LocalDateTime` with the specified period added. @param int $hours The hours to add. May be negative. @param int $minutes The minutes to add. May be negative. @param int $seconds The seconds to add. May be negative. @param int $nanos The nanos to add. May be negative. @param int $sign The sign, validated as `1` to add or `-1` to subtract. @return LocalDateTime The combined result.
[ "Returns", "a", "copy", "of", "this", "LocalDateTime", "with", "the", "specified", "period", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L808-L835
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.compareTo
public function compareTo(LocalDateTime $that) : int { return $this->date->compareTo($that->date) ?: $this->time->compareTo($that->time); }
php
public function compareTo(LocalDateTime $that) : int { return $this->date->compareTo($that->date) ?: $this->time->compareTo($that->time); }
[ "public", "function", "compareTo", "(", "LocalDateTime", "$", "that", ")", ":", "int", "{", "return", "$", "this", "->", "date", "->", "compareTo", "(", "$", "that", "->", "date", ")", "?", ":", "$", "this", "->", "time", "->", "compareTo", "(", "$",...
Compares this date-time to another date-time. @param LocalDateTime $that The date-time to compare to. @return int [-1,0,1] If this date-time is before, on, or after the given date-time.
[ "Compares", "this", "date", "-", "time", "to", "another", "date", "-", "time", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L844-L847
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.isFuture
public function isFuture(TimeZone $timeZone, Clock $clock = null) : bool { return $this->isAfter(LocalDateTime::now($timeZone, $clock)); }
php
public function isFuture(TimeZone $timeZone, Clock $clock = null) : bool { return $this->isAfter(LocalDateTime::now($timeZone, $clock)); }
[ "public", "function", "isFuture", "(", "TimeZone", "$", "timeZone", ",", "Clock", "$", "clock", "=", "null", ")", ":", "bool", "{", "return", "$", "this", "->", "isAfter", "(", "LocalDateTime", "::", "now", "(", "$", "timeZone", ",", "$", "clock", ")",...
Returns whether this LocalDateTime is in the future, in the given time-zone, according to the given clock. If no clock is provided, the system clock is used. @param TimeZone $timeZone @param Clock|null $clock @return bool
[ "Returns", "whether", "this", "LocalDateTime", "is", "in", "the", "future", "in", "the", "given", "time", "-", "zone", "according", "to", "the", "given", "clock", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L909-L912
train
brick/date-time
src/LocalDateTime.php
LocalDateTime.isPast
public function isPast(TimeZone $timeZone, Clock $clock = null) : bool { return $this->isBefore(LocalDateTime::now($timeZone, $clock)); }
php
public function isPast(TimeZone $timeZone, Clock $clock = null) : bool { return $this->isBefore(LocalDateTime::now($timeZone, $clock)); }
[ "public", "function", "isPast", "(", "TimeZone", "$", "timeZone", ",", "Clock", "$", "clock", "=", "null", ")", ":", "bool", "{", "return", "$", "this", "->", "isBefore", "(", "LocalDateTime", "::", "now", "(", "$", "timeZone", ",", "$", "clock", ")", ...
Returns whether this LocalDateTime is in the past, in the given time-zone, according to the given clock. If no clock is provided, the system clock is used. @param TimeZone $timeZone @param Clock|null $clock @return bool
[ "Returns", "whether", "this", "LocalDateTime", "is", "in", "the", "past", "in", "the", "given", "time", "-", "zone", "according", "to", "the", "given", "clock", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateTime.php#L924-L927
train
uecode/qpush-bundle
src/Provider/IronMqProvider.php
IronMqProvider.queueExists
public function queueExists() { if (isset($this->queue)) { return true; } $queueName = $this->getNameWithPrefix(); if ($this->cache->contains($queueName)) { $this->queue = json_decode($this->cache->fetch($queueName)); return true; } try { $this->queue = $this->ironmq->getQueue($queueName); $this->cache->save($queueName, json_encode($this->queue)); } catch (\Exception $e) { if (false !== strpos($e->getMessage(), "Queue not found")) { $this->log(400, "Queue did not exist"); } else { throw $e; } } return false; }
php
public function queueExists() { if (isset($this->queue)) { return true; } $queueName = $this->getNameWithPrefix(); if ($this->cache->contains($queueName)) { $this->queue = json_decode($this->cache->fetch($queueName)); return true; } try { $this->queue = $this->ironmq->getQueue($queueName); $this->cache->save($queueName, json_encode($this->queue)); } catch (\Exception $e) { if (false !== strpos($e->getMessage(), "Queue not found")) { $this->log(400, "Queue did not exist"); } else { throw $e; } } return false; }
[ "public", "function", "queueExists", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queue", ")", ")", "{", "return", "true", ";", "}", "$", "queueName", "=", "$", "this", "->", "getNameWithPrefix", "(", ")", ";", "if", "(", "$", "this"...
Checks whether or not the Queue exists This method relies on in-memory cache and the Cache provider to reduce the need to needlessly call the create method on an existing Queue. @return bool @throws \Exception
[ "Checks", "whether", "or", "not", "the", "Queue", "exists" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/IronMqProvider.php#L248-L272
train
uecode/qpush-bundle
src/Provider/IronMqProvider.php
IronMqProvider.onNotification
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $message = new Message( $event->getNotification()->getId(), $event->getNotification()->getBody(), $event->getNotification()->getMetadata()->toArray() ); $this->log( 200, "Message has been received from Push Notification.", ['message_id' => $event->getNotification()->getId()] ); $messageEvent = new MessageEvent($this->name, $message); $dispatcher->dispatch( Events::Message($this->name), $messageEvent ); }
php
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $message = new Message( $event->getNotification()->getId(), $event->getNotification()->getBody(), $event->getNotification()->getMetadata()->toArray() ); $this->log( 200, "Message has been received from Push Notification.", ['message_id' => $event->getNotification()->getId()] ); $messageEvent = new MessageEvent($this->name, $message); $dispatcher->dispatch( Events::Message($this->name), $messageEvent ); }
[ "public", "function", "onNotification", "(", "NotificationEvent", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "$", "message", "=", "new", "Message", "(", "$", "event", "->", "getNotification", "(", ")", "-...
Polls the Queue on Notification from IronMQ Dispatches the `{queue}.message_received` event @param NotificationEvent $event The Notification Event @param string $eventName Name of the event @param EventDispatcherInterface $dispatcher @return void
[ "Polls", "the", "Queue", "on", "Notification", "from", "IronMQ" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/IronMqProvider.php#L284-L304
train
uecode/qpush-bundle
src/Provider/IronMqProvider.php
IronMqProvider.queueInfo
public function queueInfo() { if ($this->queueExists()) { $queueName = $this->getNameWithPrefix(); $this->queue = $this->ironmq->getQueue($queueName); return $this->queue; } return null; }
php
public function queueInfo() { if ($this->queueExists()) { $queueName = $this->getNameWithPrefix(); $this->queue = $this->ironmq->getQueue($queueName); return $this->queue; } return null; }
[ "public", "function", "queueInfo", "(", ")", "{", "if", "(", "$", "this", "->", "queueExists", "(", ")", ")", "{", "$", "queueName", "=", "$", "this", "->", "getNameWithPrefix", "(", ")", ";", "$", "this", "->", "queue", "=", "$", "this", "->", "ir...
Get queue info This allows to get queue size. Allowing to know if processing is finished or not @return mixed
[ "Get", "queue", "info" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/IronMqProvider.php#L336-L346
train
uecode/qpush-bundle
src/Provider/IronMqProvider.php
IronMqProvider.publishMessages
public function publishMessages(array $messages, array $options = []) { $options = $this->mergeOptions($options); $publishStart = microtime(true); if (!$this->queueExists()) { $this->create(); } $encodedMessages = []; foreach ($messages as $message) { $encodedMessages[] = json_encode($message + ['_qpush_queue' => $this->name]); } $result = $this->ironmq->postMessages( $this->getNameWithPrefix(), $encodedMessages, [ 'timeout' => $options['message_timeout'], 'delay' => $options['message_delay'], 'expires_in' => $options['message_expiration'] ] ); $context = [ 'message_ids' => $result->ids, 'publish_time' => microtime(true) - $publishStart ]; $this->log(200, "Messages have been published.", $context); return $result->ids; }
php
public function publishMessages(array $messages, array $options = []) { $options = $this->mergeOptions($options); $publishStart = microtime(true); if (!$this->queueExists()) { $this->create(); } $encodedMessages = []; foreach ($messages as $message) { $encodedMessages[] = json_encode($message + ['_qpush_queue' => $this->name]); } $result = $this->ironmq->postMessages( $this->getNameWithPrefix(), $encodedMessages, [ 'timeout' => $options['message_timeout'], 'delay' => $options['message_delay'], 'expires_in' => $options['message_expiration'] ] ); $context = [ 'message_ids' => $result->ids, 'publish_time' => microtime(true) - $publishStart ]; $this->log(200, "Messages have been published.", $context); return $result->ids; }
[ "public", "function", "publishMessages", "(", "array", "$", "messages", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "mergeOptions", "(", "$", "options", ")", ";", "$", "publishStart", "=", "microtime", ...
Publishes multiple message at once @param array $messages @param array $options @return array
[ "Publishes", "multiple", "message", "at", "once" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/IronMqProvider.php#L356-L387
train
brick/date-time
src/Parser/DateTimeParseResult.php
DateTimeParseResult.hasField
public function hasField(string $name) : bool { return isset($this->fields[$name]) && $this->fields[$name]; }
php
public function hasField(string $name) : bool { return isset($this->fields[$name]) && $this->fields[$name]; }
[ "public", "function", "hasField", "(", "string", "$", "name", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "fields", "[", "$", "name", "]", ")", "&&", "$", "this", "->", "fields", "[", "$", "name", "]", ";", "}" ]
Returns whether this result has at least one value for the given field. @param string $name @return bool
[ "Returns", "whether", "this", "result", "has", "at", "least", "one", "value", "for", "the", "given", "field", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Parser/DateTimeParseResult.php#L35-L38
train
brick/date-time
src/Parser/DateTimeParseResult.php
DateTimeParseResult.getField
public function getField(string $name) : string { $value = $this->getOptionalField($name); if ($value === '') { throw new DateTimeParseException(\sprintf('Field %s is not present in the parsed result.', $name)); } return $value; }
php
public function getField(string $name) : string { $value = $this->getOptionalField($name); if ($value === '') { throw new DateTimeParseException(\sprintf('Field %s is not present in the parsed result.', $name)); } return $value; }
[ "public", "function", "getField", "(", "string", "$", "name", ")", ":", "string", "{", "$", "value", "=", "$", "this", "->", "getOptionalField", "(", "$", "name", ")", ";", "if", "(", "$", "value", "===", "''", ")", "{", "throw", "new", "DateTimePars...
Returns the first value parsed for the given field. @param string $name One of the field constants. @return string The value for this field. @throws DateTimeParseException If the field is not present in this set.
[ "Returns", "the", "first", "value", "parsed", "for", "the", "given", "field", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Parser/DateTimeParseResult.php#L49-L58
train
brick/date-time
src/Parser/DateTimeParseResult.php
DateTimeParseResult.getOptionalField
public function getOptionalField(string $name) : string { if (isset($this->fields[$name])) { if ($this->fields[$name]) { return \array_shift($this->fields[$name]); } } return ''; }
php
public function getOptionalField(string $name) : string { if (isset($this->fields[$name])) { if ($this->fields[$name]) { return \array_shift($this->fields[$name]); } } return ''; }
[ "public", "function", "getOptionalField", "(", "string", "$", "name", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "name", "]", ")", ")", "{", "if", "(", "$", "this", "->", "fields", "[", "$", "name", "...
Returns the first value for the given field, or an empty string if not present. @param string $name @return string
[ "Returns", "the", "first", "value", "for", "the", "given", "field", "or", "an", "empty", "string", "if", "not", "present", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Parser/DateTimeParseResult.php#L67-L76
train
brick/date-time
src/TimeZone.php
TimeZone.parse
public static function parse(string $text) : TimeZone { $text = (string) $text; if ($text === 'Z' || $text === 'z') { return TimeZoneOffset::utc(); } if ($text === '') { throw new DateTimeParseException('The string is empty.'); } if ($text[0] === '+' || $text[0] === '-') { return TimeZoneOffset::parse($text); } return TimeZoneRegion::parse($text); }
php
public static function parse(string $text) : TimeZone { $text = (string) $text; if ($text === 'Z' || $text === 'z') { return TimeZoneOffset::utc(); } if ($text === '') { throw new DateTimeParseException('The string is empty.'); } if ($text[0] === '+' || $text[0] === '-') { return TimeZoneOffset::parse($text); } return TimeZoneRegion::parse($text); }
[ "public", "static", "function", "parse", "(", "string", "$", "text", ")", ":", "TimeZone", "{", "$", "text", "=", "(", "string", ")", "$", "text", ";", "if", "(", "$", "text", "===", "'Z'", "||", "$", "text", "===", "'z'", ")", "{", "return", "Ti...
Obtains an instance of `TimeZone` from a string representation. @param string $text @return TimeZone @throws \Brick\DateTime\Parser\DateTimeParseException
[ "Obtains", "an", "instance", "of", "TimeZone", "from", "a", "string", "representation", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/TimeZone.php#L26-L43
train
brick/date-time
src/Utility/Math.php
Math.floorDiv
public static function floorDiv(int $a, int $b) : int { $r = \intdiv($a, $b); // If the signs are different and modulo not zero, round down. if (($a ^ $b) < 0 && ($r * $b !== $a)) { $r--; } return $r; }
php
public static function floorDiv(int $a, int $b) : int { $r = \intdiv($a, $b); // If the signs are different and modulo not zero, round down. if (($a ^ $b) < 0 && ($r * $b !== $a)) { $r--; } return $r; }
[ "public", "static", "function", "floorDiv", "(", "int", "$", "a", ",", "int", "$", "b", ")", ":", "int", "{", "$", "r", "=", "\\", "intdiv", "(", "$", "a", ",", "$", "b", ")", ";", "// If the signs are different and modulo not zero, round down.", "if", "...
Returns the largest integer value that is less than or equal to the algebraic quotient. @param int $a The first argument. @param int $b The second argument, non-zero. @return int
[ "Returns", "the", "largest", "integer", "value", "that", "is", "less", "than", "or", "equal", "to", "the", "algebraic", "quotient", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Utility/Math.php#L22-L32
train
brick/date-time
src/Utility/Math.php
Math.floorMod
public static function floorMod(int $a, int $b) : int { return (($a % $b) + $b) % $b; }
php
public static function floorMod(int $a, int $b) : int { return (($a % $b) + $b) % $b; }
[ "public", "static", "function", "floorMod", "(", "int", "$", "a", ",", "int", "$", "b", ")", ":", "int", "{", "return", "(", "(", "$", "a", "%", "$", "b", ")", "+", "$", "b", ")", "%", "$", "b", ";", "}" ]
Returns the floor modulus of the integer arguments. The relationship between floorDiv and floorMod is such that: floorDiv(x, y) * y + floorMod(x, y) == x @param int $a The first argument. @param int $b The second argument, non-zero. @return int
[ "Returns", "the", "floor", "modulus", "of", "the", "integer", "arguments", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Utility/Math.php#L45-L48
train
brick/date-time
src/Period.php
Period.of
public static function of(int $years, int $months, int $days) : Period { return new Period($years, $months, $days); }
php
public static function of(int $years, int $months, int $days) : Period { return new Period($years, $months, $days); }
[ "public", "static", "function", "of", "(", "int", "$", "years", ",", "int", "$", "months", ",", "int", "$", "days", ")", ":", "Period", "{", "return", "new", "Period", "(", "$", "years", ",", "$", "months", ",", "$", "days", ")", ";", "}" ]
Creates a Period based on years, months, days, hours, minutes and seconds. @param int $years The number of years. @param int $months The number of months. @param int $days The number of days. @return Period
[ "Creates", "a", "Period", "based", "on", "years", "months", "days", "hours", "minutes", "and", "seconds", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Period.php#L52-L55
train
brick/date-time
src/Period.php
Period.multipliedBy
public function multipliedBy(int $scalar) : Period { if ($scalar === 1) { return $this; } return new Period( $this->years * $scalar, $this->months * $scalar, $this->days * $scalar ); }
php
public function multipliedBy(int $scalar) : Period { if ($scalar === 1) { return $this; } return new Period( $this->years * $scalar, $this->months * $scalar, $this->days * $scalar ); }
[ "public", "function", "multipliedBy", "(", "int", "$", "scalar", ")", ":", "Period", "{", "if", "(", "$", "scalar", "===", "1", ")", "{", "return", "$", "this", ";", "}", "return", "new", "Period", "(", "$", "this", "->", "years", "*", "$", "scalar...
Returns a new Period with each value multiplied by the given scalar. @param int $scalar @return Period
[ "Returns", "a", "new", "Period", "with", "each", "value", "multiplied", "by", "the", "given", "scalar", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Period.php#L346-L357
train
brick/date-time
src/Period.php
Period.negated
public function negated() : Period { if ($this->isZero()) { return $this; } return new Period( - $this->years, - $this->months, - $this->days ); }
php
public function negated() : Period { if ($this->isZero()) { return $this; } return new Period( - $this->years, - $this->months, - $this->days ); }
[ "public", "function", "negated", "(", ")", ":", "Period", "{", "if", "(", "$", "this", "->", "isZero", "(", ")", ")", "{", "return", "$", "this", ";", "}", "return", "new", "Period", "(", "-", "$", "this", "->", "years", ",", "-", "$", "this", ...
Returns a new instance with each amount in this Period negated. @return Period
[ "Returns", "a", "new", "instance", "with", "each", "amount", "in", "this", "Period", "negated", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Period.php#L364-L375
train
brick/date-time
src/Period.php
Period.normalized
public function normalized() : Period { $totalMonths = $this->years * LocalTime::MONTHS_PER_YEAR + $this->months; $splitYears = \intdiv($totalMonths, 12); $splitMonths = $totalMonths % 12; if ($splitYears === $this->years || $splitMonths === $this->months) { return $this; } return new Period($splitYears, $splitMonths, $this->days); }
php
public function normalized() : Period { $totalMonths = $this->years * LocalTime::MONTHS_PER_YEAR + $this->months; $splitYears = \intdiv($totalMonths, 12); $splitMonths = $totalMonths % 12; if ($splitYears === $this->years || $splitMonths === $this->months) { return $this; } return new Period($splitYears, $splitMonths, $this->days); }
[ "public", "function", "normalized", "(", ")", ":", "Period", "{", "$", "totalMonths", "=", "$", "this", "->", "years", "*", "LocalTime", "::", "MONTHS_PER_YEAR", "+", "$", "this", "->", "months", ";", "$", "splitYears", "=", "\\", "intdiv", "(", "$", "...
Returns a copy of this Period with the years and months normalized. This normalizes the years and months units, leaving the days unit unchanged. The months unit is adjusted to have an absolute value less than 12, with the years unit being adjusted to compensate. For example, a period of "1 year and 15 months" will be normalized to "2 years and 3 months". The sign of the years and months units will be the same after normalization. For example, a period of "1 year and -25 months" will be normalized to "-1 year and -1 month". @return Period
[ "Returns", "a", "copy", "of", "this", "Period", "with", "the", "years", "and", "months", "normalized", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Period.php#L391-L403
train
brick/date-time
src/Period.php
Period.toDateInterval
public function toDateInterval() : \DateInterval { return \DateInterval::createFromDateString(\sprintf( '%d years %d months %d days', $this->years, $this->months, $this->days )); }
php
public function toDateInterval() : \DateInterval { return \DateInterval::createFromDateString(\sprintf( '%d years %d months %d days', $this->years, $this->months, $this->days )); }
[ "public", "function", "toDateInterval", "(", ")", ":", "\\", "DateInterval", "{", "return", "\\", "DateInterval", "::", "createFromDateString", "(", "\\", "sprintf", "(", "'%d years %d months %d days'", ",", "$", "this", "->", "years", ",", "$", "this", "->", ...
Returns a native DateInterval object equivalent to this Period. We cannot use the constructor with the output of __toString(), as it does not support negative values. @return \DateInterval
[ "Returns", "a", "native", "DateInterval", "object", "equivalent", "to", "this", "Period", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Period.php#L433-L441
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.create
public function create() { $this->createQueue(); if ($this->options['push_notifications']) { // Create the SNS Topic $this->createTopic(); // Add the SQS Queue as a Subscriber to the SNS Topic $this->subscribeToTopic( $this->topicArn, 'sqs', $this->sqs->getQueueArn($this->queueUrl) ); // Add configured Subscribers to the SNS Topic foreach ($this->options['subscribers'] as $subscriber) { $this->subscribeToTopic( $this->topicArn, $subscriber['protocol'], $subscriber['endpoint'] ); } } return true; }
php
public function create() { $this->createQueue(); if ($this->options['push_notifications']) { // Create the SNS Topic $this->createTopic(); // Add the SQS Queue as a Subscriber to the SNS Topic $this->subscribeToTopic( $this->topicArn, 'sqs', $this->sqs->getQueueArn($this->queueUrl) ); // Add configured Subscribers to the SNS Topic foreach ($this->options['subscribers'] as $subscriber) { $this->subscribeToTopic( $this->topicArn, $subscriber['protocol'], $subscriber['endpoint'] ); } } return true; }
[ "public", "function", "create", "(", ")", "{", "$", "this", "->", "createQueue", "(", ")", ";", "if", "(", "$", "this", "->", "options", "[", "'push_notifications'", "]", ")", "{", "// Create the SNS Topic", "$", "this", "->", "createTopic", "(", ")", ";...
Builds the configured queues If a Queue name is passed and configured, this method will build only that Queue. All Create methods are idempotent, if the resource exists, the current ARN will be returned @return bool
[ "Builds", "the", "configured", "queues" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L110-L136
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.queueExists
public function queueExists() { if (isset($this->queueUrl)) { return true; } $key = $this->getNameWithPrefix() . '_url'; if ($this->cache->contains($key)) { $this->queueUrl = $this->cache->fetch($key); return true; } try { $result = $this->sqs->getQueueUrl([ 'QueueName' => $this->getNameWithPrefix() ]); $this->queueUrl = $result->get('QueueUrl'); if ($this->queueUrl !== null) { $this->cache->save($key, $this->queueUrl); return true; } } catch (SqsException $e) {} return false; }
php
public function queueExists() { if (isset($this->queueUrl)) { return true; } $key = $this->getNameWithPrefix() . '_url'; if ($this->cache->contains($key)) { $this->queueUrl = $this->cache->fetch($key); return true; } try { $result = $this->sqs->getQueueUrl([ 'QueueName' => $this->getNameWithPrefix() ]); $this->queueUrl = $result->get('QueueUrl'); if ($this->queueUrl !== null) { $this->cache->save($key, $this->queueUrl); return true; } } catch (SqsException $e) {} return false; }
[ "public", "function", "queueExists", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queueUrl", ")", ")", "{", "return", "true", ";", "}", "$", "key", "=", "$", "this", "->", "getNameWithPrefix", "(", ")", ".", "'_url'", ";", "if", "(",...
Return the Queue Url This method relies on in-memory cache and the Cache provider to reduce the need to needlessly call the create method on an existing Queue. @return boolean
[ "Return", "the", "Queue", "Url" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L355-L382
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.createQueue
public function createQueue() { $attributes = [ 'VisibilityTimeout' => $this->options['message_timeout'], 'MessageRetentionPeriod' => $this->options['message_expiration'], 'ReceiveMessageWaitTimeSeconds' => $this->options['receive_wait_time'] ]; if ($this->isQueueFIFO()) { $attributes['FifoQueue'] = 'true'; $attributes['ContentBasedDeduplication'] = $this->options['content_based_deduplication'] === true ? 'true' : 'false'; } $result = $this->sqs->createQueue(['QueueName' => $this->getNameWithPrefix(), 'Attributes' => $attributes]); $this->queueUrl = $result->get('QueueUrl'); $key = $this->getNameWithPrefix() . '_url'; $this->cache->save($key, $this->queueUrl); $this->log(200, "Created SQS Queue", ['QueueUrl' => $this->queueUrl]); if ($this->options['push_notifications']) { $policy = $this->createSqsPolicy(); $this->sqs->setQueueAttributes([ 'QueueUrl' => $this->queueUrl, 'Attributes' => [ 'Policy' => $policy, ] ]); $this->log(200, "Created Updated SQS Policy"); } }
php
public function createQueue() { $attributes = [ 'VisibilityTimeout' => $this->options['message_timeout'], 'MessageRetentionPeriod' => $this->options['message_expiration'], 'ReceiveMessageWaitTimeSeconds' => $this->options['receive_wait_time'] ]; if ($this->isQueueFIFO()) { $attributes['FifoQueue'] = 'true'; $attributes['ContentBasedDeduplication'] = $this->options['content_based_deduplication'] === true ? 'true' : 'false'; } $result = $this->sqs->createQueue(['QueueName' => $this->getNameWithPrefix(), 'Attributes' => $attributes]); $this->queueUrl = $result->get('QueueUrl'); $key = $this->getNameWithPrefix() . '_url'; $this->cache->save($key, $this->queueUrl); $this->log(200, "Created SQS Queue", ['QueueUrl' => $this->queueUrl]); if ($this->options['push_notifications']) { $policy = $this->createSqsPolicy(); $this->sqs->setQueueAttributes([ 'QueueUrl' => $this->queueUrl, 'Attributes' => [ 'Policy' => $policy, ] ]); $this->log(200, "Created Updated SQS Policy"); } }
[ "public", "function", "createQueue", "(", ")", "{", "$", "attributes", "=", "[", "'VisibilityTimeout'", "=>", "$", "this", "->", "options", "[", "'message_timeout'", "]", ",", "'MessageRetentionPeriod'", "=>", "$", "this", "->", "options", "[", "'message_expirat...
Creates an SQS Queue and returns the Queue Url The create method for SQS Queues is idempotent - if the queue already exists, this method will return the Queue Url of the existing Queue.
[ "Creates", "an", "SQS", "Queue", "and", "returns", "the", "Queue", "Url" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L390-L427
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.createSqsPolicy
public function createSqsPolicy() { $arn = $this->sqs->getQueueArn($this->queueUrl); return json_encode([ 'Version' => '2008-10-17', 'Id' => sprintf('%s/SQSDefaultPolicy', $arn), 'Statement' => [ [ 'Sid' => 'SNSPermissions', 'Effect' => 'Allow', 'Principal' => ['AWS' => '*'], 'Action' => 'SQS:SendMessage', 'Resource' => $arn ] ] ]); }
php
public function createSqsPolicy() { $arn = $this->sqs->getQueueArn($this->queueUrl); return json_encode([ 'Version' => '2008-10-17', 'Id' => sprintf('%s/SQSDefaultPolicy', $arn), 'Statement' => [ [ 'Sid' => 'SNSPermissions', 'Effect' => 'Allow', 'Principal' => ['AWS' => '*'], 'Action' => 'SQS:SendMessage', 'Resource' => $arn ] ] ]); }
[ "public", "function", "createSqsPolicy", "(", ")", "{", "$", "arn", "=", "$", "this", "->", "sqs", "->", "getQueueArn", "(", "$", "this", "->", "queueUrl", ")", ";", "return", "json_encode", "(", "[", "'Version'", "=>", "'2008-10-17'", ",", "'Id'", "=>",...
Creates a Policy for SQS that's required to allow SNS SendMessage access @return string
[ "Creates", "a", "Policy", "for", "SQS", "that", "s", "required", "to", "allow", "SNS", "SendMessage", "access" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L434-L451
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.topicExists
public function topicExists() { if (isset($this->topicArn)) { return true; } $key = $this->getNameWithPrefix() . '_arn'; if ($this->cache->contains($key)) { $this->topicArn = $this->cache->fetch($key); return true; } if (!empty($this->queueUrl)) { $queueArn = $this->sqs->getQueueArn($this->queueUrl); $topicArn = str_replace('sqs', 'sns', $queueArn); try { $this->sns->getTopicAttributes([ 'TopicArn' => $topicArn ]); } catch (SnsException $e) { return false; } $this->topicArn = $topicArn; $this->cache->save($key, $this->topicArn); return true; } return false; }
php
public function topicExists() { if (isset($this->topicArn)) { return true; } $key = $this->getNameWithPrefix() . '_arn'; if ($this->cache->contains($key)) { $this->topicArn = $this->cache->fetch($key); return true; } if (!empty($this->queueUrl)) { $queueArn = $this->sqs->getQueueArn($this->queueUrl); $topicArn = str_replace('sqs', 'sns', $queueArn); try { $this->sns->getTopicAttributes([ 'TopicArn' => $topicArn ]); } catch (SnsException $e) { return false; } $this->topicArn = $topicArn; $this->cache->save($key, $this->topicArn); return true; } return false; }
[ "public", "function", "topicExists", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "topicArn", ")", ")", "{", "return", "true", ";", "}", "$", "key", "=", "$", "this", "->", "getNameWithPrefix", "(", ")", ".", "'_arn'", ";", "if", "(",...
Checks to see if a Topic exists This method relies on in-memory cache and the Cache provider to reduce the need to needlessly call the create method on an existing Topic. @return boolean
[ "Checks", "to", "see", "if", "a", "Topic", "exists" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L462-L494
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.createTopic
public function createTopic() { if (!$this->options['push_notifications']) { return false; } $name = str_replace('.', '-', $this->getNameWithPrefix()); $result = $this->sns->createTopic([ 'Name' => $name ]); $this->topicArn = $result->get('TopicArn'); $key = $name . '_arn'; $this->cache->save($key, $this->topicArn); $this->log(200, "Created SNS Topic", ['TopicARN' => $this->topicArn]); return true; }
php
public function createTopic() { if (!$this->options['push_notifications']) { return false; } $name = str_replace('.', '-', $this->getNameWithPrefix()); $result = $this->sns->createTopic([ 'Name' => $name ]); $this->topicArn = $result->get('TopicArn'); $key = $name . '_arn'; $this->cache->save($key, $this->topicArn); $this->log(200, "Created SNS Topic", ['TopicARN' => $this->topicArn]); return true; }
[ "public", "function", "createTopic", "(", ")", "{", "if", "(", "!", "$", "this", "->", "options", "[", "'push_notifications'", "]", ")", "{", "return", "false", ";", "}", "$", "name", "=", "str_replace", "(", "'.'", ",", "'-'", ",", "$", "this", "->"...
Creates a SNS Topic and returns the ARN The create method for the SNS Topics is idempotent - if the topic already exists, this method will return the Topic ARN of the existing Topic. @return bool
[ "Creates", "a", "SNS", "Topic", "and", "returns", "the", "ARN" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L505-L524
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.subscribeToTopic
public function subscribeToTopic($topicArn, $protocol, $endpoint) { // Check against the current Topic Subscriptions $subscriptions = $this->getTopicSubscriptions($topicArn); foreach ($subscriptions as $subscription) { if ($endpoint === $subscription['Endpoint']) { return $subscription['SubscriptionArn']; } } $result = $this->sns->subscribe([ 'TopicArn' => $topicArn, 'Protocol' => $protocol, 'Endpoint' => $endpoint ]); $arn = $result->get('SubscriptionArn'); $context = [ 'Endpoint' => $endpoint, 'Protocol' => $protocol, 'SubscriptionArn' => $arn ]; $this->log(200, "Endpoint Subscribed to SNS Topic", $context); return $arn; }
php
public function subscribeToTopic($topicArn, $protocol, $endpoint) { // Check against the current Topic Subscriptions $subscriptions = $this->getTopicSubscriptions($topicArn); foreach ($subscriptions as $subscription) { if ($endpoint === $subscription['Endpoint']) { return $subscription['SubscriptionArn']; } } $result = $this->sns->subscribe([ 'TopicArn' => $topicArn, 'Protocol' => $protocol, 'Endpoint' => $endpoint ]); $arn = $result->get('SubscriptionArn'); $context = [ 'Endpoint' => $endpoint, 'Protocol' => $protocol, 'SubscriptionArn' => $arn ]; $this->log(200, "Endpoint Subscribed to SNS Topic", $context); return $arn; }
[ "public", "function", "subscribeToTopic", "(", "$", "topicArn", ",", "$", "protocol", ",", "$", "endpoint", ")", "{", "// Check against the current Topic Subscriptions", "$", "subscriptions", "=", "$", "this", "->", "getTopicSubscriptions", "(", "$", "topicArn", ")"...
Subscribes an endpoint to a SNS Topic @param string $topicArn The ARN of the Topic @param string $protocol The protocol of the Endpoint @param string $endpoint The Endpoint of the Subscriber @return string
[ "Subscribes", "an", "endpoint", "to", "a", "SNS", "Topic" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L551-L577
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.unsubscribeFromTopic
public function unsubscribeFromTopic($topicArn, $protocol, $endpoint) { // Check against the current Topic Subscriptions $subscriptions = $this->getTopicSubscriptions($topicArn); foreach ($subscriptions as $subscription) { if ($endpoint === $subscription['Endpoint']) { $this->sns->unsubscribe([ 'SubscriptionArn' => $subscription['SubscriptionArn'] ]); $context = [ 'Endpoint' => $endpoint, 'Protocol' => $protocol, 'SubscriptionArn' => $subscription['SubscriptionArn'] ]; $this->log(200,"Endpoint unsubscribed from SNS Topic", $context); return true; } } return false; }
php
public function unsubscribeFromTopic($topicArn, $protocol, $endpoint) { // Check against the current Topic Subscriptions $subscriptions = $this->getTopicSubscriptions($topicArn); foreach ($subscriptions as $subscription) { if ($endpoint === $subscription['Endpoint']) { $this->sns->unsubscribe([ 'SubscriptionArn' => $subscription['SubscriptionArn'] ]); $context = [ 'Endpoint' => $endpoint, 'Protocol' => $protocol, 'SubscriptionArn' => $subscription['SubscriptionArn'] ]; $this->log(200,"Endpoint unsubscribed from SNS Topic", $context); return true; } } return false; }
[ "public", "function", "unsubscribeFromTopic", "(", "$", "topicArn", ",", "$", "protocol", ",", "$", "endpoint", ")", "{", "// Check against the current Topic Subscriptions", "$", "subscriptions", "=", "$", "this", "->", "getTopicSubscriptions", "(", "$", "topicArn", ...
Unsubscribes an endpoint from a SNS Topic The method will return TRUE on success, or FALSE if the Endpoint did not have a Subscription on the SNS Topic @param string $topicArn The ARN of the Topic @param string $protocol The protocol of the Endpoint @param string $endpoint The Endpoint of the Subscriber @return Boolean
[ "Unsubscribes", "an", "endpoint", "from", "a", "SNS", "Topic" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L591-L613
train
uecode/qpush-bundle
src/Provider/AwsProvider.php
AwsProvider.onNotification
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (NotificationEvent::TYPE_SUBSCRIPTION == $event->getType()) { $topicArn = $event->getNotification()->getMetadata()->get('TopicArn'); $token = $event->getNotification()->getMetadata()->get('Token'); $this->sns->confirmSubscription([ 'TopicArn' => $topicArn, 'Token' => $token ]); $context = ['TopicArn' => $topicArn]; $this->log(200,"Subscription to SNS Confirmed", $context); return; } $messages = $this->receive(); foreach ($messages as $message) { $messageEvent = new MessageEvent($this->name, $message); $dispatcher->dispatch(Events::Message($this->name), $messageEvent); } }
php
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (NotificationEvent::TYPE_SUBSCRIPTION == $event->getType()) { $topicArn = $event->getNotification()->getMetadata()->get('TopicArn'); $token = $event->getNotification()->getMetadata()->get('Token'); $this->sns->confirmSubscription([ 'TopicArn' => $topicArn, 'Token' => $token ]); $context = ['TopicArn' => $topicArn]; $this->log(200,"Subscription to SNS Confirmed", $context); return; } $messages = $this->receive(); foreach ($messages as $message) { $messageEvent = new MessageEvent($this->name, $message); $dispatcher->dispatch(Events::Message($this->name), $messageEvent); } }
[ "public", "function", "onNotification", "(", "NotificationEvent", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "if", "(", "NotificationEvent", "::", "TYPE_SUBSCRIPTION", "==", "$", "event", "->", "getType", "("...
Handles SNS Notifications For Subscription notifications, this method will automatically confirm the Subscription request For Message notifications, this method polls the queue and dispatches the `{queue}.message_received` event for each message retrieved @param NotificationEvent $event The Notification Event @param string $eventName Name of the event @param EventDispatcherInterface $dispatcher @return void
[ "Handles", "SNS", "Notifications" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/AwsProvider.php#L630-L653
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.of
public static function of(YearMonth $start, YearMonth $end) : YearMonthRange { if ($end->isBefore($start)) { throw new DateTimeException('The end year-month must not be before the start year-month.'); } return new YearMonthRange($start, $end); }
php
public static function of(YearMonth $start, YearMonth $end) : YearMonthRange { if ($end->isBefore($start)) { throw new DateTimeException('The end year-month must not be before the start year-month.'); } return new YearMonthRange($start, $end); }
[ "public", "static", "function", "of", "(", "YearMonth", "$", "start", ",", "YearMonth", "$", "end", ")", ":", "YearMonthRange", "{", "if", "(", "$", "end", "->", "isBefore", "(", "$", "start", ")", ")", "{", "throw", "new", "DateTimeException", "(", "'...
Creates an instance of YearMonthRange from a start year-month and an end year-month. @param YearMonth $start The start year-month, inclusive. @param YearMonth $end The end year-month, inclusive. @return YearMonthRange @throws DateTimeException If the end year-month is before the start year-month.
[ "Creates", "an", "instance", "of", "YearMonthRange", "from", "a", "start", "year", "-", "month", "and", "an", "end", "year", "-", "month", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L56-L63
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.from
public static function from(DateTimeParseResult $result) : YearMonthRange { $start = YearMonth::from($result); if ($result->hasField(Field\Year::NAME)) { $end = YearMonth::from($result); } else { $end = $start->withMonth((int) $result->getField(Field\MonthOfYear::NAME)); } return YearMonthRange::of($start, $end); }
php
public static function from(DateTimeParseResult $result) : YearMonthRange { $start = YearMonth::from($result); if ($result->hasField(Field\Year::NAME)) { $end = YearMonth::from($result); } else { $end = $start->withMonth((int) $result->getField(Field\MonthOfYear::NAME)); } return YearMonthRange::of($start, $end); }
[ "public", "static", "function", "from", "(", "DateTimeParseResult", "$", "result", ")", ":", "YearMonthRange", "{", "$", "start", "=", "YearMonth", "::", "from", "(", "$", "result", ")", ";", "if", "(", "$", "result", "->", "hasField", "(", "Field", "\\"...
Obtains an instance of `YearMonthRange` from a set of date-time fields. This method is only useful to parsers. @param DateTimeParseResult $result @return YearMonthRange @throws DateTimeException If the year-month range is not valid. @throws DateTimeParseException If required fields are missing from the result.
[ "Obtains", "an", "instance", "of", "YearMonthRange", "from", "a", "set", "of", "date", "-", "time", "fields", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L77-L88
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.parse
public static function parse(string $text, DateTimeParser $parser = null) : YearMonthRange { if (! $parser) { $parser = IsoParsers::yearMonthRange(); } return YearMonthRange::from($parser->parse($text)); }
php
public static function parse(string $text, DateTimeParser $parser = null) : YearMonthRange { if (! $parser) { $parser = IsoParsers::yearMonthRange(); } return YearMonthRange::from($parser->parse($text)); }
[ "public", "static", "function", "parse", "(", "string", "$", "text", ",", "DateTimeParser", "$", "parser", "=", "null", ")", ":", "YearMonthRange", "{", "if", "(", "!", "$", "parser", ")", "{", "$", "parser", "=", "IsoParsers", "::", "yearMonthRange", "(...
Obtains an instance of `YearMonthRange` from a text string. Partial representations are allowed; for example, the following representations are equivalent: - `2001-02/2001-07` - `2001-02/07` @param string $text The text to parse. @param DateTimeParser|null $parser The parser to use, defaults to the ISO 8601 parser. @return YearMonthRange @throws DateTimeException If either of the year-months is not valid. @throws DateTimeParseException If the text string does not follow the expected format.
[ "Obtains", "an", "instance", "of", "YearMonthRange", "from", "a", "text", "string", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L106-L113
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.isEqualTo
public function isEqualTo(YearMonthRange $that) : bool { return $this->start->isEqualTo($that->start) && $this->end->isEqualTo($that->end); }
php
public function isEqualTo(YearMonthRange $that) : bool { return $this->start->isEqualTo($that->start) && $this->end->isEqualTo($that->end); }
[ "public", "function", "isEqualTo", "(", "YearMonthRange", "$", "that", ")", ":", "bool", "{", "return", "$", "this", "->", "start", "->", "isEqualTo", "(", "$", "that", "->", "start", ")", "&&", "$", "this", "->", "end", "->", "isEqualTo", "(", "$", ...
Returns whether this YearMonthRange is equal to the given one. @param YearMonthRange $that The range to compare to. @return bool True if this range equals the given one, false otherwise.
[ "Returns", "whether", "this", "YearMonthRange", "is", "equal", "to", "the", "given", "one", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L142-L145
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.contains
public function contains(YearMonth $yearMonth) : bool { return $yearMonth->isAfterOrEqualTo($this->start) && $yearMonth->isBeforeOrEqualTo($this->end); }
php
public function contains(YearMonth $yearMonth) : bool { return $yearMonth->isAfterOrEqualTo($this->start) && $yearMonth->isBeforeOrEqualTo($this->end); }
[ "public", "function", "contains", "(", "YearMonth", "$", "yearMonth", ")", ":", "bool", "{", "return", "$", "yearMonth", "->", "isAfterOrEqualTo", "(", "$", "this", "->", "start", ")", "&&", "$", "yearMonth", "->", "isBeforeOrEqualTo", "(", "$", "this", "-...
Returns whether this YearMonthRange contains the given year-month. @param YearMonth $yearMonth The year-month to check. @return bool True if this range contains the given year-month, false otherwise.
[ "Returns", "whether", "this", "YearMonthRange", "contains", "the", "given", "year", "-", "month", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L154-L157
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.getIterator
public function getIterator() : \Generator { for ($current = $this->start; $current->isBeforeOrEqualTo($this->end); $current = $current->plusMonths(1)) { yield $current; } }
php
public function getIterator() : \Generator { for ($current = $this->start; $current->isBeforeOrEqualTo($this->end); $current = $current->plusMonths(1)) { yield $current; } }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Generator", "{", "for", "(", "$", "current", "=", "$", "this", "->", "start", ";", "$", "current", "->", "isBeforeOrEqualTo", "(", "$", "this", "->", "end", ")", ";", "$", "current", "=", "$"...
Returns an iterator for all the year-months contained in this range. @return YearMonth[]
[ "Returns", "an", "iterator", "for", "all", "the", "year", "-", "months", "contained", "in", "this", "range", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L164-L169
train
brick/date-time
src/YearMonthRange.php
YearMonthRange.count
public function count() : int { return 12 * ($this->end->getYear() - $this->start->getYear()) + ($this->end->getMonth() - $this->start->getMonth()) + 1; }
php
public function count() : int { return 12 * ($this->end->getYear() - $this->start->getYear()) + ($this->end->getMonth() - $this->start->getMonth()) + 1; }
[ "public", "function", "count", "(", ")", ":", "int", "{", "return", "12", "*", "(", "$", "this", "->", "end", "->", "getYear", "(", ")", "-", "$", "this", "->", "start", "->", "getYear", "(", ")", ")", "+", "(", "$", "this", "->", "end", "->", ...
Returns the number of year-months in this range. @return int The number of year-months, >= 1.
[ "Returns", "the", "number", "of", "year", "-", "months", "in", "this", "range", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/YearMonthRange.php#L176-L181
train
brick/date-time
src/LocalTime.php
LocalTime.ofSecondOfDay
public static function ofSecondOfDay(int $secondOfDay, int $nanoOfSecond = 0) : LocalTime { Field\SecondOfDay::check($secondOfDay); Field\NanoOfSecond::check($nanoOfSecond); $hours = \intdiv($secondOfDay, self::SECONDS_PER_HOUR); $secondOfDay -= $hours * self::SECONDS_PER_HOUR; $minutes = \intdiv($secondOfDay, self::SECONDS_PER_MINUTE); $secondOfDay -= $minutes * self::SECONDS_PER_MINUTE; return new LocalTime($hours, $minutes, $secondOfDay, $nanoOfSecond); }
php
public static function ofSecondOfDay(int $secondOfDay, int $nanoOfSecond = 0) : LocalTime { Field\SecondOfDay::check($secondOfDay); Field\NanoOfSecond::check($nanoOfSecond); $hours = \intdiv($secondOfDay, self::SECONDS_PER_HOUR); $secondOfDay -= $hours * self::SECONDS_PER_HOUR; $minutes = \intdiv($secondOfDay, self::SECONDS_PER_MINUTE); $secondOfDay -= $minutes * self::SECONDS_PER_MINUTE; return new LocalTime($hours, $minutes, $secondOfDay, $nanoOfSecond); }
[ "public", "static", "function", "ofSecondOfDay", "(", "int", "$", "secondOfDay", ",", "int", "$", "nanoOfSecond", "=", "0", ")", ":", "LocalTime", "{", "Field", "\\", "SecondOfDay", "::", "check", "(", "$", "secondOfDay", ")", ";", "Field", "\\", "NanoOfSe...
Creates a LocalTime instance from a number of seconds since midnight. @param int $secondOfDay The second-of-day, from 0 to 86,399. @param int $nanoOfSecond The nano-of-second, from 0 to 999,999,999. @return LocalTime @throws DateTimeException
[ "Creates", "a", "LocalTime", "instance", "from", "a", "number", "of", "seconds", "since", "midnight", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L108-L119
train
brick/date-time
src/LocalTime.php
LocalTime.parse
public static function parse(string $text, DateTimeParser $parser = null) : LocalTime { if (! $parser) { $parser = IsoParsers::localTime(); } return LocalTime::from($parser->parse($text)); }
php
public static function parse(string $text, DateTimeParser $parser = null) : LocalTime { if (! $parser) { $parser = IsoParsers::localTime(); } return LocalTime::from($parser->parse($text)); }
[ "public", "static", "function", "parse", "(", "string", "$", "text", ",", "DateTimeParser", "$", "parser", "=", "null", ")", ":", "LocalTime", "{", "if", "(", "!", "$", "parser", ")", "{", "$", "parser", "=", "IsoParsers", "::", "localTime", "(", ")", ...
Obtains an instance of `LocalTime` from a text string. @param string $text The text to parse, such as `10:15`. @param DateTimeParser|null $parser The parser to use, defaults to the ISO 8601 parser. @return LocalTime @throws DateTimeException If the time is not valid. @throws DateTimeParseException If the text string does not follow the expected format.
[ "Obtains", "an", "instance", "of", "LocalTime", "from", "a", "text", "string", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L152-L159
train
brick/date-time
src/LocalTime.php
LocalTime.fromDateTime
public static function fromDateTime(\DateTimeInterface $dateTime) : LocalTime { return new LocalTime( (int) $dateTime->format('G'), (int) $dateTime->format('i'), (int) $dateTime->format('s'), 1000 * (int) $dateTime->format('u') ); }
php
public static function fromDateTime(\DateTimeInterface $dateTime) : LocalTime { return new LocalTime( (int) $dateTime->format('G'), (int) $dateTime->format('i'), (int) $dateTime->format('s'), 1000 * (int) $dateTime->format('u') ); }
[ "public", "static", "function", "fromDateTime", "(", "\\", "DateTimeInterface", "$", "dateTime", ")", ":", "LocalTime", "{", "return", "new", "LocalTime", "(", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'G'", ")", ",", "(", "int", ")", "$", ...
Creates a LocalTime from a native DateTime or DateTimeImmutable object. @param \DateTimeInterface $dateTime @return LocalTime
[ "Creates", "a", "LocalTime", "from", "a", "native", "DateTime", "or", "DateTimeImmutable", "object", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L168-L176
train
brick/date-time
src/LocalTime.php
LocalTime.now
public static function now(TimeZone $timeZone, Clock $clock = null) : LocalTime { return ZonedDateTime::now($timeZone, $clock)->getTime(); }
php
public static function now(TimeZone $timeZone, Clock $clock = null) : LocalTime { return ZonedDateTime::now($timeZone, $clock)->getTime(); }
[ "public", "static", "function", "now", "(", "TimeZone", "$", "timeZone", ",", "Clock", "$", "clock", "=", "null", ")", ":", "LocalTime", "{", "return", "ZonedDateTime", "::", "now", "(", "$", "timeZone", ",", "$", "clock", ")", "->", "getTime", "(", ")...
Returns the current local time in the given time-zone, according to the given clock. If no clock is provided, the system clock is used. @param TimeZone $timeZone @param Clock|null $clock @return LocalTime
[ "Returns", "the", "current", "local", "time", "in", "the", "given", "time", "-", "zone", "according", "to", "the", "given", "clock", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L188-L191
train
brick/date-time
src/LocalTime.php
LocalTime.withHour
public function withHour(int $hour) : LocalTime { if ($hour === $this->hour) { return $this; } Field\HourOfDay::check($hour); return new LocalTime($hour, $this->minute, $this->second, $this->nano); }
php
public function withHour(int $hour) : LocalTime { if ($hour === $this->hour) { return $this; } Field\HourOfDay::check($hour); return new LocalTime($hour, $this->minute, $this->second, $this->nano); }
[ "public", "function", "withHour", "(", "int", "$", "hour", ")", ":", "LocalTime", "{", "if", "(", "$", "hour", "===", "$", "this", "->", "hour", ")", "{", "return", "$", "this", ";", "}", "Field", "\\", "HourOfDay", "::", "check", "(", "$", "hour",...
Returns a copy of this LocalTime with the hour-of-day value altered. @param int $hour The new hour-of-day. @return LocalTime @throws DateTimeException If the hour-of-day if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "hour", "-", "of", "-", "day", "value", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L322-L331
train
brick/date-time
src/LocalTime.php
LocalTime.withMinute
public function withMinute(int $minute) : LocalTime { if ($minute === $this->minute) { return $this; } Field\MinuteOfHour::check($minute); return new LocalTime($this->hour, $minute, $this->second, $this->nano); }
php
public function withMinute(int $minute) : LocalTime { if ($minute === $this->minute) { return $this; } Field\MinuteOfHour::check($minute); return new LocalTime($this->hour, $minute, $this->second, $this->nano); }
[ "public", "function", "withMinute", "(", "int", "$", "minute", ")", ":", "LocalTime", "{", "if", "(", "$", "minute", "===", "$", "this", "->", "minute", ")", "{", "return", "$", "this", ";", "}", "Field", "\\", "MinuteOfHour", "::", "check", "(", "$"...
Returns a copy of this LocalTime with the minute-of-hour value altered. @param int $minute The new minute-of-hour. @return LocalTime @throws DateTimeException If the minute-of-hour if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "minute", "-", "of", "-", "hour", "value", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L342-L351
train
brick/date-time
src/LocalTime.php
LocalTime.withSecond
public function withSecond(int $second) : LocalTime { if ($second === $this->second) { return $this; } Field\SecondOfMinute::check($second); return new LocalTime($this->hour, $this->minute, $second, $this->nano); }
php
public function withSecond(int $second) : LocalTime { if ($second === $this->second) { return $this; } Field\SecondOfMinute::check($second); return new LocalTime($this->hour, $this->minute, $second, $this->nano); }
[ "public", "function", "withSecond", "(", "int", "$", "second", ")", ":", "LocalTime", "{", "if", "(", "$", "second", "===", "$", "this", "->", "second", ")", "{", "return", "$", "this", ";", "}", "Field", "\\", "SecondOfMinute", "::", "check", "(", "...
Returns a copy of this LocalTime with the second-of-minute value altered. @param int $second The new second-of-minute. @return LocalTime @throws DateTimeException If the second-of-minute if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "second", "-", "of", "-", "minute", "value", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L362-L371
train
brick/date-time
src/LocalTime.php
LocalTime.withNano
public function withNano(int $nano) : LocalTime { if ($nano === $this->nano) { return $this; } Field\NanoOfSecond::check($nano); return new LocalTime($this->hour, $this->minute, $this->second, $nano); }
php
public function withNano(int $nano) : LocalTime { if ($nano === $this->nano) { return $this; } Field\NanoOfSecond::check($nano); return new LocalTime($this->hour, $this->minute, $this->second, $nano); }
[ "public", "function", "withNano", "(", "int", "$", "nano", ")", ":", "LocalTime", "{", "if", "(", "$", "nano", "===", "$", "this", "->", "nano", ")", "{", "return", "$", "this", ";", "}", "Field", "\\", "NanoOfSecond", "::", "check", "(", "$", "nan...
Returns a copy of this LocalTime with the nano-of-second value altered. @param int $nano The new nano-of-second. @return LocalTime @throws DateTimeException If the nano-of-second if not valid.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "nano", "-", "of", "-", "second", "value", "altered", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L382-L391
train
brick/date-time
src/LocalTime.php
LocalTime.plusDuration
public function plusDuration(Duration $duration) : LocalTime { return $this ->plusSeconds($duration->getSeconds()) ->plusNanos($duration->getNanos()); }
php
public function plusDuration(Duration $duration) : LocalTime { return $this ->plusSeconds($duration->getSeconds()) ->plusNanos($duration->getNanos()); }
[ "public", "function", "plusDuration", "(", "Duration", "$", "duration", ")", ":", "LocalTime", "{", "return", "$", "this", "->", "plusSeconds", "(", "$", "duration", "->", "getSeconds", "(", ")", ")", "->", "plusNanos", "(", "$", "duration", "->", "getNano...
Returns a copy of this LocalTime with the specific duration added. The calculation wraps around midnight. @param Duration $duration @return LocalTime
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "specific", "duration", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L402-L407
train
brick/date-time
src/LocalTime.php
LocalTime.plusHours
public function plusHours(int $hours) : LocalTime { if ($hours === 0) { return $this; } $hour = (($hours % self::HOURS_PER_DAY) + $this->hour + self::HOURS_PER_DAY) % self::HOURS_PER_DAY; return new LocalTime($hour, $this->minute, $this->second, $this->nano); }
php
public function plusHours(int $hours) : LocalTime { if ($hours === 0) { return $this; } $hour = (($hours % self::HOURS_PER_DAY) + $this->hour + self::HOURS_PER_DAY) % self::HOURS_PER_DAY; return new LocalTime($hour, $this->minute, $this->second, $this->nano); }
[ "public", "function", "plusHours", "(", "int", "$", "hours", ")", ":", "LocalTime", "{", "if", "(", "$", "hours", "===", "0", ")", "{", "return", "$", "this", ";", "}", "$", "hour", "=", "(", "(", "$", "hours", "%", "self", "::", "HOURS_PER_DAY", ...
Returns a copy of this LocalTime with the specified period in hours added. This adds the specified number of hours to this time, returning a new time. The calculation wraps around midnight. This instance is immutable and unaffected by this method call. @param int $hours The hours to add, may be negative. @return LocalTime A LocalTime based on this time with the hours added.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "specified", "period", "in", "hours", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L421-L430
train
brick/date-time
src/LocalTime.php
LocalTime.plusMinutes
public function plusMinutes(int $minutes) : LocalTime { if ($minutes === 0) { return $this; } $mofd = $this->hour * self::MINUTES_PER_HOUR + $this->minute; $newMofd = (($minutes % self::MINUTES_PER_DAY) + $mofd + self::MINUTES_PER_DAY) % self::MINUTES_PER_DAY; if ($mofd === $newMofd) { return $this; } $hour = \intdiv($newMofd, self::MINUTES_PER_HOUR); $minute = $newMofd % self::MINUTES_PER_HOUR; return new LocalTime($hour, $minute, $this->second, $this->nano); }
php
public function plusMinutes(int $minutes) : LocalTime { if ($minutes === 0) { return $this; } $mofd = $this->hour * self::MINUTES_PER_HOUR + $this->minute; $newMofd = (($minutes % self::MINUTES_PER_DAY) + $mofd + self::MINUTES_PER_DAY) % self::MINUTES_PER_DAY; if ($mofd === $newMofd) { return $this; } $hour = \intdiv($newMofd, self::MINUTES_PER_HOUR); $minute = $newMofd % self::MINUTES_PER_HOUR; return new LocalTime($hour, $minute, $this->second, $this->nano); }
[ "public", "function", "plusMinutes", "(", "int", "$", "minutes", ")", ":", "LocalTime", "{", "if", "(", "$", "minutes", "===", "0", ")", "{", "return", "$", "this", ";", "}", "$", "mofd", "=", "$", "this", "->", "hour", "*", "self", "::", "MINUTES_...
Returns a copy of this LocalTime with the specified period in minutes added. This adds the specified number of minutes to this time, returning a new time. The calculation wraps around midnight. This instance is immutable and unaffected by this method call. @param int $minutes The minutes to add, may be negative. @return LocalTime A LocalTime based on this time with the minutes added.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "specified", "period", "in", "minutes", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L444-L461
train
brick/date-time
src/LocalTime.php
LocalTime.plusSeconds
public function plusSeconds(int $seconds) : LocalTime { if ($seconds === 0) { return $this; } $sofd = $this->hour * self::SECONDS_PER_HOUR + $this->minute * self::SECONDS_PER_MINUTE + $this->second; $newSofd = (($seconds % self::SECONDS_PER_DAY) + $sofd + self::SECONDS_PER_DAY) % self::SECONDS_PER_DAY; if ($sofd === $newSofd) { return $this; } $hour = \intdiv($newSofd, self::SECONDS_PER_HOUR); $minute = \intdiv($newSofd, self::SECONDS_PER_MINUTE) % self::MINUTES_PER_HOUR; $second = $newSofd % self::SECONDS_PER_MINUTE; return new LocalTime($hour, $minute, $second, $this->nano); }
php
public function plusSeconds(int $seconds) : LocalTime { if ($seconds === 0) { return $this; } $sofd = $this->hour * self::SECONDS_PER_HOUR + $this->minute * self::SECONDS_PER_MINUTE + $this->second; $newSofd = (($seconds % self::SECONDS_PER_DAY) + $sofd + self::SECONDS_PER_DAY) % self::SECONDS_PER_DAY; if ($sofd === $newSofd) { return $this; } $hour = \intdiv($newSofd, self::SECONDS_PER_HOUR); $minute = \intdiv($newSofd, self::SECONDS_PER_MINUTE) % self::MINUTES_PER_HOUR; $second = $newSofd % self::SECONDS_PER_MINUTE; return new LocalTime($hour, $minute, $second, $this->nano); }
[ "public", "function", "plusSeconds", "(", "int", "$", "seconds", ")", ":", "LocalTime", "{", "if", "(", "$", "seconds", "===", "0", ")", "{", "return", "$", "this", ";", "}", "$", "sofd", "=", "$", "this", "->", "hour", "*", "self", "::", "SECONDS_...
Returns a copy of this LocalTime with the specified period in seconds added. @param int $seconds The seconds to add, may be negative. @return LocalTime A LocalTime based on this time with the seconds added.
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "specified", "period", "in", "seconds", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L470-L488
train
brick/date-time
src/LocalTime.php
LocalTime.plusNanos
public function plusNanos(int $nanos) : LocalTime { if ($nanos === 0) { return $this; } $divBase = Math::floorDiv($this->nano, LocalTime::NANOS_PER_SECOND); $modBase = Math::floorMod($this->nano, LocalTime::NANOS_PER_SECOND); $divPlus = Math::floorDiv($nanos, LocalTime::NANOS_PER_SECOND); $modPlus = Math::floorMod($nanos, LocalTime::NANOS_PER_SECOND); $diffSeconds = $divBase + $divPlus; $nano = $modBase + $modPlus; if ($nano >= LocalTime::NANOS_PER_SECOND) { $nano -= LocalTime::NANOS_PER_SECOND; $diffSeconds++; } return $this->withNano($nano)->plusSeconds($diffSeconds); }
php
public function plusNanos(int $nanos) : LocalTime { if ($nanos === 0) { return $this; } $divBase = Math::floorDiv($this->nano, LocalTime::NANOS_PER_SECOND); $modBase = Math::floorMod($this->nano, LocalTime::NANOS_PER_SECOND); $divPlus = Math::floorDiv($nanos, LocalTime::NANOS_PER_SECOND); $modPlus = Math::floorMod($nanos, LocalTime::NANOS_PER_SECOND); $diffSeconds = $divBase + $divPlus; $nano = $modBase + $modPlus; if ($nano >= LocalTime::NANOS_PER_SECOND) { $nano -= LocalTime::NANOS_PER_SECOND; $diffSeconds++; } return $this->withNano($nano)->plusSeconds($diffSeconds); }
[ "public", "function", "plusNanos", "(", "int", "$", "nanos", ")", ":", "LocalTime", "{", "if", "(", "$", "nanos", "===", "0", ")", "{", "return", "$", "this", ";", "}", "$", "divBase", "=", "Math", "::", "floorDiv", "(", "$", "this", "->", "nano", ...
Returns a copy of this LocalTime with the specified period in nanoseconds added. @param int $nanos The seconds to add, may be negative. @return LocalTime A LocalTime based on this time with the nanoseconds added. @throws DateTimeException
[ "Returns", "a", "copy", "of", "this", "LocalTime", "with", "the", "specified", "period", "in", "nanoseconds", "added", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L499-L520
train
brick/date-time
src/LocalTime.php
LocalTime.compareTo
public function compareTo(LocalTime $that) : int { $seconds = $this->toSecondOfDay() - $that->toSecondOfDay(); if ($seconds !== 0) { return $seconds > 0 ? 1 : -1; } $nanos = $this->nano - $that->nano; if ($nanos !== 0) { return $nanos > 0 ? 1 : -1; } return 0; }
php
public function compareTo(LocalTime $that) : int { $seconds = $this->toSecondOfDay() - $that->toSecondOfDay(); if ($seconds !== 0) { return $seconds > 0 ? 1 : -1; } $nanos = $this->nano - $that->nano; if ($nanos !== 0) { return $nanos > 0 ? 1 : -1; } return 0; }
[ "public", "function", "compareTo", "(", "LocalTime", "$", "that", ")", ":", "int", "{", "$", "seconds", "=", "$", "this", "->", "toSecondOfDay", "(", ")", "-", "$", "that", "->", "toSecondOfDay", "(", ")", ";", "if", "(", "$", "seconds", "!==", "0", ...
Compares this LocalTime with another. @param LocalTime $that The time to compare to. @return int [-1,0,1] If this time is before, on, or after the given time.
[ "Compares", "this", "LocalTime", "with", "another", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalTime.php#L583-L598
train
brick/date-time
src/TimeZoneRegion.php
TimeZoneRegion.getAllIdentifiers
public static function getAllIdentifiers(bool $includeObsolete = false) : array { return \DateTimeZone::listIdentifiers( $includeObsolete ? \DateTimeZone::ALL_WITH_BC : \DateTimeZone::ALL ); }
php
public static function getAllIdentifiers(bool $includeObsolete = false) : array { return \DateTimeZone::listIdentifiers( $includeObsolete ? \DateTimeZone::ALL_WITH_BC : \DateTimeZone::ALL ); }
[ "public", "static", "function", "getAllIdentifiers", "(", "bool", "$", "includeObsolete", "=", "false", ")", ":", "array", "{", "return", "\\", "DateTimeZone", "::", "listIdentifiers", "(", "$", "includeObsolete", "?", "\\", "DateTimeZone", "::", "ALL_WITH_BC", ...
Returns all the available time-zone identifiers. @param bool $includeObsolete Whether to include obsolete time-zone identifiers. Defaults to false. @return string[] An array of time-zone identifiers.
[ "Returns", "all", "the", "available", "time", "-", "zone", "identifiers", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/TimeZoneRegion.php#L77-L84
train
brick/date-time
src/TimeZoneOffset.php
TimeZoneOffset.of
public static function of(int $hours, int $minutes = 0, int $seconds = 0) : TimeZoneOffset { Field\TimeZoneOffsetHour::check($hours); Field\TimeZoneOffsetMinute::check($minutes); Field\TimeZoneOffsetSecond::check($seconds); $err = ($hours > 0 && ($minutes < 0 || $seconds < 0)) || ($hours < 0 && ($minutes > 0 || $seconds > 0)) || ($minutes > 0 && $seconds < 0) || ($minutes < 0 && $seconds > 0); if ($err) { throw new DateTimeException('Time zone offset hours, minutes and seconds must have the same sign'); } $totalSeconds = $hours * LocalTime::SECONDS_PER_HOUR + $minutes * LocalTime::SECONDS_PER_MINUTE + $seconds; Field\TimeZoneOffsetTotalSeconds::check($totalSeconds); return new TimeZoneOffset($totalSeconds); }
php
public static function of(int $hours, int $minutes = 0, int $seconds = 0) : TimeZoneOffset { Field\TimeZoneOffsetHour::check($hours); Field\TimeZoneOffsetMinute::check($minutes); Field\TimeZoneOffsetSecond::check($seconds); $err = ($hours > 0 && ($minutes < 0 || $seconds < 0)) || ($hours < 0 && ($minutes > 0 || $seconds > 0)) || ($minutes > 0 && $seconds < 0) || ($minutes < 0 && $seconds > 0); if ($err) { throw new DateTimeException('Time zone offset hours, minutes and seconds must have the same sign'); } $totalSeconds = $hours * LocalTime::SECONDS_PER_HOUR + $minutes * LocalTime::SECONDS_PER_MINUTE + $seconds; Field\TimeZoneOffsetTotalSeconds::check($totalSeconds); return new TimeZoneOffset($totalSeconds); }
[ "public", "static", "function", "of", "(", "int", "$", "hours", ",", "int", "$", "minutes", "=", "0", ",", "int", "$", "seconds", "=", "0", ")", ":", "TimeZoneOffset", "{", "Field", "\\", "TimeZoneOffsetHour", "::", "check", "(", "$", "hours", ")", "...
Obtains an instance of `TimeZoneOffset` using an offset in hours, minutes and seconds. The total number of seconds must not exceed 64,800 seconds. @param int $hours The time-zone offset in hours. @param int $minutes The time-zone offset in minutes, from 0 to 59, sign matching hours. @param int $seconds The time-zone offset in seconds, from 0 to 59, sign matching hours and minute. @return TimeZoneOffset @throws DateTimeException If the values are not in range or the signs don't match.
[ "Obtains", "an", "instance", "of", "TimeZoneOffset", "using", "an", "offset", "in", "hours", "minutes", "and", "seconds", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/TimeZoneOffset.php#L54-L76
train
brick/date-time
src/TimeZoneOffset.php
TimeZoneOffset.ofTotalSeconds
public static function ofTotalSeconds(int $totalSeconds) : TimeZoneOffset { Field\TimeZoneOffsetTotalSeconds::check($totalSeconds); return new TimeZoneOffset($totalSeconds); }
php
public static function ofTotalSeconds(int $totalSeconds) : TimeZoneOffset { Field\TimeZoneOffsetTotalSeconds::check($totalSeconds); return new TimeZoneOffset($totalSeconds); }
[ "public", "static", "function", "ofTotalSeconds", "(", "int", "$", "totalSeconds", ")", ":", "TimeZoneOffset", "{", "Field", "\\", "TimeZoneOffsetTotalSeconds", "::", "check", "(", "$", "totalSeconds", ")", ";", "return", "new", "TimeZoneOffset", "(", "$", "tota...
Obtains an instance of `TimeZoneOffset` specifying the total offset in seconds. The offset must be in the range `-18:00` to `+18:00`, which corresponds to -64800 to +64800. @param int $totalSeconds The total offset in seconds. @return TimeZoneOffset @throws DateTimeException
[ "Obtains", "an", "instance", "of", "TimeZoneOffset", "specifying", "the", "total", "offset", "in", "seconds", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/TimeZoneOffset.php#L89-L94
train
brick/date-time
src/TimeZoneOffset.php
TimeZoneOffset.parse
public static function parse(string $text, DateTimeParser $parser = null) : TimeZone { if (! $parser) { $parser = IsoParsers::timeZoneOffset(); } return TimeZoneOffset::from($parser->parse($text)); }
php
public static function parse(string $text, DateTimeParser $parser = null) : TimeZone { if (! $parser) { $parser = IsoParsers::timeZoneOffset(); } return TimeZoneOffset::from($parser->parse($text)); }
[ "public", "static", "function", "parse", "(", "string", "$", "text", ",", "DateTimeParser", "$", "parser", "=", "null", ")", ":", "TimeZone", "{", "if", "(", "!", "$", "parser", ")", "{", "$", "parser", "=", "IsoParsers", "::", "timeZoneOffset", "(", "...
Parses a time-zone offset. The following ISO 8601 formats are accepted: * `Z` - for UTC * `±hh:mm` * `±hh:mm:ss` Note that ± means either the plus or minus symbol. @param string $text @param DateTimeParser|null $parser @return TimeZone @throws DateTimeParseException
[ "Parses", "a", "time", "-", "zone", "offset", "." ]
a1bbf608816baff12181b6c06f976ef00ca29c76
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/TimeZoneOffset.php#L155-L162
train
uecode/qpush-bundle
src/Provider/ProviderRegistry.php
ProviderRegistry.get
public function get($name) { if (!array_key_exists($name, $this->queues)) { throw new \InvalidArgumentException("The queue does not exist. {$name}"); } return $this->queues[$name]; }
php
public function get($name) { if (!array_key_exists($name, $this->queues)) { throw new \InvalidArgumentException("The queue does not exist. {$name}"); } return $this->queues[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "queues", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The queue does not exist. {$name}\"", ")...
Returns a Single QueueProvider by Queue Name @param string $name @throws \InvalidArgumentException @return ProviderInterface
[ "Returns", "a", "Single", "QueueProvider", "by", "Queue", "Name" ]
cf4540278f1344bf7fd3601789cb10da5d706602
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/Provider/ProviderRegistry.php#L86-L93
train
thephpleague/monga
src/League/Monga.php
Monga.data
public static function data($data, $type = null) { $type === null && $type = MongoBinData::BYTE_ARRAY; return new MongoBinData($data, $type); }
php
public static function data($data, $type = null) { $type === null && $type = MongoBinData::BYTE_ARRAY; return new MongoBinData($data, $type); }
[ "public", "static", "function", "data", "(", "$", "data", ",", "$", "type", "=", "null", ")", "{", "$", "type", "===", "null", "&&", "$", "type", "=", "MongoBinData", "::", "BYTE_ARRAY", ";", "return", "new", "MongoBinData", "(", "$", "data", ",", "$...
Returns a MongoBinData object @param string $data data @param int $type data type @return MongoBinData
[ "Returns", "a", "MongoBinData", "object" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga.php#L36-L41
train
thephpleague/monga
src/League/Monga.php
Monga.date
public static function date($sec = null, $usec = 0) { $sec === null && $sec = time(); return new MongoDate($sec, $usec); }
php
public static function date($sec = null, $usec = 0) { $sec === null && $sec = time(); return new MongoDate($sec, $usec); }
[ "public", "static", "function", "date", "(", "$", "sec", "=", "null", ",", "$", "usec", "=", "0", ")", "{", "$", "sec", "===", "null", "&&", "$", "sec", "=", "time", "(", ")", ";", "return", "new", "MongoDate", "(", "$", "sec", ",", "$", "usec"...
Create a MongoDate object @param int $sec timestamp @param int $usec @return MongoDate
[ "Create", "a", "MongoDate", "object" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga.php#L76-L81
train
thephpleague/monga
src/League/Monga/Cursor.php
Cursor.toRefArray
public function toRefArray() { // Retrieve the actual objects. $documents = $this->toArray(); // Get the collection idenfitier $collection = (string) $this->collection->getCollection(); foreach ($documents as &$document) { $document = MongoDBRef::create($collection, $document); } return $documents; }
php
public function toRefArray() { // Retrieve the actual objects. $documents = $this->toArray(); // Get the collection idenfitier $collection = (string) $this->collection->getCollection(); foreach ($documents as &$document) { $document = MongoDBRef::create($collection, $document); } return $documents; }
[ "public", "function", "toRefArray", "(", ")", "{", "// Retrieve the actual objects.", "$", "documents", "=", "$", "this", "->", "toArray", "(", ")", ";", "// Get the collection idenfitier", "$", "collection", "=", "(", "string", ")", "$", "this", "->", "collecti...
Return the result content as MongoDBREf objects. @return array array of mongo references
[ "Return", "the", "result", "content", "as", "MongoDBREf", "objects", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Cursor.php#L97-L110
train
thephpleague/monga
src/League/Monga/Query/Projection.php
Projection.alias
public function alias($field, $alias) { $this->fields[$alias] = $this->prepareField($field); return $this; }
php
public function alias($field, $alias) { $this->fields[$alias] = $this->prepareField($field); return $this; }
[ "public", "function", "alias", "(", "$", "field", ",", "$", "alias", ")", "{", "$", "this", "->", "fields", "[", "$", "alias", "]", "=", "$", "this", "->", "prepareField", "(", "$", "field", ")", ";", "return", "$", "this", ";", "}" ]
Sets an alias for a field. @param string $field The field's name @param string $alias The field's alias @return object $this
[ "Sets", "an", "alias", "for", "a", "field", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Projection.php#L53-L58
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.getOptions
public function getOptions() { $options = parent::getOptions(); $options['upsert'] = $this->upsert; $options['multiple'] = $this->multiple; return $options; }
php
public function getOptions() { $options = parent::getOptions(); $options['upsert'] = $this->upsert; $options['multiple'] = $this->multiple; return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "parent", "::", "getOptions", "(", ")", ";", "$", "options", "[", "'upsert'", "]", "=", "$", "this", "->", "upsert", ";", "$", "options", "[", "'multiple'", "]", "=", "$", "this"...
Returns the query options @return array query options
[ "Returns", "the", "query", "options" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L42-L50
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.update
protected function update($type, $field, $value) { $this->update[$field] = [$type, $value]; return $this; }
php
protected function update($type, $field, $value) { $this->update[$field] = [$type, $value]; return $this; }
[ "protected", "function", "update", "(", "$", "type", ",", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "[", "$", "field", "]", "=", "[", "$", "type", ",", "$", "value", "]", ";", "return", "$", "this", ";", "}" ]
Sets the value of the insert. @param string $type update modifier @param string $field field to update @param mixed $value update value
[ "Sets", "the", "value", "of", "the", "insert", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L115-L120
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.set
public function set($field, $value = null) { if (! is_array($field)) { $field = [$field => $value]; } foreach ($field as $f => $v) { $this->update('$set', $f, $v); } return $this; }
php
public function set($field, $value = null) { if (! is_array($field)) { $field = [$field => $value]; } foreach ($field as $f => $v) { $this->update('$set', $f, $v); } return $this; }
[ "public", "function", "set", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "field", ")", ")", "{", "$", "field", "=", "[", "$", "field", "=>", "$", "value", "]", ";", "}", "foreach", "(", "...
Update the field from a document. @param string $field field name @param string $value new value @return object $this
[ "Update", "the", "field", "from", "a", "document", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L130-L141
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.remove
public function remove($field) { if (! is_array($field)) { $field = func_get_args(); } foreach ($field as $f) { $this->update('$unset', $f, 1); } return $this; }
php
public function remove($field) { if (! is_array($field)) { $field = func_get_args(); } foreach ($field as $f) { $this->update('$unset', $f, 1); } return $this; }
[ "public", "function", "remove", "(", "$", "field", ")", "{", "if", "(", "!", "is_array", "(", "$", "field", ")", ")", "{", "$", "field", "=", "func_get_args", "(", ")", ";", "}", "foreach", "(", "$", "field", "as", "$", "f", ")", "{", "$", "thi...
Removes a field from a document. @param string $field field to remove @return object $this
[ "Removes", "a", "field", "from", "a", "document", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L150-L161
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.push
public function push($field, $value, $all = false) { return $this->update($all ? '$pushAll' : '$push', $field, $value); }
php
public function push($field, $value, $all = false) { return $this->update($all ? '$pushAll' : '$push', $field, $value); }
[ "public", "function", "push", "(", "$", "field", ",", "$", "value", ",", "$", "all", "=", "false", ")", "{", "return", "$", "this", "->", "update", "(", "$", "all", "?", "'$pushAll'", ":", "'$push'", ",", "$", "field", ",", "$", "value", ")", ";"...
Pushes a value onto a field array @param string $field field name @param mixed $value value to append to the array @param bool $all whether to remove all (must be array) @return object $this
[ "Pushes", "a", "value", "onto", "a", "field", "array" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L185-L188
train
thephpleague/monga
src/League/Monga/Query/Update.php
Update.getUpdate
public function getUpdate() { $update = []; foreach ($this->update as $field => $data) { list($type, $value) = $data; if (! isset($update[$type])) { $update[$type] = []; } $update[$type][$field] = $value; } if ($this->atomic) { $update['$atomic'] = 1; } return $update; }
php
public function getUpdate() { $update = []; foreach ($this->update as $field => $data) { list($type, $value) = $data; if (! isset($update[$type])) { $update[$type] = []; } $update[$type][$field] = $value; } if ($this->atomic) { $update['$atomic'] = 1; } return $update; }
[ "public", "function", "getUpdate", "(", ")", "{", "$", "update", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "update", "as", "$", "field", "=>", "$", "data", ")", "{", "list", "(", "$", "type", ",", "$", "value", ")", "=", "$", "data...
Returns the formatted update query. @return array update query
[ "Returns", "the", "formatted", "update", "query", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Update.php#L292-L311
train
thephpleague/monga
src/League/Monga/Connection.php
Connection.database
public function database($database, $wrap = true) { $database = $this->connection->{$database}; return $wrap ? new Database($database, $this) : $database; }
php
public function database($database, $wrap = true) { $database = $this->connection->{$database}; return $wrap ? new Database($database, $this) : $database; }
[ "public", "function", "database", "(", "$", "database", ",", "$", "wrap", "=", "true", ")", "{", "$", "database", "=", "$", "this", "->", "connection", "->", "{", "$", "database", "}", ";", "return", "$", "wrap", "?", "new", "Database", "(", "$", "...
Retrieve a database object from a connection @param string $database database name @param boolean $wrap whether to wrap in a Database object @return Database|MongoDB
[ "Retrieve", "a", "database", "object", "from", "a", "connection" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Connection.php#L147-L152
train
thephpleague/monga
src/League/Monga/Connection.php
Connection.listDatabases
public function listDatabases($detailed = false) { $result = $this->connection->listDBs(); if ($detailed) { return $result; } return array_map( function ($database) { return $database['name']; }, $result['databases'] ); }
php
public function listDatabases($detailed = false) { $result = $this->connection->listDBs(); if ($detailed) { return $result; } return array_map( function ($database) { return $database['name']; }, $result['databases'] ); }
[ "public", "function", "listDatabases", "(", "$", "detailed", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "connection", "->", "listDBs", "(", ")", ";", "if", "(", "$", "detailed", ")", "{", "return", "$", "result", ";", "}", "return...
Returns a list of databases. @param boolean $detailed return detailed information @return array array containing database name or info arrays
[ "Returns", "a", "list", "of", "databases", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Connection.php#L173-L187
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.count
public function count($query = []) { if ($query instanceof Closure) { $callback = $query; $query = new Query\Where(); $callback($query); } if ($query instanceof Query\Where) { $query = $query->getWhere(); } if (! is_array($query)) { throw new \InvalidArgumentException('The count query should be an array.'); } return $this->collection->count($query); }
php
public function count($query = []) { if ($query instanceof Closure) { $callback = $query; $query = new Query\Where(); $callback($query); } if ($query instanceof Query\Where) { $query = $query->getWhere(); } if (! is_array($query)) { throw new \InvalidArgumentException('The count query should be an array.'); } return $this->collection->count($query); }
[ "public", "function", "count", "(", "$", "query", "=", "[", "]", ")", "{", "if", "(", "$", "query", "instanceof", "Closure", ")", "{", "$", "callback", "=", "$", "query", ";", "$", "query", "=", "new", "Query", "\\", "Where", "(", ")", ";", "$", ...
Counts the given collection with an optional filter query @param array|closure $query count filter @return int number of documents
[ "Counts", "the", "given", "collection", "with", "an", "optional", "filter", "query" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L98-L115
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.distinct
public function distinct($key, $query = []) { if ($query instanceof Closure) { // Store the callback $callback = $query; // Create a new Where filter. $query = new Query\Where(); // trigger callback $callback($query); } if ($query instanceof Query\Where) { // Get the filter. $query = $query->getWhere(); } return $this->collection->distinct($key, $query); }
php
public function distinct($key, $query = []) { if ($query instanceof Closure) { // Store the callback $callback = $query; // Create a new Where filter. $query = new Query\Where(); // trigger callback $callback($query); } if ($query instanceof Query\Where) { // Get the filter. $query = $query->getWhere(); } return $this->collection->distinct($key, $query); }
[ "public", "function", "distinct", "(", "$", "key", ",", "$", "query", "=", "[", "]", ")", "{", "if", "(", "$", "query", "instanceof", "Closure", ")", "{", "// Store the callback", "$", "callback", "=", "$", "query", ";", "// Create a new Where filter.", "$...
Returns the distinct values for a given key. @param string $field field to use @param mixed $query match query @return array array of distinct values
[ "Returns", "the", "distinct", "values", "for", "a", "given", "key", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L125-L144
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.aggregate
public function aggregate($aggregation = []) { if ($aggregation instanceof Closure) { // Store the callback $callback = $aggregation; // Create a new pipeline $aggregation = new Query\Aggregation(); // Fire the callback $callback($aggregation); } if ($aggregation instanceof Query\Aggregation) { // Retrieve the pipeline $aggregation = $aggregation->getPipeline(); } // Execute the aggregation. return $this->collection->aggregate($aggregation); }
php
public function aggregate($aggregation = []) { if ($aggregation instanceof Closure) { // Store the callback $callback = $aggregation; // Create a new pipeline $aggregation = new Query\Aggregation(); // Fire the callback $callback($aggregation); } if ($aggregation instanceof Query\Aggregation) { // Retrieve the pipeline $aggregation = $aggregation->getPipeline(); } // Execute the aggregation. return $this->collection->aggregate($aggregation); }
[ "public", "function", "aggregate", "(", "$", "aggregation", "=", "[", "]", ")", "{", "if", "(", "$", "aggregation", "instanceof", "Closure", ")", "{", "// Store the callback", "$", "callback", "=", "$", "aggregation", ";", "// Create a new pipeline", "$", "agg...
Aggregate a collection @param mixed $aggregation aggregaction pipeline of callback Closure @return array aggregation result
[ "Aggregate", "a", "collection" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L153-L173
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.indexes
public function indexes(Closure $callback) { $indexes = new Query\Indexes($this->collection); $callback($indexes); return $this; }
php
public function indexes(Closure $callback) { $indexes = new Query\Indexes($this->collection); $callback($indexes); return $this; }
[ "public", "function", "indexes", "(", "Closure", "$", "callback", ")", "{", "$", "indexes", "=", "new", "Query", "\\", "Indexes", "(", "$", "this", "->", "collection", ")", ";", "$", "callback", "(", "$", "indexes", ")", ";", "return", "$", "this", "...
Manipulate collection indexes @param Closure $callback callback @return object $this
[ "Manipulate", "collection", "indexes" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L194-L200
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.remove
public function remove($criteria, $options = []) { if ($criteria instanceof Closure) { $callback = $criteria; // Create new Remove query $criteria = new Query\Remove(); // Set the given options $criteria->setOptions($options); // Execute the callback $callback($criteria); } if ($criteria instanceof Query\Remove) { // Retrieve the options, these might // have been altered in the closure. $options = $criteria->getOptions(); // Retrieve the where filter $criteria = $criteria->getWhere(); } if (! is_array($criteria)) { throw new \InvalidArgumentException('Remove criteria must be an array.'); } $maxRetries = $this->maxRetries; $tries = 0; do { try { $result = $this->collection->remove($criteria, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); return $result === true || (bool) $result['ok']; }
php
public function remove($criteria, $options = []) { if ($criteria instanceof Closure) { $callback = $criteria; // Create new Remove query $criteria = new Query\Remove(); // Set the given options $criteria->setOptions($options); // Execute the callback $callback($criteria); } if ($criteria instanceof Query\Remove) { // Retrieve the options, these might // have been altered in the closure. $options = $criteria->getOptions(); // Retrieve the where filter $criteria = $criteria->getWhere(); } if (! is_array($criteria)) { throw new \InvalidArgumentException('Remove criteria must be an array.'); } $maxRetries = $this->maxRetries; $tries = 0; do { try { $result = $this->collection->remove($criteria, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); return $result === true || (bool) $result['ok']; }
[ "public", "function", "remove", "(", "$", "criteria", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "criteria", "instanceof", "Closure", ")", "{", "$", "callback", "=", "$", "criteria", ";", "// Create new Remove query", "$", "criteria", ...
Removes documents from the current collection @param array|Closure $criteria remove filter @param array $options remove options @return mixed false on failure, number of deleted items on success
[ "Removes", "documents", "from", "the", "current", "collection" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L220-L273
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.find
public function find($query = [], $fields = [], $findOne = false) { $postFind = false; if ($query instanceof Closure) { $callback = $query; $query = new Query\Find(); // set the fields to select $query->fields($fields); $query->one($findOne); $callback($query); } if ($query instanceof Query\Find) { $findOne = $query->getFindOne(); $fields = $query->getFields(); $postFind = $query->getPostFindActions(); $query = $query->getWhere(); } if (! is_array($query) || ! is_array($fields)) { throw new \InvalidArgumentException('Find params $query and $fields must be arrays.'); } // Prepare the find arguments $arguments = []; $arguments[] = $query; $arguments[] = $fields; // Wrap the find function so it is callable $function = [ $this->getCollection(), ($findOne && ! $postFind) ? 'findOne' : 'find', ]; $result = call_user_func_array($function, $arguments); // Trigger any post find actions. if ($postFind) { foreach ($postFind as $arguments) { $method = array_shift($arguments); $result = call_user_func_array([$result, $method], $arguments); } } // When there were post-find actions, we used normal find // so we can sort, skip, and limit. Now we'll need to retrieve // the first result. if ($findOne && $postFind) { $result = $result->getNext(); } return $findOne ? $result : new Cursor($result, $this); }
php
public function find($query = [], $fields = [], $findOne = false) { $postFind = false; if ($query instanceof Closure) { $callback = $query; $query = new Query\Find(); // set the fields to select $query->fields($fields); $query->one($findOne); $callback($query); } if ($query instanceof Query\Find) { $findOne = $query->getFindOne(); $fields = $query->getFields(); $postFind = $query->getPostFindActions(); $query = $query->getWhere(); } if (! is_array($query) || ! is_array($fields)) { throw new \InvalidArgumentException('Find params $query and $fields must be arrays.'); } // Prepare the find arguments $arguments = []; $arguments[] = $query; $arguments[] = $fields; // Wrap the find function so it is callable $function = [ $this->getCollection(), ($findOne && ! $postFind) ? 'findOne' : 'find', ]; $result = call_user_func_array($function, $arguments); // Trigger any post find actions. if ($postFind) { foreach ($postFind as $arguments) { $method = array_shift($arguments); $result = call_user_func_array([$result, $method], $arguments); } } // When there were post-find actions, we used normal find // so we can sort, skip, and limit. Now we'll need to retrieve // the first result. if ($findOne && $postFind) { $result = $result->getNext(); } return $findOne ? $result : new Cursor($result, $this); }
[ "public", "function", "find", "(", "$", "query", "=", "[", "]", ",", "$", "fields", "=", "[", "]", ",", "$", "findOne", "=", "false", ")", "{", "$", "postFind", "=", "false", ";", "if", "(", "$", "query", "instanceof", "Closure", ")", "{", "$", ...
Finds documents. @param mixed $query find query, configuration closure, raw mongo conditions array @param array $fields associative array for field exclusion/inclusion @param boolean $findOne whether to find one or multiple @return mixed result Cursor for multiple, document array for one.
[ "Finds", "documents", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L284-L340
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.insert
public function insert(array $data, $options = []) { $maxRetries = $this->maxRetries; $tries = 0; // Check whether we're dealing with a batch insert. if (isset($data[0]) && is_array($data[0])) { // Insert using batchInsert do { try { $result = $this->collection->batchInsert($data, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); if (! $result || ! ($result === true || (bool) $result['ok'])) { return false; } $result = []; foreach ($data as $r) { // Collect all the id's for the return value $result[] = $r['_id']; } // Return all inserted id's. return $result; } do { try { $result = $this->collection->insert($data, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); if ($result === true || (bool) $result['ok']) { return $data['_id']; } return false; }
php
public function insert(array $data, $options = []) { $maxRetries = $this->maxRetries; $tries = 0; // Check whether we're dealing with a batch insert. if (isset($data[0]) && is_array($data[0])) { // Insert using batchInsert do { try { $result = $this->collection->batchInsert($data, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); if (! $result || ! ($result === true || (bool) $result['ok'])) { return false; } $result = []; foreach ($data as $r) { // Collect all the id's for the return value $result[] = $r['_id']; } // Return all inserted id's. return $result; } do { try { $result = $this->collection->insert($data, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); if ($result === true || (bool) $result['ok']) { return $data['_id']; } return false; }
[ "public", "function", "insert", "(", "array", "$", "data", ",", "$", "options", "=", "[", "]", ")", "{", "$", "maxRetries", "=", "$", "this", "->", "maxRetries", ";", "$", "tries", "=", "0", ";", "// Check whether we're dealing with a batch insert.", "if", ...
Inserts one or multiple documents. @param array $data documents or array of documents @param array $options insert options @return boolean success boolean
[ "Inserts", "one", "or", "multiple", "documents", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L363-L433
train
thephpleague/monga
src/League/Monga/Collection.php
Collection.save
public function save(&$document, $options = []) { $maxRetries = $this->maxRetries; $tries = 0; do { try { $result = $this->collection->save($document, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); return $result === true || (bool) $result['ok']; }
php
public function save(&$document, $options = []) { $maxRetries = $this->maxRetries; $tries = 0; do { try { $result = $this->collection->save($document, $options); break; } catch (MongoCursorException $e) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if (in_array($e->getCode(), [10107, 13435, 10058])) { if ($tries === $maxRetries) { throw $e; } else { $tries++; continue; } } else { throw $e; } } } while ($tries <= $maxRetries); return $result === true || (bool) $result['ok']; }
[ "public", "function", "save", "(", "&", "$", "document", ",", "$", "options", "=", "[", "]", ")", "{", "$", "maxRetries", "=", "$", "this", "->", "maxRetries", ";", "$", "tries", "=", "0", ";", "do", "{", "try", "{", "$", "result", "=", "$", "t...
Saves a documents. @param array $document document @param array $options save options @return boolean success boolean
[ "Saves", "a", "documents", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Collection.php#L501-L528
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.setWhere
public function setWhere(array $where) { // When the statement is empty set the // where property to null to prevent // empty statement errors. if (empty($where)) { // delete the current where statement $this->where = null; // Skip further execution return $this; } // Ensure the base $or clause if (! isset($where['$or'])) { // wrap the statement in an $or clause $where = ['$or' => [$where]]; } // Fetch the last clause in the $or array // to allow further chaining it's required // to be wrapped in an @and statement. $lastClause = array_pop($where['$or']); if (! isset($lastClause['$and'])) { // Wrap in an @and statement $lastClause = ['$and' => [$lastClause]]; } // Re-append the $and clause $where['$or'][] = $lastClause; // Replace the base where statement $this->where = $where; return $this; }
php
public function setWhere(array $where) { // When the statement is empty set the // where property to null to prevent // empty statement errors. if (empty($where)) { // delete the current where statement $this->where = null; // Skip further execution return $this; } // Ensure the base $or clause if (! isset($where['$or'])) { // wrap the statement in an $or clause $where = ['$or' => [$where]]; } // Fetch the last clause in the $or array // to allow further chaining it's required // to be wrapped in an @and statement. $lastClause = array_pop($where['$or']); if (! isset($lastClause['$and'])) { // Wrap in an @and statement $lastClause = ['$and' => [$lastClause]]; } // Re-append the $and clause $where['$or'][] = $lastClause; // Replace the base where statement $this->where = $where; return $this; }
[ "public", "function", "setWhere", "(", "array", "$", "where", ")", "{", "// When the statement is empty set the", "// where property to null to prevent", "// empty statement errors.", "if", "(", "empty", "(", "$", "where", ")", ")", "{", "// delete the current where stateme...
Replaces the where statement. The statement will be reformatted to match, allowing further chaining by Monga. @param array $where An array of where conditions @return object $this
[ "Replaces", "the", "where", "statement", ".", "The", "statement", "will", "be", "reformatted", "to", "match", "allowing", "further", "chaining", "by", "Monga", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L35-L71
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.formatWhere
protected function formatWhere($type, $field, $statement = null) { if (is_array($field)) { foreach ($field as $_field => $_statement) { $this->formatWhere($type, $_field, $_statement); } return $this; } $isNested = false; // Closures represent nested where clauses. if ($field instanceof Closure) { // Create a new query. $nested = new static(); // Fire the contents of the closure // on the newly created object $field($nested); // Compile the query $statement = $nested->getWhere(); if (empty($statement)) { return $this; } // set the $field to $type so we can detect it later on $field = $type; // set the query as nested $isNested = true; } // Ensure the master $or clause $this->where || $this->where = ['$or' => []]; // Because $or is the base for every query // $or queries can always be appended to the // main stack. if ($type === '$or') { if ($isNested) { $this->where['$or'][] = ['$and' => [$statement]]; } else { $this->where['$or'][] = ['$and' => [[$field => $statement]]]; } return $this; } // Retrieve the last $or clause or create a new one // when none available. $lastOrClause = array_pop($this->where['$or']) ?: ['$and' => []]; // Retrieve the last $and clause from the $or clause // or create a new one when none available. $lastAndClause = array_pop($lastOrClause['$and']) ?: []; // Handle the result from nested where statements if ($isNested) { // Re-append the last $and clause empty($lastAndClause) || $lastOrClause['$and'][] = $lastAndClause; // The nested query has a base key (either $and or $or) // So following queries will always begin in a new clause $lastAndClause = $statement; } else { if (! isset($lastAndClause['$and'])) { if (! isset($lastAndClause[$field])) { $lastAndClause[$field] = $statement; } elseif ($field === '$nor') { $lastAndClause['$nor'] = array_merge($lastAndClause['$nor'], $statement); } else { $lastAndClause = [ '$and' => [ $lastAndClause, [$field => $statement], ], ]; } } else { $lastSubAnd = array_pop($lastAndClause['$and']) ?: []; if (isset($lastSubAnd['$and']) || isset($lastSubAnd['$or']) || isset($lastSubAnd[$field])) { empty($lastSubAnd) || $lastAndClause['$and'][] = $lastSubAnd; $lastSubAnd = []; } $lastSubAnd[$field] = $statement; $lastAndClause['$and'][] = $lastSubAnd; } } // Re-append the last $and clause $lastOrClause['$and'][] = $lastAndClause; // Re-append the last $or clause $this->where['$or'][] = $lastOrClause; return $this; }
php
protected function formatWhere($type, $field, $statement = null) { if (is_array($field)) { foreach ($field as $_field => $_statement) { $this->formatWhere($type, $_field, $_statement); } return $this; } $isNested = false; // Closures represent nested where clauses. if ($field instanceof Closure) { // Create a new query. $nested = new static(); // Fire the contents of the closure // on the newly created object $field($nested); // Compile the query $statement = $nested->getWhere(); if (empty($statement)) { return $this; } // set the $field to $type so we can detect it later on $field = $type; // set the query as nested $isNested = true; } // Ensure the master $or clause $this->where || $this->where = ['$or' => []]; // Because $or is the base for every query // $or queries can always be appended to the // main stack. if ($type === '$or') { if ($isNested) { $this->where['$or'][] = ['$and' => [$statement]]; } else { $this->where['$or'][] = ['$and' => [[$field => $statement]]]; } return $this; } // Retrieve the last $or clause or create a new one // when none available. $lastOrClause = array_pop($this->where['$or']) ?: ['$and' => []]; // Retrieve the last $and clause from the $or clause // or create a new one when none available. $lastAndClause = array_pop($lastOrClause['$and']) ?: []; // Handle the result from nested where statements if ($isNested) { // Re-append the last $and clause empty($lastAndClause) || $lastOrClause['$and'][] = $lastAndClause; // The nested query has a base key (either $and or $or) // So following queries will always begin in a new clause $lastAndClause = $statement; } else { if (! isset($lastAndClause['$and'])) { if (! isset($lastAndClause[$field])) { $lastAndClause[$field] = $statement; } elseif ($field === '$nor') { $lastAndClause['$nor'] = array_merge($lastAndClause['$nor'], $statement); } else { $lastAndClause = [ '$and' => [ $lastAndClause, [$field => $statement], ], ]; } } else { $lastSubAnd = array_pop($lastAndClause['$and']) ?: []; if (isset($lastSubAnd['$and']) || isset($lastSubAnd['$or']) || isset($lastSubAnd[$field])) { empty($lastSubAnd) || $lastAndClause['$and'][] = $lastSubAnd; $lastSubAnd = []; } $lastSubAnd[$field] = $statement; $lastAndClause['$and'][] = $lastSubAnd; } } // Re-append the last $and clause $lastOrClause['$and'][] = $lastAndClause; // Re-append the last $or clause $this->where['$or'][] = $lastOrClause; return $this; }
[ "protected", "function", "formatWhere", "(", "$", "type", ",", "$", "field", ",", "$", "statement", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", ")", "{", "foreach", "(", "$", "field", "as", "$", "_field", "=>", "$", "_stat...
Internal where statement formatter @param string $type chain type @param string $field fieldname @param mixed $statement filter statement @return object $this
[ "Internal", "where", "statement", "formatter" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L82-L184
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.orWhere
public function orWhere($field, $value = null) { if ($field instanceof Closure) { return $this->formatWhere('$or', $field); } return $this->formatWhere('$or', $field, $value); }
php
public function orWhere($field, $value = null) { if ($field instanceof Closure) { return $this->formatWhere('$or', $field); } return $this->formatWhere('$or', $field, $value); }
[ "public", "function", "orWhere", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "field", "instanceof", "Closure", ")", "{", "return", "$", "this", "->", "formatWhere", "(", "'$or'", ",", "$", "field", ")", ";", "}", "r...
Appends a or-where statement. @param mixed $field field name or nested query closure @param mixed $value filter value @return object $this
[ "Appends", "a", "or", "-", "where", "statement", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L220-L227
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.orWhereLike
public function orWhereLike($field, $value, $flags = 'imxsu', $delimiter = null) { return $this->whereLike($field, $value, $flags, $delimiter, '$or'); }
php
public function orWhereLike($field, $value, $flags = 'imxsu', $delimiter = null) { return $this->whereLike($field, $value, $flags, $delimiter, '$or'); }
[ "public", "function", "orWhereLike", "(", "$", "field", ",", "$", "value", ",", "$", "flags", "=", "'imxsu'", ",", "$", "delimiter", "=", "null", ")", "{", "return", "$", "this", "->", "whereLike", "(", "$", "field", ",", "$", "value", ",", "$", "f...
Appends a or-where-regex statement defined in sql syntax. @param string $field field name @param mixed $value filter value @param string $flags regex flags @param string $delimiter preg_quote delimiter @return object $this
[ "Appends", "a", "or", "-", "where", "-", "regex", "statement", "defined", "in", "sql", "syntax", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L308-L311
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.whereRegex
public function whereRegex($field, $value) { if (! $value instanceof MongoRegex) { $value = new MongoRegex($value); } return $this->formatWhere('$and', $field, $value); }
php
public function whereRegex($field, $value) { if (! $value instanceof MongoRegex) { $value = new MongoRegex($value); } return $this->formatWhere('$and', $field, $value); }
[ "public", "function", "whereRegex", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "MongoRegex", ")", "{", "$", "value", "=", "new", "MongoRegex", "(", "$", "value", ")", ";", "}", "return", "$", "this", ...
Appends an and-where-regex statement @param string $field field name @param mixed $value filter value @return object $this
[ "Appends", "an", "and", "-", "where", "-", "regex", "statement" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L336-L343
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.orWhereRegex
public function orWhereRegex($field, $value) { if (! $value instanceof MongoRegex) { $value = new MongoRegex($value); } return $this->formatWhere('$or', $field, $value); }
php
public function orWhereRegex($field, $value) { if (! $value instanceof MongoRegex) { $value = new MongoRegex($value); } return $this->formatWhere('$or', $field, $value); }
[ "public", "function", "orWhereRegex", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "MongoRegex", ")", "{", "$", "value", "=", "new", "MongoRegex", "(", "$", "value", ")", ";", "}", "return", "$", "this",...
Appends a or-where-regex statement @param string $field field name @param mixed $value filter value @return object $this
[ "Appends", "a", "or", "-", "where", "-", "regex", "statement" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L366-L373
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.whereId
public function whereId($value, $field = '_id') { if (! $value instanceof MongoId) { $value = new MongoId($value); } return $this->formatWhere('$and', $field, $value); }
php
public function whereId($value, $field = '_id') { if (! $value instanceof MongoId) { $value = new MongoId($value); } return $this->formatWhere('$and', $field, $value); }
[ "public", "function", "whereId", "(", "$", "value", ",", "$", "field", "=", "'_id'", ")", "{", "if", "(", "!", "$", "value", "instanceof", "MongoId", ")", "{", "$", "value", "=", "new", "MongoId", "(", "$", "value", ")", ";", "}", "return", "$", ...
Appends a and-where-id statement @param string $value id @param integer $field _id field @return object $this
[ "Appends", "a", "and", "-", "where", "-", "id", "statement" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L848-L855
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.orWhereId
public function orWhereId($value, $field = '_id') { if (! $value instanceof MongoId) { $value = new MongoId($value); } return $this->formatWhere('$or', $field, $value); }
php
public function orWhereId($value, $field = '_id') { if (! $value instanceof MongoId) { $value = new MongoId($value); } return $this->formatWhere('$or', $field, $value); }
[ "public", "function", "orWhereId", "(", "$", "value", ",", "$", "field", "=", "'_id'", ")", "{", "if", "(", "!", "$", "value", "instanceof", "MongoId", ")", "{", "$", "value", "=", "new", "MongoId", "(", "$", "value", ")", ";", "}", "return", "$", ...
Appends a or-where-id statement @param string $value id @param string $field _id field @return object $this
[ "Appends", "a", "or", "-", "where", "-", "id", "statement" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L878-L885
train