id
int32
0
241k
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
38,600
addwiki/mediawiki-api-base
src/MediawikiSession.php
MediawikiSession.clearTokens
public function clearTokens() { $this->logger->log( LogLevel::DEBUG, 'Clearing session tokens', [ 'tokens' => $this->tokens ] ); $this->tokens = []; }
php
public function clearTokens() { $this->logger->log( LogLevel::DEBUG, 'Clearing session tokens', [ 'tokens' => $this->tokens ] ); $this->tokens = []; }
[ "public", "function", "clearTokens", "(", ")", "{", "$", "this", "->", "logger", "->", "log", "(", "LogLevel", "::", "DEBUG", ",", "'Clearing session tokens'", ",", "[", "'tokens'", "=>", "$", "this", "->", "tokens", "]", ")", ";", "$", "this", "->", "...
Clears all tokens stored by the api @since 0.2
[ "Clears", "all", "tokens", "stored", "by", "the", "api" ]
48202fcce7490c15bb6932aaa8b39c7795febbbe
https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/MediawikiSession.php#L163-L166
38,601
addwiki/mediawiki-api-base
src/Guzzle/MiddlewareFactory.php
MiddlewareFactory.getRetryDelay
private function getRetryDelay() { return function ( $numberOfRetries, Response $response = null ) { // The $response argument is only passed as of Guzzle 6.2.2. if ( $response !== null ) { // Retry-After may be a number of seconds or an absolute date (RFC 7231, // section 7.1.3). $retryAfter = $response->getHeaderLine( 'Retry-After' ); if ( is_numeric( $retryAfter ) ) { return 1000 * $retryAfter; } if ( $retryAfter ) { $seconds = strtotime( $retryAfter ) - time(); return 1000 * max( 1, $seconds ); } } return 1000 * $numberOfRetries; }; }
php
private function getRetryDelay() { return function ( $numberOfRetries, Response $response = null ) { // The $response argument is only passed as of Guzzle 6.2.2. if ( $response !== null ) { // Retry-After may be a number of seconds or an absolute date (RFC 7231, // section 7.1.3). $retryAfter = $response->getHeaderLine( 'Retry-After' ); if ( is_numeric( $retryAfter ) ) { return 1000 * $retryAfter; } if ( $retryAfter ) { $seconds = strtotime( $retryAfter ) - time(); return 1000 * max( 1, $seconds ); } } return 1000 * $numberOfRetries; }; }
[ "private", "function", "getRetryDelay", "(", ")", "{", "return", "function", "(", "$", "numberOfRetries", ",", "Response", "$", "response", "=", "null", ")", "{", "// The $response argument is only passed as of Guzzle 6.2.2.", "if", "(", "$", "response", "!==", "nul...
Returns a method that takes the number of retries and returns the number of miliseconds to wait @return callable
[ "Returns", "a", "method", "that", "takes", "the", "number", "of", "retries", "and", "returns", "the", "number", "of", "miliseconds", "to", "wait" ]
48202fcce7490c15bb6932aaa8b39c7795febbbe
https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/Guzzle/MiddlewareFactory.php#L58-L78
38,602
timegridio/concierge
src/Models/Contact.php
Contact.getAppointmentsCountAttribute
public function getAppointmentsCountAttribute() { // If relation is not loaded already, let's do it first if (!array_key_exists('appointmentsCount', $this->relations)) { $this->load('appointmentsCount'); } $related = $this->getRelation('appointmentsCount'); // Return the count directly return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; }
php
public function getAppointmentsCountAttribute() { // If relation is not loaded already, let's do it first if (!array_key_exists('appointmentsCount', $this->relations)) { $this->load('appointmentsCount'); } $related = $this->getRelation('appointmentsCount'); // Return the count directly return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; }
[ "public", "function", "getAppointmentsCountAttribute", "(", ")", "{", "// If relation is not loaded already, let's do it first", "if", "(", "!", "array_key_exists", "(", "'appointmentsCount'", ",", "$", "this", "->", "relations", ")", ")", "{", "$", "this", "->", "loa...
get AppointmentsCount. @return int Count of Appointments held by this Contact
[ "get", "AppointmentsCount", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Contact.php#L124-L135
38,603
timegridio/concierge
src/Models/Contact.php
Contact.setBirthdateAttribute
public function setBirthdateAttribute(Carbon $birthdate = null) { if ($birthdate === null) { return $this->attributes['birthdate'] = null; } return $this->attributes['birthdate'] = $birthdate; }
php
public function setBirthdateAttribute(Carbon $birthdate = null) { if ($birthdate === null) { return $this->attributes['birthdate'] = null; } return $this->attributes['birthdate'] = $birthdate; }
[ "public", "function", "setBirthdateAttribute", "(", "Carbon", "$", "birthdate", "=", "null", ")", "{", "if", "(", "$", "birthdate", "===", "null", ")", "{", "return", "$", "this", "->", "attributes", "[", "'birthdate'", "]", "=", "null", ";", "}", "retur...
set Birthdate. @param Carbon $birthdate Carbon parseable birth date
[ "set", "Birthdate", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Contact.php#L182-L189
38,604
timegridio/concierge
src/Concierge.php
Concierge.isBookable
public function isBookable($fromDate = 'now', $days = 7) { $fromDate = Carbon::parse($fromDate)->timezone($this->business->timezone); $count = $this->business ->vacancies() ->future($fromDate) ->until($fromDate->addDays($days)) ->count(); return $count > 0; }
php
public function isBookable($fromDate = 'now', $days = 7) { $fromDate = Carbon::parse($fromDate)->timezone($this->business->timezone); $count = $this->business ->vacancies() ->future($fromDate) ->until($fromDate->addDays($days)) ->count(); return $count > 0; }
[ "public", "function", "isBookable", "(", "$", "fromDate", "=", "'now'", ",", "$", "days", "=", "7", ")", "{", "$", "fromDate", "=", "Carbon", "::", "parse", "(", "$", "fromDate", ")", "->", "timezone", "(", "$", "this", "->", "business", "->", "timez...
Determine if the Business has any published Vacancies available for booking. @param string $fromDate @param int $days @return bool
[ "Determine", "if", "the", "Business", "has", "any", "published", "Vacancies", "available", "for", "booking", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Concierge.php#L159-L170
38,605
timegridio/concierge
src/Traits/Preferenceable.php
Preferenceable.pref
public function pref($key, $value = null, $type = 'string') { if (isset($value)) { $this->preferences()->updateOrCreate(['key' => $key], ['value' => $this->cast($value, $type), 'type' => $type, ]); Cache::put("{$this->slug}.'/'.{$key}", $value, 60); return $value; } if($value = Cache::get("{$this->slug}.'/'.{$key}")) { return $value; } if ($pref = $this->preferences()->forKey($key)->first()) { $value = $pref->value(); $type = $pref->type(); } else { $default = Preference::getDefault($this, $key); $value = $default->value(); $type = $default->type(); } Cache::put("{$this->slug}.'/'.{$key}", $value, 60); return $this->cast($value, $type); }
php
public function pref($key, $value = null, $type = 'string') { if (isset($value)) { $this->preferences()->updateOrCreate(['key' => $key], ['value' => $this->cast($value, $type), 'type' => $type, ]); Cache::put("{$this->slug}.'/'.{$key}", $value, 60); return $value; } if($value = Cache::get("{$this->slug}.'/'.{$key}")) { return $value; } if ($pref = $this->preferences()->forKey($key)->first()) { $value = $pref->value(); $type = $pref->type(); } else { $default = Preference::getDefault($this, $key); $value = $default->value(); $type = $default->type(); } Cache::put("{$this->slug}.'/'.{$key}", $value, 60); return $this->cast($value, $type); }
[ "public", "function", "pref", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "type", "=", "'string'", ")", "{", "if", "(", "isset", "(", "$", "value", ")", ")", "{", "$", "this", "->", "preferences", "(", ")", "->", "updateOrCreate", ...
Get or set preference value. @param mixed $key @param mixed $value @param string $type @return mixed Value.
[ "Get", "or", "set", "preference", "value", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Traits/Preferenceable.php#L29-L55
38,606
timegridio/concierge
src/Traits/Preferenceable.php
Preferenceable.cast
private function cast($value, $type) { switch ($type) { case 'bool': return boolval($value); break; case 'int': return intval($value); break; case 'float': return floatval($value); break; case 'string': return $value; break; case 'array': if (is_array($value)) { return serialize($value); } else { return unserialize($value); } break; default: return $value; } }
php
private function cast($value, $type) { switch ($type) { case 'bool': return boolval($value); break; case 'int': return intval($value); break; case 'float': return floatval($value); break; case 'string': return $value; break; case 'array': if (is_array($value)) { return serialize($value); } else { return unserialize($value); } break; default: return $value; } }
[ "private", "function", "cast", "(", "$", "value", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'bool'", ":", "return", "boolval", "(", "$", "value", ")", ";", "break", ";", "case", "'int'", ":", "return", "intval", "("...
Cast value. @param mixed $value @param mixed $type @return mixed Value.
[ "Cast", "value", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Traits/Preferenceable.php#L65-L90
38,607
timegridio/concierge
src/Vacancy/VacancyManager.php
VacancyManager.updateBatch
public function updateBatch(Business $business, $parsedStatements) { $changed = false; $dates = $this->arrayGroupBy('date', $parsedStatements); foreach ($dates as $date => $statements) { $services = $this->arrayGroupBy('service', $statements); $changed |= $this->processServiceStatements($business, $date, $services); } return $changed; }
php
public function updateBatch(Business $business, $parsedStatements) { $changed = false; $dates = $this->arrayGroupBy('date', $parsedStatements); foreach ($dates as $date => $statements) { $services = $this->arrayGroupBy('service', $statements); $changed |= $this->processServiceStatements($business, $date, $services); } return $changed; }
[ "public", "function", "updateBatch", "(", "Business", "$", "business", ",", "$", "parsedStatements", ")", "{", "$", "changed", "=", "false", ";", "$", "dates", "=", "$", "this", "->", "arrayGroupBy", "(", "'date'", ",", "$", "parsedStatements", ")", ";", ...
Update vacancies from batch statements. @param Business $business @param array $parsedStatements @return bool
[ "Update", "vacancies", "from", "batch", "statements", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Vacancy/VacancyManager.php#L37-L49
38,608
timegridio/concierge
src/Presenters/BusinessPresenter.php
BusinessPresenter.facebookImg
public function facebookImg($type = 'square') { $url = parse_url($this->wrappedObject->social_facebook); if(!$this->wrappedObject->social_facebook || !array_key_exists('path', $url)){ return "<img class=\"img-thumbnail\" src=\"//placehold.it/100x100\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; } $userId = trim($url['path'], '/'); if ($url['path'] == '/profile.php') { parse_str($url['query'], $parts); $userId = $parts['id']; } $url = "http://graph.facebook.com/{$userId}/picture?type=$type"; return "<img class=\"img-thumbnail media-object\" src=\"$url\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; }
php
public function facebookImg($type = 'square') { $url = parse_url($this->wrappedObject->social_facebook); if(!$this->wrappedObject->social_facebook || !array_key_exists('path', $url)){ return "<img class=\"img-thumbnail\" src=\"//placehold.it/100x100\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; } $userId = trim($url['path'], '/'); if ($url['path'] == '/profile.php') { parse_str($url['query'], $parts); $userId = $parts['id']; } $url = "http://graph.facebook.com/{$userId}/picture?type=$type"; return "<img class=\"img-thumbnail media-object\" src=\"$url\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; }
[ "public", "function", "facebookImg", "(", "$", "type", "=", "'square'", ")", "{", "$", "url", "=", "parse_url", "(", "$", "this", "->", "wrappedObject", "->", "social_facebook", ")", ";", "if", "(", "!", "$", "this", "->", "wrappedObject", "->", "social_...
get Facebook Profile Public Picture. @param string $type Type of picture to print @return string HTML code to render img with facebook picture
[ "get", "Facebook", "Profile", "Public", "Picture", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Presenters/BusinessPresenter.php#L22-L40
38,609
timegridio/concierge
src/Presenters/BusinessPresenter.php
BusinessPresenter.staticMap
public function staticMap($zoom = 15) { $data = [ 'center' => $this->wrappedObject->postal_address, 'zoom' => intval($zoom), 'scale' => '2', 'size' => '180x100', 'maptype' => 'roadmap', 'format' => 'gif', 'visual_refresh' => 'true', ]; $src = 'http://maps.googleapis.com/maps/api/staticmap?'.http_build_query($data, '', '&amp;'); return "<img class=\"img-responsive img-thumbnail center-block\" width=\"180\" height=\"100\" src=\"$src\"/>"; }
php
public function staticMap($zoom = 15) { $data = [ 'center' => $this->wrappedObject->postal_address, 'zoom' => intval($zoom), 'scale' => '2', 'size' => '180x100', 'maptype' => 'roadmap', 'format' => 'gif', 'visual_refresh' => 'true', ]; $src = 'http://maps.googleapis.com/maps/api/staticmap?'.http_build_query($data, '', '&amp;'); return "<img class=\"img-responsive img-thumbnail center-block\" width=\"180\" height=\"100\" src=\"$src\"/>"; }
[ "public", "function", "staticMap", "(", "$", "zoom", "=", "15", ")", "{", "$", "data", "=", "[", "'center'", "=>", "$", "this", "->", "wrappedObject", "->", "postal_address", ",", "'zoom'", "=>", "intval", "(", "$", "zoom", ")", ",", "'scale'", "=>", ...
get Google Static Map img. @param int $zoom Zoom Level @return string HTML code to render img with map
[ "get", "Google", "Static", "Map", "img", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Presenters/BusinessPresenter.php#L49-L63
38,610
timegridio/concierge
src/Models/Appointment.php
Appointment.getStatusLabelAttribute
public function getStatusLabelAttribute() { $labels = [ Self::STATUS_RESERVED => 'reserved', Self::STATUS_CONFIRMED => 'confirmed', Self::STATUS_CANCELED => 'canceled', Self::STATUS_SERVED => 'served', ]; return array_key_exists($this->status, $labels) ? $labels[$this->status] : ''; }
php
public function getStatusLabelAttribute() { $labels = [ Self::STATUS_RESERVED => 'reserved', Self::STATUS_CONFIRMED => 'confirmed', Self::STATUS_CANCELED => 'canceled', Self::STATUS_SERVED => 'served', ]; return array_key_exists($this->status, $labels) ? $labels[$this->status] : ''; }
[ "public", "function", "getStatusLabelAttribute", "(", ")", "{", "$", "labels", "=", "[", "Self", "::", "STATUS_RESERVED", "=>", "'reserved'", ",", "Self", "::", "STATUS_CONFIRMED", "=>", "'confirmed'", ",", "Self", "::", "STATUS_CANCELED", "=>", "'canceled'", ",...
Get the human readable status name. @return string
[ "Get", "the", "human", "readable", "status", "name", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L259-L271
38,611
timegridio/concierge
src/Models/Appointment.php
Appointment.getCodeAttribute
public function getCodeAttribute() { $length = $this->business->pref('appointment_code_length'); return strtoupper(substr($this->hash, 0, $length)); }
php
public function getCodeAttribute() { $length = $this->business->pref('appointment_code_length'); return strtoupper(substr($this->hash, 0, $length)); }
[ "public", "function", "getCodeAttribute", "(", ")", "{", "$", "length", "=", "$", "this", "->", "business", "->", "pref", "(", "'appointment_code_length'", ")", ";", "return", "strtoupper", "(", "substr", "(", "$", "this", "->", "hash", ",", "0", ",", "$...
Get user-friendly unique identification code. @return string
[ "Get", "user", "-", "friendly", "unique", "identification", "code", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L290-L295
38,612
timegridio/concierge
src/Models/Appointment.php
Appointment.doHash
public function doHash() { return $this->attributes['hash'] = md5( $this->start_at.'/'. $this->contact_id.'/'. $this->business_id.'/'. $this->service_id ); }
php
public function doHash() { return $this->attributes['hash'] = md5( $this->start_at.'/'. $this->contact_id.'/'. $this->business_id.'/'. $this->service_id ); }
[ "public", "function", "doHash", "(", ")", "{", "return", "$", "this", "->", "attributes", "[", "'hash'", "]", "=", "md5", "(", "$", "this", "->", "start_at", ".", "'/'", ".", "$", "this", "->", "contact_id", ".", "'/'", ".", "$", "this", "->", "bus...
Generate Appointment hash. @return string
[ "Generate", "Appointment", "hash", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L306-L314
38,613
timegridio/concierge
src/Models/Appointment.php
Appointment.scopeUnarchived
public function scopeUnarchived($query) { $carbon = Carbon::parse('today midnight')->timezone('UTC'); return $query ->where(function ($query) use ($carbon) { $query->whereIn('status', [Self::STATUS_RESERVED, Self::STATUS_CONFIRMED]) ->where('start_at', '<=', $carbon) ->orWhere(function ($query) use ($carbon) { $query->where('start_at', '>=', $carbon); }); }); }
php
public function scopeUnarchived($query) { $carbon = Carbon::parse('today midnight')->timezone('UTC'); return $query ->where(function ($query) use ($carbon) { $query->whereIn('status', [Self::STATUS_RESERVED, Self::STATUS_CONFIRMED]) ->where('start_at', '<=', $carbon) ->orWhere(function ($query) use ($carbon) { $query->where('start_at', '>=', $carbon); }); }); }
[ "public", "function", "scopeUnarchived", "(", "$", "query", ")", "{", "$", "carbon", "=", "Carbon", "::", "parse", "(", "'today midnight'", ")", "->", "timezone", "(", "'UTC'", ")", ";", "return", "$", "query", "->", "where", "(", "function", "(", "$", ...
Scope to Unarchived Appointments. @param Illuminate\Database\Query $query @return Illuminate\Database\Query
[ "Scope", "to", "Unarchived", "Appointments", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L462-L475
38,614
timegridio/concierge
src/Models/Appointment.php
Appointment.scopeOfDate
public function scopeOfDate($query, Carbon $date) { $date->timezone('UTC'); return $query->whereRaw('date(`start_at`) = ?', [$date->toDateString()]); }
php
public function scopeOfDate($query, Carbon $date) { $date->timezone('UTC'); return $query->whereRaw('date(`start_at`) = ?', [$date->toDateString()]); }
[ "public", "function", "scopeOfDate", "(", "$", "query", ",", "Carbon", "$", "date", ")", "{", "$", "date", "->", "timezone", "(", "'UTC'", ")", ";", "return", "$", "query", "->", "whereRaw", "(", "'date(`start_at`) = ?'", ",", "[", "$", "date", "->", "...
Scope of date. @param Illuminate\Database\Query $query @param Carbon $date @return Illuminate\Database\Query
[ "Scope", "of", "date", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L537-L542
38,615
timegridio/concierge
src/Models/Appointment.php
Appointment.scopeAffectingInterval
public function scopeAffectingInterval($query, Carbon $startAt, Carbon $finishAt) { $startAt->timezone('UTC'); $finishAt->timezone('UTC'); return $query ->where(function ($query) use ($startAt, $finishAt) { $query->where(function ($query) use ($startAt, $finishAt) { $query->where('finish_at', '>=', $finishAt) ->where('start_at', '<', $startAt); }) ->orWhere(function ($query) use ($startAt, $finishAt) { $query->where('finish_at', '<=', $finishAt) ->where('finish_at', '>', $startAt); }) ->orWhere(function ($query) use ($startAt, $finishAt) { $query->where('start_at', '>=', $startAt) ->where('start_at', '<', $finishAt); }); // ->orWhere(function ($query) use ($startAt, $finishAt) { // $query->where('start_at', '>', $startAt) // ->where('finish_at', '>', $finishAt); // }); }); }
php
public function scopeAffectingInterval($query, Carbon $startAt, Carbon $finishAt) { $startAt->timezone('UTC'); $finishAt->timezone('UTC'); return $query ->where(function ($query) use ($startAt, $finishAt) { $query->where(function ($query) use ($startAt, $finishAt) { $query->where('finish_at', '>=', $finishAt) ->where('start_at', '<', $startAt); }) ->orWhere(function ($query) use ($startAt, $finishAt) { $query->where('finish_at', '<=', $finishAt) ->where('finish_at', '>', $startAt); }) ->orWhere(function ($query) use ($startAt, $finishAt) { $query->where('start_at', '>=', $startAt) ->where('start_at', '<', $finishAt); }); // ->orWhere(function ($query) use ($startAt, $finishAt) { // $query->where('start_at', '>', $startAt) // ->where('finish_at', '>', $finishAt); // }); }); }
[ "public", "function", "scopeAffectingInterval", "(", "$", "query", ",", "Carbon", "$", "startAt", ",", "Carbon", "$", "finishAt", ")", "{", "$", "startAt", "->", "timezone", "(", "'UTC'", ")", ";", "$", "finishAt", "->", "timezone", "(", "'UTC'", ")", ";...
Soft check of time interval affectation @param Illuminate\Database\Query $query @param Carbon $startAt @param Carbon $finishAt @return Illuminate\Database\Query
[ "Soft", "check", "of", "time", "interval", "affectation" ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L553-L579
38,616
timegridio/concierge
src/Models/Appointment.php
Appointment.canCancel
public function canCancel($userId) { return $this->isOwner($userId) || ($this->isIssuer($userId) && $this->isOnTimeToCancel()) || ($this->isTarget($userId) && $this->isOnTimeToCancel()); }
php
public function canCancel($userId) { return $this->isOwner($userId) || ($this->isIssuer($userId) && $this->isOnTimeToCancel()) || ($this->isTarget($userId) && $this->isOnTimeToCancel()); }
[ "public", "function", "canCancel", "(", "$", "userId", ")", "{", "return", "$", "this", "->", "isOwner", "(", "$", "userId", ")", "||", "(", "$", "this", "->", "isIssuer", "(", "$", "userId", ")", "&&", "$", "this", "->", "isOnTimeToCancel", "(", ")"...
can be canceled by user. @param int $userId @return bool
[ "can", "be", "canceled", "by", "user", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L644-L649
38,617
timegridio/concierge
src/Models/Appointment.php
Appointment.isOnTimeToCancel
public function isOnTimeToCancel() { $graceHours = $this->business->pref('appointment_cancellation_pre_hs'); $diff = $this->start_at->diffInHours(Carbon::now()); return intval($diff) >= intval($graceHours); }
php
public function isOnTimeToCancel() { $graceHours = $this->business->pref('appointment_cancellation_pre_hs'); $diff = $this->start_at->diffInHours(Carbon::now()); return intval($diff) >= intval($graceHours); }
[ "public", "function", "isOnTimeToCancel", "(", ")", "{", "$", "graceHours", "=", "$", "this", "->", "business", "->", "pref", "(", "'appointment_cancellation_pre_hs'", ")", ";", "$", "diff", "=", "$", "this", "->", "start_at", "->", "diffInHours", "(", "Carb...
Determine if it is still possible to cancel according business policy. @return bool
[ "Determine", "if", "it", "is", "still", "possible", "to", "cancel", "according", "business", "policy", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L656-L663
38,618
timegridio/concierge
src/Models/Appointment.php
Appointment.isConfirmableBy
public function isConfirmableBy($userId) { return $this->isConfirmable() && $this->shouldConfirmBy($userId) && $this->canConfirm($userId); }
php
public function isConfirmableBy($userId) { return $this->isConfirmable() && $this->shouldConfirmBy($userId) && $this->canConfirm($userId); }
[ "public", "function", "isConfirmableBy", "(", "$", "userId", ")", "{", "return", "$", "this", "->", "isConfirmable", "(", ")", "&&", "$", "this", "->", "shouldConfirmBy", "(", "$", "userId", ")", "&&", "$", "this", "->", "canConfirm", "(", "$", "userId",...
is Confirmable By user. @param int $userId @return bool
[ "is", "Confirmable", "By", "user", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L708-L714
38,619
timegridio/concierge
src/Models/Appointment.php
Appointment.shouldConfirmBy
public function shouldConfirmBy($userId) { return ($this->isSelfIssued() && $this->isOwner($userId)) || $this->isIssuer($userId); }
php
public function shouldConfirmBy($userId) { return ($this->isSelfIssued() && $this->isOwner($userId)) || $this->isIssuer($userId); }
[ "public", "function", "shouldConfirmBy", "(", "$", "userId", ")", "{", "return", "(", "$", "this", "->", "isSelfIssued", "(", ")", "&&", "$", "this", "->", "isOwner", "(", "$", "userId", ")", ")", "||", "$", "this", "->", "isIssuer", "(", "$", "userI...
Determine if the queried userId may confirm the appointment or not. @param int $userId @return bool
[ "Determine", "if", "the", "queried", "userId", "may", "confirm", "the", "appointment", "or", "not", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L735-L738
38,620
timegridio/concierge
src/Models/Appointment.php
Appointment.isSelfIssued
public function isSelfIssued() { if (!$this->issuer) { return false; } if (!$this->contact) { return false; } if (!$this->contact->user) { return false; } return $this->issuer->id == $this->contact->user->id; }
php
public function isSelfIssued() { if (!$this->issuer) { return false; } if (!$this->contact) { return false; } if (!$this->contact->user) { return false; } return $this->issuer->id == $this->contact->user->id; }
[ "public", "function", "isSelfIssued", "(", ")", "{", "if", "(", "!", "$", "this", "->", "issuer", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "contact", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "...
Determine if the target Contact's User is the same of the Appointment issuer User. @return bool
[ "Determine", "if", "the", "target", "Contact", "s", "User", "is", "the", "same", "of", "the", "Appointment", "issuer", "User", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L746-L759
38,621
timegridio/concierge
src/Models/Appointment.php
Appointment.doConfirm
public function doConfirm() { if ($this->isConfirmable()) { $this->status = self::STATUS_CONFIRMED; $this->save(); } return $this; }
php
public function doConfirm() { if ($this->isConfirmable()) { $this->status = self::STATUS_CONFIRMED; $this->save(); } return $this; }
[ "public", "function", "doConfirm", "(", ")", "{", "if", "(", "$", "this", "->", "isConfirmable", "(", ")", ")", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_CONFIRMED", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "...
Check and perform Confirm action. @return $this
[ "Check", "and", "perform", "Confirm", "action", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L814-L823
38,622
timegridio/concierge
src/Models/Appointment.php
Appointment.doCancel
public function doCancel() { if ($this->isCancelable()) { $this->status = self::STATUS_CANCELED; $this->save(); } return $this; }
php
public function doCancel() { if ($this->isCancelable()) { $this->status = self::STATUS_CANCELED; $this->save(); } return $this; }
[ "public", "function", "doCancel", "(", ")", "{", "if", "(", "$", "this", "->", "isCancelable", "(", ")", ")", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_CANCELED", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "$",...
Check and perform cancel action. @return $this
[ "Check", "and", "perform", "cancel", "action", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L830-L839
38,623
timegridio/concierge
src/Models/Appointment.php
Appointment.doServe
public function doServe() { if ($this->isServeable()) { $this->status = self::STATUS_SERVED; $this->save(); } return $this; }
php
public function doServe() { if ($this->isServeable()) { $this->status = self::STATUS_SERVED; $this->save(); } return $this; }
[ "public", "function", "doServe", "(", ")", "{", "if", "(", "$", "this", "->", "isServeable", "(", ")", ")", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_SERVED", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "$", "...
Check and perform Serve action. @return $this
[ "Check", "and", "perform", "Serve", "action", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Appointment.php#L846-L855
38,624
timegridio/concierge
src/Models/Vacancy.php
Vacancy.scopeForDateTime
public function scopeForDateTime($query, Carbon $datetime) { return $query->where('start_at', '<=', $datetime->toDateTimeString()) ->where('finish_at', '>=', $datetime->toDateTimeString()); }
php
public function scopeForDateTime($query, Carbon $datetime) { return $query->where('start_at', '<=', $datetime->toDateTimeString()) ->where('finish_at', '>=', $datetime->toDateTimeString()); }
[ "public", "function", "scopeForDateTime", "(", "$", "query", ",", "Carbon", "$", "datetime", ")", "{", "return", "$", "query", "->", "where", "(", "'start_at'", ",", "'<='", ",", "$", "datetime", "->", "toDateTimeString", "(", ")", ")", "->", "where", "(...
Scope For DateTime. @param Illuminate\Database\Query $query @param Carbon $datetime Date and Time of inquiry @return Illuminate\Database\Query Scoped query
[ "Scope", "For", "DateTime", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L135-L139
38,625
timegridio/concierge
src/Models/Vacancy.php
Vacancy.scopeFuture
public function scopeFuture($query, $since = null) { if (!$since) { $since = Carbon::now(); } return $query->where('date', '>=', $since->toDateTimeString()); }
php
public function scopeFuture($query, $since = null) { if (!$since) { $since = Carbon::now(); } return $query->where('date', '>=', $since->toDateTimeString()); }
[ "public", "function", "scopeFuture", "(", "$", "query", ",", "$", "since", "=", "null", ")", "{", "if", "(", "!", "$", "since", ")", "{", "$", "since", "=", "Carbon", "::", "now", "(", ")", ";", "}", "return", "$", "query", "->", "where", "(", ...
Scope only Future. @param Illuminate\Database\Query $query @param \Carbon\Carbon $since @return Illuminate\Database\Query Scoped query
[ "Scope", "only", "Future", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L149-L156
38,626
timegridio/concierge
src/Models/Vacancy.php
Vacancy.scopeUntil
public function scopeUntil($query, $until = null) { if (!$until) { return $query; } return $query->where('date', '<', $until->toDateTimeString()); }
php
public function scopeUntil($query, $until = null) { if (!$until) { return $query; } return $query->where('date', '<', $until->toDateTimeString()); }
[ "public", "function", "scopeUntil", "(", "$", "query", ",", "$", "until", "=", "null", ")", "{", "if", "(", "!", "$", "until", ")", "{", "return", "$", "query", ";", "}", "return", "$", "query", "->", "where", "(", "'date'", ",", "'<'", ",", "$",...
Scope Until. @param Illuminate\Database\Query $query @param \Carbon\Carbon $until @return Illuminate\Database\Query Scoped query
[ "Scope", "Until", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L166-L173
38,627
timegridio/concierge
src/Models/Vacancy.php
Vacancy.isHoldingAnyFor
public function isHoldingAnyFor($userId) { $appointments = $this->appointments()->get(); foreach ($appointments as $appointment) { $contact = $appointment->contact()->first(); if ($contact->isProfileOf($userId)) { return true; } } return false; }
php
public function isHoldingAnyFor($userId) { $appointments = $this->appointments()->get(); foreach ($appointments as $appointment) { $contact = $appointment->contact()->first(); if ($contact->isProfileOf($userId)) { return true; } } return false; }
[ "public", "function", "isHoldingAnyFor", "(", "$", "userId", ")", "{", "$", "appointments", "=", "$", "this", "->", "appointments", "(", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "appointments", "as", "$", "appointment", ")", "{", "$", "con...
is Holding Any Appointment for given User. ToDo: Remove from here as needs knowledge from User @param int $userId User to check belonging Appointments @return bool Vacancy holds at least one Appointment of User
[ "is", "Holding", "Any", "Appointment", "for", "given", "User", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L201-L213
38,628
timegridio/concierge
src/Models/Vacancy.php
Vacancy.getCapacityAttribute
public function getCapacityAttribute() { if ($this->humanresource) { return intval($this->humanresource->capacity); } return intval($this->attributes['capacity']); }
php
public function getCapacityAttribute() { if ($this->humanresource) { return intval($this->humanresource->capacity); } return intval($this->attributes['capacity']); }
[ "public", "function", "getCapacityAttribute", "(", ")", "{", "if", "(", "$", "this", "->", "humanresource", ")", "{", "return", "intval", "(", "$", "this", "->", "humanresource", "->", "capacity", ")", ";", "}", "return", "intval", "(", "$", "this", "->"...
get capacity. @return int Capacity of the vacancy (in appointment instances)
[ "get", "capacity", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L242-L249
38,629
timegridio/concierge
src/Models/Vacancy.php
Vacancy.hasRoomBetween
public function hasRoomBetween(Carbon $startAt, Carbon $finishAt) { return $this->capacity > $this->business ->bookings() ->active() ->affectingInterval($startAt, $finishAt) ->affectingHumanresource($this->humanresource_id) ->count() && ($this->start_at <= $startAt && $this->finish_at >= $finishAt); }
php
public function hasRoomBetween(Carbon $startAt, Carbon $finishAt) { return $this->capacity > $this->business ->bookings() ->active() ->affectingInterval($startAt, $finishAt) ->affectingHumanresource($this->humanresource_id) ->count() && ($this->start_at <= $startAt && $this->finish_at >= $finishAt); }
[ "public", "function", "hasRoomBetween", "(", "Carbon", "$", "startAt", ",", "Carbon", "$", "finishAt", ")", "{", "return", "$", "this", "->", "capacity", ">", "$", "this", "->", "business", "->", "bookings", "(", ")", "->", "active", "(", ")", "->", "a...
has Room between time. @return bool There is more capacity than used
[ "has", "Room", "between", "time", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Vacancy.php#L266-L275
38,630
fvsch/kirby-staticbuilder
src/Builder.php
Builder.normalizePath
protected function normalizePath($path, $sep='/') { $path = $this->normalizeSlashes($path, $sep); $out = []; foreach (explode($sep, $path) as $i => $fold) { if ($fold == '..' && $i > 0 && end($out) != '..') array_pop($out); $fold = preg_replace('/\.{2,}/', '.', $fold); if ($fold == '' || $fold == '.') continue; else $out[] = $fold; } return ($path[0] == $sep ? $sep : '') . join($sep, $out); }
php
protected function normalizePath($path, $sep='/') { $path = $this->normalizeSlashes($path, $sep); $out = []; foreach (explode($sep, $path) as $i => $fold) { if ($fold == '..' && $i > 0 && end($out) != '..') array_pop($out); $fold = preg_replace('/\.{2,}/', '.', $fold); if ($fold == '' || $fold == '.') continue; else $out[] = $fold; } return ($path[0] == $sep ? $sep : '') . join($sep, $out); }
[ "protected", "function", "normalizePath", "(", "$", "path", ",", "$", "sep", "=", "'/'", ")", "{", "$", "path", "=", "$", "this", "->", "normalizeSlashes", "(", "$", "path", ",", "$", "sep", ")", ";", "$", "out", "=", "[", "]", ";", "foreach", "(...
Normalize a file path string to remove ".." etc. @param string $path @param string $sep Path separator to use in output @return string
[ "Normalize", "a", "file", "path", "string", "to", "remove", "..", "etc", "." ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L172-L183
38,631
fvsch/kirby-staticbuilder
src/Builder.php
Builder.normalizeSlashes
function normalizeSlashes($str, $sep='/') { $result = preg_replace('/[\\/\\\]+/', $sep, $str); return $result === null ? '' : $result; }
php
function normalizeSlashes($str, $sep='/') { $result = preg_replace('/[\\/\\\]+/', $sep, $str); return $result === null ? '' : $result; }
[ "function", "normalizeSlashes", "(", "$", "str", ",", "$", "sep", "=", "'/'", ")", "{", "$", "result", "=", "preg_replace", "(", "'/[\\\\/\\\\\\]+/'", ",", "$", "sep", ",", "$", "str", ")", ";", "return", "$", "result", "===", "null", "?", "''", ":",...
Normalize slashes in a string to use forward slashes only @param string $str @param string $sep @return string
[ "Normalize", "slashes", "in", "a", "string", "to", "use", "forward", "slashes", "only" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L191-L195
38,632
fvsch/kirby-staticbuilder
src/Builder.php
Builder.filterPath
protected function filterPath($absolutePath) { // Unresolved paths with '..' are invalid if (Str::contains($absolutePath, '..')) return false; return Str::startsWith($absolutePath, $this->outputdir . '/'); }
php
protected function filterPath($absolutePath) { // Unresolved paths with '..' are invalid if (Str::contains($absolutePath, '..')) return false; return Str::startsWith($absolutePath, $this->outputdir . '/'); }
[ "protected", "function", "filterPath", "(", "$", "absolutePath", ")", "{", "// Unresolved paths with '..' are invalid", "if", "(", "Str", "::", "contains", "(", "$", "absolutePath", ",", "'..'", ")", ")", "return", "false", ";", "return", "Str", "::", "startsWit...
Check that the destination path is somewhere we can write to @param string $absolutePath @return boolean
[ "Check", "that", "the", "destination", "path", "is", "somewhere", "we", "can", "write", "to" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L202-L207
38,633
fvsch/kirby-staticbuilder
src/Builder.php
Builder.relativeUrl
protected function relativeUrl($from='', $to='') { $from = explode('/', ltrim($from, '/')); $to = explode('/', ltrim($to, '/')); $last = false; while (count($from) && count($to) && $from[0] === $to[0]) { $last = array_shift($from); array_shift($to); } if (count($from) == 0) { if ($last) array_unshift($to, $last); return './' . implode('/', $to); } else { return './' . str_repeat('../', count($from)-1) . implode('/', $to); } }
php
protected function relativeUrl($from='', $to='') { $from = explode('/', ltrim($from, '/')); $to = explode('/', ltrim($to, '/')); $last = false; while (count($from) && count($to) && $from[0] === $to[0]) { $last = array_shift($from); array_shift($to); } if (count($from) == 0) { if ($last) array_unshift($to, $last); return './' . implode('/', $to); } else { return './' . str_repeat('../', count($from)-1) . implode('/', $to); } }
[ "protected", "function", "relativeUrl", "(", "$", "from", "=", "''", ",", "$", "to", "=", "''", ")", "{", "$", "from", "=", "explode", "(", "'/'", ",", "ltrim", "(", "$", "from", ",", "'/'", ")", ")", ";", "$", "to", "=", "explode", "(", "'/'",...
Build a relative URL from one absolute path to another, going back as many times as needed. Paths should be absolute or are considered to be starting from the same root. @param string $from @param string $to @return string
[ "Build", "a", "relative", "URL", "from", "one", "absolute", "path", "to", "another", "going", "back", "as", "many", "times", "as", "needed", ".", "Paths", "should", "be", "absolute", "or", "are", "considered", "to", "be", "starting", "from", "the", "same",...
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L217-L233
38,634
fvsch/kirby-staticbuilder
src/Builder.php
Builder.rewriteUrls
protected function rewriteUrls($text, $pageUrl) { $relative = $this->baseurl === './'; if ($relative || $this->uglyurls) { // Match restrictively urls starting with prefix, and which are // correctly escaped (no whitespace or quotes). $find = preg_quote(static::URLPREFIX) . '(\/?[^\?\&<>{}"\'\s]*)'; $text = preg_replace_callback( "!$find!", function($found) use ($pageUrl, $relative) { $url = $found[0]; if ($this->uglyurls) { $path = $found[1]; if (!$path || $path === '/') { $url = rtrim($url, '/') . '/index.html'; } elseif (!Str::endsWith($url, '/') && !pathinfo($url, PATHINFO_EXTENSION)) { $url .= $this->extension; } } if ($relative) { $pageUrl .= $this->extension; $pageUrl = str_replace(static::URLPREFIX, '', $pageUrl); $url = str_replace(static::URLPREFIX, '', $url); $url = $this->relativeUrl($pageUrl, $url); } return $url; }, $text ); } // Except if we have converted to relative URLs, we still have // the placeholder prefix in the text. Swap in the base URL. $pattern = '!' . preg_quote(static::URLPREFIX) . '\/?!'; return preg_replace($pattern, $this->baseurl, $text); }
php
protected function rewriteUrls($text, $pageUrl) { $relative = $this->baseurl === './'; if ($relative || $this->uglyurls) { // Match restrictively urls starting with prefix, and which are // correctly escaped (no whitespace or quotes). $find = preg_quote(static::URLPREFIX) . '(\/?[^\?\&<>{}"\'\s]*)'; $text = preg_replace_callback( "!$find!", function($found) use ($pageUrl, $relative) { $url = $found[0]; if ($this->uglyurls) { $path = $found[1]; if (!$path || $path === '/') { $url = rtrim($url, '/') . '/index.html'; } elseif (!Str::endsWith($url, '/') && !pathinfo($url, PATHINFO_EXTENSION)) { $url .= $this->extension; } } if ($relative) { $pageUrl .= $this->extension; $pageUrl = str_replace(static::URLPREFIX, '', $pageUrl); $url = str_replace(static::URLPREFIX, '', $url); $url = $this->relativeUrl($pageUrl, $url); } return $url; }, $text ); } // Except if we have converted to relative URLs, we still have // the placeholder prefix in the text. Swap in the base URL. $pattern = '!' . preg_quote(static::URLPREFIX) . '\/?!'; return preg_replace($pattern, $this->baseurl, $text); }
[ "protected", "function", "rewriteUrls", "(", "$", "text", ",", "$", "pageUrl", ")", "{", "$", "relative", "=", "$", "this", "->", "baseurl", "===", "'./'", ";", "if", "(", "$", "relative", "||", "$", "this", "->", "uglyurls", ")", "{", "// Match restri...
Rewrites URLs in the response body of a page @param string $text Response text @param string $pageUrl URL for the page @return string
[ "Rewrites", "URLs", "in", "the", "response", "body", "of", "a", "page" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L241-L276
38,635
fvsch/kirby-staticbuilder
src/Builder.php
Builder.pageFilename
protected function pageFilename(Page $page, $lang=null) { // We basically want the page $page->id(), but localized for multilang $url = $page->url($lang); // Strip the temporary URL prefix $url = trim(str_replace(static::URLPREFIX, '', $url), '/'); // Page URL fragment should not contain a protocol or domain name at this point; // did we fail to override the base URL with static::URLPREFIX? if (Str::startsWith($url, 'http') || Str::contains($url, '://')) { throw new Exception("Cannot use '$url' as basis for page's file name."); } // Special case: home page if (!$url) { $file = $this->outputdir . '/index.html'; } // Don’t add any extension if we already have one in the URL // (using a short whitelist for likely use cases). elseif (preg_match('/\.(js|json|css|txt|svg|xml|atom|rss)$/i', $url)) { $file = $this->outputdir . '/' . $url; } else { $file = $this->outputdir . '/' . $url . $this->extension; } $validPath = $this->normalizePath($file); if ($this->filterPath($validPath) == false) { throw new Exception('Output path for page goes outside of static directory: ' . $file); } return $validPath; }
php
protected function pageFilename(Page $page, $lang=null) { // We basically want the page $page->id(), but localized for multilang $url = $page->url($lang); // Strip the temporary URL prefix $url = trim(str_replace(static::URLPREFIX, '', $url), '/'); // Page URL fragment should not contain a protocol or domain name at this point; // did we fail to override the base URL with static::URLPREFIX? if (Str::startsWith($url, 'http') || Str::contains($url, '://')) { throw new Exception("Cannot use '$url' as basis for page's file name."); } // Special case: home page if (!$url) { $file = $this->outputdir . '/index.html'; } // Don’t add any extension if we already have one in the URL // (using a short whitelist for likely use cases). elseif (preg_match('/\.(js|json|css|txt|svg|xml|atom|rss)$/i', $url)) { $file = $this->outputdir . '/' . $url; } else { $file = $this->outputdir . '/' . $url . $this->extension; } $validPath = $this->normalizePath($file); if ($this->filterPath($validPath) == false) { throw new Exception('Output path for page goes outside of static directory: ' . $file); } return $validPath; }
[ "protected", "function", "pageFilename", "(", "Page", "$", "page", ",", "$", "lang", "=", "null", ")", "{", "// We basically want the page $page->id(), but localized for multilang", "$", "url", "=", "$", "page", "->", "url", "(", "$", "lang", ")", ";", "// Strip...
Generate the file path that a page should be written to @param Page $page @param string|null $lang @return string @throws Exception
[ "Generate", "the", "file", "path", "that", "a", "page", "should", "be", "written", "to" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L285-L313
38,636
fvsch/kirby-staticbuilder
src/Builder.php
Builder.buildPage
protected function buildPage(Page $page, $write=false) { // Check if we will build this page and report why not. // Note: in 2.1 the page filtering API changed, the return value // can be a boolean or an array with a boolean + a string. if (is_callable($this->filter)) { $filterResult = call_user_func($this->filter, $page); } else { $filterResult = $this->defaultFilter($page); } if (!is_array($filterResult)) { $filterResult = [$filterResult]; } if (A::get($filterResult, 0, false) == false) { $log = [ 'type' => 'page', 'source' => 'content/'.$page->diruri(), 'status' => 'ignore', 'reason' => A::get($filterResult, 1, 'Excluded by filter'), 'dest' => null, 'size' => null ]; $this->summary[] = $log; return; } // Build the HTML for each language version of the page foreach ($this->langs as $lang) { $this->buildPageVersion(clone $page, $lang, $write); } }
php
protected function buildPage(Page $page, $write=false) { // Check if we will build this page and report why not. // Note: in 2.1 the page filtering API changed, the return value // can be a boolean or an array with a boolean + a string. if (is_callable($this->filter)) { $filterResult = call_user_func($this->filter, $page); } else { $filterResult = $this->defaultFilter($page); } if (!is_array($filterResult)) { $filterResult = [$filterResult]; } if (A::get($filterResult, 0, false) == false) { $log = [ 'type' => 'page', 'source' => 'content/'.$page->diruri(), 'status' => 'ignore', 'reason' => A::get($filterResult, 1, 'Excluded by filter'), 'dest' => null, 'size' => null ]; $this->summary[] = $log; return; } // Build the HTML for each language version of the page foreach ($this->langs as $lang) { $this->buildPageVersion(clone $page, $lang, $write); } }
[ "protected", "function", "buildPage", "(", "Page", "$", "page", ",", "$", "write", "=", "false", ")", "{", "// Check if we will build this page and report why not.", "// Note: in 2.1 the page filtering API changed, the return value", "// can be a boolean or an array with a boolean + ...
Write the HTML for a page and copy its files @param Page $page @param bool $write Should we write files or just report info (dry-run).
[ "Write", "the", "HTML", "for", "a", "page", "and", "copy", "its", "files" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L320-L350
38,637
fvsch/kirby-staticbuilder
src/Builder.php
Builder.copyAsset
protected function copyAsset($from=null, $to=null, $write=false) { if (!is_string($from) or !is_string($to)) { return false; } $log = [ 'type' => 'asset', 'status' => '', 'reason' => '', // Use unnormalized, relative paths in log, because they // might help understand why a file was ignored 'source' => $from, 'dest' => 'static/', 'size' => null ]; // Source can be absolute if ($this->isAbsolutePath($from)) { $source = $from; } else { $source = $this->normalizePath($this->root . '/' . $from); } // But target is always relative to static dir $target = $this->normalizePath($this->outputdir . '/' . $to); if ($this->filterPath($target) == false) { $log['status'] = 'ignore'; $log['reason'] = 'Cannot copy asset outside of the static folder'; return $this->summary[] = $log; } $log['dest'] .= str_replace($this->outputdir . '/', '', $target); // Get type of asset if (is_dir($source)) { $log['type'] = 'dir'; } elseif (is_file($source)) { $log['type'] = 'file'; } else { $log['status'] = 'ignore'; $log['reason'] = 'Source file or folder not found'; } // Copy a folder if ($write && $log['type'] == 'dir') { $source = new Folder($source); $existing = new Folder($target); if ($existing->exists()) $existing->remove(); $log['status'] = $source->copy($target) ? 'done' : 'failed'; } // Copy a file if ($write && $log['type'] == 'file') { $log['status'] = copy($source, $target) ? 'done' : 'failed'; } return $this->summary[] = $log; }
php
protected function copyAsset($from=null, $to=null, $write=false) { if (!is_string($from) or !is_string($to)) { return false; } $log = [ 'type' => 'asset', 'status' => '', 'reason' => '', // Use unnormalized, relative paths in log, because they // might help understand why a file was ignored 'source' => $from, 'dest' => 'static/', 'size' => null ]; // Source can be absolute if ($this->isAbsolutePath($from)) { $source = $from; } else { $source = $this->normalizePath($this->root . '/' . $from); } // But target is always relative to static dir $target = $this->normalizePath($this->outputdir . '/' . $to); if ($this->filterPath($target) == false) { $log['status'] = 'ignore'; $log['reason'] = 'Cannot copy asset outside of the static folder'; return $this->summary[] = $log; } $log['dest'] .= str_replace($this->outputdir . '/', '', $target); // Get type of asset if (is_dir($source)) { $log['type'] = 'dir'; } elseif (is_file($source)) { $log['type'] = 'file'; } else { $log['status'] = 'ignore'; $log['reason'] = 'Source file or folder not found'; } // Copy a folder if ($write && $log['type'] == 'dir') { $source = new Folder($source); $existing = new Folder($target); if ($existing->exists()) $existing->remove(); $log['status'] = $source->copy($target) ? 'done' : 'failed'; } // Copy a file if ($write && $log['type'] == 'file') { $log['status'] = copy($source, $target) ? 'done' : 'failed'; } return $this->summary[] = $log; }
[ "protected", "function", "copyAsset", "(", "$", "from", "=", "null", ",", "$", "to", "=", "null", ",", "$", "write", "=", "false", ")", "{", "if", "(", "!", "is_string", "(", "$", "from", ")", "or", "!", "is_string", "(", "$", "to", ")", ")", "...
Copy a file or folder to the static directory This function is responsible for normalizing paths and making sure we don't write files outside of the static directory. @param string $from Source file or folder @param string $to Destination path @param bool $write Should we write files or just report info (dry-run). @return array|boolean @throws Exception
[ "Copy", "a", "file", "or", "folder", "to", "the", "static", "directory", "This", "function", "is", "responsible", "for", "normalizing", "paths", "and", "making", "sure", "we", "don", "t", "write", "files", "outside", "of", "the", "static", "directory", "." ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L447-L505
38,638
fvsch/kirby-staticbuilder
src/Builder.php
Builder.showFatalError
protected function showFatalError() { $error = error_get_last(); switch ($error['type']) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_PARSE: ob_clean(); echo $this->htmlReport([ 'mode' => 'fatal', 'error' => 'Error while building pages', 'summary' => $this->summary, 'errorTitle' => 'Failed to build page <code>' . $this->lastpage . '</code>', 'errorDetails' => $error['message'] . "<br>\n" . 'In ' . $error['file'] . ', line ' . $error['line'] ]); } }
php
protected function showFatalError() { $error = error_get_last(); switch ($error['type']) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_PARSE: ob_clean(); echo $this->htmlReport([ 'mode' => 'fatal', 'error' => 'Error while building pages', 'summary' => $this->summary, 'errorTitle' => 'Failed to build page <code>' . $this->lastpage . '</code>', 'errorDetails' => $error['message'] . "<br>\n" . 'In ' . $error['file'] . ', line ' . $error['line'] ]); } }
[ "protected", "function", "showFatalError", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "switch", "(", "$", "error", "[", "'type'", "]", ")", "{", "case", "E_ERROR", ":", "case", "E_CORE_ERROR", ":", "case", "E_COMPILE_ERROR", ":", ...
Try to render any PHP Fatal Error in our own template @return bool
[ "Try", "to", "render", "any", "PHP", "Fatal", "Error", "in", "our", "own", "template" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L531-L553
38,639
fvsch/kirby-staticbuilder
src/Builder.php
Builder.run
public function run($content, $write=false) { $this->summary = []; $this->kirby->cache()->flush(); $level = 1; if ($write) { // Kill PHP Error reporting when building pages, to "catch" PHP errors // from the pages or their controllers (and plugins etc.). We're going // to try to hande it ourselves $level = error_reporting(); $this->shutdown = function () { $this->showFatalError(); }; register_shutdown_function($this->shutdown); error_reporting(0); } // Empty folder on full site build if ($write && $content instanceof Site) { $folder = new Folder($this->outputdir); $folder->flush(); } // Build each page (possibly several times for multilingual sites) foreach($this->getPages($content) as $page) { $this->buildPage($page, $write); } // Copy assets after building pages (so that e.g. thumbs are ready) if ($content instanceof Site) { foreach ($this->assets as $from=>$to) { $this->copyAsset($from, $to, $write); } } // Restore error reporting if building pages worked if ($write) { error_reporting($level); $this->shutdown = function () {}; } }
php
public function run($content, $write=false) { $this->summary = []; $this->kirby->cache()->flush(); $level = 1; if ($write) { // Kill PHP Error reporting when building pages, to "catch" PHP errors // from the pages or their controllers (and plugins etc.). We're going // to try to hande it ourselves $level = error_reporting(); $this->shutdown = function () { $this->showFatalError(); }; register_shutdown_function($this->shutdown); error_reporting(0); } // Empty folder on full site build if ($write && $content instanceof Site) { $folder = new Folder($this->outputdir); $folder->flush(); } // Build each page (possibly several times for multilingual sites) foreach($this->getPages($content) as $page) { $this->buildPage($page, $write); } // Copy assets after building pages (so that e.g. thumbs are ready) if ($content instanceof Site) { foreach ($this->assets as $from=>$to) { $this->copyAsset($from, $to, $write); } } // Restore error reporting if building pages worked if ($write) { error_reporting($level); $this->shutdown = function () {}; } }
[ "public", "function", "run", "(", "$", "content", ",", "$", "write", "=", "false", ")", "{", "$", "this", "->", "summary", "=", "[", "]", ";", "$", "this", "->", "kirby", "->", "cache", "(", ")", "->", "flush", "(", ")", ";", "$", "level", "=",...
Build or rebuild static content @param Page|Pages|Site $content Content to write to the static folder @param boolean $write Should we actually write files @return array
[ "Build", "or", "rebuild", "static", "content" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L561-L602
38,640
fvsch/kirby-staticbuilder
src/Builder.php
Builder.htmlReport
public function htmlReport($data=[]) { // Forcefully remove headers that might have been set by some // templates, controllers or plugins when rendering pages. header_remove(); $root = dirname(__DIR__); $data['styles'] = file_get_contents($root . '/assets/report.css'); $data['script'] = file_get_contents($root . '/assets/report.js'); $body = Tpl::load(__DIR__ . '/report.php', $data); return new Response($body, 'html', $data['error'] ? 500 : 200); }
php
public function htmlReport($data=[]) { // Forcefully remove headers that might have been set by some // templates, controllers or plugins when rendering pages. header_remove(); $root = dirname(__DIR__); $data['styles'] = file_get_contents($root . '/assets/report.css'); $data['script'] = file_get_contents($root . '/assets/report.js'); $body = Tpl::load(__DIR__ . '/report.php', $data); return new Response($body, 'html', $data['error'] ? 500 : 200); }
[ "public", "function", "htmlReport", "(", "$", "data", "=", "[", "]", ")", "{", "// Forcefully remove headers that might have been set by some", "// templates, controllers or plugins when rendering pages.", "header_remove", "(", ")", ";", "$", "root", "=", "dirname", "(", ...
Render the HTML report page @param array $data @return Response
[ "Render", "the", "HTML", "report", "page" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L610-L620
38,641
fvsch/kirby-staticbuilder
src/Builder.php
Builder.defaultFilter
public static function defaultFilter($page) { // Exclude folders containing Kirby Modules // https://github.com/getkirby-plugins/modules-plugin $mod = C::get('modules.template.prefix', 'module.'); if (Str::startsWith($page->intendedTemplate(), $mod)) { return [false, "Ignoring module pages (template prefix: \"$mod\")"]; } // Exclude pages missing a content file // Note: $page->content()->exists() returns the wrong information, // so we use the inventory instead. For an empty directory, it can // be [] (single-language site) or ['code' => null] (multilang). if (array_shift($page->inventory()['content']) === null) { return [false, 'Page has no content file.']; } return true; }
php
public static function defaultFilter($page) { // Exclude folders containing Kirby Modules // https://github.com/getkirby-plugins/modules-plugin $mod = C::get('modules.template.prefix', 'module.'); if (Str::startsWith($page->intendedTemplate(), $mod)) { return [false, "Ignoring module pages (template prefix: \"$mod\")"]; } // Exclude pages missing a content file // Note: $page->content()->exists() returns the wrong information, // so we use the inventory instead. For an empty directory, it can // be [] (single-language site) or ['code' => null] (multilang). if (array_shift($page->inventory()['content']) === null) { return [false, 'Page has no content file.']; } return true; }
[ "public", "static", "function", "defaultFilter", "(", "$", "page", ")", "{", "// Exclude folders containing Kirby Modules", "// https://github.com/getkirby-plugins/modules-plugin", "$", "mod", "=", "C", "::", "get", "(", "'modules.template.prefix'", ",", "'module.'", ")", ...
Standard filter used to exclude empty "page" directories @param Page $page @return bool|array
[ "Standard", "filter", "used", "to", "exclude", "empty", "page", "directories" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Builder.php#L627-L643
38,642
fvsch/kirby-staticbuilder
src/Controller.php
Controller.register
static function register() { if (static::$registered) { return 'StaticBuilder is already enabled'; } if (!C::get('staticbuilder', false)) { return 'StaticBuilder does not seem to be enabled in your config. See https://github.com/fvsch/kirby-staticbuilder/blob/master/doc/install.md for instructions.'; } $kirby = kirby(); if (!class_exists('Kirby\\Registry')) { throw new Exception('Twig plugin requires Kirby 2.3 or higher. Current version: ' . $kirby->version()); } $kirby->set('route', [ 'pattern' => 'staticbuilder', 'action' => 'Kirby\\StaticBuilder\\Controller::siteAction', 'method' => 'GET|POST' ]); $kirby->set('route', [ 'pattern' => 'staticbuilder/(:all)', 'action' => 'Kirby\\StaticBuilder\\Controller::pageAction', 'method' => 'GET|POST' ]); static::$registered = true; return 'Enabled StaticBuilder routes.'; }
php
static function register() { if (static::$registered) { return 'StaticBuilder is already enabled'; } if (!C::get('staticbuilder', false)) { return 'StaticBuilder does not seem to be enabled in your config. See https://github.com/fvsch/kirby-staticbuilder/blob/master/doc/install.md for instructions.'; } $kirby = kirby(); if (!class_exists('Kirby\\Registry')) { throw new Exception('Twig plugin requires Kirby 2.3 or higher. Current version: ' . $kirby->version()); } $kirby->set('route', [ 'pattern' => 'staticbuilder', 'action' => 'Kirby\\StaticBuilder\\Controller::siteAction', 'method' => 'GET|POST' ]); $kirby->set('route', [ 'pattern' => 'staticbuilder/(:all)', 'action' => 'Kirby\\StaticBuilder\\Controller::pageAction', 'method' => 'GET|POST' ]); static::$registered = true; return 'Enabled StaticBuilder routes.'; }
[ "static", "function", "register", "(", ")", "{", "if", "(", "static", "::", "$", "registered", ")", "{", "return", "'StaticBuilder is already enabled'", ";", "}", "if", "(", "!", "C", "::", "get", "(", "'staticbuilder'", ",", "false", ")", ")", "{", "ret...
Register StaticBuilder's routes Returns a string with the current status @return string
[ "Register", "StaticBuilder", "s", "routes", "Returns", "a", "string", "with", "the", "current", "status" ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Controller.php#L19-L43
38,643
fvsch/kirby-staticbuilder
src/Controller.php
Controller.pageAction
static function pageAction($uri) { $write = R::is('POST') and R::get('confirm'); $page = page($uri); $builder = new Builder(); $data = [ 'mode' => 'page', 'error' => false, 'confirm' => $write, 'summary' => [] ]; if (!$page) { $data['error'] = "Error: Cannot find page for \"$uri\""; } else { $builder->run($page, $write); $data['summary'] = $builder->summary; } return $builder->htmlReport($data); }
php
static function pageAction($uri) { $write = R::is('POST') and R::get('confirm'); $page = page($uri); $builder = new Builder(); $data = [ 'mode' => 'page', 'error' => false, 'confirm' => $write, 'summary' => [] ]; if (!$page) { $data['error'] = "Error: Cannot find page for \"$uri\""; } else { $builder->run($page, $write); $data['summary'] = $builder->summary; } return $builder->htmlReport($data); }
[ "static", "function", "pageAction", "(", "$", "uri", ")", "{", "$", "write", "=", "R", "::", "is", "(", "'POST'", ")", "and", "R", "::", "get", "(", "'confirm'", ")", ";", "$", "page", "=", "page", "(", "$", "uri", ")", ";", "$", "builder", "="...
Similar to siteAction but for a single page. @param $uri @return Response
[ "Similar", "to", "siteAction", "but", "for", "a", "single", "page", "." ]
b2802f48ee978086661df97992ec27a9e08d0f28
https://github.com/fvsch/kirby-staticbuilder/blob/b2802f48ee978086661df97992ec27a9e08d0f28/src/Controller.php#L89-L108
38,644
timegridio/concierge
src/Models/Business.php
Business.boot
public static function boot() { parent::boot(); static::creating(function ($business) { $business->slug = $business->makeSlug($business->name); }); }
php
public static function boot() { parent::boot(); static::creating(function ($business) { $business->slug = $business->makeSlug($business->name); }); }
[ "public", "static", "function", "boot", "(", ")", "{", "parent", "::", "boot", "(", ")", ";", "static", "::", "creating", "(", "function", "(", "$", "business", ")", "{", "$", "business", "->", "slug", "=", "$", "business", "->", "makeSlug", "(", "$"...
Define model events. @return void
[ "Define", "model", "events", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Models/Business.php#L78-L87
38,645
timegridio/concierge
src/Timetable/Strategies/TimetableTimeslotStrategy.php
TimetableTimeslotStrategy.buildTimetable
public function buildTimetable($vacancies, $starting = 'today', $days = 1) { $this->initTimetable($starting, $days); foreach ($vacancies as $vacancy) { $this->updateTimeslots($vacancy, $this->interval); } return $this->timetable->get(); }
php
public function buildTimetable($vacancies, $starting = 'today', $days = 1) { $this->initTimetable($starting, $days); foreach ($vacancies as $vacancy) { $this->updateTimeslots($vacancy, $this->interval); } return $this->timetable->get(); }
[ "public", "function", "buildTimetable", "(", "$", "vacancies", ",", "$", "starting", "=", "'today'", ",", "$", "days", "=", "1", ")", "{", "$", "this", "->", "initTimetable", "(", "$", "starting", ",", "$", "days", ")", ";", "foreach", "(", "$", "vac...
Build timetable. @param \Illuminate\Database\Eloquent\Collection $vacancies @param string $starting @param int $days @return array
[ "Build", "timetable", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Timetable/Strategies/TimetableTimeslotStrategy.php#L38-L47
38,646
timegridio/concierge
src/Timetable/Timetable.php
Timetable.init
public function init() { $this->timetable = []; $dimensions['service'] = $this->inflateServices(); $dimensions['date'] = $this->inflateDates(); $dimensions['time'] = $this->inflateTimes(); foreach ($dimensions['service'] as $service) { foreach ($dimensions['date'] as $date) { foreach ($dimensions['time'] as $time) { $this->capacity($date, $time, $service, 0); } } } return $this; }
php
public function init() { $this->timetable = []; $dimensions['service'] = $this->inflateServices(); $dimensions['date'] = $this->inflateDates(); $dimensions['time'] = $this->inflateTimes(); foreach ($dimensions['service'] as $service) { foreach ($dimensions['date'] as $date) { foreach ($dimensions['time'] as $time) { $this->capacity($date, $time, $service, 0); } } } return $this; }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "timetable", "=", "[", "]", ";", "$", "dimensions", "[", "'service'", "]", "=", "$", "this", "->", "inflateServices", "(", ")", ";", "$", "dimensions", "[", "'date'", "]", "=", "$", "t...
Initialize Timetable. @return $this
[ "Initialize", "Timetable", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Timetable/Timetable.php#L154-L171
38,647
timegridio/concierge
src/Timetable/Timetable.php
Timetable.capacity
public function capacity($date, $time, $service, $capacity = null) { $path = $this->dimensions(compact('date', 'service', 'time')); return $capacity === null ? $this->array_get($this->timetable, $path) : $this->array_set($this->timetable, $path, $capacity); }
php
public function capacity($date, $time, $service, $capacity = null) { $path = $this->dimensions(compact('date', 'service', 'time')); return $capacity === null ? $this->array_get($this->timetable, $path) : $this->array_set($this->timetable, $path, $capacity); }
[ "public", "function", "capacity", "(", "$", "date", ",", "$", "time", ",", "$", "service", ",", "$", "capacity", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "dimensions", "(", "compact", "(", "'date'", ",", "'service'", ",", "'time'",...
Set the capacity for a slot. @param string $date @param string $time @param string $service @param int $capacity @return int
[ "Set", "the", "capacity", "for", "a", "slot", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Timetable/Timetable.php#L230-L237
38,648
timegridio/concierge
src/Timetable/Timetable.php
Timetable.dimensions
private function dimensions(array $segments) { $translatedDimensions = $this->dimensions; $this->array_substitute($translatedDimensions, $segments); return implode('.', $translatedDimensions); }
php
private function dimensions(array $segments) { $translatedDimensions = $this->dimensions; $this->array_substitute($translatedDimensions, $segments); return implode('.', $translatedDimensions); }
[ "private", "function", "dimensions", "(", "array", "$", "segments", ")", "{", "$", "translatedDimensions", "=", "$", "this", "->", "dimensions", ";", "$", "this", "->", "array_substitute", "(", "$", "translatedDimensions", ",", "$", "segments", ")", ";", "re...
Get a concrete Timetable path. @param array $segments @return string
[ "Get", "a", "concrete", "Timetable", "path", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Timetable/Timetable.php#L246-L253
38,649
timegridio/concierge
src/Timetable/Timetable.php
Timetable.format
public function format($dimensions) { if (is_array($dimensions)) { $this->dimensions = $dimensions; } if (is_string($dimensions)) { $this->dimensions = explode('.', $dimensions); } return $this; }
php
public function format($dimensions) { if (is_array($dimensions)) { $this->dimensions = $dimensions; } if (is_string($dimensions)) { $this->dimensions = explode('.', $dimensions); } return $this; }
[ "public", "function", "format", "(", "$", "dimensions", ")", "{", "if", "(", "is_array", "(", "$", "dimensions", ")", ")", "{", "$", "this", "->", "dimensions", "=", "$", "dimensions", ";", "}", "if", "(", "is_string", "(", "$", "dimensions", ")", ")...
Setter for the dimensions format. @param string $dimensions @return $this
[ "Setter", "for", "the", "dimensions", "format", "." ]
f5495dab5907ba9df3210af843fceaa8c8d009d6
https://github.com/timegridio/concierge/blob/f5495dab5907ba9df3210af843fceaa8c8d009d6/src/Timetable/Timetable.php#L262-L273
38,650
hpolthof/laravel-translations-db
src/DatabaseLoader.php
DatabaseLoader.addTranslation
public function addTranslation($locale, $group, $key) { if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return; // Extract the real key from the translation. if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) { $name = $match[1]; } else { throw new TranslationException('Could not extract key from translation.'); } $item = \DB::table('translations') ->where('locale', $locale) ->where('group', $group) ->where('name', $name)->first(); $data = compact('locale', 'group', 'name'); $data = array_merge($data, [ 'viewed_at' => date_create(), 'updated_at' => date_create(), ]); if($item === null) { $data = array_merge($data, [ 'created_at' => date_create(), ]); \DB::table('translations')->insert($data); } else { if($this->_app['config']->get('translation-db.update_viewed_at')) { \DB::table('translations')->where('id', $item->id)->update($data); } } }
php
public function addTranslation($locale, $group, $key) { if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return; // Extract the real key from the translation. if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) { $name = $match[1]; } else { throw new TranslationException('Could not extract key from translation.'); } $item = \DB::table('translations') ->where('locale', $locale) ->where('group', $group) ->where('name', $name)->first(); $data = compact('locale', 'group', 'name'); $data = array_merge($data, [ 'viewed_at' => date_create(), 'updated_at' => date_create(), ]); if($item === null) { $data = array_merge($data, [ 'created_at' => date_create(), ]); \DB::table('translations')->insert($data); } else { if($this->_app['config']->get('translation-db.update_viewed_at')) { \DB::table('translations')->where('id', $item->id)->update($data); } } }
[ "public", "function", "addTranslation", "(", "$", "locale", ",", "$", "group", ",", "$", "key", ")", "{", "if", "(", "!", "\\", "Config", "::", "get", "(", "'app.debug'", ")", "||", "\\", "Config", "::", "get", "(", "'translation-db.minimal'", ")", ")"...
Adds a new translation to the database or updates an existing record if the viewed_at updates are allowed. @param string $locale @param string $group @param string $name @return void
[ "Adds", "a", "new", "translation", "to", "the", "database", "or", "updates", "an", "existing", "record", "if", "the", "viewed_at", "updates", "are", "allowed", "." ]
4f7a7136687f64321a392b1d610a2b8f7a18383e
https://github.com/hpolthof/laravel-translations-db/blob/4f7a7136687f64321a392b1d610a2b8f7a18383e/src/DatabaseLoader.php#L54-L86
38,651
hpolthof/laravel-translations-db
src/ServiceProvider.php
ServiceProvider.pluckOrLists
public static function pluckOrLists(Builder $query, $column, $key = null) { if(\Illuminate\Foundation\Application::VERSION < '5.2') { $result = $query->lists($column, $key); } else { $result = $query->pluck($column, $key); } return $result; }
php
public static function pluckOrLists(Builder $query, $column, $key = null) { if(\Illuminate\Foundation\Application::VERSION < '5.2') { $result = $query->lists($column, $key); } else { $result = $query->pluck($column, $key); } return $result; }
[ "public", "static", "function", "pluckOrLists", "(", "Builder", "$", "query", ",", "$", "column", ",", "$", "key", "=", "null", ")", "{", "if", "(", "\\", "Illuminate", "\\", "Foundation", "\\", "Application", "::", "VERSION", "<", "'5.2'", ")", "{", "...
Alternative pluck to stay backwards compatible with Laravel 5.1 LTS. @param Builder $query @param $column @param null $key @return array|mixed
[ "Alternative", "pluck", "to", "stay", "backwards", "compatible", "with", "Laravel", "5", ".", "1", "LTS", "." ]
4f7a7136687f64321a392b1d610a2b8f7a18383e
https://github.com/hpolthof/laravel-translations-db/blob/4f7a7136687f64321a392b1d610a2b8f7a18383e/src/ServiceProvider.php#L147-L156
38,652
vajiralasantha/PHP-Image-Compare
src/ImageCompare.php
ImageCompare.compare
public function compare($pathOne, $pathTwo) { $i1 = $this->createImage($pathOne); $i2 = $this->createImage($pathTwo); if (!$i1 || !$i2) { return false; } $i1 = $this->resizeImage($pathOne); $i2 = $this->resizeImage($pathTwo); imagefilter($i1, IMG_FILTER_GRAYSCALE); imagefilter($i2, IMG_FILTER_GRAYSCALE); $colorMeanOne = $this->colorMeanValue($i1); $colorMeanTwo = $this->colorMeanValue($i2); $bits1 = $this->bits($colorMeanOne); $bits2 = $this->bits($colorMeanTwo); $hammeringDistance = 0; for ($x = 0; $x < 64; $x++) { if ($bits1[$x] != $bits2[$x]) { $hammeringDistance++; } } return $hammeringDistance; }
php
public function compare($pathOne, $pathTwo) { $i1 = $this->createImage($pathOne); $i2 = $this->createImage($pathTwo); if (!$i1 || !$i2) { return false; } $i1 = $this->resizeImage($pathOne); $i2 = $this->resizeImage($pathTwo); imagefilter($i1, IMG_FILTER_GRAYSCALE); imagefilter($i2, IMG_FILTER_GRAYSCALE); $colorMeanOne = $this->colorMeanValue($i1); $colorMeanTwo = $this->colorMeanValue($i2); $bits1 = $this->bits($colorMeanOne); $bits2 = $this->bits($colorMeanTwo); $hammeringDistance = 0; for ($x = 0; $x < 64; $x++) { if ($bits1[$x] != $bits2[$x]) { $hammeringDistance++; } } return $hammeringDistance; }
[ "public", "function", "compare", "(", "$", "pathOne", ",", "$", "pathTwo", ")", "{", "$", "i1", "=", "$", "this", "->", "createImage", "(", "$", "pathOne", ")", ";", "$", "i2", "=", "$", "this", "->", "createImage", "(", "$", "pathTwo", ")", ";", ...
Main function. Returns the hammering distance of two images' bit value. @param string $pathOne Path to image 1 @param string $pathTwo Path to image 2 @return bool|int Hammering value on success. False on error.
[ "Main", "function", ".", "Returns", "the", "hammering", "distance", "of", "two", "images", "bit", "value", "." ]
9ea466236c91b8bfa169b3459e3089d2f4b31f7e
https://github.com/vajiralasantha/PHP-Image-Compare/blob/9ea466236c91b8bfa169b3459e3089d2f4b31f7e/src/ImageCompare.php#L14-L43
38,653
vajiralasantha/PHP-Image-Compare
src/ImageCompare.php
ImageCompare.createImage
private function createImage($path) { $mime = $this->mimeType($path); if ($mime[2] == 'jpg') { return imagecreatefromjpeg ($path); } else if ($mime[2] == 'png') { return imagecreatefrompng ($path); } else { return false; } }
php
private function createImage($path) { $mime = $this->mimeType($path); if ($mime[2] == 'jpg') { return imagecreatefromjpeg ($path); } else if ($mime[2] == 'png') { return imagecreatefrompng ($path); } else { return false; } }
[ "private", "function", "createImage", "(", "$", "path", ")", "{", "$", "mime", "=", "$", "this", "->", "mimeType", "(", "$", "path", ")", ";", "if", "(", "$", "mime", "[", "2", "]", "==", "'jpg'", ")", "{", "return", "imagecreatefromjpeg", "(", "$"...
Returns image resource or false if it's not jpg or png @param string $path Path to image @return bool|resource
[ "Returns", "image", "resource", "or", "false", "if", "it", "s", "not", "jpg", "or", "png" ]
9ea466236c91b8bfa169b3459e3089d2f4b31f7e
https://github.com/vajiralasantha/PHP-Image-Compare/blob/9ea466236c91b8bfa169b3459e3089d2f4b31f7e/src/ImageCompare.php#L75-L85
38,654
vajiralasantha/PHP-Image-Compare
src/ImageCompare.php
ImageCompare.resizeImage
private function resizeImage($path) { $mime = $this->mimeType($path); $t = imagecreatetruecolor(8, 8); $source = $this->createImage($path); imagecopyresized($t, $source, 0, 0, 0, 0, 8, 8, $mime[0], $mime[1]); return $t; }
php
private function resizeImage($path) { $mime = $this->mimeType($path); $t = imagecreatetruecolor(8, 8); $source = $this->createImage($path); imagecopyresized($t, $source, 0, 0, 0, 0, 8, 8, $mime[0], $mime[1]); return $t; }
[ "private", "function", "resizeImage", "(", "$", "path", ")", "{", "$", "mime", "=", "$", "this", "->", "mimeType", "(", "$", "path", ")", ";", "$", "t", "=", "imagecreatetruecolor", "(", "8", ",", "8", ")", ";", "$", "source", "=", "$", "this", "...
Resize the image to a 8x8 square and returns as image resource. @param string $path Path to image @return resource Image resource identifier
[ "Resize", "the", "image", "to", "a", "8x8", "square", "and", "returns", "as", "image", "resource", "." ]
9ea466236c91b8bfa169b3459e3089d2f4b31f7e
https://github.com/vajiralasantha/PHP-Image-Compare/blob/9ea466236c91b8bfa169b3459e3089d2f4b31f7e/src/ImageCompare.php#L94-L104
38,655
vajiralasantha/PHP-Image-Compare
src/ImageCompare.php
ImageCompare.colorMeanValue
private function colorMeanValue($resource) { $colorList = array(); $colorSum = 0; for ($a = 0; $a<8; $a++) { for ($b = 0; $b<8; $b++) { $rgb = imagecolorat($resource, $a, $b); $colorList[] = $rgb & 0xFF; $colorSum += $rgb & 0xFF; } } return array($colorSum/64,$colorList); }
php
private function colorMeanValue($resource) { $colorList = array(); $colorSum = 0; for ($a = 0; $a<8; $a++) { for ($b = 0; $b<8; $b++) { $rgb = imagecolorat($resource, $a, $b); $colorList[] = $rgb & 0xFF; $colorSum += $rgb & 0xFF; } } return array($colorSum/64,$colorList); }
[ "private", "function", "colorMeanValue", "(", "$", "resource", ")", "{", "$", "colorList", "=", "array", "(", ")", ";", "$", "colorSum", "=", "0", ";", "for", "(", "$", "a", "=", "0", ";", "$", "a", "<", "8", ";", "$", "a", "++", ")", "{", "f...
Returns the mean value of the colors and the list of all pixel's colors. @param resource $resource Image resource identifier @return array
[ "Returns", "the", "mean", "value", "of", "the", "colors", "and", "the", "list", "of", "all", "pixel", "s", "colors", "." ]
9ea466236c91b8bfa169b3459e3089d2f4b31f7e
https://github.com/vajiralasantha/PHP-Image-Compare/blob/9ea466236c91b8bfa169b3459e3089d2f4b31f7e/src/ImageCompare.php#L113-L125
38,656
vajiralasantha/PHP-Image-Compare
src/ImageCompare.php
ImageCompare.bits
private function bits($colorMean) { $bits = array(); foreach ($colorMean[1] as $color) { $bits[] = ($color >= $colorMean[0]) ? 1 : 0; } return $bits; }
php
private function bits($colorMean) { $bits = array(); foreach ($colorMean[1] as $color) { $bits[] = ($color >= $colorMean[0]) ? 1 : 0; } return $bits; }
[ "private", "function", "bits", "(", "$", "colorMean", ")", "{", "$", "bits", "=", "array", "(", ")", ";", "foreach", "(", "$", "colorMean", "[", "1", "]", "as", "$", "color", ")", "{", "$", "bits", "[", "]", "=", "(", "$", "color", ">=", "$", ...
Returns an array with 1 and zeros. If a color is bigger than the mean value of colors it is 1 @param array $colorMean Color Mean details. @return array
[ "Returns", "an", "array", "with", "1", "and", "zeros", ".", "If", "a", "color", "is", "bigger", "than", "the", "mean", "value", "of", "colors", "it", "is", "1" ]
9ea466236c91b8bfa169b3459e3089d2f4b31f7e
https://github.com/vajiralasantha/PHP-Image-Compare/blob/9ea466236c91b8bfa169b3459e3089d2f4b31f7e/src/ImageCompare.php#L134-L142
38,657
mormat/php-formula-interpreter
src/FormulaInterpreter/Compiler.php
Compiler.compile
function compile($expression) { $options = $this->parser->parse($expression); $command = $this->commandFactory->create($options); return new Executable($command, $this->variables); }
php
function compile($expression) { $options = $this->parser->parse($expression); $command = $this->commandFactory->create($options); return new Executable($command, $this->variables); }
[ "function", "compile", "(", "$", "expression", ")", "{", "$", "options", "=", "$", "this", "->", "parser", "->", "parse", "(", "$", "expression", ")", ";", "$", "command", "=", "$", "this", "->", "commandFactory", "->", "create", "(", "$", "options", ...
Compile an expression and return the corresponding executable @param string $expression @return \FormulaInterpreter\Executable
[ "Compile", "an", "expression", "and", "return", "the", "corresponding", "executable" ]
d6a25ed5cbb051b87f16372d7ee248c573a59c35
https://github.com/mormat/php-formula-interpreter/blob/d6a25ed5cbb051b87f16372d7ee248c573a59c35/src/FormulaInterpreter/Compiler.php#L67-L71
38,658
wapmorgan/PhpCodeAnalyzer
src/PhpCodeAnalyzer.php
PhpCodeAnalyzer.catchAsStringUntilSemicolon
protected function catchAsStringUntilSemicolon(array $tokens, $pos) { $t = count($tokens); $catched = null; for ($i = $pos; $i < $t; $i++) { if ($tokens[$i] == ';') return $catched; else if ($tokens[$i] == '\\') $catched .= '\\'; else if (is_array($tokens[$i])) { $catched .= $tokens[$i][1]; } } return $catched; }
php
protected function catchAsStringUntilSemicolon(array $tokens, $pos) { $t = count($tokens); $catched = null; for ($i = $pos; $i < $t; $i++) { if ($tokens[$i] == ';') return $catched; else if ($tokens[$i] == '\\') $catched .= '\\'; else if (is_array($tokens[$i])) { $catched .= $tokens[$i][1]; } } return $catched; }
[ "protected", "function", "catchAsStringUntilSemicolon", "(", "array", "$", "tokens", ",", "$", "pos", ")", "{", "$", "t", "=", "count", "(", "$", "tokens", ")", ";", "$", "catched", "=", "null", ";", "for", "(", "$", "i", "=", "$", "pos", ";", "$",...
Catches class name after use statement;
[ "Catches", "class", "name", "after", "use", "statement", ";" ]
89d06eaa3de85d2fe468ffff4dd2ab12d996dca1
https://github.com/wapmorgan/PhpCodeAnalyzer/blob/89d06eaa3de85d2fe468ffff4dd2ab12d996dca1/src/PhpCodeAnalyzer.php#L241-L254
38,659
mercari/dietcube
src/Dispatcher.php
Dispatcher.dispatchRouter
protected function dispatchRouter($method, $path) { $router = $this->container['router']; $logger = $this->container['logger']; $logger->debug('Router dispatch.', ['method' => $method, 'path' => $path]); $router->init(); $route_info = $router->dispatch($method, $path); $handler = null; $vars = []; switch ($route_info[0]) { case RouteDispatcher::NOT_FOUND: $logger->debug('Routing failed. Not Found.'); throw new HttpNotFoundException('404 Not Found'); break; case RouteDispatcher::METHOD_NOT_ALLOWED: $logger->debug('Routing failed. Method Not Allowd.'); throw new HttpMethodNotAllowedException('405 Method Not Allowed'); break; case RouteDispatcher::FOUND: $handler = $route_info[1]; $vars = $route_info[2]; $logger->debug('Route found.', ['handler' => $handler]); break; } return [$handler, $vars]; }
php
protected function dispatchRouter($method, $path) { $router = $this->container['router']; $logger = $this->container['logger']; $logger->debug('Router dispatch.', ['method' => $method, 'path' => $path]); $router->init(); $route_info = $router->dispatch($method, $path); $handler = null; $vars = []; switch ($route_info[0]) { case RouteDispatcher::NOT_FOUND: $logger->debug('Routing failed. Not Found.'); throw new HttpNotFoundException('404 Not Found'); break; case RouteDispatcher::METHOD_NOT_ALLOWED: $logger->debug('Routing failed. Method Not Allowd.'); throw new HttpMethodNotAllowedException('405 Method Not Allowed'); break; case RouteDispatcher::FOUND: $handler = $route_info[1]; $vars = $route_info[2]; $logger->debug('Route found.', ['handler' => $handler]); break; } return [$handler, $vars]; }
[ "protected", "function", "dispatchRouter", "(", "$", "method", ",", "$", "path", ")", "{", "$", "router", "=", "$", "this", "->", "container", "[", "'router'", "]", ";", "$", "logger", "=", "$", "this", "->", "container", "[", "'logger'", "]", ";", "...
Dispatch router with HTTP request information. @param $method @param $path @return array
[ "Dispatch", "router", "with", "HTTP", "request", "information", "." ]
fceda3bd3a51c0bcdd51bcc928e8de80765a2590
https://github.com/mercari/dietcube/blob/fceda3bd3a51c0bcdd51bcc928e8de80765a2590/src/Dispatcher.php#L264-L294
38,660
mercari/dietcube
src/Dispatcher.php
Dispatcher.filterResponse
protected function filterResponse(Response $response) { $event = new FilterResponseEvent($this->app, $response); $this->event_dispatcher->dispatch(DietcubeEvents::FILTER_RESPONSE, $event); return $this->finishRequest($event->getResponse()); }
php
protected function filterResponse(Response $response) { $event = new FilterResponseEvent($this->app, $response); $this->event_dispatcher->dispatch(DietcubeEvents::FILTER_RESPONSE, $event); return $this->finishRequest($event->getResponse()); }
[ "protected", "function", "filterResponse", "(", "Response", "$", "response", ")", "{", "$", "event", "=", "new", "FilterResponseEvent", "(", "$", "this", "->", "app", ",", "$", "response", ")", ";", "$", "this", "->", "event_dispatcher", "->", "dispatch", ...
Dispatch FILTER_RESPONSE event to filter response. @param Response $response @return Response
[ "Dispatch", "FILTER_RESPONSE", "event", "to", "filter", "response", "." ]
fceda3bd3a51c0bcdd51bcc928e8de80765a2590
https://github.com/mercari/dietcube/blob/fceda3bd3a51c0bcdd51bcc928e8de80765a2590/src/Dispatcher.php#L315-L321
38,661
mercari/dietcube
src/Dispatcher.php
Dispatcher.finishRequest
protected function finishRequest(Response $response) { $event = new FinishRequestEvent($this->app, $response); $this->event_dispatcher->dispatch(DietcubeEvents::FINISH_REQUEST, $event); $response = $event->getResponse(); $response->sendHeaders(); $response->sendBody(); return $response; }
php
protected function finishRequest(Response $response) { $event = new FinishRequestEvent($this->app, $response); $this->event_dispatcher->dispatch(DietcubeEvents::FINISH_REQUEST, $event); $response = $event->getResponse(); $response->sendHeaders(); $response->sendBody(); return $response; }
[ "protected", "function", "finishRequest", "(", "Response", "$", "response", ")", "{", "$", "event", "=", "new", "FinishRequestEvent", "(", "$", "this", "->", "app", ",", "$", "response", ")", ";", "$", "this", "->", "event_dispatcher", "->", "dispatch", "(...
Finish request and send response. @param Response $response @return Response
[ "Finish", "request", "and", "send", "response", "." ]
fceda3bd3a51c0bcdd51bcc928e8de80765a2590
https://github.com/mercari/dietcube/blob/fceda3bd3a51c0bcdd51bcc928e8de80765a2590/src/Dispatcher.php#L329-L340
38,662
wbrowar/craft-3-adminbar
src/AdminBar.php
AdminBar.settingsHtml
protected function settingsHtml(): string { //AdminBar::$plugin->bar->clearAdminBarCache(); $settings = $this->getSettings(); // Create one empty table row if non are present if (empty($settings->customLinks)) { $settings['customLinks'] = [['','',0]]; } $adminBarWidgets = AdminBar::$plugin->bar->getAdminBarWidgetsFromPlugins(); return Craft::$app->view->renderTemplate( 'admin-bar/settings', [ 'widgets' => $adminBarWidgets, 'settings' => $settings ] ); }
php
protected function settingsHtml(): string { //AdminBar::$plugin->bar->clearAdminBarCache(); $settings = $this->getSettings(); // Create one empty table row if non are present if (empty($settings->customLinks)) { $settings['customLinks'] = [['','',0]]; } $adminBarWidgets = AdminBar::$plugin->bar->getAdminBarWidgetsFromPlugins(); return Craft::$app->view->renderTemplate( 'admin-bar/settings', [ 'widgets' => $adminBarWidgets, 'settings' => $settings ] ); }
[ "protected", "function", "settingsHtml", "(", ")", ":", "string", "{", "//AdminBar::$plugin->bar->clearAdminBarCache();", "$", "settings", "=", "$", "this", "->", "getSettings", "(", ")", ";", "// Create one empty table row if non are present", "if", "(", "empty", "(", ...
Returns the rendered settings HTML, which will be inserted into the content block on the settings page. @return string The rendered settings HTML
[ "Returns", "the", "rendered", "settings", "HTML", "which", "will", "be", "inserted", "into", "the", "content", "block", "on", "the", "settings", "page", "." ]
173f6d7049a11852d1f6453eb35af0e5ea644ef2
https://github.com/wbrowar/craft-3-adminbar/blob/173f6d7049a11852d1f6453eb35af0e5ea644ef2/src/AdminBar.php#L147-L167
38,663
fortrabbit/slimcontroller
src/SlimController/Slim.php
Slim.addRoutes
public function addRoutes(array $routes, $globalMiddlewares = array()) { if (!is_array($globalMiddlewares)) { if (func_num_args() > 2) { $args = func_get_args(); $globalMiddlewares = array_slice($args, 1); } else { $globalMiddlewares = array($globalMiddlewares); } } foreach ($routes as $path => $routeArgs) { // create array for simple request $routeArgs = (is_array($routeArgs)) ? $routeArgs : array('any' => $routeArgs); if (array_keys($routeArgs) === range(0, count($routeArgs) - 1)) { // route args is a sequential array not associative $routeArgs = array('any' => array($routeArgs[0], isset($routeArgs[1]) && is_array($routeArgs[1]) ? $routeArgs[1] : array_slice($routeArgs, 1)) ); } foreach ($routeArgs as $httpMethod => $classArgs) { // assign vars if middleware callback exists if (is_array($classArgs)) { $classRoute = $classArgs[0]; $localMiddlewares = is_array($classArgs[1]) ? $classArgs[1] : array_slice($classArgs, 1); } else { $classRoute = $classArgs; $localMiddlewares = array(); } // specific HTTP method $httpMethod = strtoupper($httpMethod); if (!in_array($httpMethod, static::$ALLOWED_HTTP_METHODS)) { throw new \InvalidArgumentException("Http method '$httpMethod' is not supported."); } $routeMiddlewares = array_merge($localMiddlewares, $globalMiddlewares); $route = $this->addControllerRoute($path, $classRoute, $routeMiddlewares); if (!isset($this->routeNames[$classRoute])) { $route->name($classRoute); $this->routeNames[$classRoute] = 1; } if ('any' === $httpMethod) { call_user_func_array(array($route, 'via'), static::$ALLOWED_HTTP_METHODS); } else { $route->via($httpMethod); } } } return $this; }
php
public function addRoutes(array $routes, $globalMiddlewares = array()) { if (!is_array($globalMiddlewares)) { if (func_num_args() > 2) { $args = func_get_args(); $globalMiddlewares = array_slice($args, 1); } else { $globalMiddlewares = array($globalMiddlewares); } } foreach ($routes as $path => $routeArgs) { // create array for simple request $routeArgs = (is_array($routeArgs)) ? $routeArgs : array('any' => $routeArgs); if (array_keys($routeArgs) === range(0, count($routeArgs) - 1)) { // route args is a sequential array not associative $routeArgs = array('any' => array($routeArgs[0], isset($routeArgs[1]) && is_array($routeArgs[1]) ? $routeArgs[1] : array_slice($routeArgs, 1)) ); } foreach ($routeArgs as $httpMethod => $classArgs) { // assign vars if middleware callback exists if (is_array($classArgs)) { $classRoute = $classArgs[0]; $localMiddlewares = is_array($classArgs[1]) ? $classArgs[1] : array_slice($classArgs, 1); } else { $classRoute = $classArgs; $localMiddlewares = array(); } // specific HTTP method $httpMethod = strtoupper($httpMethod); if (!in_array($httpMethod, static::$ALLOWED_HTTP_METHODS)) { throw new \InvalidArgumentException("Http method '$httpMethod' is not supported."); } $routeMiddlewares = array_merge($localMiddlewares, $globalMiddlewares); $route = $this->addControllerRoute($path, $classRoute, $routeMiddlewares); if (!isset($this->routeNames[$classRoute])) { $route->name($classRoute); $this->routeNames[$classRoute] = 1; } if ('any' === $httpMethod) { call_user_func_array(array($route, 'via'), static::$ALLOWED_HTTP_METHODS); } else { $route->via($httpMethod); } } } return $this; }
[ "public", "function", "addRoutes", "(", "array", "$", "routes", ",", "$", "globalMiddlewares", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "globalMiddlewares", ")", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "2", ...
Add multiple controller based routes Simple Format <code> $app->addRoutes(array( '/some/path' => 'className:methodName' )); </code> With explicit HTTP method <code> $app->addRoutes(array( '/some/path' => array('get' => 'className:methodName') )); </code> With local middleware <code> $app->addRoutes(array( '/some/path' => array('get' => 'className:methodName', function() {}) '/other/path' => array('className:methodName', function() {}) )); </code> With global middleware <code> $app->addRoutes(array( '/some/path' => 'className:methodName', ), function() {}); </code> @param array $routes The route definitions @param array $globalMiddlewares @throws \InvalidArgumentException @internal param $callable ,... $middlewares Optional callable used for all routes as middleware @return $this
[ "Add", "multiple", "controller", "based", "routes" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/Slim.php#L71-L126
38,664
fortrabbit/slimcontroller
src/SlimController/Slim.php
Slim.addControllerRoute
public function addControllerRoute($path, $route, array $middleware = array()) { $callback = $this->buildCallbackFromControllerRoute($route); array_unshift($middleware, $path); array_push($middleware, $callback); $route = call_user_func_array(array($this, 'map'), $middleware); return $route; }
php
public function addControllerRoute($path, $route, array $middleware = array()) { $callback = $this->buildCallbackFromControllerRoute($route); array_unshift($middleware, $path); array_push($middleware, $callback); $route = call_user_func_array(array($this, 'map'), $middleware); return $route; }
[ "public", "function", "addControllerRoute", "(", "$", "path", ",", "$", "route", ",", "array", "$", "middleware", "=", "array", "(", ")", ")", "{", "$", "callback", "=", "$", "this", "->", "buildCallbackFromControllerRoute", "(", "$", "route", ")", ";", ...
Add a new controller route <code> $app->addControllerRoute("/the/path", "className:methodName", array(function () { doSome(); })) ->via('GET')->condition(..); $app->addControllerRoute("/the/path", "className:methodName") ->via('GET')->condition(..); </code> @param string $path @param string $route @param callable[] $middleware,... @return \Slim\Route
[ "Add", "a", "new", "controller", "route" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/Slim.php#L145-L155
38,665
fortrabbit/slimcontroller
src/SlimController/Slim.php
Slim.buildCallbackFromControllerRoute
protected function buildCallbackFromControllerRoute($route) { list($controller, $methodName) = $this->determineClassAndMethod($route); $app = & $this; $callable = function () use ($app, $controller, $methodName) { // Get action arguments $args = func_get_args(); // Try to fetch the instance from Slim's container, otherwise lazy-instantiate it $instance = $app->container->has($controller) ? $app->container->get($controller) : new $controller($app); return call_user_func_array(array($instance, $methodName), $args); }; return $callable; }
php
protected function buildCallbackFromControllerRoute($route) { list($controller, $methodName) = $this->determineClassAndMethod($route); $app = & $this; $callable = function () use ($app, $controller, $methodName) { // Get action arguments $args = func_get_args(); // Try to fetch the instance from Slim's container, otherwise lazy-instantiate it $instance = $app->container->has($controller) ? $app->container->get($controller) : new $controller($app); return call_user_func_array(array($instance, $methodName), $args); }; return $callable; }
[ "protected", "function", "buildCallbackFromControllerRoute", "(", "$", "route", ")", "{", "list", "(", "$", "controller", ",", "$", "methodName", ")", "=", "$", "this", "->", "determineClassAndMethod", "(", "$", "route", ")", ";", "$", "app", "=", "&", "$"...
Builds closure callback from controller route @param $route @return \Closure
[ "Builds", "closure", "callback", "from", "controller", "route" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/Slim.php#L164-L178
38,666
fortrabbit/slimcontroller
src/SlimController/SlimController.php
SlimController.render
protected function render($template, $args = array()) { if (!is_null($this->renderTemplateSuffix) && !preg_match('/\.' . $this->renderTemplateSuffix . '$/', $template) ) { $template .= '.' . $this->renderTemplateSuffix; } $this->app->render($template, $args); }
php
protected function render($template, $args = array()) { if (!is_null($this->renderTemplateSuffix) && !preg_match('/\.' . $this->renderTemplateSuffix . '$/', $template) ) { $template .= '.' . $this->renderTemplateSuffix; } $this->app->render($template, $args); }
[ "protected", "function", "render", "(", "$", "template", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "renderTemplateSuffix", ")", "&&", "!", "preg_match", "(", "'/\\.'", ".", "$", "this", "->...
Renders output with given template @param string $template Name of the template to be rendererd @param array $args Args for view
[ "Renders", "output", "with", "given", "template" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/SlimController.php#L94-L102
38,667
fortrabbit/slimcontroller
src/SlimController/SlimController.php
SlimController.params
protected function params($names = array(), $reqMode = null, $defaults = null) { // no names given -> get them all if (!$names) { $names = $this->getAllParamNames($reqMode); } $res = array(); foreach ($names as $obj) { $name = is_array($obj) ? $obj[0] : $obj; $param = $this->param($name, $reqMode); if (!is_null($param) && (!is_array($param) || !empty($param))) { $res[$name] = $param; } // if in "need all" mode elseif ($defaults === true) { return null; } // if in default mode elseif (is_array($defaults) && isset($defaults[$name])) { $res[$name] = $defaults[$name]; } } return $res; }
php
protected function params($names = array(), $reqMode = null, $defaults = null) { // no names given -> get them all if (!$names) { $names = $this->getAllParamNames($reqMode); } $res = array(); foreach ($names as $obj) { $name = is_array($obj) ? $obj[0] : $obj; $param = $this->param($name, $reqMode); if (!is_null($param) && (!is_array($param) || !empty($param))) { $res[$name] = $param; } // if in "need all" mode elseif ($defaults === true) { return null; } // if in default mode elseif (is_array($defaults) && isset($defaults[$name])) { $res[$name] = $defaults[$name]; } } return $res; }
[ "protected", "function", "params", "(", "$", "names", "=", "array", "(", ")", ",", "$", "reqMode", "=", "null", ",", "$", "defaults", "=", "null", ")", "{", "// no names given -> get them all", "if", "(", "!", "$", "names", ")", "{", "$", "names", "=",...
Reads multiple params at once <code> $params = $this->params(['prefix.name', 'other.name']); // -> ["prefix.name" => "value", ..] $params = $this->params(['prefix.name', 'other.name'], true); // -> null if not all found $params = $this->params(['prefix.name', 'other.name'], ['other.name' => "Default Value"]); </code> @param mixed $names Name or names of parameters (GET or POST) @param mixed $reqMode Optional mode. Either null (all params), true | "post" (only POST params), false | "get" (only GET params) @param mixed $defaults Either true (require ALL given or return null), array (defaults) @return mixed Either array or single string or null
[ "Reads", "multiple", "params", "at", "once" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/SlimController.php#L192-L214
38,668
fortrabbit/slimcontroller
src/SlimController/SlimController.php
SlimController.cleanupParam
protected function cleanupParam($value) { if (is_array($value)) { foreach ($value as $k => $v) { $clean = $this->cleanupParam($v); if (!is_null($clean)) { $value[$k] = $clean; } } return $value; } else { return preg_replace('/>/', '', preg_replace('/</', '', $value)); } }
php
protected function cleanupParam($value) { if (is_array($value)) { foreach ($value as $k => $v) { $clean = $this->cleanupParam($v); if (!is_null($clean)) { $value[$k] = $clean; } } return $value; } else { return preg_replace('/>/', '', preg_replace('/</', '', $value)); } }
[ "protected", "function", "cleanupParam", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "clean", "=", "$", "this", "->", "cleanupP...
Cleans up a single or a list of params by stripping HTML encodings @param string $value @return string
[ "Cleans", "up", "a", "single", "or", "a", "list", "of", "params", "by", "stripping", "HTML", "encodings" ]
d85f097ef2f75c653dcd7f8ee518fdeb64825c38
https://github.com/fortrabbit/slimcontroller/blob/d85f097ef2f75c653dcd7f8ee518fdeb64825c38/src/SlimController/SlimController.php#L223-L237
38,669
daixianceng/yii2-echarts
src/ECharts.php
ECharts.registerClientScript
protected function registerClientScript() { $id = $this->options['id']; $view = $this->getView(); $option = !empty($this->pluginOptions['option']) ? Json::encode($this->pluginOptions['option']) : '{}'; if ($this->theme) { $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'), " . $this->quote($this->theme) . ");"; } else { $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'));"; } $js .= "{$this->clientId}.setOption({$option});"; if (isset($this->pluginOptions['group'])) { $js .= "{$this->clientId}.group = " . $this->quote($this->pluginOptions['group']) . ";"; } if ($this->responsive) { $js .= "$(window).resize(function () {{$this->clientId}.resize()});"; } foreach ($this->pluginEvents as $name => $handlers) { $handlers = (array) $handlers; foreach ($handlers as $handler) { $js .= "{$this->clientId}.on(" . $this->quote($name) . ", $handler);"; } } EChartsAsset::register($view); $view->registerJs($js); }
php
protected function registerClientScript() { $id = $this->options['id']; $view = $this->getView(); $option = !empty($this->pluginOptions['option']) ? Json::encode($this->pluginOptions['option']) : '{}'; if ($this->theme) { $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'), " . $this->quote($this->theme) . ");"; } else { $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'));"; } $js .= "{$this->clientId}.setOption({$option});"; if (isset($this->pluginOptions['group'])) { $js .= "{$this->clientId}.group = " . $this->quote($this->pluginOptions['group']) . ";"; } if ($this->responsive) { $js .= "$(window).resize(function () {{$this->clientId}.resize()});"; } foreach ($this->pluginEvents as $name => $handlers) { $handlers = (array) $handlers; foreach ($handlers as $handler) { $js .= "{$this->clientId}.on(" . $this->quote($name) . ", $handler);"; } } EChartsAsset::register($view); $view->registerJs($js); }
[ "protected", "function", "registerClientScript", "(", ")", "{", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "option", "=", "!", "empty", "(", "$", "this", ...
Registers the required js files and script to initialize echarts plugin.
[ "Registers", "the", "required", "js", "files", "and", "script", "to", "initialize", "echarts", "plugin", "." ]
511995efe02025b4b2d7f5723a5be668a06d1f2c
https://github.com/daixianceng/yii2-echarts/blob/511995efe02025b4b2d7f5723a5be668a06d1f2c/src/ECharts.php#L107-L134
38,670
daixianceng/yii2-echarts
src/ECharts.php
ECharts.getClientId
public function getClientId() { if ($this->_clientId === null) { $id = $this->options['id']; $this->_clientId = "echarts_{$id}"; } return $this->_clientId; }
php
public function getClientId() { if ($this->_clientId === null) { $id = $this->options['id']; $this->_clientId = "echarts_{$id}"; } return $this->_clientId; }
[ "public", "function", "getClientId", "(", ")", "{", "if", "(", "$", "this", "->", "_clientId", "===", "null", ")", "{", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "$", "this", "->", "_clientId", "=", "\"echarts_{$id}\"", ";"...
Returns the client ID of the echarts. @return string
[ "Returns", "the", "client", "ID", "of", "the", "echarts", "." ]
511995efe02025b4b2d7f5723a5be668a06d1f2c
https://github.com/daixianceng/yii2-echarts/blob/511995efe02025b4b2d7f5723a5be668a06d1f2c/src/ECharts.php#L152-L160
38,671
daixianceng/yii2-echarts
src/ECharts.php
ECharts.registerTheme
public static function registerTheme($theme) { $themes = (array) $theme; array_walk($themes, function (&$name) { $name .= '.js'; }); static::$_themeJsFiles = array_unique(array_merge(static::$_themeJsFiles, $themes)); if (static::$_themeJsFiles) { ThemeAsset::register(Yii::$app->getView())->js = static::$_themeJsFiles; } }
php
public static function registerTheme($theme) { $themes = (array) $theme; array_walk($themes, function (&$name) { $name .= '.js'; }); static::$_themeJsFiles = array_unique(array_merge(static::$_themeJsFiles, $themes)); if (static::$_themeJsFiles) { ThemeAsset::register(Yii::$app->getView())->js = static::$_themeJsFiles; } }
[ "public", "static", "function", "registerTheme", "(", "$", "theme", ")", "{", "$", "themes", "=", "(", "array", ")", "$", "theme", ";", "array_walk", "(", "$", "themes", ",", "function", "(", "&", "$", "name", ")", "{", "$", "name", ".=", "'.js'", ...
Registers the JS files of the given themes. @param string|array $theme
[ "Registers", "the", "JS", "files", "of", "the", "given", "themes", "." ]
511995efe02025b4b2d7f5723a5be668a06d1f2c
https://github.com/daixianceng/yii2-echarts/blob/511995efe02025b4b2d7f5723a5be668a06d1f2c/src/ECharts.php#L167-L177
38,672
daixianceng/yii2-echarts
src/ECharts.php
ECharts.registerMap
public static function registerMap($map) { $maps = (array) $map; array_walk($maps, function (&$name) { $name = 'js/' . $name . '.js'; }); static::$_mapJsFiles = array_unique(array_merge(static::$_mapJsFiles, $maps)); if (static::$_mapJsFiles) { MapAsset::register(Yii::$app->getView())->js = static::$_mapJsFiles; } }
php
public static function registerMap($map) { $maps = (array) $map; array_walk($maps, function (&$name) { $name = 'js/' . $name . '.js'; }); static::$_mapJsFiles = array_unique(array_merge(static::$_mapJsFiles, $maps)); if (static::$_mapJsFiles) { MapAsset::register(Yii::$app->getView())->js = static::$_mapJsFiles; } }
[ "public", "static", "function", "registerMap", "(", "$", "map", ")", "{", "$", "maps", "=", "(", "array", ")", "$", "map", ";", "array_walk", "(", "$", "maps", ",", "function", "(", "&", "$", "name", ")", "{", "$", "name", "=", "'js/'", ".", "$",...
Registers the JS files of the given maps. @param string|array $map
[ "Registers", "the", "JS", "files", "of", "the", "given", "maps", "." ]
511995efe02025b4b2d7f5723a5be668a06d1f2c
https://github.com/daixianceng/yii2-echarts/blob/511995efe02025b4b2d7f5723a5be668a06d1f2c/src/ECharts.php#L184-L194
38,673
minchao/mitake-php
src/Message/Message.php
Message.toINI
public function toINI() { $smBody = str_replace("\n", chr(6), $this->smbody); $ini = ''; $ini .= "dstaddr={$this->dstaddr}\n"; $ini .= "smbody={$smBody}\n"; if (!empty($this->dlvtime)) { $ini .= "dlvtime={$this->dlvtime}\n"; } if (!empty($this->vldtime)) { $ini .= "vldtime={$this->vldtime}\n"; } if (!empty($this->response)) { $ini .= "response={$this->response}\n"; } return $ini; }
php
public function toINI() { $smBody = str_replace("\n", chr(6), $this->smbody); $ini = ''; $ini .= "dstaddr={$this->dstaddr}\n"; $ini .= "smbody={$smBody}\n"; if (!empty($this->dlvtime)) { $ini .= "dlvtime={$this->dlvtime}\n"; } if (!empty($this->vldtime)) { $ini .= "vldtime={$this->vldtime}\n"; } if (!empty($this->response)) { $ini .= "response={$this->response}\n"; } return $ini; }
[ "public", "function", "toINI", "(", ")", "{", "$", "smBody", "=", "str_replace", "(", "\"\\n\"", ",", "chr", "(", "6", ")", ",", "$", "this", "->", "smbody", ")", ";", "$", "ini", "=", "''", ";", "$", "ini", ".=", "\"dstaddr={$this->dstaddr}\\n\"", "...
toINI returns the INI format string from the message fields @return string
[ "toINI", "returns", "the", "INI", "format", "string", "from", "the", "message", "fields" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/Message/Message.php#L136-L154
38,674
minchao/mitake-php
src/Client.php
Client.sendRequest
public function sendRequest(Request $request) { $response = $this->httpClient->send($request); $this->checkErrorResponse($response); return $response; }
php
public function sendRequest(Request $request) { $response = $this->httpClient->send($request); $this->checkErrorResponse($response); return $response; }
[ "public", "function", "sendRequest", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "send", "(", "$", "request", ")", ";", "$", "this", "->", "checkErrorResponse", "(", "$", "response", ")", ";", ...
Send an API request @param Request $request @return ResponseInterface @throws BadResponseException @throws \GuzzleHttp\Exception\GuzzleException
[ "Send", "an", "API", "request" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/Client.php#L206-L213
38,675
minchao/mitake-php
src/Client.php
Client.newRequest
public function newRequest($method, $uri, $contentType = null, $body = null) { // TODO $uri whitelist (trusted domain) $headers = [ 'User-Agent' => $this->userAgent, ]; if (!is_null($contentType)) { $headers['Content-Type'] = $contentType; } return new Request( $method, $uri, $headers, $body ); }
php
public function newRequest($method, $uri, $contentType = null, $body = null) { // TODO $uri whitelist (trusted domain) $headers = [ 'User-Agent' => $this->userAgent, ]; if (!is_null($contentType)) { $headers['Content-Type'] = $contentType; } return new Request( $method, $uri, $headers, $body ); }
[ "public", "function", "newRequest", "(", "$", "method", ",", "$", "uri", ",", "$", "contentType", "=", "null", ",", "$", "body", "=", "null", ")", "{", "// TODO $uri whitelist (trusted domain)", "$", "headers", "=", "[", "'User-Agent'", "=>", "$", "this", ...
Create an API request @param string $method @param string|UriInterface $uri @param string|null $contentType @param string|null $body @return Request
[ "Create", "an", "API", "request" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/Client.php#L224-L241
38,676
minchao/mitake-php
src/Client.php
Client.buildUriWithQuery
public function buildUriWithQuery($uri, array $params = []) { $uri = uri_for($uri); if (!Uri::isAbsolute($uri)) { $uri = $uri->withScheme($this->baseURL->getScheme()) ->withUserInfo($this->baseURL->getUserInfo()) ->withHost($this->baseURL->getHost()) ->withPort($this->baseURL->getPort()); } $default = [ 'username' => $this->username, 'password' => $this->password, ]; return $uri->withQuery(build_query(array_merge($default, $params))); }
php
public function buildUriWithQuery($uri, array $params = []) { $uri = uri_for($uri); if (!Uri::isAbsolute($uri)) { $uri = $uri->withScheme($this->baseURL->getScheme()) ->withUserInfo($this->baseURL->getUserInfo()) ->withHost($this->baseURL->getHost()) ->withPort($this->baseURL->getPort()); } $default = [ 'username' => $this->username, 'password' => $this->password, ]; return $uri->withQuery(build_query(array_merge($default, $params))); }
[ "public", "function", "buildUriWithQuery", "(", "$", "uri", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "uri", "=", "uri_for", "(", "$", "uri", ")", ";", "if", "(", "!", "Uri", "::", "isAbsolute", "(", "$", "uri", ")", ")", "{", ...
Return the uri with authentication parameters and query string @param string|UriInterface $uri @param array $params Query string parameters @return UriInterface
[ "Return", "the", "uri", "with", "authentication", "parameters", "and", "query", "string" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/Client.php#L251-L268
38,677
minchao/mitake-php
src/Client.php
Client.checkErrorResponse
protected function checkErrorResponse(ResponseInterface $response) { $statusCode = $response->getStatusCode(); if (200 <= $statusCode && $statusCode < 299) { if (!$response->getBody()->getSize()) { throw new BadResponseException('unexpected empty body'); } return; } // Mitake API always return status code 200 throw new BadResponseException(sprintf('unexpected status code: %d', $statusCode)); }
php
protected function checkErrorResponse(ResponseInterface $response) { $statusCode = $response->getStatusCode(); if (200 <= $statusCode && $statusCode < 299) { if (!$response->getBody()->getSize()) { throw new BadResponseException('unexpected empty body'); } return; } // Mitake API always return status code 200 throw new BadResponseException(sprintf('unexpected status code: %d', $statusCode)); }
[ "protected", "function", "checkErrorResponse", "(", "ResponseInterface", "$", "response", ")", "{", "$", "statusCode", "=", "$", "response", "->", "getStatusCode", "(", ")", ";", "if", "(", "200", "<=", "$", "statusCode", "&&", "$", "statusCode", "<", "299",...
Check the API response for errors @param ResponseInterface $response @throws BadResponseException
[ "Check", "the", "API", "response", "for", "errors" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/Client.php#L276-L289
38,678
minchao/mitake-php
src/API.php
API.sendBatch
public function sendBatch(array $messages) { $body = ''; /** @var Message\Message $message */ foreach ($messages as $i => $message) { if (!$message instanceof Message\Message) { throw new InvalidArgumentException(); } $body .= "[{$i}]\n"; $body .= $message->toINI(); } $body = trim($body); $request = $this->client->newRequest( 'POST', $this->client->buildUriWithQuery('/SmSendPost.asp', ['encoding' => 'UTF8']), 'text/plain', $body ); $response = $this->client->sendRequest($request); return $this->parseMessageResponse($response); }
php
public function sendBatch(array $messages) { $body = ''; /** @var Message\Message $message */ foreach ($messages as $i => $message) { if (!$message instanceof Message\Message) { throw new InvalidArgumentException(); } $body .= "[{$i}]\n"; $body .= $message->toINI(); } $body = trim($body); $request = $this->client->newRequest( 'POST', $this->client->buildUriWithQuery('/SmSendPost.asp', ['encoding' => 'UTF8']), 'text/plain', $body ); $response = $this->client->sendRequest($request); return $this->parseMessageResponse($response); }
[ "public", "function", "sendBatch", "(", "array", "$", "messages", ")", "{", "$", "body", "=", "''", ";", "/** @var Message\\Message $message */", "foreach", "(", "$", "messages", "as", "$", "i", "=>", "$", "message", ")", "{", "if", "(", "!", "$", "messa...
Send multiple SMS @param Message\Message[] $messages @return Message\Response @throws Exception\BadResponseException @throws InvalidArgumentException @throws \GuzzleHttp\Exception\GuzzleException
[ "Send", "multiple", "SMS" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/API.php#L38-L62
38,679
minchao/mitake-php
src/API.php
API.queryAccountPoint
public function queryAccountPoint() { $request = $this->client->newRequest( 'GET', $this->client->buildUriWithQuery('/SmQueryGet.asp') ); $response = $this->client->sendRequest($request); $contents = $response->getBody()->getContents(); $data = explode("=", $contents); return $data[1]; }
php
public function queryAccountPoint() { $request = $this->client->newRequest( 'GET', $this->client->buildUriWithQuery('/SmQueryGet.asp') ); $response = $this->client->sendRequest($request); $contents = $response->getBody()->getContents(); $data = explode("=", $contents); return $data[1]; }
[ "public", "function", "queryAccountPoint", "(", ")", "{", "$", "request", "=", "$", "this", "->", "client", "->", "newRequest", "(", "'GET'", ",", "$", "this", "->", "client", "->", "buildUriWithQuery", "(", "'/SmQueryGet.asp'", ")", ")", ";", "$", "respon...
Retrieve your account balance @return integer @throws Exception\BadResponseException @throws \GuzzleHttp\Exception\GuzzleException
[ "Retrieve", "your", "account", "balance" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/API.php#L131-L143
38,680
minchao/mitake-php
src/API.php
API.queryMessageStatus
public function queryMessageStatus(array $ids) { $request = $this->client->newRequest( 'GET', $this->client->buildUriWithQuery('/SmQueryGet.asp', ['msgid' => implode(',', $ids)]) ); $response = $this->client->sendRequest($request); return $this->parseMessageStatusResponse($response); }
php
public function queryMessageStatus(array $ids) { $request = $this->client->newRequest( 'GET', $this->client->buildUriWithQuery('/SmQueryGet.asp', ['msgid' => implode(',', $ids)]) ); $response = $this->client->sendRequest($request); return $this->parseMessageStatusResponse($response); }
[ "public", "function", "queryMessageStatus", "(", "array", "$", "ids", ")", "{", "$", "request", "=", "$", "this", "->", "client", "->", "newRequest", "(", "'GET'", ",", "$", "this", "->", "client", "->", "buildUriWithQuery", "(", "'/SmQueryGet.asp'", ",", ...
Fetch the status of specific messages @param string[] $ids @return Message\StatusResponse @throws Exception\BadResponseException @throws InvalidArgumentException @throws \GuzzleHttp\Exception\GuzzleException
[ "Fetch", "the", "status", "of", "specific", "messages" ]
23d2a17660ea58fb63ee08bd6cd495fe6da526f5
https://github.com/minchao/mitake-php/blob/23d2a17660ea58fb63ee08bd6cd495fe6da526f5/src/API.php#L154-L164
38,681
estahn/phpunit-json-assertions
src/Extension/Symfony.php
Symfony.assertJsonResponse
public static function assertJsonResponse(Response $response, $statusCode = 200) { \PHPUnit\Framework\Assert::assertEquals( $statusCode, $response->getStatusCode(), $response->getContent() ); \PHPUnit\Framework\Assert::assertTrue( $response->headers->contains('Content-Type', 'application/json'), $response->headers ); }
php
public static function assertJsonResponse(Response $response, $statusCode = 200) { \PHPUnit\Framework\Assert::assertEquals( $statusCode, $response->getStatusCode(), $response->getContent() ); \PHPUnit\Framework\Assert::assertTrue( $response->headers->contains('Content-Type', 'application/json'), $response->headers ); }
[ "public", "static", "function", "assertJsonResponse", "(", "Response", "$", "response", ",", "$", "statusCode", "=", "200", ")", "{", "\\", "PHPUnit", "\\", "Framework", "\\", "Assert", "::", "assertEquals", "(", "$", "statusCode", ",", "$", "response", "->"...
Asserts that a response is successful and of type json. @param Response $response Response object @param int $statusCode Expected status code (default 200) @see \Bazinga\Bundle\RestExtraBundle\Test\WebTestCase::assertJsonResponse()
[ "Asserts", "that", "a", "response", "is", "successful", "and", "of", "type", "json", "." ]
e75e20ddec1072656e99db48e489455609912319
https://github.com/estahn/phpunit-json-assertions/blob/e75e20ddec1072656e99db48e489455609912319/src/Extension/Symfony.php#L70-L81
38,682
whitemerry/phpkin
src/Span.php
Span.toArray
public function toArray() { $span = [ 'id' => (string) $this->id, 'traceId' => (string) $this->traceId, 'name' => $this->name, 'timestamp' => $this->annotationBlock->getStartTimestamp(), 'duration' => $this->annotationBlock->getDuration(), 'annotations' => $this->annotationBlock->toArray() ]; if ($this->parentId !== null) { $span['parentId'] = (string) $this->parentId; } if ($this->metadata !== null) { $span['binaryAnnotations'] = $this->metadata->toArray(); } return $span; }
php
public function toArray() { $span = [ 'id' => (string) $this->id, 'traceId' => (string) $this->traceId, 'name' => $this->name, 'timestamp' => $this->annotationBlock->getStartTimestamp(), 'duration' => $this->annotationBlock->getDuration(), 'annotations' => $this->annotationBlock->toArray() ]; if ($this->parentId !== null) { $span['parentId'] = (string) $this->parentId; } if ($this->metadata !== null) { $span['binaryAnnotations'] = $this->metadata->toArray(); } return $span; }
[ "public", "function", "toArray", "(", ")", "{", "$", "span", "=", "[", "'id'", "=>", "(", "string", ")", "$", "this", "->", "id", ",", "'traceId'", "=>", "(", "string", ")", "$", "this", "->", "traceId", ",", "'name'", "=>", "$", "this", "->", "n...
Converts Span to array @return array
[ "Converts", "Span", "to", "array" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/Span.php#L76-L96
38,683
whitemerry/phpkin
src/Span.php
Span.setMetadata
protected function setMetadata($metadata) { if ($metadata !== null && !($metadata instanceof Metadata)) { throw new \InvalidArgumentException('$metadata must be instance of Metadata'); } $this->metadata = $metadata; }
php
protected function setMetadata($metadata) { if ($metadata !== null && !($metadata instanceof Metadata)) { throw new \InvalidArgumentException('$metadata must be instance of Metadata'); } $this->metadata = $metadata; }
[ "protected", "function", "setMetadata", "(", "$", "metadata", ")", "{", "if", "(", "$", "metadata", "!==", "null", "&&", "!", "(", "$", "metadata", "instanceof", "Metadata", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$metadata mu...
Valid and set metadata @param $metadata Metadata @throws \InvalidArgumentException
[ "Valid", "and", "set", "metadata" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/Span.php#L145-L152
38,684
whitemerry/phpkin
src/Tracer.php
Tracer.addTraceSpan
protected function addTraceSpan($unsetParentId = true) { $span = new Span( TracerInfo::getTraceSpanId(), $this->name, new AnnotationBlock( $this->endpoint, $this->startTimestamp, zipkin_timestamp(), AnnotationBlock::SERVER ) ); if ($unsetParentId) { $span->unsetParentId(); } $this->addSpan($span); }
php
protected function addTraceSpan($unsetParentId = true) { $span = new Span( TracerInfo::getTraceSpanId(), $this->name, new AnnotationBlock( $this->endpoint, $this->startTimestamp, zipkin_timestamp(), AnnotationBlock::SERVER ) ); if ($unsetParentId) { $span->unsetParentId(); } $this->addSpan($span); }
[ "protected", "function", "addTraceSpan", "(", "$", "unsetParentId", "=", "true", ")", "{", "$", "span", "=", "new", "Span", "(", "TracerInfo", "::", "getTraceSpanId", "(", ")", ",", "$", "this", "->", "name", ",", "new", "AnnotationBlock", "(", "$", "thi...
Adds main span to Spans @param $unsetParentId bool are you frontend?
[ "Adds", "main", "span", "to", "Spans" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/Tracer.php#L124-L140
38,685
whitemerry/phpkin
src/AnnotationBlock.php
AnnotationBlock.toArray
public function toArray() { return [ [ 'endpoint' => $this->endpoint->toArray(), 'timestamp' => $this->startTimestamp, 'value' => $this->values[0] ], [ 'endpoint' => $this->endpoint->toArray(), 'timestamp' => $this->endTimestamp, 'value' => $this->values[1] ] ]; }
php
public function toArray() { return [ [ 'endpoint' => $this->endpoint->toArray(), 'timestamp' => $this->startTimestamp, 'value' => $this->values[0] ], [ 'endpoint' => $this->endpoint->toArray(), 'timestamp' => $this->endTimestamp, 'value' => $this->values[1] ] ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "[", "'endpoint'", "=>", "$", "this", "->", "endpoint", "->", "toArray", "(", ")", ",", "'timestamp'", "=>", "$", "this", "->", "startTimestamp", ",", "'value'", "=>", "$", "this", "->", "v...
AnnotationBlock to array @return array
[ "AnnotationBlock", "to", "array" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/AnnotationBlock.php#L77-L91
38,686
whitemerry/phpkin
src/AnnotationBlock.php
AnnotationBlock.setValues
protected function setValues($type) { switch ($type) { case static::CLIENT: $this->values = ['cs', 'cr']; break; case static::SERVER: $this->values = ['sr', 'ss']; break; default: throw new \InvalidArgumentException('$type must be TYPE_CLIENT or TYPE_SERVER'); } }
php
protected function setValues($type) { switch ($type) { case static::CLIENT: $this->values = ['cs', 'cr']; break; case static::SERVER: $this->values = ['sr', 'ss']; break; default: throw new \InvalidArgumentException('$type must be TYPE_CLIENT or TYPE_SERVER'); } }
[ "protected", "function", "setValues", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "static", "::", "CLIENT", ":", "$", "this", "->", "values", "=", "[", "'cs'", ",", "'cr'", "]", ";", "break", ";", "case", "static", "::...
Valid type and set annotation types @param $type string @throws \InvalidArgumentException
[ "Valid", "type", "and", "set", "annotation", "types" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/AnnotationBlock.php#L100-L112
38,687
whitemerry/phpkin
src/AnnotationBlock.php
AnnotationBlock.setTimestamp
protected function setTimestamp($field, $timestamp, $now = false) { if ($timestamp === null && $now) { $this->{$field} = zipkin_timestamp(); return null; } if (!is_zipkin_timestamp($timestamp)) { throw new \InvalidArgumentException($field . ' must be generated by zipkin_timestamp()'); } $this->{$field} = $timestamp; return null; }
php
protected function setTimestamp($field, $timestamp, $now = false) { if ($timestamp === null && $now) { $this->{$field} = zipkin_timestamp(); return null; } if (!is_zipkin_timestamp($timestamp)) { throw new \InvalidArgumentException($field . ' must be generated by zipkin_timestamp()'); } $this->{$field} = $timestamp; return null; }
[ "protected", "function", "setTimestamp", "(", "$", "field", ",", "$", "timestamp", ",", "$", "now", "=", "false", ")", "{", "if", "(", "$", "timestamp", "===", "null", "&&", "$", "now", ")", "{", "$", "this", "->", "{", "$", "field", "}", "=", "z...
Valid and set timestamp @param $field string @param $timestamp int @param $now bool @throws \InvalidArgumentException @return null
[ "Valid", "and", "set", "timestamp" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/AnnotationBlock.php#L141-L154
38,688
unicodeveloper/laravel-mentions
src/MentionServiceProvider.php
MentionServiceProvider.boot
public function boot() { $config = realpath(__DIR__.'/../resources/config/mentions.php'); $views = realpath(__DIR__.'/../resources/views'); $script = realpath(__DIR__.'/../resources/assets'); $this->publishes([ $config => config_path('mentions.php'), $views => base_path('resources/views/vendor/mentions'), $script => public_path('js'), ]); $this->loadViewsFrom(__DIR__.'/../resources/views', 'mentions'); if (! $this->app->routesAreCached()) { require __DIR__.'/Http/routes.php'; } }
php
public function boot() { $config = realpath(__DIR__.'/../resources/config/mentions.php'); $views = realpath(__DIR__.'/../resources/views'); $script = realpath(__DIR__.'/../resources/assets'); $this->publishes([ $config => config_path('mentions.php'), $views => base_path('resources/views/vendor/mentions'), $script => public_path('js'), ]); $this->loadViewsFrom(__DIR__.'/../resources/views', 'mentions'); if (! $this->app->routesAreCached()) { require __DIR__.'/Http/routes.php'; } }
[ "public", "function", "boot", "(", ")", "{", "$", "config", "=", "realpath", "(", "__DIR__", ".", "'/../resources/config/mentions.php'", ")", ";", "$", "views", "=", "realpath", "(", "__DIR__", ".", "'/../resources/views'", ")", ";", "$", "script", "=", "rea...
Publishes all the assets this package needs to function and load all routes @return [type] [description]
[ "Publishes", "all", "the", "assets", "this", "package", "needs", "to", "function", "and", "load", "all", "routes" ]
e58e38b6b08f0d165cf9e7f5a510efc2eb0e635d
https://github.com/unicodeveloper/laravel-mentions/blob/e58e38b6b08f0d165cf9e7f5a510efc2eb0e635d/src/MentionServiceProvider.php#L22-L39
38,689
whitemerry/phpkin
src/Metadata.php
Metadata.set
public function set($key, $value) { if (!is_string($key)) { throw new \InvalidArgumentException('$key must be string'); } if (!is_string($value) && !is_numeric($value) && !is_bool($value)) { throw new \InvalidArgumentException('$value must be string, int or bool'); } $this->annotations[] = [ 'key' => $key, 'value' => (string) $value ]; }
php
public function set($key, $value) { if (!is_string($key)) { throw new \InvalidArgumentException('$key must be string'); } if (!is_string($value) && !is_numeric($value) && !is_bool($value)) { throw new \InvalidArgumentException('$value must be string, int or bool'); } $this->annotations[] = [ 'key' => $key, 'value' => (string) $value ]; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$key must be string'", ")", ";", "}", "if", "(", "!", "is...
Set meta annotation @param $key string @param $value string|int|float|bool @throws \InvalidArgumentException
[ "Set", "meta", "annotation" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/Metadata.php#L81-L95
38,690
whitemerry/phpkin
src/Endpoint.php
Endpoint.setIp
protected function setIp($ip) { if (filter_var($ip, FILTER_VALIDATE_IP) === false) { throw new \InvalidArgumentException('$ip must be correct'); } $this->ip = $ip; }
php
protected function setIp($ip) { if (filter_var($ip, FILTER_VALIDATE_IP) === false) { throw new \InvalidArgumentException('$ip must be correct'); } $this->ip = $ip; }
[ "protected", "function", "setIp", "(", "$", "ip", ")", "{", "if", "(", "filter_var", "(", "$", "ip", ",", "FILTER_VALIDATE_IP", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$ip must be correct'", ")", ";", "}", "$...
Valid and set ip @param $ip string @throws \InvalidArgumentException
[ "Valid", "and", "set", "ip" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/Endpoint.php#L78-L85
38,691
whitemerry/phpkin
src/TracerInfo.php
TracerInfo.setSampled
protected static function setSampled($sampler) { if ($sampler === null) { static::$sampled = true; return null; } if (is_bool($sampler)) { static::$sampled = $sampler; return null; } if (!is_bool($sampler) && !($sampler instanceof Sampler)) { throw new \InvalidArgumentException('$sampler must be instance of Sampler or boolean'); } static::$sampled = $sampler->isSampled(); return null; }
php
protected static function setSampled($sampler) { if ($sampler === null) { static::$sampled = true; return null; } if (is_bool($sampler)) { static::$sampled = $sampler; return null; } if (!is_bool($sampler) && !($sampler instanceof Sampler)) { throw new \InvalidArgumentException('$sampler must be instance of Sampler or boolean'); } static::$sampled = $sampler->isSampled(); return null; }
[ "protected", "static", "function", "setSampled", "(", "$", "sampler", ")", "{", "if", "(", "$", "sampler", "===", "null", ")", "{", "static", "::", "$", "sampled", "=", "true", ";", "return", "null", ";", "}", "if", "(", "is_bool", "(", "$", "sampler...
Valid and set sampled @param $sampler Sampler|bool @throws \InvalidArgumentException @return null
[ "Valid", "and", "set", "sampled" ]
5dcd9e4e8b7c7244539830669aefdea924902d8f
https://github.com/whitemerry/phpkin/blob/5dcd9e4e8b7c7244539830669aefdea924902d8f/src/TracerInfo.php#L91-L109
38,692
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Activity/Starring.php
Starring.listRepositories
public function listRepositories(string $sort = AbstractApi::SORT_CREATED, string $direction = AbstractApi::DIRECTION_DESC, string $username = null): array { if (null !== $username) { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/starred?:args', $username, http_build_query(['sort' => $sort, 'direction' => $direction]))); } return $this->getApi()->request($this->getApi()->sprintf('/user/starred?:args', http_build_query(['sort' => $sort, 'direction' => $direction]))); }
php
public function listRepositories(string $sort = AbstractApi::SORT_CREATED, string $direction = AbstractApi::DIRECTION_DESC, string $username = null): array { if (null !== $username) { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/starred?:args', $username, http_build_query(['sort' => $sort, 'direction' => $direction]))); } return $this->getApi()->request($this->getApi()->sprintf('/user/starred?:args', http_build_query(['sort' => $sort, 'direction' => $direction]))); }
[ "public", "function", "listRepositories", "(", "string", "$", "sort", "=", "AbstractApi", "::", "SORT_CREATED", ",", "string", "$", "direction", "=", "AbstractApi", "::", "DIRECTION_DESC", ",", "string", "$", "username", "=", "null", ")", ":", "array", "{", ...
List repositories being starred @link https://developer.github.com/v3/activity/starring/#list-repositories-being-starred @param string $sort @param string $direction @param string $username @return array
[ "List", "repositories", "being", "starred" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Starring.php#L39-L49
38,693
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Activity/Starring.php
Starring.checkYouAreStarringRepository
public function checkYouAreStarringRepository(): bool { $this->getApi()->request($this->getApi() ->sprintf('/user/starred/:owner/:repo', $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { return true; } return false; }
php
public function checkYouAreStarringRepository(): bool { $this->getApi()->request($this->getApi() ->sprintf('/user/starred/:owner/:repo', $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { return true; } return false; }
[ "public", "function", "checkYouAreStarringRepository", "(", ")", ":", "bool", "{", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/user/starred/:owner/:repo'", ",", "$", "this", "...
Check if you are starring a repository @link https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository @return bool
[ "Check", "if", "you", "are", "starring", "a", "repository" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Activity/Starring.php#L57-L68
38,694
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Users/PublicKeys.php
PublicKeys.listUserPublicKeys
public function listUserPublicKeys(string $username): array { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/keys', $username)); }
php
public function listUserPublicKeys(string $username): array { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/keys', $username)); }
[ "public", "function", "listUserPublicKeys", "(", "string", "$", "username", ")", ":", "array", "{", "return", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/users/:username/keys'...
List public keys for a user @link https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user @param string $username @return array @throws \Exception
[ "List", "public", "keys", "for", "a", "user" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Users/PublicKeys.php#L25-L28
38,695
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Users/PublicKeys.php
PublicKeys.getSinglePublicKey
public function getSinglePublicKey(int $id): array { return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id)); }
php
public function getSinglePublicKey(int $id): array { return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id)); }
[ "public", "function", "getSinglePublicKey", "(", "int", "$", "id", ")", ":", "array", "{", "return", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/user/keys/:id'", ",", "(",...
Get a single public key @link https://developer.github.com/v3/users/keys/#get-a-single-public-key @param int $id @return array @throws \Exception
[ "Get", "a", "single", "public", "key" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Users/PublicKeys.php#L52-L55
38,696
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Users/PublicKeys.php
PublicKeys.deletePublicKey
public function deletePublicKey(int $id): array { return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id), Request::METHOD_DELETE); }
php
public function deletePublicKey(int $id): array { return $this->getApi()->request($this->getApi()->sprintf('/user/keys/:id', (string)$id), Request::METHOD_DELETE); }
[ "public", "function", "deletePublicKey", "(", "int", "$", "id", ")", ":", "array", "{", "return", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/user/keys/:id'", ",", "(", ...
Delete a public key @link https://developer.github.com/v3/users/keys/#delete-a-public-key @param int $id @return array @throws \Exception
[ "Delete", "a", "public", "key" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Users/PublicKeys.php#L79-L83
38,697
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Organizations.php
Organizations.listUserOrganizations
public function listUserOrganizations(string $username): array { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/orgs', $username)); }
php
public function listUserOrganizations(string $username): array { return $this->getApi()->request($this->getApi()->sprintf('/users/:username/orgs', $username)); }
[ "public", "function", "listUserOrganizations", "(", "string", "$", "username", ")", ":", "array", "{", "return", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/users/:username/or...
List user organizations @link https://developer.github.com/v3/orgs/#list-user-organizations @param string $username @return array @throws \Exception
[ "List", "user", "organizations" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Organizations.php#L42-L45
38,698
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Organizations.php
Organizations.get
public function get(string $org): array { return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org', $org)); }
php
public function get(string $org): array { return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org', $org)); }
[ "public", "function", "get", "(", "string", "$", "org", ")", ":", "array", "{", "return", "$", "this", "->", "getApi", "(", ")", "->", "request", "(", "$", "this", "->", "getApi", "(", ")", "->", "sprintf", "(", "'/orgs/:org'", ",", "$", "org", ")"...
Get an organization @link https://developer.github.com/v3/orgs/#get-an-organization @param string $org @return array @throws \Exception
[ "Get", "an", "organization" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Organizations.php#L57-L60
38,699
FlexyProject/GitHubAPI
lib/GitHub/Receiver/Organizations.php
Organizations.edit
public function edit(string $org, string $billingEmail = null, string $company = null, string $email = null, string $location = null, string $name = null, string $description = null): array { return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org', $org), Request::METHOD_PATCH, [ 'billing_email' => $billingEmail, 'company' => $company, 'email' => $email, 'location' => $location, 'name' => $name, 'description' => $description ]); }
php
public function edit(string $org, string $billingEmail = null, string $company = null, string $email = null, string $location = null, string $name = null, string $description = null): array { return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org', $org), Request::METHOD_PATCH, [ 'billing_email' => $billingEmail, 'company' => $company, 'email' => $email, 'location' => $location, 'name' => $name, 'description' => $description ]); }
[ "public", "function", "edit", "(", "string", "$", "org", ",", "string", "$", "billingEmail", "=", "null", ",", "string", "$", "company", "=", "null", ",", "string", "$", "email", "=", "null", ",", "string", "$", "location", "=", "null", ",", "string", ...
Edit an organization @link https://developer.github.com/v3/orgs/#edit-an-organization @param string $org @param string $billingEmail @param string $company @param string $email @param string $location @param string $name @param string $description @return array @throws \Exception
[ "Edit", "an", "organization" ]
cb5044443daf138787a7feb9aa9bf50220a44fd6
https://github.com/FlexyProject/GitHubAPI/blob/cb5044443daf138787a7feb9aa9bf50220a44fd6/lib/GitHub/Receiver/Organizations.php#L78-L89