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
233,300
joomla-framework/twitter-api
src/Lists.php
Lists.isMember
public function isMember($list, $user, $owner = null, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('lists', 'members/show'); // Determine which type of data was passed for $list if (is_numeric($list)) { $data['list_id'] = $list; } elseif (\is_string($list)) { $data['slug'] = $list; // In this case the owner is required. if (is_numeric($owner)) { $data['owner_id'] = $owner; } elseif (\is_string($owner)) { $data['owner_screen_name'] = $owner; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } } else { // We don't have a valid entry throw new \RuntimeException('The specified list is not in the correct format; must use integer or string'); } if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Set the API path $path = '/lists/members/show.json'; // Check if entities is specified if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function isMember($list, $user, $owner = null, $entities = null, $skipStatus = null) { // Check the rate limit for remaining hits $this->checkRateLimit('lists', 'members/show'); // Determine which type of data was passed for $list if (is_numeric($list)) { $data['list_id'] = $list; } elseif (\is_string($list)) { $data['slug'] = $list; // In this case the owner is required. if (is_numeric($owner)) { $data['owner_id'] = $owner; } elseif (\is_string($owner)) { $data['owner_screen_name'] = $owner; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } } else { // We don't have a valid entry throw new \RuntimeException('The specified list is not in the correct format; must use integer or string'); } if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } // Set the API path $path = '/lists/members/show.json'; // Check if entities is specified if ($entities !== null) { $data['include_entities'] = $entities; } // Check if skip_status is specified if ($skipStatus !== null) { $data['skip_status'] = $skipStatus; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "isMember", "(", "$", "list", ",", "$", "user", ",", "$", "owner", "=", "null", ",", "$", "entities", "=", "null", ",", "$", "skipStatus", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'lists'", ",", "'members/show'", ")", ";", "// Determine which type of data was passed for $list", "if", "(", "is_numeric", "(", "$", "list", ")", ")", "{", "$", "data", "[", "'list_id'", "]", "=", "$", "list", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "list", ")", ")", "{", "$", "data", "[", "'slug'", "]", "=", "$", "list", ";", "// In this case the owner is required.", "if", "(", "is_numeric", "(", "$", "owner", ")", ")", "{", "$", "data", "[", "'owner_id'", "]", "=", "$", "owner", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "owner", ")", ")", "{", "$", "data", "[", "'owner_screen_name'", "]", "=", "$", "owner", ";", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'The specified username is not in the correct format; must use integer or string'", ")", ";", "}", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'The specified list is not in the correct format; must use integer or string'", ")", ";", "}", "if", "(", "is_numeric", "(", "$", "user", ")", ")", "{", "$", "data", "[", "'user_id'", "]", "=", "$", "user", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "user", ")", ")", "{", "$", "data", "[", "'screen_name'", "]", "=", "$", "user", ";", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'The specified username is not in the correct format; must use integer or string'", ")", ";", "}", "// Set the API path", "$", "path", "=", "'/lists/members/show.json'", ";", "// Check if entities is specified", "if", "(", "$", "entities", "!==", "null", ")", "{", "$", "data", "[", "'include_entities'", "]", "=", "$", "entities", ";", "}", "// Check if skip_status is specified", "if", "(", "$", "skipStatus", "!==", "null", ")", "{", "$", "data", "[", "'skip_status'", "]", "=", "$", "skipStatus", ";", "}", "// Send the request.", "return", "$", "this", "->", "sendRequest", "(", "$", "path", ",", "'GET'", ",", "$", "data", ")", ";", "}" ]
Method to check if the specified user is a member of the specified list. @param mixed $list Either an integer containing the list ID or a string containing the list slug. @param mixed $user Either an integer containing the user ID or a string containing the screen name of the user to remove. @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner. @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects. @return array The decoded JSON response @since 1.0 @throws \RuntimeException
[ "Method", "to", "check", "if", "the", "specified", "user", "is", "a", "member", "of", "the", "specified", "list", "." ]
289719bbd67e83c7cfaf515b94b1d5497b1f0525
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Lists.php#L481-L547
233,301
joomla-framework/twitter-api
src/Lists.php
Lists.update
public function update($list, $owner = null, $name = null, $mode = null, $description = null) { // Check the rate limit for remaining hits $this->checkRateLimit('lists', 'update'); // Determine which type of data was passed for $list if (is_numeric($list)) { $data['list_id'] = $list; } elseif (\is_string($list)) { $data['slug'] = $list; // In this case the owner is required. if (is_numeric($owner)) { $data['owner_id'] = $owner; } elseif (\is_string($owner)) { $data['owner_screen_name'] = $owner; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } } else { // We don't have a valid entry throw new \RuntimeException('The specified list is not in the correct format; must use integer or string'); } // Check if name is specified. if ($name) { $data['name'] = $name; } // Check if mode is specified. if ($mode) { $data['mode'] = $mode; } // Check if description is specified. if ($description) { $data['description'] = $description; } // Set the API path $path = '/lists/update.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function update($list, $owner = null, $name = null, $mode = null, $description = null) { // Check the rate limit for remaining hits $this->checkRateLimit('lists', 'update'); // Determine which type of data was passed for $list if (is_numeric($list)) { $data['list_id'] = $list; } elseif (\is_string($list)) { $data['slug'] = $list; // In this case the owner is required. if (is_numeric($owner)) { $data['owner_id'] = $owner; } elseif (\is_string($owner)) { $data['owner_screen_name'] = $owner; } else { // We don't have a valid entry throw new \RuntimeException('The specified username is not in the correct format; must use integer or string'); } } else { // We don't have a valid entry throw new \RuntimeException('The specified list is not in the correct format; must use integer or string'); } // Check if name is specified. if ($name) { $data['name'] = $name; } // Check if mode is specified. if ($mode) { $data['mode'] = $mode; } // Check if description is specified. if ($description) { $data['description'] = $description; } // Set the API path $path = '/lists/update.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "update", "(", "$", "list", ",", "$", "owner", "=", "null", ",", "$", "name", "=", "null", ",", "$", "mode", "=", "null", ",", "$", "description", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'lists'", ",", "'update'", ")", ";", "// Determine which type of data was passed for $list", "if", "(", "is_numeric", "(", "$", "list", ")", ")", "{", "$", "data", "[", "'list_id'", "]", "=", "$", "list", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "list", ")", ")", "{", "$", "data", "[", "'slug'", "]", "=", "$", "list", ";", "// In this case the owner is required.", "if", "(", "is_numeric", "(", "$", "owner", ")", ")", "{", "$", "data", "[", "'owner_id'", "]", "=", "$", "owner", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "owner", ")", ")", "{", "$", "data", "[", "'owner_screen_name'", "]", "=", "$", "owner", ";", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'The specified username is not in the correct format; must use integer or string'", ")", ";", "}", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'The specified list is not in the correct format; must use integer or string'", ")", ";", "}", "// Check if name is specified.", "if", "(", "$", "name", ")", "{", "$", "data", "[", "'name'", "]", "=", "$", "name", ";", "}", "// Check if mode is specified.", "if", "(", "$", "mode", ")", "{", "$", "data", "[", "'mode'", "]", "=", "$", "mode", ";", "}", "// Check if description is specified.", "if", "(", "$", "description", ")", "{", "$", "data", "[", "'description'", "]", "=", "$", "description", ";", "}", "// Set the API path", "$", "path", "=", "'/lists/update.json'", ";", "// Send the request.", "return", "$", "this", "->", "sendRequest", "(", "$", "path", ",", "'POST'", ",", "$", "data", ")", ";", "}" ]
Method to update the specified list @param mixed $list Either an integer containing the list ID or a string containing the list slug. @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner. @param string $name The name of the list. @param string $mode Whether your list is public or private. Values can be public or private. If no mode is specified the list will be public. @param string $description The description to give the list. @return array The decoded JSON response @since 1.0 @throws \RuntimeException
[ "Method", "to", "update", "the", "specified", "list" ]
289719bbd67e83c7cfaf515b94b1d5497b1f0525
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Lists.php#L994-L1052
233,302
diemuzi/mp3
src/Mp3/Service/Index.php
Index.playSingle
public function playSingle($base64) { try { /** * Decode Path */ $base64 = base64_decode($base64); /** * Path to File on Disk */ $path = $this->getSearchPath() . '/' . $base64; /** * Path to Web URL */ $file = ltrim($this->getBaseDir() . '/' . $base64, '/'); /** * Server URL */ $serverUrl = $this->serverUrl->get('serverurl') ->__invoke('/'); clearstatcache(); if (is_file($path)) { switch ($this->getFormat()) { /** * The most common playlist format */ case 'm3u': header("Content-Type: audio/mpegurl"); header("Content-Disposition: attachment; filename=" . basename($file) . ".m3u"); echo $serverUrl . str_replace(' ', '%20', $file); exit; break; /** * Shoutcast / Icecast / Winamp */ case 'pls': header("Content-Type: audio/x-scpls"); header("Content-Disposition: attachment; filename=" . basename($file) . ".pls"); $id3 = $this->getId3($path); $name = !empty($id3['comments_html']['title']) ? implode( '<br>', $id3['comments_html']['title'] ) : basename($path); $playlist = '[Playlist]' . "\n"; $playlist .= 'File1=' . $serverUrl . str_replace(' ', '%20', $file) . "\n"; $playlist .= 'Title1=' . $name . "\n"; $playlist .= 'Length1=-1' . "\n"; $playlist .= 'Numberofentries=1' . "\n"; $playlist .= 'Version=2' . "\n"; echo $playlist; exit; break; /** * Error */ default: throw new \Exception( $this->translate->translate( 'Format is not currently supported. Supported formats are: pls, m3u', 'mp3' ) ); } } else { throw new \Exception( $path . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } catch (\Exception $e) { throw $e; } }
php
public function playSingle($base64) { try { /** * Decode Path */ $base64 = base64_decode($base64); /** * Path to File on Disk */ $path = $this->getSearchPath() . '/' . $base64; /** * Path to Web URL */ $file = ltrim($this->getBaseDir() . '/' . $base64, '/'); /** * Server URL */ $serverUrl = $this->serverUrl->get('serverurl') ->__invoke('/'); clearstatcache(); if (is_file($path)) { switch ($this->getFormat()) { /** * The most common playlist format */ case 'm3u': header("Content-Type: audio/mpegurl"); header("Content-Disposition: attachment; filename=" . basename($file) . ".m3u"); echo $serverUrl . str_replace(' ', '%20', $file); exit; break; /** * Shoutcast / Icecast / Winamp */ case 'pls': header("Content-Type: audio/x-scpls"); header("Content-Disposition: attachment; filename=" . basename($file) . ".pls"); $id3 = $this->getId3($path); $name = !empty($id3['comments_html']['title']) ? implode( '<br>', $id3['comments_html']['title'] ) : basename($path); $playlist = '[Playlist]' . "\n"; $playlist .= 'File1=' . $serverUrl . str_replace(' ', '%20', $file) . "\n"; $playlist .= 'Title1=' . $name . "\n"; $playlist .= 'Length1=-1' . "\n"; $playlist .= 'Numberofentries=1' . "\n"; $playlist .= 'Version=2' . "\n"; echo $playlist; exit; break; /** * Error */ default: throw new \Exception( $this->translate->translate( 'Format is not currently supported. Supported formats are: pls, m3u', 'mp3' ) ); } } else { throw new \Exception( $path . ' ' . $this->translate->translate( 'was not found', 'mp3' ) ); } } catch (\Exception $e) { throw $e; } }
[ "public", "function", "playSingle", "(", "$", "base64", ")", "{", "try", "{", "/**\n * Decode Path\n */", "$", "base64", "=", "base64_decode", "(", "$", "base64", ")", ";", "/**\n * Path to File on Disk\n */", "$", "path", "=", "$", "this", "->", "getSearchPath", "(", ")", ".", "'/'", ".", "$", "base64", ";", "/**\n * Path to Web URL\n */", "$", "file", "=", "ltrim", "(", "$", "this", "->", "getBaseDir", "(", ")", ".", "'/'", ".", "$", "base64", ",", "'/'", ")", ";", "/**\n * Server URL\n */", "$", "serverUrl", "=", "$", "this", "->", "serverUrl", "->", "get", "(", "'serverurl'", ")", "->", "__invoke", "(", "'/'", ")", ";", "clearstatcache", "(", ")", ";", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "switch", "(", "$", "this", "->", "getFormat", "(", ")", ")", "{", "/**\n * The most common playlist format\n */", "case", "'m3u'", ":", "header", "(", "\"Content-Type: audio/mpegurl\"", ")", ";", "header", "(", "\"Content-Disposition: attachment; filename=\"", ".", "basename", "(", "$", "file", ")", ".", "\".m3u\"", ")", ";", "echo", "$", "serverUrl", ".", "str_replace", "(", "' '", ",", "'%20'", ",", "$", "file", ")", ";", "exit", ";", "break", ";", "/**\n * Shoutcast / Icecast / Winamp\n */", "case", "'pls'", ":", "header", "(", "\"Content-Type: audio/x-scpls\"", ")", ";", "header", "(", "\"Content-Disposition: attachment; filename=\"", ".", "basename", "(", "$", "file", ")", ".", "\".pls\"", ")", ";", "$", "id3", "=", "$", "this", "->", "getId3", "(", "$", "path", ")", ";", "$", "name", "=", "!", "empty", "(", "$", "id3", "[", "'comments_html'", "]", "[", "'title'", "]", ")", "?", "implode", "(", "'<br>'", ",", "$", "id3", "[", "'comments_html'", "]", "[", "'title'", "]", ")", ":", "basename", "(", "$", "path", ")", ";", "$", "playlist", "=", "'[Playlist]'", ".", "\"\\n\"", ";", "$", "playlist", ".=", "'File1='", ".", "$", "serverUrl", ".", "str_replace", "(", "' '", ",", "'%20'", ",", "$", "file", ")", ".", "\"\\n\"", ";", "$", "playlist", ".=", "'Title1='", ".", "$", "name", ".", "\"\\n\"", ";", "$", "playlist", ".=", "'Length1=-1'", ".", "\"\\n\"", ";", "$", "playlist", ".=", "'Numberofentries=1'", ".", "\"\\n\"", ";", "$", "playlist", ".=", "'Version=2'", ".", "\"\\n\"", ";", "echo", "$", "playlist", ";", "exit", ";", "break", ";", "/**\n * Error\n */", "default", ":", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translate", "->", "translate", "(", "'Format is not currently supported. Supported formats are: pls, m3u'", ",", "'mp3'", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "$", "path", ".", "' '", ".", "$", "this", "->", "translate", "->", "translate", "(", "'was not found'", ",", "'mp3'", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Play Single Song @param string $base64 @return null|string|void @throws \Exception
[ "Play", "Single", "Song" ]
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Index.php#L228-L320
233,303
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.getAdapterFactoryClass
public function getAdapterFactoryClass() { $config = config('jwt'); if (!isset($config['adapter'])) { $config['adapter'] = 'lcobucci'; } if (class_exists($config['adapter'])) { $factoryClass = $config['adapter']; } else { $factoryClass = 'Canis\Lumen\Jwt\Adapters\\' . ucfirst($config['adapter']) . '\Factory'; if (!class_exists($factoryClass)) { throw new InvalidAdapterException("{$config['adapter']} is not available"); } } return $factoryClass; }
php
public function getAdapterFactoryClass() { $config = config('jwt'); if (!isset($config['adapter'])) { $config['adapter'] = 'lcobucci'; } if (class_exists($config['adapter'])) { $factoryClass = $config['adapter']; } else { $factoryClass = 'Canis\Lumen\Jwt\Adapters\\' . ucfirst($config['adapter']) . '\Factory'; if (!class_exists($factoryClass)) { throw new InvalidAdapterException("{$config['adapter']} is not available"); } } return $factoryClass; }
[ "public", "function", "getAdapterFactoryClass", "(", ")", "{", "$", "config", "=", "config", "(", "'jwt'", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'adapter'", "]", ")", ")", "{", "$", "config", "[", "'adapter'", "]", "=", "'lcobucci'", ";", "}", "if", "(", "class_exists", "(", "$", "config", "[", "'adapter'", "]", ")", ")", "{", "$", "factoryClass", "=", "$", "config", "[", "'adapter'", "]", ";", "}", "else", "{", "$", "factoryClass", "=", "'Canis\\Lumen\\Jwt\\Adapters\\\\'", ".", "ucfirst", "(", "$", "config", "[", "'adapter'", "]", ")", ".", "'\\Factory'", ";", "if", "(", "!", "class_exists", "(", "$", "factoryClass", ")", ")", "{", "throw", "new", "InvalidAdapterException", "(", "\"{$config['adapter']} is not available\"", ")", ";", "}", "}", "return", "$", "factoryClass", ";", "}" ]
Returns the adapter class name to use @return string
[ "Returns", "the", "adapter", "class", "name", "to", "use" ]
5e1a76a9878ec58348a76aeea382e6cb9c104ef9
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L65-L80
233,304
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.getAdapterFactory
protected function getAdapterFactory() { if (!isset($this->factoryCache[$this->id])) { $config = config('jwt'); if (isset($this->config['adapter'])) { $config = array_merge($config, $this->config['adapter']); } $factoryClass = $this->getAdapterFactoryClass(); $this->factoryCache[$this->id] = new $factoryClass($config); } return $this->factoryCache[$this->id]; }
php
protected function getAdapterFactory() { if (!isset($this->factoryCache[$this->id])) { $config = config('jwt'); if (isset($this->config['adapter'])) { $config = array_merge($config, $this->config['adapter']); } $factoryClass = $this->getAdapterFactoryClass(); $this->factoryCache[$this->id] = new $factoryClass($config); } return $this->factoryCache[$this->id]; }
[ "protected", "function", "getAdapterFactory", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factoryCache", "[", "$", "this", "->", "id", "]", ")", ")", "{", "$", "config", "=", "config", "(", "'jwt'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'adapter'", "]", ")", ")", "{", "$", "config", "=", "array_merge", "(", "$", "config", ",", "$", "this", "->", "config", "[", "'adapter'", "]", ")", ";", "}", "$", "factoryClass", "=", "$", "this", "->", "getAdapterFactoryClass", "(", ")", ";", "$", "this", "->", "factoryCache", "[", "$", "this", "->", "id", "]", "=", "new", "$", "factoryClass", "(", "$", "config", ")", ";", "}", "return", "$", "this", "->", "factoryCache", "[", "$", "this", "->", "id", "]", ";", "}" ]
Returns the adapter factory object @return AdapterFactoryContract
[ "Returns", "the", "adapter", "factory", "object" ]
5e1a76a9878ec58348a76aeea382e6cb9c104ef9
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L87-L98
233,305
tableau-mkt/elomentary
src/Api/Assets/CustomObject.php
CustomObject.data
public function data($customObjectId) { if ($this->client->getOption('version') != '1.0') { throw new \Exception("Accessing customObject data is currently only supported with the Rest API v1.0"); } return new \Eloqua\Api\Data\CustomObject($this->client, $customObjectId); }
php
public function data($customObjectId) { if ($this->client->getOption('version') != '1.0') { throw new \Exception("Accessing customObject data is currently only supported with the Rest API v1.0"); } return new \Eloqua\Api\Data\CustomObject($this->client, $customObjectId); }
[ "public", "function", "data", "(", "$", "customObjectId", ")", "{", "if", "(", "$", "this", "->", "client", "->", "getOption", "(", "'version'", ")", "!=", "'1.0'", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Accessing customObject data is currently only supported with the Rest API v1.0\"", ")", ";", "}", "return", "new", "\\", "Eloqua", "\\", "Api", "\\", "Data", "\\", "CustomObject", "(", "$", "this", "->", "client", ",", "$", "customObjectId", ")", ";", "}" ]
Gets custom object data API @param number $customObjectId The custom object ID from which you're trying to interface with @throws \Exception Accessing custom object data is currently only possible with the 1.0 API. See http://topliners.eloqua.com/thread/13397 for more information. @return \Eloqua\Api\Data\CustomObject
[ "Gets", "custom", "object", "data", "API" ]
c9e8e67f8239cfd813fae59fe665ed7130c439d2
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/CustomObject.php#L104-L110
233,306
CampaignChain/core
Controller/LocationController.php
LocationController.apiListActivitiesAction
public function apiListActivitiesAction(Request $request, $id){ $location = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:Location') ->find($id); if (!$location) { throw new \Exception( 'No channel found for id '.$id ); } // Get the modules of type "activity" that are related to the channel. $activityModules = $location->getChannel()->getChannelModule()->getActivityModules(); $response = array(); // TODO: Check whether there are any activity modules. // if($activityModules->count()){ foreach($activityModules as $activityModule){ $response[] = array( 'id' => $activityModule->getId(), 'display_name' => $activityModule->getDisplayName(), 'name' => $activityModule->getIdentifier(), ); } // } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
php
public function apiListActivitiesAction(Request $request, $id){ $location = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:Location') ->find($id); if (!$location) { throw new \Exception( 'No channel found for id '.$id ); } // Get the modules of type "activity" that are related to the channel. $activityModules = $location->getChannel()->getChannelModule()->getActivityModules(); $response = array(); // TODO: Check whether there are any activity modules. // if($activityModules->count()){ foreach($activityModules as $activityModule){ $response[] = array( 'id' => $activityModule->getId(), 'display_name' => $activityModule->getDisplayName(), 'name' => $activityModule->getIdentifier(), ); } // } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
[ "public", "function", "apiListActivitiesAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "location", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'CampaignChainCoreBundle:Location'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "location", ")", "{", "throw", "new", "\\", "Exception", "(", "'No channel found for id '", ".", "$", "id", ")", ";", "}", "// Get the modules of type \"activity\" that are related to the channel.", "$", "activityModules", "=", "$", "location", "->", "getChannel", "(", ")", "->", "getChannelModule", "(", ")", "->", "getActivityModules", "(", ")", ";", "$", "response", "=", "array", "(", ")", ";", "// TODO: Check whether there are any activity modules.", "// if($activityModules->count()){", "foreach", "(", "$", "activityModules", "as", "$", "activityModule", ")", "{", "$", "response", "[", "]", "=", "array", "(", "'id'", "=>", "$", "activityModule", "->", "getId", "(", ")", ",", "'display_name'", "=>", "$", "activityModule", "->", "getDisplayName", "(", ")", ",", "'name'", "=>", "$", "activityModule", "->", "getIdentifier", "(", ")", ",", ")", ";", "}", "// }", "$", "serializer", "=", "$", "this", "->", "get", "(", "'campaignchain.core.serializer.default'", ")", ";", "return", "new", "Response", "(", "$", "serializer", "->", "serialize", "(", "$", "response", ",", "'json'", ")", ")", ";", "}" ]
Get the Activity modules that are available for a Location. @ApiDoc( section = "Core", views = { "private" }, requirements={ { "name"="id", "requirement"="\d+" } } ) @param Request $request @param $id Location ID @return Response @throws \Exception
[ "Get", "the", "Activity", "modules", "that", "are", "available", "for", "a", "Location", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/LocationController.php#L77-L107
233,307
prooph/link-process-manager
src/Projection/Log/ProcessLogFinder.php
ProcessLogFinder.getLogsTriggeredBy
public function getLogsTriggeredBy($startMessage) { $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG) ->where('start_message = :start_message') ->orderBy('started_at', 'DESC') ->setParameter('start_message', $startMessage); return $query->execute()->fetchAll(); }
php
public function getLogsTriggeredBy($startMessage) { $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG) ->where('start_message = :start_message') ->orderBy('started_at', 'DESC') ->setParameter('start_message', $startMessage); return $query->execute()->fetchAll(); }
[ "public", "function", "getLogsTriggeredBy", "(", "$", "startMessage", ")", "{", "$", "query", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "query", "->", "select", "(", "'*'", ")", "->", "from", "(", "Tables", "::", "PROCESS_LOG", ")", "->", "where", "(", "'start_message = :start_message'", ")", "->", "orderBy", "(", "'started_at'", ",", "'DESC'", ")", "->", "setParameter", "(", "'start_message'", ",", "$", "startMessage", ")", ";", "return", "$", "query", "->", "execute", "(", ")", "->", "fetchAll", "(", ")", ";", "}" ]
Get logs triggered by given start message Orders the logs by started_at DESC @param string $startMessage @return array
[ "Get", "logs", "triggered", "by", "given", "start", "message", "Orders", "the", "logs", "by", "started_at", "DESC" ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Projection/Log/ProcessLogFinder.php#L82-L92
233,308
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.create
public static function create($transactionID, $sum, $params = []) { $transaction = new self; $transaction->setTransactionID($transactionID) ->setSum($sum) ->setCurrency(PaymentHandlerBase::DEFAULT_CURRENCY) ->setLanguage(PaymentHandlerBase::DEFAULT_LANGUAGE); foreach ($params as $key => $value) { $transaction->params[$key] = $value; } return $transaction; }
php
public static function create($transactionID, $sum, $params = []) { $transaction = new self; $transaction->setTransactionID($transactionID) ->setSum($sum) ->setCurrency(PaymentHandlerBase::DEFAULT_CURRENCY) ->setLanguage(PaymentHandlerBase::DEFAULT_LANGUAGE); foreach ($params as $key => $value) { $transaction->params[$key] = $value; } return $transaction; }
[ "public", "static", "function", "create", "(", "$", "transactionID", ",", "$", "sum", ",", "$", "params", "=", "[", "]", ")", "{", "$", "transaction", "=", "new", "self", ";", "$", "transaction", "->", "setTransactionID", "(", "$", "transactionID", ")", "->", "setSum", "(", "$", "sum", ")", "->", "setCurrency", "(", "PaymentHandlerBase", "::", "DEFAULT_CURRENCY", ")", "->", "setLanguage", "(", "PaymentHandlerBase", "::", "DEFAULT_LANGUAGE", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "transaction", "->", "params", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "transaction", ";", "}" ]
Create a new transaction object @param mixed $transactionID @param float $sum @param array $params @return self
[ "Create", "a", "new", "transaction", "object" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L51-L63
233,309
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setSum
public function setSum($sum) { $sum = (float)str_replace(',', '.', $sum); $this->params['sum'] = $sum; return $this; }
php
public function setSum($sum) { $sum = (float)str_replace(',', '.', $sum); $this->params['sum'] = $sum; return $this; }
[ "public", "function", "setSum", "(", "$", "sum", ")", "{", "$", "sum", "=", "(", "float", ")", "str_replace", "(", "','", ",", "'.'", ",", "$", "sum", ")", ";", "$", "this", "->", "params", "[", "'sum'", "]", "=", "$", "sum", ";", "return", "$", "this", ";", "}" ]
Set the transaction sum @param float $sum @return Transaction
[ "Set", "the", "transaction", "sum" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L95-L100
233,310
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setTransactionId
public function setTransactionId($transactionId) { if (is_numeric($transactionId) || $transactionId === false) { $this->params['transactionId'] = $transactionId; return $this; } throw new Exception("Please use a numeric value for transaction ID"); }
php
public function setTransactionId($transactionId) { if (is_numeric($transactionId) || $transactionId === false) { $this->params['transactionId'] = $transactionId; return $this; } throw new Exception("Please use a numeric value for transaction ID"); }
[ "public", "function", "setTransactionId", "(", "$", "transactionId", ")", "{", "if", "(", "is_numeric", "(", "$", "transactionId", ")", "||", "$", "transactionId", "===", "false", ")", "{", "$", "this", "->", "params", "[", "'transactionId'", "]", "=", "$", "transactionId", ";", "return", "$", "this", ";", "}", "throw", "new", "Exception", "(", "\"Please use a numeric value for transaction ID\"", ")", ";", "}" ]
Set the transaction ID @param int $transactionId @throws \opus\payment\Exception If transaction ID is not numeric @return Transaction
[ "Set", "the", "transaction", "ID" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L109-L116
233,311
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setReference
public function setReference($reference = null) { $reference === null && $reference = PaymentHelper::generateReference($this->getTransactionId()); $this->params['reference'] = $reference; return $this; }
php
public function setReference($reference = null) { $reference === null && $reference = PaymentHelper::generateReference($this->getTransactionId()); $this->params['reference'] = $reference; return $this; }
[ "public", "function", "setReference", "(", "$", "reference", "=", "null", ")", "{", "$", "reference", "===", "null", "&&", "$", "reference", "=", "PaymentHelper", "::", "generateReference", "(", "$", "this", "->", "getTransactionId", "(", ")", ")", ";", "$", "this", "->", "params", "[", "'reference'", "]", "=", "$", "reference", ";", "return", "$", "this", ";", "}" ]
Sets the payment reference @param mixed $reference If NULL, the reference will be generated automatically from Transaction ID @return Transaction
[ "Sets", "the", "payment", "reference" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L144-L149
233,312
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel._validate_element
private function _validate_element($element, $position) { $key = reset($element); $allowed_keys = array(self::CONTEXT, self::LANG, self::PARAMETER, self::STRING); if ( ! in_array($key, $allowed_keys)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to be one of "'.implode('", "', $allowed_keys).'", "'.$key.'" found.'); } $elements_count = count($element); if ($key !== self::PARAMETER && $elements_count !== 2) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to have 2 elements, '.$elements_count.' found.'); } elseif ($key === self::PARAMETER && ($elements_count < 2 || $elements_count > 3)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" at position '.($position + 1).' expected to have 2 or 3 elements, '.$elements_count.' found.'); } }
php
private function _validate_element($element, $position) { $key = reset($element); $allowed_keys = array(self::CONTEXT, self::LANG, self::PARAMETER, self::STRING); if ( ! in_array($key, $allowed_keys)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to be one of "'.implode('", "', $allowed_keys).'", "'.$key.'" found.'); } $elements_count = count($element); if ($key !== self::PARAMETER && $elements_count !== 2) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to have 2 elements, '.$elements_count.' found.'); } elseif ($key === self::PARAMETER && ($elements_count < 2 || $elements_count > 3)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" at position '.($position + 1).' expected to have 2 or 3 elements, '.$elements_count.' found.'); } }
[ "private", "function", "_validate_element", "(", "$", "element", ",", "$", "position", ")", "{", "$", "key", "=", "reset", "(", "$", "element", ")", ";", "$", "allowed_keys", "=", "array", "(", "self", "::", "CONTEXT", ",", "self", "::", "LANG", ",", "self", "::", "PARAMETER", ",", "self", "::", "STRING", ")", ";", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "allowed_keys", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Translation definition \"'", ".", "$", "key", ".", "'\" expected to be one of \"'", ".", "implode", "(", "'\", \"'", ",", "$", "allowed_keys", ")", ".", "'\", \"'", ".", "$", "key", ".", "'\" found.'", ")", ";", "}", "$", "elements_count", "=", "count", "(", "$", "element", ")", ";", "if", "(", "$", "key", "!==", "self", "::", "PARAMETER", "&&", "$", "elements_count", "!==", "2", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Translation definition \"'", ".", "$", "key", ".", "'\" expected to have 2 elements, '", ".", "$", "elements_count", ".", "' found.'", ")", ";", "}", "elseif", "(", "$", "key", "===", "self", "::", "PARAMETER", "&&", "(", "$", "elements_count", "<", "2", "||", "$", "elements_count", ">", "3", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Translation definition \"'", ".", "$", "key", ".", "'\" at position '", ".", "(", "$", "position", "+", "1", ")", ".", "' expected to have 2 or 3 elements, '", ".", "$", "elements_count", ".", "' found.'", ")", ";", "}", "}" ]
Validates that translate element conforms to the specification. @param array $element N-th argument definition from `$_translate` property. @param integer $position argument position (N) @throws \InvalidArgumentException
[ "Validates", "that", "translate", "element", "conforms", "to", "the", "specification", "." ]
6782aeac50e22a194d3840759c9da97d1f9c50d0
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L97-L114
233,313
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel.string
public function string($string = NULL) { if (func_num_args() === 0) { return $this->_string; } $this->_string = $string; return $this; }
php
public function string($string = NULL) { if (func_num_args() === 0) { return $this->_string; } $this->_string = $string; return $this; }
[ "public", "function", "string", "(", "$", "string", "=", "NULL", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "0", ")", "{", "return", "$", "this", "->", "_string", ";", "}", "$", "this", "->", "_string", "=", "$", "string", ";", "return", "$", "this", ";", "}" ]
Translation string getter and setter. This makes sense here for 'parametrized' translation logic for changing translation string on-the-fly. @param string $string @return $this|string
[ "Translation", "string", "getter", "and", "setter", ".", "This", "makes", "sense", "here", "for", "parametrized", "translation", "logic", "for", "changing", "translation", "string", "on", "-", "the", "-", "fly", "." ]
6782aeac50e22a194d3840759c9da97d1f9c50d0
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L123-L131
233,314
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel.translate
public function translate() { $arguments = func_get_args(); // Default translation parameters. $translate = array( 'context' => $this->context(), 'lang' => $this->lang(), 'parameters' => $this->parameters(), 'string' => $this->string(), ); // Populate `$translate` variable with function arguments and/or model state. foreach ($this->_translate as $i => $element) { $this->_setup_element($translate, $element, $i, $arguments); } // Now that the basic data have been set, parameters that need to have context values. foreach ($this->_context_params as $parameter) { $translate['parameters'][$parameter] = $translate[self::CONTEXT]; } // Translate using the populated data. return $this->i18n() ->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']); }
php
public function translate() { $arguments = func_get_args(); // Default translation parameters. $translate = array( 'context' => $this->context(), 'lang' => $this->lang(), 'parameters' => $this->parameters(), 'string' => $this->string(), ); // Populate `$translate` variable with function arguments and/or model state. foreach ($this->_translate as $i => $element) { $this->_setup_element($translate, $element, $i, $arguments); } // Now that the basic data have been set, parameters that need to have context values. foreach ($this->_context_params as $parameter) { $translate['parameters'][$parameter] = $translate[self::CONTEXT]; } // Translate using the populated data. return $this->i18n() ->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']); }
[ "public", "function", "translate", "(", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "// Default translation parameters.", "$", "translate", "=", "array", "(", "'context'", "=>", "$", "this", "->", "context", "(", ")", ",", "'lang'", "=>", "$", "this", "->", "lang", "(", ")", ",", "'parameters'", "=>", "$", "this", "->", "parameters", "(", ")", ",", "'string'", "=>", "$", "this", "->", "string", "(", ")", ",", ")", ";", "// Populate `$translate` variable with function arguments and/or model state.", "foreach", "(", "$", "this", "->", "_translate", "as", "$", "i", "=>", "$", "element", ")", "{", "$", "this", "->", "_setup_element", "(", "$", "translate", ",", "$", "element", ",", "$", "i", ",", "$", "arguments", ")", ";", "}", "// Now that the basic data have been set, parameters that need to have context values.", "foreach", "(", "$", "this", "->", "_context_params", "as", "$", "parameter", ")", "{", "$", "translate", "[", "'parameters'", "]", "[", "$", "parameter", "]", "=", "$", "translate", "[", "self", "::", "CONTEXT", "]", ";", "}", "// Translate using the populated data.", "return", "$", "this", "->", "i18n", "(", ")", "->", "translate", "(", "$", "translate", "[", "'string'", "]", ",", "$", "translate", "[", "'context'", "]", ",", "$", "translate", "[", "'parameters'", "]", ",", "$", "translate", "[", "'lang'", "]", ")", ";", "}" ]
Parametrized translation method. Provides 'automatic' translation using method arguments, model state and default values. @return string
[ "Parametrized", "translation", "method", ".", "Provides", "automatic", "translation", "using", "method", "arguments", "model", "state", "and", "default", "values", "." ]
6782aeac50e22a194d3840759c9da97d1f9c50d0
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L139-L165
233,315
tableau-mkt/elomentary
src/Api/Data/Contact/Segment.php
Segment.searchExcluded
public function searchExcluded($search, array $options = array()) { return $this->get('data/contacts/segment/' . rawurlencode($this->segmentId) . '/excluded', array_merge(array( 'search' => $search, ), $options)); }
php
public function searchExcluded($search, array $options = array()) { return $this->get('data/contacts/segment/' . rawurlencode($this->segmentId) . '/excluded', array_merge(array( 'search' => $search, ), $options)); }
[ "public", "function", "searchExcluded", "(", "$", "search", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "get", "(", "'data/contacts/segment/'", ".", "rawurlencode", "(", "$", "this", "->", "segmentId", ")", ".", "'/excluded'", ",", "array_merge", "(", "array", "(", "'search'", "=>", "$", "search", ",", ")", ",", "$", "options", ")", ")", ";", "}" ]
Search contacts that are excluded in this segment. @param string $search @param array $options @return \Guzzle\Http\EntityBodyInterface|mixed|string
[ "Search", "contacts", "that", "are", "excluded", "in", "this", "segment", "." ]
c9e8e67f8239cfd813fae59fe665ed7130c439d2
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Data/Contact/Segment.php#L67-L71
233,316
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.addCommonParams
public function addCommonParams(Dataset $dataset) { $dataset ->setParam('VK_SERVICE', $this->getConfParam('VK_SERVICE', '1011')) ->setParam('VK_VERSION', '008') ->setParam('VK_SND_ID', $this->getConfParam('VK_SND_ID')) ->setParam('VK_ACC', $this->getConfParam('VK_ACC')) ->setParam('VK_NAME', $this->getConfParam('VK_NAME')) ->setParam('VK_RETURN', $this->getReturnUrl()) ->setParam('VK_CANCEL', $this->getCancelUrl()) ->setParam('VK_ENCODING', $this->getConfParam('VK_ENCODING', 'UTF-8')) ->setParam('VK_DATETIME', date(DATE_ISO8601)) ; }
php
public function addCommonParams(Dataset $dataset) { $dataset ->setParam('VK_SERVICE', $this->getConfParam('VK_SERVICE', '1011')) ->setParam('VK_VERSION', '008') ->setParam('VK_SND_ID', $this->getConfParam('VK_SND_ID')) ->setParam('VK_ACC', $this->getConfParam('VK_ACC')) ->setParam('VK_NAME', $this->getConfParam('VK_NAME')) ->setParam('VK_RETURN', $this->getReturnUrl()) ->setParam('VK_CANCEL', $this->getCancelUrl()) ->setParam('VK_ENCODING', $this->getConfParam('VK_ENCODING', 'UTF-8')) ->setParam('VK_DATETIME', date(DATE_ISO8601)) ; }
[ "public", "function", "addCommonParams", "(", "Dataset", "$", "dataset", ")", "{", "$", "dataset", "->", "setParam", "(", "'VK_SERVICE'", ",", "$", "this", "->", "getConfParam", "(", "'VK_SERVICE'", ",", "'1011'", ")", ")", "->", "setParam", "(", "'VK_VERSION'", ",", "'008'", ")", "->", "setParam", "(", "'VK_SND_ID'", ",", "$", "this", "->", "getConfParam", "(", "'VK_SND_ID'", ")", ")", "->", "setParam", "(", "'VK_ACC'", ",", "$", "this", "->", "getConfParam", "(", "'VK_ACC'", ")", ")", "->", "setParam", "(", "'VK_NAME'", ",", "$", "this", "->", "getConfParam", "(", "'VK_NAME'", ")", ")", "->", "setParam", "(", "'VK_RETURN'", ",", "$", "this", "->", "getReturnUrl", "(", ")", ")", "->", "setParam", "(", "'VK_CANCEL'", ",", "$", "this", "->", "getCancelUrl", "(", ")", ")", "->", "setParam", "(", "'VK_ENCODING'", ",", "$", "this", "->", "getConfParam", "(", "'VK_ENCODING'", ",", "'UTF-8'", ")", ")", "->", "setParam", "(", "'VK_DATETIME'", ",", "date", "(", "DATE_ISO8601", ")", ")", ";", "}" ]
This can be overridden by child classes of iPizza if necessary
[ "This", "can", "be", "overridden", "by", "child", "classes", "of", "iPizza", "if", "necessary" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L85-L98
233,317
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.getMacSource
private function getMacSource(Dataset $dataset) { $macParams = $this->getNormalizedMacParams($dataset, $dataset->getParam('VK_SERVICE')); $source = ''; foreach ($macParams as $value) { $length = $this->getParamValueLength($value); $source .= str_pad($length, 3, '0', STR_PAD_LEFT) . $value; } return $source; }
php
private function getMacSource(Dataset $dataset) { $macParams = $this->getNormalizedMacParams($dataset, $dataset->getParam('VK_SERVICE')); $source = ''; foreach ($macParams as $value) { $length = $this->getParamValueLength($value); $source .= str_pad($length, 3, '0', STR_PAD_LEFT) . $value; } return $source; }
[ "private", "function", "getMacSource", "(", "Dataset", "$", "dataset", ")", "{", "$", "macParams", "=", "$", "this", "->", "getNormalizedMacParams", "(", "$", "dataset", ",", "$", "dataset", "->", "getParam", "(", "'VK_SERVICE'", ")", ")", ";", "$", "source", "=", "''", ";", "foreach", "(", "$", "macParams", "as", "$", "value", ")", "{", "$", "length", "=", "$", "this", "->", "getParamValueLength", "(", "$", "value", ")", ";", "$", "source", ".=", "str_pad", "(", "$", "length", ",", "3", ",", "'0'", ",", "STR_PAD_LEFT", ")", ".", "$", "value", ";", "}", "return", "$", "source", ";", "}" ]
Generates the MAC source string from a dataset @param Dataset $dataset @return string
[ "Generates", "the", "MAC", "source", "string", "from", "a", "dataset" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L140-L151
233,318
Deathnerd/php-wtforms
src/csrf/session/SessionCSRF.php
SessionCSRF.generateCSRFToken
public function generateCSRFToken(CSRFTokenField $csrf_token_field) { $meta = $this->form_meta; if (!$meta->csrf_secret) { throw new \Exception("Must set `csrf_secret` on class Meta for SessionCSRF to work"); } if (session_status() !== PHP_SESSION_ACTIVE) { throw new TypeError("Must must have an active session to use SessionCSRF"); } if (!array_key_exists($this->session_key, $_SESSION)) { $_SESSION[$this->session_key] = sha1(openssl_random_pseudo_bytes(64)); } if ($this->time_limit) { $expires = $this->now()->addSeconds($this->time_limit)->format(str_replace('%', '', self::TIME_FORMAT)); $this->now()->subSeconds($this->time_limit); $csrf_build = sprintf("%s%s", $_SESSION[$this->session_key], $expires); } else { $expires = ''; $csrf_build = $_SESSION[$this->session_key]; } $hmac_csrf = hash_hmac('sha1', $csrf_build, $meta->csrf_secret); return "$expires##$hmac_csrf"; }
php
public function generateCSRFToken(CSRFTokenField $csrf_token_field) { $meta = $this->form_meta; if (!$meta->csrf_secret) { throw new \Exception("Must set `csrf_secret` on class Meta for SessionCSRF to work"); } if (session_status() !== PHP_SESSION_ACTIVE) { throw new TypeError("Must must have an active session to use SessionCSRF"); } if (!array_key_exists($this->session_key, $_SESSION)) { $_SESSION[$this->session_key] = sha1(openssl_random_pseudo_bytes(64)); } if ($this->time_limit) { $expires = $this->now()->addSeconds($this->time_limit)->format(str_replace('%', '', self::TIME_FORMAT)); $this->now()->subSeconds($this->time_limit); $csrf_build = sprintf("%s%s", $_SESSION[$this->session_key], $expires); } else { $expires = ''; $csrf_build = $_SESSION[$this->session_key]; } $hmac_csrf = hash_hmac('sha1', $csrf_build, $meta->csrf_secret); return "$expires##$hmac_csrf"; }
[ "public", "function", "generateCSRFToken", "(", "CSRFTokenField", "$", "csrf_token_field", ")", "{", "$", "meta", "=", "$", "this", "->", "form_meta", ";", "if", "(", "!", "$", "meta", "->", "csrf_secret", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Must set `csrf_secret` on class Meta for SessionCSRF to work\"", ")", ";", "}", "if", "(", "session_status", "(", ")", "!==", "PHP_SESSION_ACTIVE", ")", "{", "throw", "new", "TypeError", "(", "\"Must must have an active session to use SessionCSRF\"", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "session_key", ",", "$", "_SESSION", ")", ")", "{", "$", "_SESSION", "[", "$", "this", "->", "session_key", "]", "=", "sha1", "(", "openssl_random_pseudo_bytes", "(", "64", ")", ")", ";", "}", "if", "(", "$", "this", "->", "time_limit", ")", "{", "$", "expires", "=", "$", "this", "->", "now", "(", ")", "->", "addSeconds", "(", "$", "this", "->", "time_limit", ")", "->", "format", "(", "str_replace", "(", "'%'", ",", "''", ",", "self", "::", "TIME_FORMAT", ")", ")", ";", "$", "this", "->", "now", "(", ")", "->", "subSeconds", "(", "$", "this", "->", "time_limit", ")", ";", "$", "csrf_build", "=", "sprintf", "(", "\"%s%s\"", ",", "$", "_SESSION", "[", "$", "this", "->", "session_key", "]", ",", "$", "expires", ")", ";", "}", "else", "{", "$", "expires", "=", "''", ";", "$", "csrf_build", "=", "$", "_SESSION", "[", "$", "this", "->", "session_key", "]", ";", "}", "$", "hmac_csrf", "=", "hash_hmac", "(", "'sha1'", ",", "$", "csrf_build", ",", "$", "meta", "->", "csrf_secret", ")", ";", "return", "\"$expires##$hmac_csrf\"", ";", "}" ]
Implementations must override this to provide a method with which one can get a CSRF token for this form. A CSRF token is usually a string that is generated deterministically based on some sort of user data, though it can be anything which you can validate on a subsequent request. @param CSRFTokenField $csrf_token_field The field which is being used for CSRF @return string @throws \Exception @throws TypeError
[ "Implementations", "must", "override", "this", "to", "provide", "a", "method", "with", "which", "one", "can", "get", "a", "CSRF", "token", "for", "this", "form", "." ]
2e1f9ad515f6241c9fac57edc472bf657267f4a1
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/csrf/session/SessionCSRF.php#L59-L84
233,319
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Thing/Thing.php
Thing.getProperty
public function getProperty($name, VocabularyInterface $vocabulary) { $name = (new PropertyService())->validatePropertyName($name); return $this->properties[$vocabulary->expand($name)]; }
php
public function getProperty($name, VocabularyInterface $vocabulary) { $name = (new PropertyService())->validatePropertyName($name); return $this->properties[$vocabulary->expand($name)]; }
[ "public", "function", "getProperty", "(", "$", "name", ",", "VocabularyInterface", "$", "vocabulary", ")", "{", "$", "name", "=", "(", "new", "PropertyService", "(", ")", ")", "->", "validatePropertyName", "(", "$", "name", ")", ";", "return", "$", "this", "->", "properties", "[", "$", "vocabulary", "->", "expand", "(", "$", "name", ")", "]", ";", "}" ]
Return the values of a single property @param string $name Property name @param VocabularyInterface $vocabulary Vocabulary @return array Property values
[ "Return", "the", "values", "of", "a", "single", "property" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Thing/Thing.php#L149-L153
233,320
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseStatusCodeEquals
public function assertResponseStatusCodeEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getStatusCode(), $message); }
php
public function assertResponseStatusCodeEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getStatusCode(), $message); }
[ "public", "function", "assertResponseStatusCodeEquals", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "inExpected", ",", "$", "inResponse", "->", "getStatusCode", "(", ")", ",", "$", "message", ")", ";", "}" ]
Asserts that the value of the status code is equal to a given value. @param int $inExpected Expected value. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "value", "of", "the", "status", "code", "is", "equal", "to", "a", "given", "value", "." ]
aa11dc6da421879b09aa170b7b990711de543395
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L26-L28
233,321
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseBodyEquals
public function assertResponseBodyEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getBody(), $message); }
php
public function assertResponseBodyEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getBody(), $message); }
[ "public", "function", "assertResponseBodyEquals", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "inExpected", ",", "$", "inResponse", "->", "getBody", "(", ")", ",", "$", "message", ")", ";", "}" ]
Asserts that the body of the response is equal to a given string. @param string $inExpected The expected response's body. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "body", "of", "the", "response", "is", "equal", "to", "a", "given", "string", "." ]
aa11dc6da421879b09aa170b7b990711de543395
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L129-L131
233,322
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseHasHeader
public function assertResponseHasHeader($inHeader, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertTrue($inResponse->hasHeader($inHeader), $message); }
php
public function assertResponseHasHeader($inHeader, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertTrue($inResponse->hasHeader($inHeader), $message); }
[ "public", "function", "assertResponseHasHeader", "(", "$", "inHeader", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "inResponse", "->", "hasHeader", "(", "$", "inHeader", ")", ",", "$", "message", ")", ";", "}" ]
Asserts that the response has a given header. @param string $inHeader Name of the header. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "response", "has", "a", "given", "header", "." ]
aa11dc6da421879b09aa170b7b990711de543395
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L139-L141
233,323
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseBodyEqualsFile
public function assertResponseBodyEqualsFile($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertStringEqualsFile($inExpected, $inResponse->getBody(), $message); }
php
public function assertResponseBodyEqualsFile($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertStringEqualsFile($inExpected, $inResponse->getBody(), $message); }
[ "public", "function", "assertResponseBodyEqualsFile", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertStringEqualsFile", "(", "$", "inExpected", ",", "$", "inResponse", "->", "getBody", "(", ")", ",", "$", "message", ")", ";", "}" ]
Asserts that the body of the response is equal to the content of a given file. @param string $inExpected Path to the file. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "body", "of", "the", "response", "is", "equal", "to", "the", "content", "of", "a", "given", "file", "." ]
aa11dc6da421879b09aa170b7b990711de543395
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L149-L151
233,324
kgilden/php-digidoc
src/Api.php
Api.createEnvelope
private function createEnvelope($sessionCode, SignedDocInfo $signedDocInfo) { $envelope = new Envelope( new Session($sessionCode), $this->createAndTrack($signedDocInfo->DataFileInfo, 'KG\DigiDoc\File'), $this->createAndTrack($signedDocInfo->SignatureInfo, 'KG\DigiDoc\Signature') ); $this->tracker->add($envelope); return $envelope; }
php
private function createEnvelope($sessionCode, SignedDocInfo $signedDocInfo) { $envelope = new Envelope( new Session($sessionCode), $this->createAndTrack($signedDocInfo->DataFileInfo, 'KG\DigiDoc\File'), $this->createAndTrack($signedDocInfo->SignatureInfo, 'KG\DigiDoc\Signature') ); $this->tracker->add($envelope); return $envelope; }
[ "private", "function", "createEnvelope", "(", "$", "sessionCode", ",", "SignedDocInfo", "$", "signedDocInfo", ")", "{", "$", "envelope", "=", "new", "Envelope", "(", "new", "Session", "(", "$", "sessionCode", ")", ",", "$", "this", "->", "createAndTrack", "(", "$", "signedDocInfo", "->", "DataFileInfo", ",", "'KG\\DigiDoc\\File'", ")", ",", "$", "this", "->", "createAndTrack", "(", "$", "signedDocInfo", "->", "SignatureInfo", ",", "'KG\\DigiDoc\\Signature'", ")", ")", ";", "$", "this", "->", "tracker", "->", "add", "(", "$", "envelope", ")", ";", "return", "$", "envelope", ";", "}" ]
Creates a new DigiDoc envelope. @param string $sessionCode @param SignedDocInfo $signedDocInfo @return Envelope
[ "Creates", "a", "new", "DigiDoc", "envelope", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L96-L107
233,325
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php
YUMLMetadataGrapher.generateFromMetadata
public function generateFromMetadata( array $metadata, $showFieldsDescription = false, $colors = array(), $notes = array() ) { $this->classStore = new ClassStore($metadata); $this->stringGenerator = new StringGenerator($this->classStore); $this->colorManager = new ColorManager($this->stringGenerator, $this->classStore); $this->stringGenerator->setShowFieldsDescription($showFieldsDescription); $annotations = $this->annotationParser->getAnnotations($metadata); $colors = array_merge($colors, $annotations['colors']); $notes = array_merge($notes, $annotations['notes']); foreach ($metadata as $class) { $this->writeParentAssociation($class); $this->dispatchStringWriter($class, $class->getAssociationNames()); } $this->addColors($metadata, $colors); $this->addNotes($notes); return implode(',', $this->str); }
php
public function generateFromMetadata( array $metadata, $showFieldsDescription = false, $colors = array(), $notes = array() ) { $this->classStore = new ClassStore($metadata); $this->stringGenerator = new StringGenerator($this->classStore); $this->colorManager = new ColorManager($this->stringGenerator, $this->classStore); $this->stringGenerator->setShowFieldsDescription($showFieldsDescription); $annotations = $this->annotationParser->getAnnotations($metadata); $colors = array_merge($colors, $annotations['colors']); $notes = array_merge($notes, $annotations['notes']); foreach ($metadata as $class) { $this->writeParentAssociation($class); $this->dispatchStringWriter($class, $class->getAssociationNames()); } $this->addColors($metadata, $colors); $this->addNotes($notes); return implode(',', $this->str); }
[ "public", "function", "generateFromMetadata", "(", "array", "$", "metadata", ",", "$", "showFieldsDescription", "=", "false", ",", "$", "colors", "=", "array", "(", ")", ",", "$", "notes", "=", "array", "(", ")", ")", "{", "$", "this", "->", "classStore", "=", "new", "ClassStore", "(", "$", "metadata", ")", ";", "$", "this", "->", "stringGenerator", "=", "new", "StringGenerator", "(", "$", "this", "->", "classStore", ")", ";", "$", "this", "->", "colorManager", "=", "new", "ColorManager", "(", "$", "this", "->", "stringGenerator", ",", "$", "this", "->", "classStore", ")", ";", "$", "this", "->", "stringGenerator", "->", "setShowFieldsDescription", "(", "$", "showFieldsDescription", ")", ";", "$", "annotations", "=", "$", "this", "->", "annotationParser", "->", "getAnnotations", "(", "$", "metadata", ")", ";", "$", "colors", "=", "array_merge", "(", "$", "colors", ",", "$", "annotations", "[", "'colors'", "]", ")", ";", "$", "notes", "=", "array_merge", "(", "$", "notes", ",", "$", "annotations", "[", "'notes'", "]", ")", ";", "foreach", "(", "$", "metadata", "as", "$", "class", ")", "{", "$", "this", "->", "writeParentAssociation", "(", "$", "class", ")", ";", "$", "this", "->", "dispatchStringWriter", "(", "$", "class", ",", "$", "class", "->", "getAssociationNames", "(", ")", ")", ";", "}", "$", "this", "->", "addColors", "(", "$", "metadata", ",", "$", "colors", ")", ";", "$", "this", "->", "addNotes", "(", "$", "notes", ")", ";", "return", "implode", "(", "','", ",", "$", "this", "->", "str", ")", ";", "}" ]
Generate a yUML compatible `dsl_text` to describe a given array of entities @param ClassMetadata[] $metadata @param boolean $showFieldsDescription @param array $colors @param array $notes @return string
[ "Generate", "a", "yUML", "compatible", "dsl_text", "to", "describe", "a", "given", "array", "of", "entities" ]
414b95f81d36b6530b083b296c5eeb700679ab3b
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php#L80-L106
233,326
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php
YUMLMetadataGrapher.getInheritanceAssociations
private function getInheritanceAssociations(ClassMetadata $class, $associations = array()) { if ($parent = $this->classStore->getParent($class)) { foreach ($parent->getAssociationNames() as $association) { if (!in_array($association, $associations)) { $associations[] = $association; } } $associations = $this->getInheritanceAssociations($parent, $associations); } return $associations; }
php
private function getInheritanceAssociations(ClassMetadata $class, $associations = array()) { if ($parent = $this->classStore->getParent($class)) { foreach ($parent->getAssociationNames() as $association) { if (!in_array($association, $associations)) { $associations[] = $association; } } $associations = $this->getInheritanceAssociations($parent, $associations); } return $associations; }
[ "private", "function", "getInheritanceAssociations", "(", "ClassMetadata", "$", "class", ",", "$", "associations", "=", "array", "(", ")", ")", "{", "if", "(", "$", "parent", "=", "$", "this", "->", "classStore", "->", "getParent", "(", "$", "class", ")", ")", "{", "foreach", "(", "$", "parent", "->", "getAssociationNames", "(", ")", "as", "$", "association", ")", "{", "if", "(", "!", "in_array", "(", "$", "association", ",", "$", "associations", ")", ")", "{", "$", "associations", "[", "]", "=", "$", "association", ";", "}", "}", "$", "associations", "=", "$", "this", "->", "getInheritanceAssociations", "(", "$", "parent", ",", "$", "associations", ")", ";", "}", "return", "$", "associations", ";", "}" ]
Recursive function to get all associations in inheritance @param ClassMetadata $class @param array $associations @return array
[ "Recursive", "function", "to", "get", "all", "associations", "in", "inheritance" ]
414b95f81d36b6530b083b296c5eeb700679ab3b
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php#L187-L199
233,327
swoft-cloud/swoft-console
src/Command.php
Command.showCommandHelp
private function showCommandHelp(string $controllerClass, string $commandMethod) { // 反射获取方法描述 $reflectionClass = new \ReflectionClass($controllerClass); $reflectionMethod = $reflectionClass->getMethod($commandMethod); $document = $reflectionMethod->getDocComment(); $document = $this->parseAnnotationVars($document, $this->annotationVars()); $docs = DocBlockHelper::getTags($document); $commands = []; // 描述 if (isset($docs['Description'])) { $commands['Description:'] = explode("\n", $docs['Description']); } // 使用 if (isset($docs['Usage'])) { $commands['Usage:'] = $docs['Usage']; } // 参数 if (isset($docs['Arguments'])) { // $arguments = $this->parserKeyAndDesc($docs['Arguments']); $commands['Arguments:'] = $docs['Arguments']; } // 选项 if (isset($docs['Options'])) { // $options = $this->parserKeyAndDesc($docs['Options']); $commands['Options:'] = $docs['Options']; } // 实例 if (isset($docs['Example'])) { $commands['Example:'] = [$docs['Example']]; } \output()->writeList($commands); }
php
private function showCommandHelp(string $controllerClass, string $commandMethod) { // 反射获取方法描述 $reflectionClass = new \ReflectionClass($controllerClass); $reflectionMethod = $reflectionClass->getMethod($commandMethod); $document = $reflectionMethod->getDocComment(); $document = $this->parseAnnotationVars($document, $this->annotationVars()); $docs = DocBlockHelper::getTags($document); $commands = []; // 描述 if (isset($docs['Description'])) { $commands['Description:'] = explode("\n", $docs['Description']); } // 使用 if (isset($docs['Usage'])) { $commands['Usage:'] = $docs['Usage']; } // 参数 if (isset($docs['Arguments'])) { // $arguments = $this->parserKeyAndDesc($docs['Arguments']); $commands['Arguments:'] = $docs['Arguments']; } // 选项 if (isset($docs['Options'])) { // $options = $this->parserKeyAndDesc($docs['Options']); $commands['Options:'] = $docs['Options']; } // 实例 if (isset($docs['Example'])) { $commands['Example:'] = [$docs['Example']]; } \output()->writeList($commands); }
[ "private", "function", "showCommandHelp", "(", "string", "$", "controllerClass", ",", "string", "$", "commandMethod", ")", "{", "// 反射获取方法描述", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "controllerClass", ")", ";", "$", "reflectionMethod", "=", "$", "reflectionClass", "->", "getMethod", "(", "$", "commandMethod", ")", ";", "$", "document", "=", "$", "reflectionMethod", "->", "getDocComment", "(", ")", ";", "$", "document", "=", "$", "this", "->", "parseAnnotationVars", "(", "$", "document", ",", "$", "this", "->", "annotationVars", "(", ")", ")", ";", "$", "docs", "=", "DocBlockHelper", "::", "getTags", "(", "$", "document", ")", ";", "$", "commands", "=", "[", "]", ";", "// 描述", "if", "(", "isset", "(", "$", "docs", "[", "'Description'", "]", ")", ")", "{", "$", "commands", "[", "'Description:'", "]", "=", "explode", "(", "\"\\n\"", ",", "$", "docs", "[", "'Description'", "]", ")", ";", "}", "// 使用", "if", "(", "isset", "(", "$", "docs", "[", "'Usage'", "]", ")", ")", "{", "$", "commands", "[", "'Usage:'", "]", "=", "$", "docs", "[", "'Usage'", "]", ";", "}", "// 参数", "if", "(", "isset", "(", "$", "docs", "[", "'Arguments'", "]", ")", ")", "{", "// $arguments = $this->parserKeyAndDesc($docs['Arguments']);", "$", "commands", "[", "'Arguments:'", "]", "=", "$", "docs", "[", "'Arguments'", "]", ";", "}", "// 选项", "if", "(", "isset", "(", "$", "docs", "[", "'Options'", "]", ")", ")", "{", "// $options = $this->parserKeyAndDesc($docs['Options']);", "$", "commands", "[", "'Options:'", "]", "=", "$", "docs", "[", "'Options'", "]", ";", "}", "// 实例", "if", "(", "isset", "(", "$", "docs", "[", "'Example'", "]", ")", ")", "{", "$", "commands", "[", "'Example:'", "]", "=", "[", "$", "docs", "[", "'Example'", "]", "]", ";", "}", "\\", "output", "(", ")", "->", "writeList", "(", "$", "commands", ")", ";", "}" ]
the help of group @param string $controllerClass @param string $commandMethod @throws \ReflectionException
[ "the", "help", "of", "group" ]
d7153f56505a9be420ebae9eb29f7e45bfb2982e
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L139-L178
233,328
swoft-cloud/swoft-console
src/Command.php
Command.showCommandList
public function showCommandList(bool $showLogo = true) { $commands = $this->parserCmdAndDesc(); $commandList = []; $script = \input()->getFullScript(); $commandList['Usage:'] = ["php $script {command} [arguments] [options]"]; $commandList['Commands:'] = $commands; $commandList['Options:'] = [ '-h, --help' => 'Display help information', '-v, --version' => 'Display version information', ]; // show logo if ($showLogo) { \output()->writeLogo(); } // output list \output()->writeList($commandList, 'comment', 'info'); }
php
public function showCommandList(bool $showLogo = true) { $commands = $this->parserCmdAndDesc(); $commandList = []; $script = \input()->getFullScript(); $commandList['Usage:'] = ["php $script {command} [arguments] [options]"]; $commandList['Commands:'] = $commands; $commandList['Options:'] = [ '-h, --help' => 'Display help information', '-v, --version' => 'Display version information', ]; // show logo if ($showLogo) { \output()->writeLogo(); } // output list \output()->writeList($commandList, 'comment', 'info'); }
[ "public", "function", "showCommandList", "(", "bool", "$", "showLogo", "=", "true", ")", "{", "$", "commands", "=", "$", "this", "->", "parserCmdAndDesc", "(", ")", ";", "$", "commandList", "=", "[", "]", ";", "$", "script", "=", "\\", "input", "(", ")", "->", "getFullScript", "(", ")", ";", "$", "commandList", "[", "'Usage:'", "]", "=", "[", "\"php $script {command} [arguments] [options]\"", "]", ";", "$", "commandList", "[", "'Commands:'", "]", "=", "$", "commands", ";", "$", "commandList", "[", "'Options:'", "]", "=", "[", "'-h, --help'", "=>", "'Display help information'", ",", "'-v, --version'", "=>", "'Display version information'", ",", "]", ";", "// show logo", "if", "(", "$", "showLogo", ")", "{", "\\", "output", "(", ")", "->", "writeLogo", "(", ")", ";", "}", "// output list", "\\", "output", "(", ")", "->", "writeList", "(", "$", "commandList", ",", "'comment'", ",", "'info'", ")", ";", "}" ]
show all commands for the console app @param bool $showLogo @throws \ReflectionException
[ "show", "all", "commands", "for", "the", "console", "app" ]
d7153f56505a9be420ebae9eb29f7e45bfb2982e
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L186-L206
233,329
swoft-cloud/swoft-console
src/Command.php
Command.parserCmdAndDesc
private function parserCmdAndDesc(): array { $commands = []; $collector = CommandCollector::getCollector(); /* @var \Swoft\Console\Router\HandlerMapping $route */ $route = App::getBean('commandRoute'); foreach ($collector as $className => $command) { if (!$command['enabled']) { continue; } $rc = new \ReflectionClass($className); $docComment = $rc->getDocComment(); $docAry = DocBlockHelper::getTags($docComment); $prefix = $command['name']; $prefix = $route->getPrefix($prefix, $className); $commands[$prefix] = StringHelper::ucfirst($docAry['Description']); } // sort commands ksort($commands); return $commands; }
php
private function parserCmdAndDesc(): array { $commands = []; $collector = CommandCollector::getCollector(); /* @var \Swoft\Console\Router\HandlerMapping $route */ $route = App::getBean('commandRoute'); foreach ($collector as $className => $command) { if (!$command['enabled']) { continue; } $rc = new \ReflectionClass($className); $docComment = $rc->getDocComment(); $docAry = DocBlockHelper::getTags($docComment); $prefix = $command['name']; $prefix = $route->getPrefix($prefix, $className); $commands[$prefix] = StringHelper::ucfirst($docAry['Description']); } // sort commands ksort($commands); return $commands; }
[ "private", "function", "parserCmdAndDesc", "(", ")", ":", "array", "{", "$", "commands", "=", "[", "]", ";", "$", "collector", "=", "CommandCollector", "::", "getCollector", "(", ")", ";", "/* @var \\Swoft\\Console\\Router\\HandlerMapping $route */", "$", "route", "=", "App", "::", "getBean", "(", "'commandRoute'", ")", ";", "foreach", "(", "$", "collector", "as", "$", "className", "=>", "$", "command", ")", "{", "if", "(", "!", "$", "command", "[", "'enabled'", "]", ")", "{", "continue", ";", "}", "$", "rc", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "$", "docComment", "=", "$", "rc", "->", "getDocComment", "(", ")", ";", "$", "docAry", "=", "DocBlockHelper", "::", "getTags", "(", "$", "docComment", ")", ";", "$", "prefix", "=", "$", "command", "[", "'name'", "]", ";", "$", "prefix", "=", "$", "route", "->", "getPrefix", "(", "$", "prefix", ",", "$", "className", ")", ";", "$", "commands", "[", "$", "prefix", "]", "=", "StringHelper", "::", "ucfirst", "(", "$", "docAry", "[", "'Description'", "]", ")", ";", "}", "// sort commands", "ksort", "(", "$", "commands", ")", ";", "return", "$", "commands", ";", "}" ]
the command list @return array @throws \ReflectionException
[ "the", "command", "list" ]
d7153f56505a9be420ebae9eb29f7e45bfb2982e
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L232-L258
233,330
notthatbad/silverstripe-rest-api
code/extensions/SlugableExtension.php
SlugableExtension.onBeforeWrite
public function onBeforeWrite() { parent::onBeforeWrite(); $defaults = $this->owner->config()->defaults; $URLSegment = $this->owner->URLSegment; // If there is no URLSegment set, generate one from Title if((!$URLSegment || $URLSegment == $defaults['URLSegment']) && $this->owner->Title != $defaults['Title']) { $URLSegment = $this->generateURLSegment($this->owner->Title); } else if($this->owner->isChanged('URLSegment')) { // Make sure the URLSegment is valid for use in a URL $segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->owner->URLSegment); $segment = preg_replace('/-+/','-',$segment); // If after sanitising there is no URLSegment, give it a reasonable default if(!$segment) { $segment = $this->fallbackUrl(); } $URLSegment = $segment; } // Ensure that this object has a non-conflicting URLSegment value. $count = 2; $ID = $this->owner->ID; while($this->lookForExistingURLSegment($URLSegment, $ID)) { $URLSegment = preg_replace('/-[0-9]+$/', null, $URLSegment) . '-' . $count; $count++; } $this->owner->URLSegment = $URLSegment; }
php
public function onBeforeWrite() { parent::onBeforeWrite(); $defaults = $this->owner->config()->defaults; $URLSegment = $this->owner->URLSegment; // If there is no URLSegment set, generate one from Title if((!$URLSegment || $URLSegment == $defaults['URLSegment']) && $this->owner->Title != $defaults['Title']) { $URLSegment = $this->generateURLSegment($this->owner->Title); } else if($this->owner->isChanged('URLSegment')) { // Make sure the URLSegment is valid for use in a URL $segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->owner->URLSegment); $segment = preg_replace('/-+/','-',$segment); // If after sanitising there is no URLSegment, give it a reasonable default if(!$segment) { $segment = $this->fallbackUrl(); } $URLSegment = $segment; } // Ensure that this object has a non-conflicting URLSegment value. $count = 2; $ID = $this->owner->ID; while($this->lookForExistingURLSegment($URLSegment, $ID)) { $URLSegment = preg_replace('/-[0-9]+$/', null, $URLSegment) . '-' . $count; $count++; } $this->owner->URLSegment = $URLSegment; }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "parent", "::", "onBeforeWrite", "(", ")", ";", "$", "defaults", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "defaults", ";", "$", "URLSegment", "=", "$", "this", "->", "owner", "->", "URLSegment", ";", "// If there is no URLSegment set, generate one from Title", "if", "(", "(", "!", "$", "URLSegment", "||", "$", "URLSegment", "==", "$", "defaults", "[", "'URLSegment'", "]", ")", "&&", "$", "this", "->", "owner", "->", "Title", "!=", "$", "defaults", "[", "'Title'", "]", ")", "{", "$", "URLSegment", "=", "$", "this", "->", "generateURLSegment", "(", "$", "this", "->", "owner", "->", "Title", ")", ";", "}", "else", "if", "(", "$", "this", "->", "owner", "->", "isChanged", "(", "'URLSegment'", ")", ")", "{", "// Make sure the URLSegment is valid for use in a URL", "$", "segment", "=", "preg_replace", "(", "'/[^A-Za-z0-9]+/'", ",", "'-'", ",", "$", "this", "->", "owner", "->", "URLSegment", ")", ";", "$", "segment", "=", "preg_replace", "(", "'/-+/'", ",", "'-'", ",", "$", "segment", ")", ";", "// If after sanitising there is no URLSegment, give it a reasonable default", "if", "(", "!", "$", "segment", ")", "{", "$", "segment", "=", "$", "this", "->", "fallbackUrl", "(", ")", ";", "}", "$", "URLSegment", "=", "$", "segment", ";", "}", "// Ensure that this object has a non-conflicting URLSegment value.", "$", "count", "=", "2", ";", "$", "ID", "=", "$", "this", "->", "owner", "->", "ID", ";", "while", "(", "$", "this", "->", "lookForExistingURLSegment", "(", "$", "URLSegment", ",", "$", "ID", ")", ")", "{", "$", "URLSegment", "=", "preg_replace", "(", "'/-[0-9]+$/'", ",", "null", ",", "$", "URLSegment", ")", ".", "'-'", ".", "$", "count", ";", "$", "count", "++", ";", "}", "$", "this", "->", "owner", "->", "URLSegment", "=", "$", "URLSegment", ";", "}" ]
Set URLSegment to be unique on write
[ "Set", "URLSegment", "to", "be", "unique", "on", "write" ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/SlugableExtension.php#L33-L60
233,331
notthatbad/silverstripe-rest-api
code/extensions/SlugableExtension.php
SlugableExtension.lookForExistingURLSegment
protected function lookForExistingURLSegment($urlSegment, $id) { return $this->owner->get()->filter( 'URLSegment', $urlSegment )->exclude('ID', is_null($id) ? 0 : $id)->exists(); }
php
protected function lookForExistingURLSegment($urlSegment, $id) { return $this->owner->get()->filter( 'URLSegment', $urlSegment )->exclude('ID', is_null($id) ? 0 : $id)->exists(); }
[ "protected", "function", "lookForExistingURLSegment", "(", "$", "urlSegment", ",", "$", "id", ")", "{", "return", "$", "this", "->", "owner", "->", "get", "(", ")", "->", "filter", "(", "'URLSegment'", ",", "$", "urlSegment", ")", "->", "exclude", "(", "'ID'", ",", "is_null", "(", "$", "id", ")", "?", "0", ":", "$", "id", ")", "->", "exists", "(", ")", ";", "}" ]
Check if there is already a database entry with this url segment @param string $urlSegment @param int $id @return bool
[ "Check", "if", "there", "is", "already", "a", "database", "entry", "with", "this", "url", "segment" ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/SlugableExtension.php#L69-L73
233,332
CampaignChain/core
Controller/REST/ChannelController.php
ChannelController.getLocationsUrlsMetaAction
public function getLocationsUrlsMetaAction() { $qb = $this->getQueryBuilder(); $qb->select('l.url'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.operation IS NULL'); $qb->groupBy(('l.url')); $query = $qb->getQuery(); $urls = $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); return $this->response( VariableUtil::arrayFlatten($urls) ); }
php
public function getLocationsUrlsMetaAction() { $qb = $this->getQueryBuilder(); $qb->select('l.url'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.operation IS NULL'); $qb->groupBy(('l.url')); $query = $qb->getQuery(); $urls = $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); return $this->response( VariableUtil::arrayFlatten($urls) ); }
[ "public", "function", "getLocationsUrlsMetaAction", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "'l.url'", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Channel'", ",", "'c'", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Location'", ",", "'l'", ")", ";", "$", "qb", "->", "where", "(", "'c.id = l.channel'", ")", ";", "$", "qb", "->", "andWhere", "(", "'l.operation IS NULL'", ")", ";", "$", "qb", "->", "groupBy", "(", "(", "'l.url'", ")", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "urls", "=", "$", "query", "->", "getResult", "(", "\\", "Doctrine", "\\", "ORM", "\\", "Query", "::", "HYDRATE_ARRAY", ")", ";", "return", "$", "this", "->", "response", "(", "VariableUtil", "::", "arrayFlatten", "(", "$", "urls", ")", ")", ";", "}" ]
List all URLs of all connected Locations in all Channels. Example Request =============== GET /api/v1/locations/urls Example Response ================ { "1": "http://wordpress.amariki.com", "2": "http://www.slideshare.net/amariki_test", "3": "https://global.gotowebinar.com/webinars.tmpl", "4": "https://twitter.com/AmarikiTest1", "5": "https://www.facebook.com/pages/Amariki/1384145015223372", "6": "https://www.facebook.com/profile.php?id=100008874400259", "7": "https://www.facebook.com/profile.php?id=100008922632416", "8": "https://www.linkedin.com/pub/amariki-software/a1/455/616" } @ApiDoc( section="Core" ) @REST\GET("/locations/urls") @return \Symfony\Component\HttpFoundation\Response
[ "List", "all", "URLs", "of", "all", "connected", "Locations", "in", "all", "Channels", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ChannelController.php#L65-L81
233,333
CampaignChain/core
Controller/REST/ChannelController.php
ChannelController.getLocationsUrlsAction
public function getLocationsUrlsAction($url) { $qb = $this->getQueryBuilder(); $qb->select('c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.url = :url'); $qb->setParameter('url', $url); $qb = $this->getModulePackage($qb, 'c.channelModule'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getLocationsUrlsAction($url) { $qb = $this->getQueryBuilder(); $qb->select('c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.url = :url'); $qb->setParameter('url', $url); $qb = $this->getModulePackage($qb, 'c.channelModule'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getLocationsUrlsAction", "(", "$", "url", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "'c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Channel'", ",", "'c'", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Location'", ",", "'l'", ")", ";", "$", "qb", "->", "where", "(", "'c.id = l.channel'", ")", ";", "$", "qb", "->", "andWhere", "(", "'l.url = :url'", ")", ";", "$", "qb", "->", "setParameter", "(", "'url'", ",", "$", "url", ")", ";", "$", "qb", "=", "$", "this", "->", "getModulePackage", "(", "$", "qb", ",", "'c.channelModule'", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "return", "$", "this", "->", "response", "(", "$", "query", "->", "getResult", "(", "\\", "Doctrine", "\\", "ORM", "\\", "Query", "::", "HYDRATE_ARRAY", ")", ")", ";", "}" ]
Get a specific Channel Location by its URL. Example Request =============== GET /api/v1/channels/locations/urls/https%3A%2F%2Ftwitter.com%2FAmarikiTest1 Example Response ================ [ { "id": 2, "displayName": "Corporate Twitter Account", "url": "https://twitter.com/AmarikiTest1", "trackingId": "2f6d485e7789e7b6d70b546d221739cf", "status": "active", "createdDate": "2015-11-26T11:08:29+0000", "composerPackage": "campaignchain/channel-twitter", "moduleIdentifier": "campaignchain-twitter" } ] @ApiDoc( section="Core", requirements={ { "name"="url", "requirement"=".+" } } ) @REST\NoRoute() // We have specified a route manually. @param string $url URL of a Channel connected to CampaignChain, e.g. 'https://twitter.com/AmarikiTest1'. @return \Symfony\Component\HttpFoundation\Response
[ "Get", "a", "specific", "Channel", "Location", "by", "its", "URL", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ChannelController.php#L123-L138
233,334
cornernote/yii-email-module
email/EmailModule.php
EmailModule.initYiiStrap
public function initYiiStrap() { // check that we are in a web application if (!(Yii::app() instanceof CWebApplication)) return; // and in this module $route = explode('/', Yii::app()->urlManager->parseUrl(Yii::app()->request)); if ($route[0] != $this->id) return; // and yiiStrap is not configured if (Yii::getPathOfAlias('bootstrap') && file_exists(Yii::getPathOfAlias('bootstrap.helpers') . '/TbHtml.php')) return; // try to guess yiiStrapPath if ($this->yiiStrapPath === null) $this->yiiStrapPath = Yii::getPathOfAlias('vendor.crisu83.yiistrap'); // check for valid path if (!realpath($this->yiiStrapPath)) return; // setup yiiStrap components Yii::setPathOfAlias('bootstrap', realpath($this->yiiStrapPath)); Yii::import('bootstrap.helpers.*'); Yii::import('bootstrap.widgets.*'); Yii::import('bootstrap.behaviors.*'); Yii::import('bootstrap.form.*'); Yii::app()->setComponents(array( 'bootstrap' => array( 'class' => 'bootstrap.components.TbApi', ), ), false); }
php
public function initYiiStrap() { // check that we are in a web application if (!(Yii::app() instanceof CWebApplication)) return; // and in this module $route = explode('/', Yii::app()->urlManager->parseUrl(Yii::app()->request)); if ($route[0] != $this->id) return; // and yiiStrap is not configured if (Yii::getPathOfAlias('bootstrap') && file_exists(Yii::getPathOfAlias('bootstrap.helpers') . '/TbHtml.php')) return; // try to guess yiiStrapPath if ($this->yiiStrapPath === null) $this->yiiStrapPath = Yii::getPathOfAlias('vendor.crisu83.yiistrap'); // check for valid path if (!realpath($this->yiiStrapPath)) return; // setup yiiStrap components Yii::setPathOfAlias('bootstrap', realpath($this->yiiStrapPath)); Yii::import('bootstrap.helpers.*'); Yii::import('bootstrap.widgets.*'); Yii::import('bootstrap.behaviors.*'); Yii::import('bootstrap.form.*'); Yii::app()->setComponents(array( 'bootstrap' => array( 'class' => 'bootstrap.components.TbApi', ), ), false); }
[ "public", "function", "initYiiStrap", "(", ")", "{", "// check that we are in a web application", "if", "(", "!", "(", "Yii", "::", "app", "(", ")", "instanceof", "CWebApplication", ")", ")", "return", ";", "// and in this module", "$", "route", "=", "explode", "(", "'/'", ",", "Yii", "::", "app", "(", ")", "->", "urlManager", "->", "parseUrl", "(", "Yii", "::", "app", "(", ")", "->", "request", ")", ")", ";", "if", "(", "$", "route", "[", "0", "]", "!=", "$", "this", "->", "id", ")", "return", ";", "// and yiiStrap is not configured", "if", "(", "Yii", "::", "getPathOfAlias", "(", "'bootstrap'", ")", "&&", "file_exists", "(", "Yii", "::", "getPathOfAlias", "(", "'bootstrap.helpers'", ")", ".", "'/TbHtml.php'", ")", ")", "return", ";", "// try to guess yiiStrapPath", "if", "(", "$", "this", "->", "yiiStrapPath", "===", "null", ")", "$", "this", "->", "yiiStrapPath", "=", "Yii", "::", "getPathOfAlias", "(", "'vendor.crisu83.yiistrap'", ")", ";", "// check for valid path", "if", "(", "!", "realpath", "(", "$", "this", "->", "yiiStrapPath", ")", ")", "return", ";", "// setup yiiStrap components", "Yii", "::", "setPathOfAlias", "(", "'bootstrap'", ",", "realpath", "(", "$", "this", "->", "yiiStrapPath", ")", ")", ";", "Yii", "::", "import", "(", "'bootstrap.helpers.*'", ")", ";", "Yii", "::", "import", "(", "'bootstrap.widgets.*'", ")", ";", "Yii", "::", "import", "(", "'bootstrap.behaviors.*'", ")", ";", "Yii", "::", "import", "(", "'bootstrap.form.*'", ")", ";", "Yii", "::", "app", "(", ")", "->", "setComponents", "(", "array", "(", "'bootstrap'", "=>", "array", "(", "'class'", "=>", "'bootstrap.components.TbApi'", ",", ")", ",", ")", ",", "false", ")", ";", "}" ]
Setup yiiStrap, works even if YiiBooster is used in main app.
[ "Setup", "yiiStrap", "works", "even", "if", "YiiBooster", "is", "used", "in", "main", "app", "." ]
dcfb9e17dc0b4daff7052418d26402e05e1c8887
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/EmailModule.php#L207-L236
233,335
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Vocabulary/VocabularyService.php
VocabularyService.validateVocabularyUri
public function validateVocabularyUri($uri) { $uri = trim($uri); // If the vocabulary URI is invalid if (!strlen($uri) || !filter_var($uri, FILTER_VALIDATE_URL)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_URI_STR, $uri), RuntimeException::INVALID_VOCABULARY_URI ); } return $uri; }
php
public function validateVocabularyUri($uri) { $uri = trim($uri); // If the vocabulary URI is invalid if (!strlen($uri) || !filter_var($uri, FILTER_VALIDATE_URL)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_URI_STR, $uri), RuntimeException::INVALID_VOCABULARY_URI ); } return $uri; }
[ "public", "function", "validateVocabularyUri", "(", "$", "uri", ")", "{", "$", "uri", "=", "trim", "(", "$", "uri", ")", ";", "// If the vocabulary URI is invalid", "if", "(", "!", "strlen", "(", "$", "uri", ")", "||", "!", "filter_var", "(", "$", "uri", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "RuntimeException", "::", "INVALID_VOCABULARY_URI_STR", ",", "$", "uri", ")", ",", "RuntimeException", "::", "INVALID_VOCABULARY_URI", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Validate a vocabulary URI @param string $uri URI @return string Valid vocabulary URI @throws RuntimeException If the vocabulary URI is invalid
[ "Validate", "a", "vocabulary", "URI" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Vocabulary/VocabularyService.php#L56-L69
233,336
Deathnerd/php-wtforms
src/Form.php
Form.populateObj
public function populateObj(&$obj) { foreach ($this->fields as $field_name => $field) { /** * @var Field $field */ $field->populateObj($obj, $field_name); } return $obj; }
php
public function populateObj(&$obj) { foreach ($this->fields as $field_name => $field) { /** * @var Field $field */ $field->populateObj($obj, $field_name); } return $obj; }
[ "public", "function", "populateObj", "(", "&", "$", "obj", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field_name", "=>", "$", "field", ")", "{", "/**\n * @var Field $field\n */", "$", "field", "->", "populateObj", "(", "$", "obj", ",", "$", "field_name", ")", ";", "}", "return", "$", "obj", ";", "}" ]
This takes in an object with properties and assigns their values to the values of fields with the same name on this form. This is a destructive operation. If a field exists on this form that has the same name as a property on the object, it WILL BE OVERWRITTEN. @param object $obj The object to populate @return object The object with the data from the form replacing values for members of the object
[ "This", "takes", "in", "an", "object", "with", "properties", "and", "assigns", "their", "values", "to", "the", "values", "of", "fields", "with", "the", "same", "name", "on", "this", "form", "." ]
2e1f9ad515f6241c9fac57edc472bf657267f4a1
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L252-L262
233,337
Deathnerd/php-wtforms
src/Form.php
Form.populateArray
public function populateArray(array $array) { foreach ($this->fields as $field_name => $field) { if ($field->data) { $array[$field_name] = $field->data; } } return $array; }
php
public function populateArray(array $array) { foreach ($this->fields as $field_name => $field) { if ($field->data) { $array[$field_name] = $field->data; } } return $array; }
[ "public", "function", "populateArray", "(", "array", "$", "array", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field_name", "=>", "$", "field", ")", "{", "if", "(", "$", "field", "->", "data", ")", "{", "$", "array", "[", "$", "field_name", "]", "=", "$", "field", "->", "data", ";", "}", "}", "return", "$", "array", ";", "}" ]
This takes in a keyed array and assigns their values to the values of fields with the same name as the key. !!!!!!!!!!!!! !!!WARNING!!! !!!!!!!!!!!!! This is a destructive operation. If a field exists on this form that has the same name as a key in the array, it WILL BE OVERWRITTEN. @param array $array The array to populate @return array The array with data from the form replacing values already existing in the array
[ "This", "takes", "in", "a", "keyed", "array", "and", "assigns", "their", "values", "to", "the", "values", "of", "fields", "with", "the", "same", "name", "as", "the", "key", "." ]
2e1f9ad515f6241c9fac57edc472bf657267f4a1
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L278-L287
233,338
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidStartDate
public function isValidStartDate(Campaign $campaign, \DateTime $startDate) { if($startDate != $campaign->getStartDate()){ /* * While changing the campaign start date, has an earlier * Action been added by someone else? */ /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); if($firstAction && $startDate > $firstAction->getStartDate()){ return false; } } return true; }
php
public function isValidStartDate(Campaign $campaign, \DateTime $startDate) { if($startDate != $campaign->getStartDate()){ /* * While changing the campaign start date, has an earlier * Action been added by someone else? */ /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); if($firstAction && $startDate > $firstAction->getStartDate()){ return false; } } return true; }
[ "public", "function", "isValidStartDate", "(", "Campaign", "$", "campaign", ",", "\\", "DateTime", "$", "startDate", ")", "{", "if", "(", "$", "startDate", "!=", "$", "campaign", "->", "getStartDate", "(", ")", ")", "{", "/*\n * While changing the campaign start date, has an earlier\n * Action been added by someone else?\n */", "/** @var Action $firstAction */", "$", "firstAction", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChain\\CoreBundle\\Entity\\Campaign'", ")", "->", "getFirstAction", "(", "$", "campaign", ")", ";", "if", "(", "$", "firstAction", "&&", "$", "startDate", ">", "$", "firstAction", "->", "getStartDate", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Find out if the start date was changed. If so, then make sure that while editing, no Actions have been added prior or after the respective date. @param Campaign $campaign @param \DateTime $startDate @throws \Exception
[ "Find", "out", "if", "the", "start", "date", "was", "changed", ".", "If", "so", "then", "make", "sure", "that", "while", "editing", "no", "Actions", "have", "been", "added", "prior", "or", "after", "the", "respective", "date", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L309-L326
233,339
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidEndDate
public function isValidEndDate(Campaign $campaign, \DateTime $endDate) { if($endDate != $campaign->getEndDate()){ /* * While changing the campaign end date, has a later * Action been added by someone else? */ /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); if($lastAction && $endDate < $lastAction->getStartDate()){ return false; } } return true; }
php
public function isValidEndDate(Campaign $campaign, \DateTime $endDate) { if($endDate != $campaign->getEndDate()){ /* * While changing the campaign end date, has a later * Action been added by someone else? */ /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); if($lastAction && $endDate < $lastAction->getStartDate()){ return false; } } return true; }
[ "public", "function", "isValidEndDate", "(", "Campaign", "$", "campaign", ",", "\\", "DateTime", "$", "endDate", ")", "{", "if", "(", "$", "endDate", "!=", "$", "campaign", "->", "getEndDate", "(", ")", ")", "{", "/*\n * While changing the campaign end date, has a later\n * Action been added by someone else?\n */", "/** @var Action $lastAction */", "$", "lastAction", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChain\\CoreBundle\\Entity\\Campaign'", ")", "->", "getLastAction", "(", "$", "campaign", ")", ";", "if", "(", "$", "lastAction", "&&", "$", "endDate", "<", "$", "lastAction", "->", "getStartDate", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Find out if the end date was changed. If so, then make sure that while editing, no Actions have been added prior or after the respective date. @param Campaign $campaign @param \DateTime $endDate @throws \Exception
[ "Find", "out", "if", "the", "end", "date", "was", "changed", ".", "If", "so", "then", "make", "sure", "that", "while", "editing", "no", "Actions", "have", "been", "added", "prior", "or", "after", "the", "respective", "date", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L336-L353
233,340
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidTimespan
public function isValidTimespan(Campaign $campaign, \DateInterval $campaignInterval) { /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); // If no first and last action, any timespan is fine. if(!$firstAction && !$lastAction){ return true; } /* * If first and last action exist, make sure the timespan stretches from * the start of the first to the start or end of the last action. */ if($firstAction && $lastAction){ if($lastAction->getEndDate()){ $endDate = $lastAction->getEndDate(); } else { $endDate = $lastAction->getStartDate(); } $actionsInterval = $firstAction->getStartDate()->diff($endDate); return $campaignInterval >= $actionsInterval; } /* * If only first action or last action, make sure the timespan covers * the duration of the action. */ if($firstAction && !$lastAction) { $action = $firstAction; } else { $action = $lastAction; } // If the action has no end date, then any timespan will do. if(!$action->getEndDate()){ return true; } $actionInterval = $action->getStartDate()->diff($action->getEndDate()); return $campaignInterval >= $actionInterval; }
php
public function isValidTimespan(Campaign $campaign, \DateInterval $campaignInterval) { /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); // If no first and last action, any timespan is fine. if(!$firstAction && !$lastAction){ return true; } /* * If first and last action exist, make sure the timespan stretches from * the start of the first to the start or end of the last action. */ if($firstAction && $lastAction){ if($lastAction->getEndDate()){ $endDate = $lastAction->getEndDate(); } else { $endDate = $lastAction->getStartDate(); } $actionsInterval = $firstAction->getStartDate()->diff($endDate); return $campaignInterval >= $actionsInterval; } /* * If only first action or last action, make sure the timespan covers * the duration of the action. */ if($firstAction && !$lastAction) { $action = $firstAction; } else { $action = $lastAction; } // If the action has no end date, then any timespan will do. if(!$action->getEndDate()){ return true; } $actionInterval = $action->getStartDate()->diff($action->getEndDate()); return $campaignInterval >= $actionInterval; }
[ "public", "function", "isValidTimespan", "(", "Campaign", "$", "campaign", ",", "\\", "DateInterval", "$", "campaignInterval", ")", "{", "/** @var Action $firstAction */", "$", "firstAction", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChain\\CoreBundle\\Entity\\Campaign'", ")", "->", "getFirstAction", "(", "$", "campaign", ")", ";", "/** @var Action $lastAction */", "$", "lastAction", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChain\\CoreBundle\\Entity\\Campaign'", ")", "->", "getLastAction", "(", "$", "campaign", ")", ";", "// If no first and last action, any timespan is fine.", "if", "(", "!", "$", "firstAction", "&&", "!", "$", "lastAction", ")", "{", "return", "true", ";", "}", "/*\n * If first and last action exist, make sure the timespan stretches from\n * the start of the first to the start or end of the last action.\n */", "if", "(", "$", "firstAction", "&&", "$", "lastAction", ")", "{", "if", "(", "$", "lastAction", "->", "getEndDate", "(", ")", ")", "{", "$", "endDate", "=", "$", "lastAction", "->", "getEndDate", "(", ")", ";", "}", "else", "{", "$", "endDate", "=", "$", "lastAction", "->", "getStartDate", "(", ")", ";", "}", "$", "actionsInterval", "=", "$", "firstAction", "->", "getStartDate", "(", ")", "->", "diff", "(", "$", "endDate", ")", ";", "return", "$", "campaignInterval", ">=", "$", "actionsInterval", ";", "}", "/*\n * If only first action or last action, make sure the timespan covers\n * the duration of the action.\n */", "if", "(", "$", "firstAction", "&&", "!", "$", "lastAction", ")", "{", "$", "action", "=", "$", "firstAction", ";", "}", "else", "{", "$", "action", "=", "$", "lastAction", ";", "}", "// If the action has no end date, then any timespan will do.", "if", "(", "!", "$", "action", "->", "getEndDate", "(", ")", ")", "{", "return", "true", ";", "}", "$", "actionInterval", "=", "$", "action", "->", "getStartDate", "(", ")", "->", "diff", "(", "$", "action", "->", "getEndDate", "(", ")", ")", ";", "return", "$", "campaignInterval", ">=", "$", "actionInterval", ";", "}" ]
Calculates whether the given timespan covers the first and last action in a campaign. @param Campaign $campaign @param \DateInterval $campaignInterval @return bool
[ "Calculates", "whether", "the", "given", "timespan", "covers", "the", "first", "and", "last", "action", "in", "a", "campaign", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L411-L460
233,341
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processVocab
protected function processVocab(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('vocab') && ($context instanceof RdfaLiteContext)) { $defaultVocabulary = new Vocabulary($element->getAttribute('vocab')); $context = $context->setDefaultVocabulary($defaultVocabulary); } return $context; }
php
protected function processVocab(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('vocab') && ($context instanceof RdfaLiteContext)) { $defaultVocabulary = new Vocabulary($element->getAttribute('vocab')); $context = $context->setDefaultVocabulary($defaultVocabulary); } return $context; }
[ "protected", "function", "processVocab", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'vocab'", ")", "&&", "(", "$", "context", "instanceof", "RdfaLiteContext", ")", ")", "{", "$", "defaultVocabulary", "=", "new", "Vocabulary", "(", "$", "element", "->", "getAttribute", "(", "'vocab'", ")", ")", ";", "$", "context", "=", "$", "context", "->", "setDefaultVocabulary", "(", "$", "defaultVocabulary", ")", ";", "}", "return", "$", "context", ";", "}" ]
Process changes of the default vocabulary @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "changes", "of", "the", "default", "vocabulary" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L80-L88
233,342
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processPrefix
protected function processPrefix(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) { $prefixes = preg_split('/\s+/', $element->getAttribute('prefix')); while (count($prefixes)) { $prefix = rtrim(array_shift($prefixes), ':'); $uri = array_shift($prefixes); $context = $context->registerVocabulary($prefix, $uri); } } return $context; }
php
protected function processPrefix(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) { $prefixes = preg_split('/\s+/', $element->getAttribute('prefix')); while (count($prefixes)) { $prefix = rtrim(array_shift($prefixes), ':'); $uri = array_shift($prefixes); $context = $context->registerVocabulary($prefix, $uri); } } return $context; }
[ "protected", "function", "processPrefix", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'prefix'", ")", "&&", "(", "$", "context", "instanceof", "RdfaLiteContext", ")", ")", "{", "$", "prefixes", "=", "preg_split", "(", "'/\\s+/'", ",", "$", "element", "->", "getAttribute", "(", "'prefix'", ")", ")", ";", "while", "(", "count", "(", "$", "prefixes", ")", ")", "{", "$", "prefix", "=", "rtrim", "(", "array_shift", "(", "$", "prefixes", ")", ",", "':'", ")", ";", "$", "uri", "=", "array_shift", "(", "$", "prefixes", ")", ";", "$", "context", "=", "$", "context", "->", "registerVocabulary", "(", "$", "prefix", ",", "$", "uri", ")", ";", "}", "}", "return", "$", "context", ";", "}" ]
Process vocabulary prefixes @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "vocabulary", "prefixes" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L97-L109
233,343
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.getPrefixName
protected function getPrefixName($prefixName) { $prefixName = explode(':', $prefixName); $name = array_pop($prefixName); $prefix = array_pop($prefixName); return [$prefix, $name]; }
php
protected function getPrefixName($prefixName) { $prefixName = explode(':', $prefixName); $name = array_pop($prefixName); $prefix = array_pop($prefixName); return [$prefix, $name]; }
[ "protected", "function", "getPrefixName", "(", "$", "prefixName", ")", "{", "$", "prefixName", "=", "explode", "(", "':'", ",", "$", "prefixName", ")", ";", "$", "name", "=", "array_pop", "(", "$", "prefixName", ")", ";", "$", "prefix", "=", "array_pop", "(", "$", "prefixName", ")", ";", "return", "[", "$", "prefix", ",", "$", "name", "]", ";", "}" ]
Split a value into a vocabulary prefix and a name @param string $prefixName Prefixed name @return array Prefix and name
[ "Split", "a", "value", "into", "a", "vocabulary", "prefix", "and", "a", "name" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L143-L149
233,344
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.getVocabulary
protected function getVocabulary($prefix, ContextInterface $context) { return (empty($prefix) || !($context instanceof RdfaLiteContext)) ? $context->getDefaultVocabulary() : $context->getVocabulary($prefix); }
php
protected function getVocabulary($prefix, ContextInterface $context) { return (empty($prefix) || !($context instanceof RdfaLiteContext)) ? $context->getDefaultVocabulary() : $context->getVocabulary($prefix); }
[ "protected", "function", "getVocabulary", "(", "$", "prefix", ",", "ContextInterface", "$", "context", ")", "{", "return", "(", "empty", "(", "$", "prefix", ")", "||", "!", "(", "$", "context", "instanceof", "RdfaLiteContext", ")", ")", "?", "$", "context", "->", "getDefaultVocabulary", "(", ")", ":", "$", "context", "->", "getVocabulary", "(", "$", "prefix", ")", ";", "}" ]
Return a vocabulary by prefix with fallback to the default vocabulary @param string $prefix Vocabulary prefix @param ContextInterface $context Context @return VocabularyInterface Vocabulary
[ "Return", "a", "vocabulary", "by", "prefix", "with", "fallback", "to", "the", "default", "vocabulary" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L229-L233
233,345
kgilden/php-digidoc
src/Tracker.php
Tracker.add
public function add($objects) { $objects = is_array($objects) ? $objects : array($objects); foreach ($objects as $object) { if ($this->has($object)) { continue; } $this->objects[] = $object; } }
php
public function add($objects) { $objects = is_array($objects) ? $objects : array($objects); foreach ($objects as $object) { if ($this->has($object)) { continue; } $this->objects[] = $object; } }
[ "public", "function", "add", "(", "$", "objects", ")", "{", "$", "objects", "=", "is_array", "(", "$", "objects", ")", "?", "$", "objects", ":", "array", "(", "$", "objects", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "object", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "objects", "[", "]", "=", "$", "object", ";", "}", "}" ]
Adds the given objects to the tracker. You can pass either a single object or an array of objects. @param object|object[] $objects
[ "Adds", "the", "given", "objects", "to", "the", "tracker", ".", "You", "can", "pass", "either", "a", "single", "object", "or", "an", "array", "of", "objects", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Tracker.php#L27-L38
233,346
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.getContent
public function getContent($type = self::URL_TYPE_SHORTENED_TRACKED) { if (self::URL_TYPE_ORIGINAL === $type) { return $this->content; } else { return ParserUtil::replaceURLsInText($this->content, $this->getReplacementUrls($type)); } }
php
public function getContent($type = self::URL_TYPE_SHORTENED_TRACKED) { if (self::URL_TYPE_ORIGINAL === $type) { return $this->content; } else { return ParserUtil::replaceURLsInText($this->content, $this->getReplacementUrls($type)); } }
[ "public", "function", "getContent", "(", "$", "type", "=", "self", "::", "URL_TYPE_SHORTENED_TRACKED", ")", "{", "if", "(", "self", "::", "URL_TYPE_ORIGINAL", "===", "$", "type", ")", "{", "return", "$", "this", "->", "content", ";", "}", "else", "{", "return", "ParserUtil", "::", "replaceURLsInText", "(", "$", "this", "->", "content", ",", "$", "this", "->", "getReplacementUrls", "(", "$", "type", ")", ")", ";", "}", "}" ]
Return the content with urls replaced. Various formats are available. @param mixed $type @return string
[ "Return", "the", "content", "with", "urls", "replaced", ".", "Various", "formats", "are", "available", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L67-L74
233,347
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.addTrackedCTA
public function addTrackedCTA(CTA $cta) { $this->trackedCTAs[] = $cta; $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $cta->getTrackingUrl(), $cta->getShortenedTrackingUrl() ); }
php
public function addTrackedCTA(CTA $cta) { $this->trackedCTAs[] = $cta; $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $cta->getTrackingUrl(), $cta->getShortenedTrackingUrl() ); }
[ "public", "function", "addTrackedCTA", "(", "CTA", "$", "cta", ")", "{", "$", "this", "->", "trackedCTAs", "[", "]", "=", "$", "cta", ";", "$", "this", "->", "queueForReplacement", "(", "$", "cta", "->", "getOriginalUrl", "(", ")", ",", "$", "cta", "->", "getExpandedUrl", "(", ")", ",", "$", "cta", "->", "getTrackingUrl", "(", ")", ",", "$", "cta", "->", "getShortenedTrackingUrl", "(", ")", ")", ";", "}" ]
Keep a record of a tracked CTA and queue it for replacement @param CTA $cta
[ "Keep", "a", "record", "of", "a", "tracked", "CTA", "and", "queue", "it", "for", "replacement" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L81-L91
233,348
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.addUntrackedCTA
public function addUntrackedCTA(CTA $cta) { $this->untrackedCTAs[] = $cta; if($cta->getShortenedExpandedUrl()) { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getShortenedExpandedUrl(); } elseif($cta->getShortenedUniqueExpandedUrl()){ $trackingUrl = $cta->getUniqueExpandedUrl(); $shortenedUrl = $cta->getShortenedUniqueExpandedUrl(); } else { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getOriginalUrl(); } $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $trackingUrl, $shortenedUrl ); }
php
public function addUntrackedCTA(CTA $cta) { $this->untrackedCTAs[] = $cta; if($cta->getShortenedExpandedUrl()) { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getShortenedExpandedUrl(); } elseif($cta->getShortenedUniqueExpandedUrl()){ $trackingUrl = $cta->getUniqueExpandedUrl(); $shortenedUrl = $cta->getShortenedUniqueExpandedUrl(); } else { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getOriginalUrl(); } $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $trackingUrl, $shortenedUrl ); }
[ "public", "function", "addUntrackedCTA", "(", "CTA", "$", "cta", ")", "{", "$", "this", "->", "untrackedCTAs", "[", "]", "=", "$", "cta", ";", "if", "(", "$", "cta", "->", "getShortenedExpandedUrl", "(", ")", ")", "{", "$", "trackingUrl", "=", "$", "cta", "->", "getOriginalUrl", "(", ")", ";", "$", "shortenedUrl", "=", "$", "cta", "->", "getShortenedExpandedUrl", "(", ")", ";", "}", "elseif", "(", "$", "cta", "->", "getShortenedUniqueExpandedUrl", "(", ")", ")", "{", "$", "trackingUrl", "=", "$", "cta", "->", "getUniqueExpandedUrl", "(", ")", ";", "$", "shortenedUrl", "=", "$", "cta", "->", "getShortenedUniqueExpandedUrl", "(", ")", ";", "}", "else", "{", "$", "trackingUrl", "=", "$", "cta", "->", "getOriginalUrl", "(", ")", ";", "$", "shortenedUrl", "=", "$", "cta", "->", "getOriginalUrl", "(", ")", ";", "}", "$", "this", "->", "queueForReplacement", "(", "$", "cta", "->", "getOriginalUrl", "(", ")", ",", "$", "cta", "->", "getExpandedUrl", "(", ")", ",", "$", "trackingUrl", ",", "$", "shortenedUrl", ")", ";", "}" ]
Keep a record of a untracked CTA and queue it for replacement @param CTA $cta
[ "Keep", "a", "record", "of", "a", "untracked", "CTA", "and", "queue", "it", "for", "replacement" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L98-L119
233,349
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.queueForReplacement
public function queueForReplacement($originalUrl, $expandedUrl, $trackingUrl, $shortenedTrackingUrl) { $this->replacementUrls[$originalUrl][] = array( self::URL_TYPE_EXPANDED => $expandedUrl, self::URL_TYPE_TRACKED => $trackingUrl, self::URL_TYPE_SHORTENED_TRACKED => $shortenedTrackingUrl ); }
php
public function queueForReplacement($originalUrl, $expandedUrl, $trackingUrl, $shortenedTrackingUrl) { $this->replacementUrls[$originalUrl][] = array( self::URL_TYPE_EXPANDED => $expandedUrl, self::URL_TYPE_TRACKED => $trackingUrl, self::URL_TYPE_SHORTENED_TRACKED => $shortenedTrackingUrl ); }
[ "public", "function", "queueForReplacement", "(", "$", "originalUrl", ",", "$", "expandedUrl", ",", "$", "trackingUrl", ",", "$", "shortenedTrackingUrl", ")", "{", "$", "this", "->", "replacementUrls", "[", "$", "originalUrl", "]", "[", "]", "=", "array", "(", "self", "::", "URL_TYPE_EXPANDED", "=>", "$", "expandedUrl", ",", "self", "::", "URL_TYPE_TRACKED", "=>", "$", "trackingUrl", ",", "self", "::", "URL_TYPE_SHORTENED_TRACKED", "=>", "$", "shortenedTrackingUrl", ")", ";", "}" ]
Queue urls for replacement @param string $originalUrl @param string $expandedUrl @param string $trackingUrl @param string $shortenedTrackingUrl
[ "Queue", "urls", "for", "replacement" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L129-L136
233,350
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.getReplacementUrls
public function getReplacementUrls($type) { $replacementUrls = array_map(function ($a1) use ($type) { return array_map(function ($a2) use ($type) { return $a2[$type]; }, $a1); }, $this->replacementUrls); return $replacementUrls; }
php
public function getReplacementUrls($type) { $replacementUrls = array_map(function ($a1) use ($type) { return array_map(function ($a2) use ($type) { return $a2[$type]; }, $a1); }, $this->replacementUrls); return $replacementUrls; }
[ "public", "function", "getReplacementUrls", "(", "$", "type", ")", "{", "$", "replacementUrls", "=", "array_map", "(", "function", "(", "$", "a1", ")", "use", "(", "$", "type", ")", "{", "return", "array_map", "(", "function", "(", "$", "a2", ")", "use", "(", "$", "type", ")", "{", "return", "$", "a2", "[", "$", "type", "]", ";", "}", ",", "$", "a1", ")", ";", "}", ",", "$", "this", "->", "replacementUrls", ")", ";", "return", "$", "replacementUrls", ";", "}" ]
Filter replacement urls so only one format is left. @param mixed $type @return array map of filtered replacement urls
[ "Filter", "replacement", "urls", "so", "only", "one", "format", "is", "left", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L144-L153
233,351
KnightSwarm/laravel-saml
src/KnightSwarm/LaravelSaml/Account.php
Account.IdExists
public function IdExists($id) { $property = $this->getUserIdProperty(); $user = User::where($property, "=", $id)->count(); return $user === 0 ? false : true; }
php
public function IdExists($id) { $property = $this->getUserIdProperty(); $user = User::where($property, "=", $id)->count(); return $user === 0 ? false : true; }
[ "public", "function", "IdExists", "(", "$", "id", ")", "{", "$", "property", "=", "$", "this", "->", "getUserIdProperty", "(", ")", ";", "$", "user", "=", "User", "::", "where", "(", "$", "property", ",", "\"=\"", ",", "$", "id", ")", "->", "count", "(", ")", ";", "return", "$", "user", "===", "0", "?", "false", ":", "true", ";", "}" ]
Check if the id exists in the specified user property. If no property is defined default to 'email'.
[ "Check", "if", "the", "id", "exists", "in", "the", "specified", "user", "property", ".", "If", "no", "property", "is", "defined", "default", "to", "email", "." ]
712d02f6edae914db7b48438361444b2daf66930
https://github.com/KnightSwarm/laravel-saml/blob/712d02f6edae914db7b48438361444b2daf66930/src/KnightSwarm/LaravelSaml/Account.php#L23-L28
233,352
KnightSwarm/laravel-saml
src/KnightSwarm/LaravelSaml/Account.php
Account.fillUserDetails
protected function fillUserDetails($user) { $mappings = Config::get('laravel-saml::saml.object_mappings',[]); foreach($mappings as $key => $mapping) { $user->{$key} = $this->getSamlAttribute($mapping); } }
php
protected function fillUserDetails($user) { $mappings = Config::get('laravel-saml::saml.object_mappings',[]); foreach($mappings as $key => $mapping) { $user->{$key} = $this->getSamlAttribute($mapping); } }
[ "protected", "function", "fillUserDetails", "(", "$", "user", ")", "{", "$", "mappings", "=", "Config", "::", "get", "(", "'laravel-saml::saml.object_mappings'", ",", "[", "]", ")", ";", "foreach", "(", "$", "mappings", "as", "$", "key", "=>", "$", "mapping", ")", "{", "$", "user", "->", "{", "$", "key", "}", "=", "$", "this", "->", "getSamlAttribute", "(", "$", "mapping", ")", ";", "}", "}" ]
If mapping between saml attributes and object attributes are defined then fill user object with mapped values.
[ "If", "mapping", "between", "saml", "attributes", "and", "object", "attributes", "are", "defined", "then", "fill", "user", "object", "with", "mapped", "values", "." ]
712d02f6edae914db7b48438361444b2daf66930
https://github.com/KnightSwarm/laravel-saml/blob/712d02f6edae914db7b48438361444b2daf66930/src/KnightSwarm/LaravelSaml/Account.php#L74-L81
233,353
yeriomin/getopt
src/Yeriomin/Getopt/Getopt.php
Getopt.getUsageMessage
public function getUsageMessage() { foreach ($this->optionDefinitions as $def) { $this->usageProvider->addOptionDefinition($def); } if (empty($this->scriptName)) { $this->scriptName = $_SERVER['PHP_SELF']; } $this->usageProvider->setScriptName($this->scriptName); return $this->usageProvider->getUsageMessage(); }
php
public function getUsageMessage() { foreach ($this->optionDefinitions as $def) { $this->usageProvider->addOptionDefinition($def); } if (empty($this->scriptName)) { $this->scriptName = $_SERVER['PHP_SELF']; } $this->usageProvider->setScriptName($this->scriptName); return $this->usageProvider->getUsageMessage(); }
[ "public", "function", "getUsageMessage", "(", ")", "{", "foreach", "(", "$", "this", "->", "optionDefinitions", "as", "$", "def", ")", "{", "$", "this", "->", "usageProvider", "->", "addOptionDefinition", "(", "$", "def", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "scriptName", ")", ")", "{", "$", "this", "->", "scriptName", "=", "$", "_SERVER", "[", "'PHP_SELF'", "]", ";", "}", "$", "this", "->", "usageProvider", "->", "setScriptName", "(", "$", "this", "->", "scriptName", ")", ";", "return", "$", "this", "->", "usageProvider", "->", "getUsageMessage", "(", ")", ";", "}" ]
Build and return the usage message based on defined options @return string
[ "Build", "and", "return", "the", "usage", "message", "based", "on", "defined", "options" ]
0b86fca451799e594aab7bc04a399a8f15d3119d
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L172-L182
233,354
yeriomin/getopt
src/Yeriomin/Getopt/Getopt.php
Getopt.parse
public function parse() { $this->parser->parse($this->rawArguments); $this->parsed = true; $this->arguments = $this->parser->getArguments(); $optionsShort = $this->parser->getOptionsShort(); $optionsLong = $this->parser->getOptionsLong(); $missongRequired = array(); foreach ($this->optionDefinitions as $definition) { $value = $this->getOptionValue($definition); $short = $definition->getShort(); $long = $definition->getLong(); $optionsShort[$short] = $value; $optionsLong[$long] = $value; if ($definition->getRequired() && $value === null) { $parts = array(); $parts[] = $short !== null ? '-' . $short : null; $parts[] = $long !== null ? '--' . $long : null; $missongRequired[] = implode('|', $parts); } } if (!empty($missongRequired)) { throw new GetoptException( 'Missing required options: ' . implode(', ', $missongRequired) ); } $this->optionsShort = $optionsShort; $this->optionsLong = $optionsLong; }
php
public function parse() { $this->parser->parse($this->rawArguments); $this->parsed = true; $this->arguments = $this->parser->getArguments(); $optionsShort = $this->parser->getOptionsShort(); $optionsLong = $this->parser->getOptionsLong(); $missongRequired = array(); foreach ($this->optionDefinitions as $definition) { $value = $this->getOptionValue($definition); $short = $definition->getShort(); $long = $definition->getLong(); $optionsShort[$short] = $value; $optionsLong[$long] = $value; if ($definition->getRequired() && $value === null) { $parts = array(); $parts[] = $short !== null ? '-' . $short : null; $parts[] = $long !== null ? '--' . $long : null; $missongRequired[] = implode('|', $parts); } } if (!empty($missongRequired)) { throw new GetoptException( 'Missing required options: ' . implode(', ', $missongRequired) ); } $this->optionsShort = $optionsShort; $this->optionsLong = $optionsLong; }
[ "public", "function", "parse", "(", ")", "{", "$", "this", "->", "parser", "->", "parse", "(", "$", "this", "->", "rawArguments", ")", ";", "$", "this", "->", "parsed", "=", "true", ";", "$", "this", "->", "arguments", "=", "$", "this", "->", "parser", "->", "getArguments", "(", ")", ";", "$", "optionsShort", "=", "$", "this", "->", "parser", "->", "getOptionsShort", "(", ")", ";", "$", "optionsLong", "=", "$", "this", "->", "parser", "->", "getOptionsLong", "(", ")", ";", "$", "missongRequired", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "optionDefinitions", "as", "$", "definition", ")", "{", "$", "value", "=", "$", "this", "->", "getOptionValue", "(", "$", "definition", ")", ";", "$", "short", "=", "$", "definition", "->", "getShort", "(", ")", ";", "$", "long", "=", "$", "definition", "->", "getLong", "(", ")", ";", "$", "optionsShort", "[", "$", "short", "]", "=", "$", "value", ";", "$", "optionsLong", "[", "$", "long", "]", "=", "$", "value", ";", "if", "(", "$", "definition", "->", "getRequired", "(", ")", "&&", "$", "value", "===", "null", ")", "{", "$", "parts", "=", "array", "(", ")", ";", "$", "parts", "[", "]", "=", "$", "short", "!==", "null", "?", "'-'", ".", "$", "short", ":", "null", ";", "$", "parts", "[", "]", "=", "$", "long", "!==", "null", "?", "'--'", ".", "$", "long", ":", "null", ";", "$", "missongRequired", "[", "]", "=", "implode", "(", "'|'", ",", "$", "parts", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "missongRequired", ")", ")", "{", "throw", "new", "GetoptException", "(", "'Missing required options: '", ".", "implode", "(", "', '", ",", "$", "missongRequired", ")", ")", ";", "}", "$", "this", "->", "optionsShort", "=", "$", "optionsShort", ";", "$", "this", "->", "optionsLong", "=", "$", "optionsLong", ";", "}" ]
Parse the console arguments using the provided parser and check them for validity @throws GetoptException
[ "Parse", "the", "console", "arguments", "using", "the", "provided", "parser", "and", "check", "them", "for", "validity" ]
0b86fca451799e594aab7bc04a399a8f15d3119d
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L200-L229
233,355
yeriomin/getopt
src/Yeriomin/Getopt/Getopt.php
Getopt.getOptionValue
private function getOptionValue(OptionDefinition $definition) { $nameShort = $definition->getShort(); $nameLong = $definition->getLong(); $valueShort = $this->parser->getOptionShort($nameShort); $valueLong = $this->parser->getOptionLong($nameLong); if ($nameShort !== null && $nameLong !== null && $valueShort !== null && $valueLong !== null && $valueShort !== $valueLong ) { throw new GetoptException( 'Both -' . $nameShort . ' and --' . $nameLong . ' given, with non-matching values. Make up your mind.' ); } return $valueShort !== null ? $valueShort : $valueLong; }
php
private function getOptionValue(OptionDefinition $definition) { $nameShort = $definition->getShort(); $nameLong = $definition->getLong(); $valueShort = $this->parser->getOptionShort($nameShort); $valueLong = $this->parser->getOptionLong($nameLong); if ($nameShort !== null && $nameLong !== null && $valueShort !== null && $valueLong !== null && $valueShort !== $valueLong ) { throw new GetoptException( 'Both -' . $nameShort . ' and --' . $nameLong . ' given, with non-matching values. Make up your mind.' ); } return $valueShort !== null ? $valueShort : $valueLong; }
[ "private", "function", "getOptionValue", "(", "OptionDefinition", "$", "definition", ")", "{", "$", "nameShort", "=", "$", "definition", "->", "getShort", "(", ")", ";", "$", "nameLong", "=", "$", "definition", "->", "getLong", "(", ")", ";", "$", "valueShort", "=", "$", "this", "->", "parser", "->", "getOptionShort", "(", "$", "nameShort", ")", ";", "$", "valueLong", "=", "$", "this", "->", "parser", "->", "getOptionLong", "(", "$", "nameLong", ")", ";", "if", "(", "$", "nameShort", "!==", "null", "&&", "$", "nameLong", "!==", "null", "&&", "$", "valueShort", "!==", "null", "&&", "$", "valueLong", "!==", "null", "&&", "$", "valueShort", "!==", "$", "valueLong", ")", "{", "throw", "new", "GetoptException", "(", "'Both -'", ".", "$", "nameShort", ".", "' and --'", ".", "$", "nameLong", ".", "' given, with non-matching values. Make up your mind.'", ")", ";", "}", "return", "$", "valueShort", "!==", "null", "?", "$", "valueShort", ":", "$", "valueLong", ";", "}" ]
Get option value based on its definition @param \Yeriomin\Getopt\OptionDefinition $definition @return mixed @throws GetoptException
[ "Get", "option", "value", "based", "on", "its", "definition" ]
0b86fca451799e594aab7bc04a399a8f15d3119d
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Getopt.php#L275-L291
233,356
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Arc.php
Arc.radius
public function radius($int_rx, $int_ry = 0) { if (!is_integer($int_rx) || !is_integer($int_ry)) { throw new \InvalidArgumentException('Radius must be integer value!'); } if ($int_ry == 0) { $this->radius->r = $int_rx; $this->radius->w = 2 * $int_rx; $this->radius->h = 2 * $int_rx; $this->radius->is_circle = true; } else { $this->radius->rx = $int_rx; $this->radius->ry = $int_ry; $this->radius->w = 2 * $int_rx; $this->radius->h = 2 * $int_ry; $this->radius->is_circle = false; } return $this; }
php
public function radius($int_rx, $int_ry = 0) { if (!is_integer($int_rx) || !is_integer($int_ry)) { throw new \InvalidArgumentException('Radius must be integer value!'); } if ($int_ry == 0) { $this->radius->r = $int_rx; $this->radius->w = 2 * $int_rx; $this->radius->h = 2 * $int_rx; $this->radius->is_circle = true; } else { $this->radius->rx = $int_rx; $this->radius->ry = $int_ry; $this->radius->w = 2 * $int_rx; $this->radius->h = 2 * $int_ry; $this->radius->is_circle = false; } return $this; }
[ "public", "function", "radius", "(", "$", "int_rx", ",", "$", "int_ry", "=", "0", ")", "{", "if", "(", "!", "is_integer", "(", "$", "int_rx", ")", "||", "!", "is_integer", "(", "$", "int_ry", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Radius must be integer value!'", ")", ";", "}", "if", "(", "$", "int_ry", "==", "0", ")", "{", "$", "this", "->", "radius", "->", "r", "=", "$", "int_rx", ";", "$", "this", "->", "radius", "->", "w", "=", "2", "*", "$", "int_rx", ";", "$", "this", "->", "radius", "->", "h", "=", "2", "*", "$", "int_rx", ";", "$", "this", "->", "radius", "->", "is_circle", "=", "true", ";", "}", "else", "{", "$", "this", "->", "radius", "->", "rx", "=", "$", "int_rx", ";", "$", "this", "->", "radius", "->", "ry", "=", "$", "int_ry", ";", "$", "this", "->", "radius", "->", "w", "=", "2", "*", "$", "int_rx", ";", "$", "this", "->", "radius", "->", "h", "=", "2", "*", "$", "int_ry", ";", "$", "this", "->", "radius", "->", "is_circle", "=", "false", ";", "}", "return", "$", "this", ";", "}" ]
Sets radius. If two values are provided, then n ellipse is defined. If only one value is given, then you get a circle. @param integer $int_rx @param integer $int_ry @throws InvalidArgumentException If radius is not an integer. @access public @return void
[ "Sets", "radius", "." ]
91affa83f8580c8e6da62c77ce34b1c4451784bf
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Arc.php#L70-L90
233,357
joomla-framework/twitter-api
src/Media.php
Media.upload
public function upload($rawMedia = null, $base64Media = null, $owners = null) { // Check the rate limit for remaining hits $this->checkRateLimit('media', 'upload'); // Determine which type of data was passed for $media if ($rawMedia !== null) { $data['media'] = $rawMedia; } elseif ($base64Media !== null) { $data['media_data'] = $base64Media; } else { // We don't have a valid entry throw new \RuntimeException('You must specify at least one valid media type.'); } if ($rawMedia !== null && $base64Media !== null) { throw new \RuntimeException('You may only specify one type of media.'); } if ($owners !== null) { $data['additional_owners'] = $owners; } // Set the API path $path = '/media/upload.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function upload($rawMedia = null, $base64Media = null, $owners = null) { // Check the rate limit for remaining hits $this->checkRateLimit('media', 'upload'); // Determine which type of data was passed for $media if ($rawMedia !== null) { $data['media'] = $rawMedia; } elseif ($base64Media !== null) { $data['media_data'] = $base64Media; } else { // We don't have a valid entry throw new \RuntimeException('You must specify at least one valid media type.'); } if ($rawMedia !== null && $base64Media !== null) { throw new \RuntimeException('You may only specify one type of media.'); } if ($owners !== null) { $data['additional_owners'] = $owners; } // Set the API path $path = '/media/upload.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "upload", "(", "$", "rawMedia", "=", "null", ",", "$", "base64Media", "=", "null", ",", "$", "owners", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'media'", ",", "'upload'", ")", ";", "// Determine which type of data was passed for $media", "if", "(", "$", "rawMedia", "!==", "null", ")", "{", "$", "data", "[", "'media'", "]", "=", "$", "rawMedia", ";", "}", "elseif", "(", "$", "base64Media", "!==", "null", ")", "{", "$", "data", "[", "'media_data'", "]", "=", "$", "base64Media", ";", "}", "else", "{", "// We don't have a valid entry", "throw", "new", "\\", "RuntimeException", "(", "'You must specify at least one valid media type.'", ")", ";", "}", "if", "(", "$", "rawMedia", "!==", "null", "&&", "$", "base64Media", "!==", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'You may only specify one type of media.'", ")", ";", "}", "if", "(", "$", "owners", "!==", "null", ")", "{", "$", "data", "[", "'additional_owners'", "]", "=", "$", "owners", ";", "}", "// Set the API path", "$", "path", "=", "'/media/upload.json'", ";", "// Send the request.", "return", "$", "this", "->", "sendRequest", "(", "$", "path", ",", "'POST'", ",", "$", "data", ")", ";", "}" ]
Method to upload media. @param string $rawMedia Raw binary data to be uploaded. @param string $base64Media A base64 encoded string containing the data to be uploaded. This cannot be used in conjunction with $rawMedia @param string $owners A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards. A maximum of 100 additional owners may be specified. @return array The decoded JSON response @since 1.2.0 @throws \RuntimeException
[ "Method", "to", "upload", "media", "." ]
289719bbd67e83c7cfaf515b94b1d5497b1f0525
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Media.php#L33-L68
233,358
CampaignChain/core
EntityService/LocationService.php
LocationService.removeLocation
public function removeLocation($id) { /** @var Location $location */ $location = $this->getLocation($id); $removableActivities = new ArrayCollection(); $notRemovableActivities = new ArrayCollection(); $accessToken = $this->em ->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token') ->findOneBy(['location' => $location]); try { $this->em->getConnection()->beginTransaction(); if ($accessToken) { $this->em->remove($accessToken); $this->em->flush(); } foreach ($location->getActivities() as $activity) { if ($this->isRemovable($location)) { $removableActivities->add($activity); } else { $notRemovableActivities->add($activity); } } foreach ($removableActivities as $activity) { $this->activityService->removeActivity($activity); } //Hack to find the belonging entities which has to be deleted first $bundleName = explode('/', $location->getLocationModule()->getBundle()->getName()); $classPrefix = 'CampaignChain\\' . implode('\\', array_map(function ($e) { return ucfirst($e); }, explode('-', $bundleName[1]))) . 'Bundle'; $entitiesToDelete = []; foreach ($this->em->getMetadataFactory()->getAllMetadata() as $metadataClass) { if (strpos(strtolower($metadataClass->getName()), strtolower($classPrefix)) === 0) { $entitiesToDelete[] = $metadataClass; } }; foreach ($entitiesToDelete as $repo) { $entities = $this->em->getRepository($repo->getName())->findBy(['location' => $location->getId()]); foreach ($entities as $entityToDelete) { $this->em->remove($entityToDelete); } } $this->em->flush(); $this->em->remove($location); $this->em->flush(); $channel = $location->getChannel(); if ($channel->getLocations()->isEmpty()) { $this->em->remove($channel); $this->em->flush(); } $this->em->getConnection()->commit(); } catch(\Exception $e) { $this->em->getConnection()->rollback(); throw $e; } }
php
public function removeLocation($id) { /** @var Location $location */ $location = $this->getLocation($id); $removableActivities = new ArrayCollection(); $notRemovableActivities = new ArrayCollection(); $accessToken = $this->em ->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token') ->findOneBy(['location' => $location]); try { $this->em->getConnection()->beginTransaction(); if ($accessToken) { $this->em->remove($accessToken); $this->em->flush(); } foreach ($location->getActivities() as $activity) { if ($this->isRemovable($location)) { $removableActivities->add($activity); } else { $notRemovableActivities->add($activity); } } foreach ($removableActivities as $activity) { $this->activityService->removeActivity($activity); } //Hack to find the belonging entities which has to be deleted first $bundleName = explode('/', $location->getLocationModule()->getBundle()->getName()); $classPrefix = 'CampaignChain\\' . implode('\\', array_map(function ($e) { return ucfirst($e); }, explode('-', $bundleName[1]))) . 'Bundle'; $entitiesToDelete = []; foreach ($this->em->getMetadataFactory()->getAllMetadata() as $metadataClass) { if (strpos(strtolower($metadataClass->getName()), strtolower($classPrefix)) === 0) { $entitiesToDelete[] = $metadataClass; } }; foreach ($entitiesToDelete as $repo) { $entities = $this->em->getRepository($repo->getName())->findBy(['location' => $location->getId()]); foreach ($entities as $entityToDelete) { $this->em->remove($entityToDelete); } } $this->em->flush(); $this->em->remove($location); $this->em->flush(); $channel = $location->getChannel(); if ($channel->getLocations()->isEmpty()) { $this->em->remove($channel); $this->em->flush(); } $this->em->getConnection()->commit(); } catch(\Exception $e) { $this->em->getConnection()->rollback(); throw $e; } }
[ "public", "function", "removeLocation", "(", "$", "id", ")", "{", "/** @var Location $location */", "$", "location", "=", "$", "this", "->", "getLocation", "(", "$", "id", ")", ";", "$", "removableActivities", "=", "new", "ArrayCollection", "(", ")", ";", "$", "notRemovableActivities", "=", "new", "ArrayCollection", "(", ")", ";", "$", "accessToken", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChainSecurityAuthenticationClientOAuthBundle:Token'", ")", "->", "findOneBy", "(", "[", "'location'", "=>", "$", "location", "]", ")", ";", "try", "{", "$", "this", "->", "em", "->", "getConnection", "(", ")", "->", "beginTransaction", "(", ")", ";", "if", "(", "$", "accessToken", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "accessToken", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "foreach", "(", "$", "location", "->", "getActivities", "(", ")", "as", "$", "activity", ")", "{", "if", "(", "$", "this", "->", "isRemovable", "(", "$", "location", ")", ")", "{", "$", "removableActivities", "->", "add", "(", "$", "activity", ")", ";", "}", "else", "{", "$", "notRemovableActivities", "->", "add", "(", "$", "activity", ")", ";", "}", "}", "foreach", "(", "$", "removableActivities", "as", "$", "activity", ")", "{", "$", "this", "->", "activityService", "->", "removeActivity", "(", "$", "activity", ")", ";", "}", "//Hack to find the belonging entities which has to be deleted first", "$", "bundleName", "=", "explode", "(", "'/'", ",", "$", "location", "->", "getLocationModule", "(", ")", "->", "getBundle", "(", ")", "->", "getName", "(", ")", ")", ";", "$", "classPrefix", "=", "'CampaignChain\\\\'", ".", "implode", "(", "'\\\\'", ",", "array_map", "(", "function", "(", "$", "e", ")", "{", "return", "ucfirst", "(", "$", "e", ")", ";", "}", ",", "explode", "(", "'-'", ",", "$", "bundleName", "[", "1", "]", ")", ")", ")", ".", "'Bundle'", ";", "$", "entitiesToDelete", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "em", "->", "getMetadataFactory", "(", ")", "->", "getAllMetadata", "(", ")", "as", "$", "metadataClass", ")", "{", "if", "(", "strpos", "(", "strtolower", "(", "$", "metadataClass", "->", "getName", "(", ")", ")", ",", "strtolower", "(", "$", "classPrefix", ")", ")", "===", "0", ")", "{", "$", "entitiesToDelete", "[", "]", "=", "$", "metadataClass", ";", "}", "}", ";", "foreach", "(", "$", "entitiesToDelete", "as", "$", "repo", ")", "{", "$", "entities", "=", "$", "this", "->", "em", "->", "getRepository", "(", "$", "repo", "->", "getName", "(", ")", ")", "->", "findBy", "(", "[", "'location'", "=>", "$", "location", "->", "getId", "(", ")", "]", ")", ";", "foreach", "(", "$", "entities", "as", "$", "entityToDelete", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "entityToDelete", ")", ";", "}", "}", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "em", "->", "remove", "(", "$", "location", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "$", "channel", "=", "$", "location", "->", "getChannel", "(", ")", ";", "if", "(", "$", "channel", "->", "getLocations", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "channel", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "$", "this", "->", "em", "->", "getConnection", "(", ")", "->", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "em", "->", "getConnection", "(", ")", "->", "rollback", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
This method deletes a location if there are no closed activities. If there are open activities the location is deactivated @param $id @throws \Exception
[ "This", "method", "deletes", "a", "location", "if", "there", "are", "no", "closed", "activities", ".", "If", "there", "are", "open", "activities", "the", "location", "is", "deactivated" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/LocationService.php#L369-L437
233,359
CampaignChain/core
Entity/ReportAnalyticsActivityFact.php
ReportAnalyticsActivityFact.getJavascriptTimestamp
public function getJavascriptTimestamp() { $date = new \DateTime($this->time->format('Y-m-d H:i:s')); $javascriptTimestamp = $date->getTimestamp() * 1000; return $javascriptTimestamp; }
php
public function getJavascriptTimestamp() { $date = new \DateTime($this->time->format('Y-m-d H:i:s')); $javascriptTimestamp = $date->getTimestamp() * 1000; return $javascriptTimestamp; }
[ "public", "function", "getJavascriptTimestamp", "(", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", "$", "this", "->", "time", "->", "format", "(", "'Y-m-d H:i:s'", ")", ")", ";", "$", "javascriptTimestamp", "=", "$", "date", "->", "getTimestamp", "(", ")", "*", "1000", ";", "return", "$", "javascriptTimestamp", ";", "}" ]
Get time in JavaScript timestamp format. @return \DateTime
[ "Get", "time", "in", "JavaScript", "timestamp", "format", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportAnalyticsActivityFact.php#L105-L111
233,360
ionux/phactor
src/Math.php
Math.Invert
public function Invert($a, $b) { $this->preOpMethodParamsCheck(array($a, $b)); return $this->math->inv($a, $b); }
php
public function Invert($a, $b) { $this->preOpMethodParamsCheck(array($a, $b)); return $this->math->inv($a, $b); }
[ "public", "function", "Invert", "(", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "preOpMethodParamsCheck", "(", "array", "(", "$", "a", ",", "$", "b", ")", ")", ";", "return", "$", "this", "->", "math", "->", "inv", "(", "$", "a", ",", "$", "b", ")", ";", "}" ]
Performs the inverse modulo of two arbitrary precision numbers. @param string $a The first number to Divide. @param string $b The second number to Divide. @return string The result of the operation.
[ "Performs", "the", "inverse", "modulo", "of", "two", "arbitrary", "precision", "numbers", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L142-L147
233,361
ionux/phactor
src/Math.php
Math.Power
public function Power($a, $b) { $this->preOpMethodParamsCheck(array($a, $b)); return $this->math->power($a, $b); }
php
public function Power($a, $b) { $this->preOpMethodParamsCheck(array($a, $b)); return $this->math->power($a, $b); }
[ "public", "function", "Power", "(", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "preOpMethodParamsCheck", "(", "array", "(", "$", "a", ",", "$", "b", ")", ")", ";", "return", "$", "this", "->", "math", "->", "power", "(", "$", "a", ",", "$", "b", ")", ";", "}" ]
Raises an arbitrary precision number to an integer power. @param string $a The number to raise to the power. @param string $b The integer power @return string The result of the operation.
[ "Raises", "an", "arbitrary", "precision", "number", "to", "an", "integer", "power", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L170-L175
233,362
ionux/phactor
src/Math.php
Math.encodeBase58
public function encodeBase58($hex) { $this->preOpMethodParamsCheck(array($hex)); try { if (strlen($hex) % 2 != 0 || $this->Test($hex) != 'hex') { throw new \Exception('Uneven number of hex characters or invalid parameter passed to encodeBase58 function. Value received was "' . var_export($hex, true) . '".'); } else { $orighex = $hex; $hex = $this->addHexPrefix($this->prepAndClean($hex)); $return = strrev($this->encodeValue($hex, '58')); for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == '00'; $i += 2) { $return = '1' . $return; } } return $return; } catch (\Exception $e) { throw $e; } }
php
public function encodeBase58($hex) { $this->preOpMethodParamsCheck(array($hex)); try { if (strlen($hex) % 2 != 0 || $this->Test($hex) != 'hex') { throw new \Exception('Uneven number of hex characters or invalid parameter passed to encodeBase58 function. Value received was "' . var_export($hex, true) . '".'); } else { $orighex = $hex; $hex = $this->addHexPrefix($this->prepAndClean($hex)); $return = strrev($this->encodeValue($hex, '58')); for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == '00'; $i += 2) { $return = '1' . $return; } } return $return; } catch (\Exception $e) { throw $e; } }
[ "public", "function", "encodeBase58", "(", "$", "hex", ")", "{", "$", "this", "->", "preOpMethodParamsCheck", "(", "array", "(", "$", "hex", ")", ")", ";", "try", "{", "if", "(", "strlen", "(", "$", "hex", ")", "%", "2", "!=", "0", "||", "$", "this", "->", "Test", "(", "$", "hex", ")", "!=", "'hex'", ")", "{", "throw", "new", "\\", "Exception", "(", "'Uneven number of hex characters or invalid parameter passed to encodeBase58 function. Value received was \"'", ".", "var_export", "(", "$", "hex", ",", "true", ")", ".", "'\".'", ")", ";", "}", "else", "{", "$", "orighex", "=", "$", "hex", ";", "$", "hex", "=", "$", "this", "->", "addHexPrefix", "(", "$", "this", "->", "prepAndClean", "(", "$", "hex", ")", ")", ";", "$", "return", "=", "strrev", "(", "$", "this", "->", "encodeValue", "(", "$", "hex", ",", "'58'", ")", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "orighex", ")", "&&", "substr", "(", "$", "orighex", ",", "$", "i", ",", "2", ")", "==", "'00'", ";", "$", "i", "+=", "2", ")", "{", "$", "return", "=", "'1'", ".", "$", "return", ";", "}", "}", "return", "$", "return", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Converts a hex number to BASE-58 used for Bitcoin-related tasks. @param string $hex @return string $return @throws \Exception
[ "Converts", "a", "hex", "number", "to", "BASE", "-", "58", "used", "for", "Bitcoin", "-", "related", "tasks", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L307-L330
233,363
ionux/phactor
src/Math.php
Math.decodeBase58
public function decodeBase58($base58) { $this->preOpMethodParamsCheck(array($base58)); try { $origbase58 = $base58; $return = '0'; $b58_len = strlen($base58); for ($i = 0; $i < $b58_len; $i++) { $current = strpos($this->b58_chars, $base58[$i]); $return = $this->math->mul($return, '58'); $return = $this->math->add($return, $current); } $return = $this->encodeHex($return); for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) { $return = '00' . $return; } return (strlen($return) % 2 != 0) ? '0' . $return : $return; } catch (\Exception $e) { throw $e; } }
php
public function decodeBase58($base58) { $this->preOpMethodParamsCheck(array($base58)); try { $origbase58 = $base58; $return = '0'; $b58_len = strlen($base58); for ($i = 0; $i < $b58_len; $i++) { $current = strpos($this->b58_chars, $base58[$i]); $return = $this->math->mul($return, '58'); $return = $this->math->add($return, $current); } $return = $this->encodeHex($return); for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) { $return = '00' . $return; } return (strlen($return) % 2 != 0) ? '0' . $return : $return; } catch (\Exception $e) { throw $e; } }
[ "public", "function", "decodeBase58", "(", "$", "base58", ")", "{", "$", "this", "->", "preOpMethodParamsCheck", "(", "array", "(", "$", "base58", ")", ")", ";", "try", "{", "$", "origbase58", "=", "$", "base58", ";", "$", "return", "=", "'0'", ";", "$", "b58_len", "=", "strlen", "(", "$", "base58", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "b58_len", ";", "$", "i", "++", ")", "{", "$", "current", "=", "strpos", "(", "$", "this", "->", "b58_chars", ",", "$", "base58", "[", "$", "i", "]", ")", ";", "$", "return", "=", "$", "this", "->", "math", "->", "mul", "(", "$", "return", ",", "'58'", ")", ";", "$", "return", "=", "$", "this", "->", "math", "->", "add", "(", "$", "return", ",", "$", "current", ")", ";", "}", "$", "return", "=", "$", "this", "->", "encodeHex", "(", "$", "return", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "origbase58", ")", "&&", "$", "origbase58", "[", "$", "i", "]", "==", "'1'", ";", "$", "i", "++", ")", "{", "$", "return", "=", "'00'", ".", "$", "return", ";", "}", "return", "(", "strlen", "(", "$", "return", ")", "%", "2", "!=", "0", ")", "?", "'0'", ".", "$", "return", ":", "$", "return", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Converts a BASE-58 number used for Bitcoin-related tasks to hex. @param string $base58 @return string $return @throws \Exception
[ "Converts", "a", "BASE", "-", "58", "number", "used", "for", "Bitcoin", "-", "related", "tasks", "to", "hex", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L339-L365
233,364
ionux/phactor
src/Math.php
Math.MathCheck
private function MathCheck() { if ($this->math == null || is_object($this->math) === false) { if (function_exists('gmp_add')) { $this->math = new GMP(); } else if (function_exists('bcadd')) { $this->math = new BC(); } else { throw new \Exception('Both GMP and BC Math extensions are missing on this system! Please install one to use the Phactor math library.'); } } $this->bytes = (empty($this->bytes)) ? $this->GenBytes() : $this->bytes; }
php
private function MathCheck() { if ($this->math == null || is_object($this->math) === false) { if (function_exists('gmp_add')) { $this->math = new GMP(); } else if (function_exists('bcadd')) { $this->math = new BC(); } else { throw new \Exception('Both GMP and BC Math extensions are missing on this system! Please install one to use the Phactor math library.'); } } $this->bytes = (empty($this->bytes)) ? $this->GenBytes() : $this->bytes; }
[ "private", "function", "MathCheck", "(", ")", "{", "if", "(", "$", "this", "->", "math", "==", "null", "||", "is_object", "(", "$", "this", "->", "math", ")", "===", "false", ")", "{", "if", "(", "function_exists", "(", "'gmp_add'", ")", ")", "{", "$", "this", "->", "math", "=", "new", "GMP", "(", ")", ";", "}", "else", "if", "(", "function_exists", "(", "'bcadd'", ")", ")", "{", "$", "this", "->", "math", "=", "new", "BC", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Both GMP and BC Math extensions are missing on this system! Please install one to use the Phactor math library.'", ")", ";", "}", "}", "$", "this", "->", "bytes", "=", "(", "empty", "(", "$", "this", "->", "bytes", ")", ")", "?", "$", "this", "->", "GenBytes", "(", ")", ":", "$", "this", "->", "bytes", ";", "}" ]
Internal function to make sure we can find an acceptable math extension to use here. @throws \Exception
[ "Internal", "function", "to", "make", "sure", "we", "can", "find", "an", "acceptable", "math", "extension", "to", "use", "here", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L372-L385
233,365
ionux/phactor
src/Math.php
Math.preOpMethodParamsCheck
private function preOpMethodParamsCheck($params) { $this->MathCheck(); foreach ($params as $key => $value) { if ($this->numberCheck($value) === false) { $caller = debug_backtrace(); throw new \Exception('Empty or invalid parameters passed to ' . $caller[count($caller) - 1]['function'] . ' function. Argument list received: ' . var_export($caller[count($caller) - 1]['args'], true)); } } }
php
private function preOpMethodParamsCheck($params) { $this->MathCheck(); foreach ($params as $key => $value) { if ($this->numberCheck($value) === false) { $caller = debug_backtrace(); throw new \Exception('Empty or invalid parameters passed to ' . $caller[count($caller) - 1]['function'] . ' function. Argument list received: ' . var_export($caller[count($caller) - 1]['args'], true)); } } }
[ "private", "function", "preOpMethodParamsCheck", "(", "$", "params", ")", "{", "$", "this", "->", "MathCheck", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "numberCheck", "(", "$", "value", ")", "===", "false", ")", "{", "$", "caller", "=", "debug_backtrace", "(", ")", ";", "throw", "new", "\\", "Exception", "(", "'Empty or invalid parameters passed to '", ".", "$", "caller", "[", "count", "(", "$", "caller", ")", "-", "1", "]", "[", "'function'", "]", ".", "' function. Argument list received: '", ".", "var_export", "(", "$", "caller", "[", "count", "(", "$", "caller", ")", "-", "1", "]", "[", "'args'", "]", ",", "true", ")", ")", ";", "}", "}", "}" ]
Handles the pre-work validation checking for method parameters. @param array $params The array of parameters to check. @return boolean Will only be true, otherwise throws \Exception @throws \Exception
[ "Handles", "the", "pre", "-", "work", "validation", "checking", "for", "method", "parameters", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L394-L404
233,366
ionux/phactor
src/Math.php
Math.encodeValue
private function encodeValue($val, $base) { $this->preOpMethodParamsCheck(array($val, $base)); $digits = $this->baseCheck($base); try { $new = ''; while ($this->math->comp($val, '0') > 0) { $qq = $this->math->div($val, $base); $rem = $this->math->mod($val, $base); $val = $qq; $new = $new . $digits[$rem]; } return $new; } catch (\Exception $e) { throw $e; } }
php
private function encodeValue($val, $base) { $this->preOpMethodParamsCheck(array($val, $base)); $digits = $this->baseCheck($base); try { $new = ''; while ($this->math->comp($val, '0') > 0) { $qq = $this->math->div($val, $base); $rem = $this->math->mod($val, $base); $val = $qq; $new = $new . $digits[$rem]; } return $new; } catch (\Exception $e) { throw $e; } }
[ "private", "function", "encodeValue", "(", "$", "val", ",", "$", "base", ")", "{", "$", "this", "->", "preOpMethodParamsCheck", "(", "array", "(", "$", "val", ",", "$", "base", ")", ")", ";", "$", "digits", "=", "$", "this", "->", "baseCheck", "(", "$", "base", ")", ";", "try", "{", "$", "new", "=", "''", ";", "while", "(", "$", "this", "->", "math", "->", "comp", "(", "$", "val", ",", "'0'", ")", ">", "0", ")", "{", "$", "qq", "=", "$", "this", "->", "math", "->", "div", "(", "$", "val", ",", "$", "base", ")", ";", "$", "rem", "=", "$", "this", "->", "math", "->", "mod", "(", "$", "val", ",", "$", "base", ")", ";", "$", "val", "=", "$", "qq", ";", "$", "new", "=", "$", "new", ".", "$", "digits", "[", "$", "rem", "]", ";", "}", "return", "$", "new", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
The generic value encoding method. @param string $val A number to convert. @param string $base The base to convert it into. @return string The same number but in a different base. @throws \Exception
[ "The", "generic", "value", "encoding", "method", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L414-L436
233,367
ionux/phactor
src/Math.php
Math.zeroCompare
private function zeroCompare($a, $b) { return ($this->math->comp($a, '0') <= 0 || $this->math->comp($b, '0') <= 0); }
php
private function zeroCompare($a, $b) { return ($this->math->comp($a, '0') <= 0 || $this->math->comp($b, '0') <= 0); }
[ "private", "function", "zeroCompare", "(", "$", "a", ",", "$", "b", ")", "{", "return", "(", "$", "this", "->", "math", "->", "comp", "(", "$", "a", ",", "'0'", ")", "<=", "0", "||", "$", "this", "->", "math", "->", "comp", "(", "$", "b", ",", "'0'", ")", "<=", "0", ")", ";", "}" ]
Checks if two parameters are less than or equal to zero. @param string $a The first parameter to check. @param string $b The second parameter to check. @return boolean Result of the check.
[ "Checks", "if", "two", "parameters", "are", "less", "than", "or", "equal", "to", "zero", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Math.php#L472-L475
233,368
notthatbad/silverstripe-rest-api
code/controllers/NestedResourceRestController.php
NestedResourceRestController.beforeCallActionHandler
public final function beforeCallActionHandler(\SS_HTTPRequest $request, $action) { $id = $request->param(\Config::inst()->get('NestedResourceRestController', 'root_resource_id_field')); if(!$id) { throw new RestUserException(static::$no_id_message, static::$no_id_message); } $resource = $this->getRootResource($id); if(!$resource) { \SS_Log::log("NoResourceError was not handled inside the controller", \SS_Log::WARN); throw new RestSystemException("NoResourceError was not handled inside the controller", 501); } // call the action and inject the root resource return $this->$action($request, $resource); }
php
public final function beforeCallActionHandler(\SS_HTTPRequest $request, $action) { $id = $request->param(\Config::inst()->get('NestedResourceRestController', 'root_resource_id_field')); if(!$id) { throw new RestUserException(static::$no_id_message, static::$no_id_message); } $resource = $this->getRootResource($id); if(!$resource) { \SS_Log::log("NoResourceError was not handled inside the controller", \SS_Log::WARN); throw new RestSystemException("NoResourceError was not handled inside the controller", 501); } // call the action and inject the root resource return $this->$action($request, $resource); }
[ "public", "final", "function", "beforeCallActionHandler", "(", "\\", "SS_HTTPRequest", "$", "request", ",", "$", "action", ")", "{", "$", "id", "=", "$", "request", "->", "param", "(", "\\", "Config", "::", "inst", "(", ")", "->", "get", "(", "'NestedResourceRestController'", ",", "'root_resource_id_field'", ")", ")", ";", "if", "(", "!", "$", "id", ")", "{", "throw", "new", "RestUserException", "(", "static", "::", "$", "no_id_message", ",", "static", "::", "$", "no_id_message", ")", ";", "}", "$", "resource", "=", "$", "this", "->", "getRootResource", "(", "$", "id", ")", ";", "if", "(", "!", "$", "resource", ")", "{", "\\", "SS_Log", "::", "log", "(", "\"NoResourceError was not handled inside the controller\"", ",", "\\", "SS_Log", "::", "WARN", ")", ";", "throw", "new", "RestSystemException", "(", "\"NoResourceError was not handled inside the controller\"", ",", "501", ")", ";", "}", "// call the action and inject the root resource", "return", "$", "this", "->", "$", "action", "(", "$", "request", ",", "$", "resource", ")", ";", "}" ]
Get called by the action handler of BaseRestController. Tries to fetch the root resource. @param \SS_HTTPRequest $request a http request @param string $action the name of the action (eg. post, put, get, delete) @return array the result of the action call @throws RestSystemException @throws RestUserException
[ "Get", "called", "by", "the", "action", "handler", "of", "BaseRestController", ".", "Tries", "to", "fetch", "the", "root", "resource", "." ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/NestedResourceRestController.php#L36-L48
233,369
diemuzi/mp3
src/Mp3/Service/ServiceProvider.php
ServiceProvider.getSearchPath
protected function getSearchPath() { if (!isset($this->config['mp3']['searchPath'])) { throw new \Exception( $this->translate->translate( 'searchPath is not currently set', 'mp3' ) ); } return $this->config['mp3']['searchPath']; }
php
protected function getSearchPath() { if (!isset($this->config['mp3']['searchPath'])) { throw new \Exception( $this->translate->translate( 'searchPath is not currently set', 'mp3' ) ); } return $this->config['mp3']['searchPath']; }
[ "protected", "function", "getSearchPath", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'searchPath'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translate", "->", "translate", "(", "'searchPath is not currently set'", ",", "'mp3'", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'searchPath'", "]", ";", "}" ]
Get Search Path @return string @throws \Exception
[ "Get", "Search", "Path" ]
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L65-L77
233,370
diemuzi/mp3
src/Mp3/Service/ServiceProvider.php
ServiceProvider.getBaseDir
protected function getBaseDir() { if (!isset($this->config['mp3']['baseDir'])) { throw new \Exception( $this->translate->translate( 'baseDir is not currently set', 'mp3' ) ); } return $this->config['mp3']['baseDir']; }
php
protected function getBaseDir() { if (!isset($this->config['mp3']['baseDir'])) { throw new \Exception( $this->translate->translate( 'baseDir is not currently set', 'mp3' ) ); } return $this->config['mp3']['baseDir']; }
[ "protected", "function", "getBaseDir", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'baseDir'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translate", "->", "translate", "(", "'baseDir is not currently set'", ",", "'mp3'", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'baseDir'", "]", ";", "}" ]
Get Base Directory @return string @throws \Exception
[ "Get", "Base", "Directory" ]
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L85-L97
233,371
diemuzi/mp3
src/Mp3/Service/ServiceProvider.php
ServiceProvider.getSearchFile
protected function getSearchFile() { if (!isset($this->config['mp3']['searchFile'])) { throw new \Exception( $this->translate->translate( 'searchFile is not currently set', 'mp3' ) ); } return $this->config['mp3']['searchFile']; }
php
protected function getSearchFile() { if (!isset($this->config['mp3']['searchFile'])) { throw new \Exception( $this->translate->translate( 'searchFile is not currently set', 'mp3' ) ); } return $this->config['mp3']['searchFile']; }
[ "protected", "function", "getSearchFile", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'searchFile'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translate", "->", "translate", "(", "'searchFile is not currently set'", ",", "'mp3'", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'searchFile'", "]", ";", "}" ]
Get Search File @return string @throws \Exception
[ "Get", "Search", "File" ]
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L125-L137
233,372
diemuzi/mp3
src/Mp3/Service/ServiceProvider.php
ServiceProvider.getMemoryLimit
protected function getMemoryLimit() { if (!isset($this->config['mp3']['memoryLimit'])) { throw new \Exception( $this->translate->translate( 'memoryLimit is not currently set', 'mp3' ) ); } return $this->config['mp3']['memoryLimit']; }
php
protected function getMemoryLimit() { if (!isset($this->config['mp3']['memoryLimit'])) { throw new \Exception( $this->translate->translate( 'memoryLimit is not currently set', 'mp3' ) ); } return $this->config['mp3']['memoryLimit']; }
[ "protected", "function", "getMemoryLimit", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'memoryLimit'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translate", "->", "translate", "(", "'memoryLimit is not currently set'", ",", "'mp3'", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "'mp3'", "]", "[", "'memoryLimit'", "]", ";", "}" ]
Get Memory Limit @return string @throws \Exception
[ "Get", "Memory", "Limit" ]
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/ServiceProvider.php#L145-L157
233,373
moharrum/laravel-geoip-world-cities
src/seeds/CitiesTableSeeder.php
CitiesTableSeeder.dumpFiles
private function dumpFiles() { $files = []; foreach(File::allFiles(Config::dumpPath()) as $dumpFile) { $files[] = $dumpFile->getRealpath(); } sort($files); return $files; }
php
private function dumpFiles() { $files = []; foreach(File::allFiles(Config::dumpPath()) as $dumpFile) { $files[] = $dumpFile->getRealpath(); } sort($files); return $files; }
[ "private", "function", "dumpFiles", "(", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "File", "::", "allFiles", "(", "Config", "::", "dumpPath", "(", ")", ")", "as", "$", "dumpFile", ")", "{", "$", "files", "[", "]", "=", "$", "dumpFile", "->", "getRealpath", "(", ")", ";", "}", "sort", "(", "$", "files", ")", ";", "return", "$", "files", ";", "}" ]
Returns an array containing the full path to each dump file. @return array
[ "Returns", "an", "array", "containing", "the", "full", "path", "to", "each", "dump", "file", "." ]
2a3e928d644da3348c3f203b4f41208209c5e97c
https://github.com/moharrum/laravel-geoip-world-cities/blob/2a3e928d644da3348c3f203b4f41208209c5e97c/src/seeds/CitiesTableSeeder.php#L56-L67
233,374
vakata/image
src/Image.php
Image.toString
public function toString(string $format = null) : string { $operations = $this->operations; $operations[] = [ 'getImage', [ $format ] ]; $driver = $this->getDriver(); return array_reduce($operations, function ($carry, $item) use ($driver) { return $driver->{$item[0]}(...$item[1]); }); }
php
public function toString(string $format = null) : string { $operations = $this->operations; $operations[] = [ 'getImage', [ $format ] ]; $driver = $this->getDriver(); return array_reduce($operations, function ($carry, $item) use ($driver) { return $driver->{$item[0]}(...$item[1]); }); }
[ "public", "function", "toString", "(", "string", "$", "format", "=", "null", ")", ":", "string", "{", "$", "operations", "=", "$", "this", "->", "operations", ";", "$", "operations", "[", "]", "=", "[", "'getImage'", ",", "[", "$", "format", "]", "]", ";", "$", "driver", "=", "$", "this", "->", "getDriver", "(", ")", ";", "return", "array_reduce", "(", "$", "operations", ",", "function", "(", "$", "carry", ",", "$", "item", ")", "use", "(", "$", "driver", ")", "{", "return", "$", "driver", "->", "{", "$", "item", "[", "0", "]", "}", "(", "...", "$", "item", "[", "1", "]", ")", ";", "}", ")", ";", "}" ]
Get the converted image @param string|null $format the format to use (optional, if null the current format will be used) @return string binary string of the converted image
[ "Get", "the", "converted", "image" ]
1d074cc6e274b1b8fe97cf138efcd2c665699686
https://github.com/vakata/image/blob/1d074cc6e274b1b8fe97cf138efcd2c665699686/src/Image.php#L100-L109
233,375
caffeinated/widgets
src/WidgetFactory.php
WidgetFactory.flattenParameters
protected function flattenParameters(array $parameters) { $flattened = array(); foreach($parameters as $parameter) { array_walk($parameter, function($value, $key) use (&$flattened) { $flattened[$key] = $value; }); } return $flattened; }
php
protected function flattenParameters(array $parameters) { $flattened = array(); foreach($parameters as $parameter) { array_walk($parameter, function($value, $key) use (&$flattened) { $flattened[$key] = $value; }); } return $flattened; }
[ "protected", "function", "flattenParameters", "(", "array", "$", "parameters", ")", "{", "$", "flattened", "=", "array", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "{", "array_walk", "(", "$", "parameter", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "flattened", ")", "{", "$", "flattened", "[", "$", "key", "]", "=", "$", "value", ";", "}", ")", ";", "}", "return", "$", "flattened", ";", "}" ]
Flattens the given array. @param array $parameters @return array
[ "Flattens", "the", "given", "array", "." ]
3cd508518c4d62cf6173304638e7a06324a69d61
https://github.com/caffeinated/widgets/blob/3cd508518c4d62cf6173304638e7a06324a69d61/src/WidgetFactory.php#L67-L78
233,376
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php
AbstractElementProcessor.getThing
protected function getThing($typeof, $resourceId, ContextInterface $context) { /** @var TypeInterface[] $types */ $types = []; if (strlen($typeof)) { foreach (preg_split('/\s+/', $typeof) as $prefixedType) { $types[] = $this->getType($prefixedType, $context); } } return new Thing($types, $resourceId); }
php
protected function getThing($typeof, $resourceId, ContextInterface $context) { /** @var TypeInterface[] $types */ $types = []; if (strlen($typeof)) { foreach (preg_split('/\s+/', $typeof) as $prefixedType) { $types[] = $this->getType($prefixedType, $context); } } return new Thing($types, $resourceId); }
[ "protected", "function", "getThing", "(", "$", "typeof", ",", "$", "resourceId", ",", "ContextInterface", "$", "context", ")", "{", "/** @var TypeInterface[] $types */", "$", "types", "=", "[", "]", ";", "if", "(", "strlen", "(", "$", "typeof", ")", ")", "{", "foreach", "(", "preg_split", "(", "'/\\s+/'", ",", "$", "typeof", ")", "as", "$", "prefixedType", ")", "{", "$", "types", "[", "]", "=", "$", "this", "->", "getType", "(", "$", "prefixedType", ",", "$", "context", ")", ";", "}", "}", "return", "new", "Thing", "(", "$", "types", ",", "$", "resourceId", ")", ";", "}" ]
Return a thing by typeof value @param string|null $typeof Thing type @param string|null $resourceId Resource ID @param ContextInterface $context Context @return Thing Thing @throws RuntimeException If the default vocabulary is empty
[ "Return", "a", "thing", "by", "typeof", "value" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php#L138-L149
233,377
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php
AbstractElementProcessor.getType
protected function getType($prefixedType, ContextInterface $context) { list($prefix, $typeName) = $this->getPrefixName($prefixedType); $vocabulary = $this->getVocabulary($prefix, $context); if ($vocabulary instanceof VocabularyInterface) { return new Type($typeName, $vocabulary); } // If the default vocabulary is empty throw new RuntimeException( RuntimeException::EMPTY_DEFAULT_VOCABULARY_STR, RuntimeException::EMPTY_DEFAULT_VOCABULARY ); }
php
protected function getType($prefixedType, ContextInterface $context) { list($prefix, $typeName) = $this->getPrefixName($prefixedType); $vocabulary = $this->getVocabulary($prefix, $context); if ($vocabulary instanceof VocabularyInterface) { return new Type($typeName, $vocabulary); } // If the default vocabulary is empty throw new RuntimeException( RuntimeException::EMPTY_DEFAULT_VOCABULARY_STR, RuntimeException::EMPTY_DEFAULT_VOCABULARY ); }
[ "protected", "function", "getType", "(", "$", "prefixedType", ",", "ContextInterface", "$", "context", ")", "{", "list", "(", "$", "prefix", ",", "$", "typeName", ")", "=", "$", "this", "->", "getPrefixName", "(", "$", "prefixedType", ")", ";", "$", "vocabulary", "=", "$", "this", "->", "getVocabulary", "(", "$", "prefix", ",", "$", "context", ")", ";", "if", "(", "$", "vocabulary", "instanceof", "VocabularyInterface", ")", "{", "return", "new", "Type", "(", "$", "typeName", ",", "$", "vocabulary", ")", ";", "}", "// If the default vocabulary is empty", "throw", "new", "RuntimeException", "(", "RuntimeException", "::", "EMPTY_DEFAULT_VOCABULARY_STR", ",", "RuntimeException", "::", "EMPTY_DEFAULT_VOCABULARY", ")", ";", "}" ]
Instantiate a type @param string $prefixedType Prefixed type @param ContextInterface $context Context @return TypeInterface Type
[ "Instantiate", "a", "type" ]
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/AbstractElementProcessor.php#L158-L171
233,378
CampaignChain/core
Util/SystemUtil.php
SystemUtil.redirectInstallMode
static function redirectInstallMode($redirectUrl = '/campaignchain/install.php') { // Only apply if in request context. if(isset($_SERVER['REQUEST_URI'])) { if ( self::isInstallMode() && false === strpos($_SERVER['REQUEST_URI'], '/install/') ) { // System is not installed yet and user wants to access // a secured page. Hence, redirect to Installation Wizard. header('Location: '.$redirectUrl); exit; } elseif ( // System is installed and user wants to access the Installation // Wizard. Hence, redirect to login page. !self::isInstallMode() && 0 === strpos($_SERVER['REQUEST_URI'], '/install/') ) { header('Location: /'); exit; } } }
php
static function redirectInstallMode($redirectUrl = '/campaignchain/install.php') { // Only apply if in request context. if(isset($_SERVER['REQUEST_URI'])) { if ( self::isInstallMode() && false === strpos($_SERVER['REQUEST_URI'], '/install/') ) { // System is not installed yet and user wants to access // a secured page. Hence, redirect to Installation Wizard. header('Location: '.$redirectUrl); exit; } elseif ( // System is installed and user wants to access the Installation // Wizard. Hence, redirect to login page. !self::isInstallMode() && 0 === strpos($_SERVER['REQUEST_URI'], '/install/') ) { header('Location: /'); exit; } } }
[ "static", "function", "redirectInstallMode", "(", "$", "redirectUrl", "=", "'/campaignchain/install.php'", ")", "{", "// Only apply if in request context.", "if", "(", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "if", "(", "self", "::", "isInstallMode", "(", ")", "&&", "false", "===", "strpos", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "'/install/'", ")", ")", "{", "// System is not installed yet and user wants to access", "// a secured page. Hence, redirect to Installation Wizard.", "header", "(", "'Location: '", ".", "$", "redirectUrl", ")", ";", "exit", ";", "}", "elseif", "(", "// System is installed and user wants to access the Installation", "// Wizard. Hence, redirect to login page.", "!", "self", "::", "isInstallMode", "(", ")", "&&", "0", "===", "strpos", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "'/install/'", ")", ")", "{", "header", "(", "'Location: /'", ")", ";", "exit", ";", "}", "}", "}" ]
Checks whether system is in install mode. @param string $redirectUrl
[ "Checks", "whether", "system", "is", "in", "install", "mode", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L44-L66
233,379
CampaignChain/core
Util/SystemUtil.php
SystemUtil.getConfigFiles
public static function getConfigFiles() { $configFiles = array(); $symfonyConfigDir = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'config'; $campaignchainConfigDir = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'campaignchain'.DIRECTORY_SEPARATOR. 'config'; $configFiles['kernel_symfony'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.'AppKernel.php'; $configFiles['bundles_dist'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'AppKernel_campaignchain.php'; $configFiles['bundles'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'campaignchain'.DIRECTORY_SEPARATOR. 'AppKernel.php'; $configFiles['config_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'config_campaignchain_imports.yml.dist'; $configFiles['config'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'imports.yml'; $configFiles['routing_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'routing_campaignchain.yml.dist'; $configFiles['routing'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'routing.yml'; $configFiles['security_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'security_campaignchain.yml.dist'; $configFiles['security'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'security.yml'; return $configFiles; }
php
public static function getConfigFiles() { $configFiles = array(); $symfonyConfigDir = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'config'; $campaignchainConfigDir = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'campaignchain'.DIRECTORY_SEPARATOR. 'config'; $configFiles['kernel_symfony'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR.'AppKernel.php'; $configFiles['bundles_dist'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'AppKernel_campaignchain.php'; $configFiles['bundles'] = self::getRootDir().'app'.DIRECTORY_SEPARATOR. 'campaignchain'.DIRECTORY_SEPARATOR. 'AppKernel.php'; $configFiles['config_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'config_campaignchain_imports.yml.dist'; $configFiles['config'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'imports.yml'; $configFiles['routing_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'routing_campaignchain.yml.dist'; $configFiles['routing'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'routing.yml'; $configFiles['security_dist'] = $symfonyConfigDir.DIRECTORY_SEPARATOR. 'security_campaignchain.yml.dist'; $configFiles['security'] = $campaignchainConfigDir.DIRECTORY_SEPARATOR. 'security.yml'; return $configFiles; }
[ "public", "static", "function", "getConfigFiles", "(", ")", "{", "$", "configFiles", "=", "array", "(", ")", ";", "$", "symfonyConfigDir", "=", "self", "::", "getRootDir", "(", ")", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'config'", ";", "$", "campaignchainConfigDir", "=", "self", "::", "getRootDir", "(", ")", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'campaignchain'", ".", "DIRECTORY_SEPARATOR", ".", "'config'", ";", "$", "configFiles", "[", "'kernel_symfony'", "]", "=", "self", "::", "getRootDir", "(", ")", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'AppKernel.php'", ";", "$", "configFiles", "[", "'bundles_dist'", "]", "=", "self", "::", "getRootDir", "(", ")", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'AppKernel_campaignchain.php'", ";", "$", "configFiles", "[", "'bundles'", "]", "=", "self", "::", "getRootDir", "(", ")", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'campaignchain'", ".", "DIRECTORY_SEPARATOR", ".", "'AppKernel.php'", ";", "$", "configFiles", "[", "'config_dist'", "]", "=", "$", "symfonyConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'config_campaignchain_imports.yml.dist'", ";", "$", "configFiles", "[", "'config'", "]", "=", "$", "campaignchainConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'imports.yml'", ";", "$", "configFiles", "[", "'routing_dist'", "]", "=", "$", "symfonyConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'routing_campaignchain.yml.dist'", ";", "$", "configFiles", "[", "'routing'", "]", "=", "$", "campaignchainConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'routing.yml'", ";", "$", "configFiles", "[", "'security_dist'", "]", "=", "$", "symfonyConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'security_campaignchain.yml.dist'", ";", "$", "configFiles", "[", "'security'", "]", "=", "$", "campaignchainConfigDir", ".", "DIRECTORY_SEPARATOR", ".", "'security.yml'", ";", "return", "$", "configFiles", ";", "}" ]
Returns an array with the absolute path of all configuration files of the CampaignChain app. @return array
[ "Returns", "an", "array", "with", "the", "absolute", "path", "of", "all", "configuration", "files", "of", "the", "CampaignChain", "app", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L98-L134
233,380
CampaignChain/core
Util/SystemUtil.php
SystemUtil.initKernel
public static function initKernel() { $configFiles = self::getConfigFiles(); $fs = new Filesystem(); if(!$fs->exists($configFiles['bundles'])){ $fs->copy($configFiles['bundles_dist'], $configFiles['bundles'], true); } if(!$fs->exists($configFiles['config'])){ $fs->copy($configFiles['config_dist'], $configFiles['config'], true); } if(!$fs->exists($configFiles['routing'])){ $fs->copy($configFiles['routing_dist'], $configFiles['routing'], true); } if(!$fs->exists($configFiles['security'])){ $fs->copy($configFiles['security_dist'], $configFiles['security'], true); } }
php
public static function initKernel() { $configFiles = self::getConfigFiles(); $fs = new Filesystem(); if(!$fs->exists($configFiles['bundles'])){ $fs->copy($configFiles['bundles_dist'], $configFiles['bundles'], true); } if(!$fs->exists($configFiles['config'])){ $fs->copy($configFiles['config_dist'], $configFiles['config'], true); } if(!$fs->exists($configFiles['routing'])){ $fs->copy($configFiles['routing_dist'], $configFiles['routing'], true); } if(!$fs->exists($configFiles['security'])){ $fs->copy($configFiles['security_dist'], $configFiles['security'], true); } }
[ "public", "static", "function", "initKernel", "(", ")", "{", "$", "configFiles", "=", "self", "::", "getConfigFiles", "(", ")", ";", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "configFiles", "[", "'bundles'", "]", ")", ")", "{", "$", "fs", "->", "copy", "(", "$", "configFiles", "[", "'bundles_dist'", "]", ",", "$", "configFiles", "[", "'bundles'", "]", ",", "true", ")", ";", "}", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "configFiles", "[", "'config'", "]", ")", ")", "{", "$", "fs", "->", "copy", "(", "$", "configFiles", "[", "'config_dist'", "]", ",", "$", "configFiles", "[", "'config'", "]", ",", "true", ")", ";", "}", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "configFiles", "[", "'routing'", "]", ")", ")", "{", "$", "fs", "->", "copy", "(", "$", "configFiles", "[", "'routing_dist'", "]", ",", "$", "configFiles", "[", "'routing'", "]", ",", "true", ")", ";", "}", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "configFiles", "[", "'security'", "]", ")", ")", "{", "$", "fs", "->", "copy", "(", "$", "configFiles", "[", "'security_dist'", "]", ",", "$", "configFiles", "[", "'security'", "]", ",", "true", ")", ";", "}", "}" ]
Creates the CampaignChain app configuration files based on the default files or overwrites existing ones with the default.
[ "Creates", "the", "CampaignChain", "app", "configuration", "files", "based", "on", "the", "default", "files", "or", "overwrites", "existing", "ones", "with", "the", "default", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SystemUtil.php#L140-L158
233,381
civicrm/civicrm-setup
src/Setup.php
Setup.assertProtocolCompatibility
public static function assertProtocolCompatibility($expectedVersion) { if (version_compare(self::PROTOCOL, $expectedVersion, '<')) { throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion)); } list ($actualFirst) = explode('.', self::PROTOCOL); list ($expectedFirst) = explode('.', $expectedVersion); if ($actualFirst > $expectedFirst) { throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion)); } }
php
public static function assertProtocolCompatibility($expectedVersion) { if (version_compare(self::PROTOCOL, $expectedVersion, '<')) { throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion)); } list ($actualFirst) = explode('.', self::PROTOCOL); list ($expectedFirst) = explode('.', $expectedVersion); if ($actualFirst > $expectedFirst) { throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion)); } }
[ "public", "static", "function", "assertProtocolCompatibility", "(", "$", "expectedVersion", ")", "{", "if", "(", "version_compare", "(", "self", "::", "PROTOCOL", ",", "$", "expectedVersion", ",", "'<'", ")", ")", "{", "throw", "new", "InitException", "(", "sprintf", "(", "\"civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.\"", ",", "self", "::", "PROTOCOL", ",", "$", "expectedVersion", ")", ")", ";", "}", "list", "(", "$", "actualFirst", ")", "=", "explode", "(", "'.'", ",", "self", "::", "PROTOCOL", ")", ";", "list", "(", "$", "expectedFirst", ")", "=", "explode", "(", "'.'", ",", "$", "expectedVersion", ")", ";", "if", "(", "$", "actualFirst", ">", "$", "expectedFirst", ")", "{", "throw", "new", "InitException", "(", "sprintf", "(", "\"civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.\"", ",", "self", "::", "PROTOCOL", ",", "$", "expectedVersion", ")", ")", ";", "}", "}" ]
Assert that this copy of civicrm-setup is compatible with the client. @param string $expectedVersion @throws \Exception
[ "Assert", "that", "this", "copy", "of", "civicrm", "-", "setup", "is", "compatible", "with", "the", "client", "." ]
556b312faf78781c85c4fc4ae6c1c3b658da9e09
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup.php#L105-L114
233,382
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Polygon.php
Polygon.point
public function point($int_x, $int_y) { if (is_double($int_x)) { $int_x = (integer) $int_x; } if (is_double($int_y)) { $int_y = (integer) $int_y; } if ((!is_integer($int_x) || !is_integer($int_y)) || $int_x < 0 || $int_y < 0) { throw new \InvalidArgumentException('Coordinates must be composed of two positive integers!'); } $this->arr_points[] = array($int_x, $int_y); return $this; }
php
public function point($int_x, $int_y) { if (is_double($int_x)) { $int_x = (integer) $int_x; } if (is_double($int_y)) { $int_y = (integer) $int_y; } if ((!is_integer($int_x) || !is_integer($int_y)) || $int_x < 0 || $int_y < 0) { throw new \InvalidArgumentException('Coordinates must be composed of two positive integers!'); } $this->arr_points[] = array($int_x, $int_y); return $this; }
[ "public", "function", "point", "(", "$", "int_x", ",", "$", "int_y", ")", "{", "if", "(", "is_double", "(", "$", "int_x", ")", ")", "{", "$", "int_x", "=", "(", "integer", ")", "$", "int_x", ";", "}", "if", "(", "is_double", "(", "$", "int_y", ")", ")", "{", "$", "int_y", "=", "(", "integer", ")", "$", "int_y", ";", "}", "if", "(", "(", "!", "is_integer", "(", "$", "int_x", ")", "||", "!", "is_integer", "(", "$", "int_y", ")", ")", "||", "$", "int_x", "<", "0", "||", "$", "int_y", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Coordinates must be composed of two positive integers!'", ")", ";", "}", "$", "this", "->", "arr_points", "[", "]", "=", "array", "(", "$", "int_x", ",", "$", "int_y", ")", ";", "return", "$", "this", ";", "}" ]
Adds one point by giving it x and y coordinates. @param integer $int_x @param integer $int_y @throws \InvalidArgumentException If coordinates are not positive integers. @access public @return Polygon
[ "Adds", "one", "point", "by", "giving", "it", "x", "and", "y", "coordinates", "." ]
91affa83f8580c8e6da62c77ce34b1c4451784bf
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Polygon.php#L66-L83
233,383
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Polygon.php
Polygon.svg
public function svg() { if (count($this->arr_points) < 3) { throw new \RuntimeException('Before exporting to SVG, you must give at least 3 points!'); } $arr = array(); foreach ($this->arr_points as $point) { $arr[] = implode(',', $point); } $str_attr_points = implode(' ', $arr); return sprintf('<polygon points="%s" style="fill:%s" />', $str_attr_points, $this->color); }
php
public function svg() { if (count($this->arr_points) < 3) { throw new \RuntimeException('Before exporting to SVG, you must give at least 3 points!'); } $arr = array(); foreach ($this->arr_points as $point) { $arr[] = implode(',', $point); } $str_attr_points = implode(' ', $arr); return sprintf('<polygon points="%s" style="fill:%s" />', $str_attr_points, $this->color); }
[ "public", "function", "svg", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "arr_points", ")", "<", "3", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Before exporting to SVG, you must give at least 3 points!'", ")", ";", "}", "$", "arr", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "arr_points", "as", "$", "point", ")", "{", "$", "arr", "[", "]", "=", "implode", "(", "','", ",", "$", "point", ")", ";", "}", "$", "str_attr_points", "=", "implode", "(", "' '", ",", "$", "arr", ")", ";", "return", "sprintf", "(", "'<polygon points=\"%s\" style=\"fill:%s\" />'", ",", "$", "str_attr_points", ",", "$", "this", "->", "color", ")", ";", "}" ]
Returns the SVG code part rendering the current polygon. @throws \RuntimeException If amount of point is less than 3. @access public @return void
[ "Returns", "the", "SVG", "code", "part", "rendering", "the", "current", "polygon", "." ]
91affa83f8580c8e6da62c77ce34b1c4451784bf
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Polygon.php#L110-L125
233,384
ionux/phactor
src/Key.php
Key.GenerateKeypair
public function GenerateKeypair() { $point = $this->GenerateNewPoint(); $point['Rx_hex'] = $this->stripHexPrefix($point['Rx_hex']); $point['Ry_hex'] = $this->stripHexPrefix($point['Ry_hex']); $point['random_number'] = $this->stripHexPrefix($point['random_number']); $comp_prefix = ($this->Modulo($point['R']['y'], '2') == '1') ? '03' : '02'; $this->keyInfo = array( 'private_key_hex' => $this->encodeHex($point['random_number']), 'private_key_dec' => $point['random_number'], 'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'], 'public_key_compressed' => $comp_prefix . $point['Rx_hex'], 'public_key_x' => $point['Rx_hex'], 'public_key_y' => $point['Ry_hex'], ); return $this->keyInfo; }
php
public function GenerateKeypair() { $point = $this->GenerateNewPoint(); $point['Rx_hex'] = $this->stripHexPrefix($point['Rx_hex']); $point['Ry_hex'] = $this->stripHexPrefix($point['Ry_hex']); $point['random_number'] = $this->stripHexPrefix($point['random_number']); $comp_prefix = ($this->Modulo($point['R']['y'], '2') == '1') ? '03' : '02'; $this->keyInfo = array( 'private_key_hex' => $this->encodeHex($point['random_number']), 'private_key_dec' => $point['random_number'], 'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'], 'public_key_compressed' => $comp_prefix . $point['Rx_hex'], 'public_key_x' => $point['Rx_hex'], 'public_key_y' => $point['Ry_hex'], ); return $this->keyInfo; }
[ "public", "function", "GenerateKeypair", "(", ")", "{", "$", "point", "=", "$", "this", "->", "GenerateNewPoint", "(", ")", ";", "$", "point", "[", "'Rx_hex'", "]", "=", "$", "this", "->", "stripHexPrefix", "(", "$", "point", "[", "'Rx_hex'", "]", ")", ";", "$", "point", "[", "'Ry_hex'", "]", "=", "$", "this", "->", "stripHexPrefix", "(", "$", "point", "[", "'Ry_hex'", "]", ")", ";", "$", "point", "[", "'random_number'", "]", "=", "$", "this", "->", "stripHexPrefix", "(", "$", "point", "[", "'random_number'", "]", ")", ";", "$", "comp_prefix", "=", "(", "$", "this", "->", "Modulo", "(", "$", "point", "[", "'R'", "]", "[", "'y'", "]", ",", "'2'", ")", "==", "'1'", ")", "?", "'03'", ":", "'02'", ";", "$", "this", "->", "keyInfo", "=", "array", "(", "'private_key_hex'", "=>", "$", "this", "->", "encodeHex", "(", "$", "point", "[", "'random_number'", "]", ")", ",", "'private_key_dec'", "=>", "$", "point", "[", "'random_number'", "]", ",", "'public_key'", "=>", "'04'", ".", "$", "point", "[", "'Rx_hex'", "]", ".", "$", "point", "[", "'Ry_hex'", "]", ",", "'public_key_compressed'", "=>", "$", "comp_prefix", ".", "$", "point", "[", "'Rx_hex'", "]", ",", "'public_key_x'", "=>", "$", "point", "[", "'Rx_hex'", "]", ",", "'public_key_y'", "=>", "$", "point", "[", "'Ry_hex'", "]", ",", ")", ";", "return", "$", "this", "->", "keyInfo", ";", "}" ]
This is the main function for generating a new keypair. @return array $keyInfo The complete keypair array.
[ "This", "is", "the", "main", "function", "for", "generating", "a", "new", "keypair", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L109-L129
233,385
ionux/phactor
src/Key.php
Key.parseUncompressedPublicKey
public function parseUncompressedPublicKey($pubkey) { return (substr($pubkey, 0, 2) == '04') ? $this->prepAndClean(substr($pubkey, 2)) : $this->prepAndClean($pubkey); }
php
public function parseUncompressedPublicKey($pubkey) { return (substr($pubkey, 0, 2) == '04') ? $this->prepAndClean(substr($pubkey, 2)) : $this->prepAndClean($pubkey); }
[ "public", "function", "parseUncompressedPublicKey", "(", "$", "pubkey", ")", "{", "return", "(", "substr", "(", "$", "pubkey", ",", "0", ",", "2", ")", "==", "'04'", ")", "?", "$", "this", "->", "prepAndClean", "(", "substr", "(", "$", "pubkey", ",", "2", ")", ")", ":", "$", "this", "->", "prepAndClean", "(", "$", "pubkey", ")", ";", "}" ]
Checks if the uncompressed public key has the 0x04 prefix. @param string $pubkey The key to check. @return string The public key without the prefix.
[ "Checks", "if", "the", "uncompressed", "public", "key", "has", "the", "0x04", "prefix", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L137-L140
233,386
ionux/phactor
src/Key.php
Key.parseCompressedPublicKey
public function parseCompressedPublicKey($pubkey, $returnHex = false) { $prefix = substr($pubkey, 0, 2); if ($prefix !== '02' && $prefix !== '03') { return $this->prepAndClean($pubkey); } $pointX = substr($pubkey, 2); $pointY = substr($this->calcYfromX($pointX, $prefix), 2); $parsedValue = $this->prepAndClean($pointX . $pointY); return ($returnHex === false) ? $parsedValue : $this->encodeHex($parsedValue); }
php
public function parseCompressedPublicKey($pubkey, $returnHex = false) { $prefix = substr($pubkey, 0, 2); if ($prefix !== '02' && $prefix !== '03') { return $this->prepAndClean($pubkey); } $pointX = substr($pubkey, 2); $pointY = substr($this->calcYfromX($pointX, $prefix), 2); $parsedValue = $this->prepAndClean($pointX . $pointY); return ($returnHex === false) ? $parsedValue : $this->encodeHex($parsedValue); }
[ "public", "function", "parseCompressedPublicKey", "(", "$", "pubkey", ",", "$", "returnHex", "=", "false", ")", "{", "$", "prefix", "=", "substr", "(", "$", "pubkey", ",", "0", ",", "2", ")", ";", "if", "(", "$", "prefix", "!==", "'02'", "&&", "$", "prefix", "!==", "'03'", ")", "{", "return", "$", "this", "->", "prepAndClean", "(", "$", "pubkey", ")", ";", "}", "$", "pointX", "=", "substr", "(", "$", "pubkey", ",", "2", ")", ";", "$", "pointY", "=", "substr", "(", "$", "this", "->", "calcYfromX", "(", "$", "pointX", ",", "$", "prefix", ")", ",", "2", ")", ";", "$", "parsedValue", "=", "$", "this", "->", "prepAndClean", "(", "$", "pointX", ".", "$", "pointY", ")", ";", "return", "(", "$", "returnHex", "===", "false", ")", "?", "$", "parsedValue", ":", "$", "this", "->", "encodeHex", "(", "$", "parsedValue", ")", ";", "}" ]
Parses a compressed public key with the 0x02 or 0x03 prefix. @param string $pubkey The key to check. @param bool $returnHex Whether or not to return the value in decimal or hex. @return string The (x,y) coordinate pair.
[ "Parses", "a", "compressed", "public", "key", "with", "the", "0x02", "or", "0x03", "prefix", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L149-L163
233,387
ionux/phactor
src/Key.php
Key.parseCoordinatePairFromPublicKey
public function parseCoordinatePairFromPublicKey($pubkey) { return array( 'x' => $this->addHexPrefix(substr($pubkey, 0, 64)), 'y' => $this->addHexPrefix(substr($pubkey, 64)) ); }
php
public function parseCoordinatePairFromPublicKey($pubkey) { return array( 'x' => $this->addHexPrefix(substr($pubkey, 0, 64)), 'y' => $this->addHexPrefix(substr($pubkey, 64)) ); }
[ "public", "function", "parseCoordinatePairFromPublicKey", "(", "$", "pubkey", ")", "{", "return", "array", "(", "'x'", "=>", "$", "this", "->", "addHexPrefix", "(", "substr", "(", "$", "pubkey", ",", "0", ",", "64", ")", ")", ",", "'y'", "=>", "$", "this", "->", "addHexPrefix", "(", "substr", "(", "$", "pubkey", ",", "64", ")", ")", ")", ";", "}" ]
Parses the x & y coordinates from an uncompressed public key. @param string $pubkey The key to parse. @return array The public key (x,y) coordinates.
[ "Parses", "the", "x", "&", "y", "coordinates", "from", "an", "uncompressed", "public", "key", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Key.php#L171-L177
233,388
CampaignChain/core
Controller/REST/LocationController.php
LocationController.getLocationsAction
public function getLocationsAction($id) { $qb = $this->getQueryBuilder(); $qb->select(self::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('l.id = :id'); $qb->setParameter('id', $id); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getLocationsAction($id) { $qb = $this->getQueryBuilder(); $qb->select(self::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('l.id = :id'); $qb->setParameter('id', $id); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getLocationsAction", "(", "$", "id", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "self", "::", "SELECT_STATEMENT", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Location'", ",", "'l'", ")", ";", "$", "qb", "->", "where", "(", "'l.id = :id'", ")", ";", "$", "qb", "->", "setParameter", "(", "'id'", ",", "$", "id", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "return", "$", "this", "->", "response", "(", "$", "query", "->", "getResult", "(", "\\", "Doctrine", "\\", "ORM", "\\", "Query", "::", "HYDRATE_ARRAY", ")", ")", ";", "}" ]
Get a specific Location by its ID. Example Request =============== GET /api/v1/locations/42 Example Response ================ [ { "id": 129, "identifier": "100008922632416", "name": "Amariki Test One", "url": "https://www.facebook.com/profile.php?id=100008922632416", "image": "https://graph.facebook.com/100008922632416/picture?width=150&height=150", "status": "active", "createdDate": "2016-10-25T12:26:57+0000", "modifiedDate": "2016-10-27T13:36:44+0000" } ] @ApiDoc( section="Core", requirements={ { "name"="id", "requirement"="\d+", "description" = "Location ID" } } ) @param string $id Location ID @return \Symfony\Component\HttpFoundation\Response
[ "Get", "a", "specific", "Location", "by", "its", "ID", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/LocationController.php#L77-L89
233,389
CampaignChain/core
Controller/REST/LocationController.php
LocationController.postToggleStatusAction
public function postToggleStatusAction(Request $request) { $id = $request->request->get('id'); $service = $this->get('campaignchain.core.location'); try { $status = $service->toggleStatus($id); $response = $this->forward( 'CampaignChainCoreBundle:REST/Location:getLocations', array( 'id' => $request->request->get('id') ) ); return $response->setStatusCode(Response::HTTP_CREATED); } catch (\Exception $e) { return $this->errorResponse($e->getMessage()); } }
php
public function postToggleStatusAction(Request $request) { $id = $request->request->get('id'); $service = $this->get('campaignchain.core.location'); try { $status = $service->toggleStatus($id); $response = $this->forward( 'CampaignChainCoreBundle:REST/Location:getLocations', array( 'id' => $request->request->get('id') ) ); return $response->setStatusCode(Response::HTTP_CREATED); } catch (\Exception $e) { return $this->errorResponse($e->getMessage()); } }
[ "public", "function", "postToggleStatusAction", "(", "Request", "$", "request", ")", "{", "$", "id", "=", "$", "request", "->", "request", "->", "get", "(", "'id'", ")", ";", "$", "service", "=", "$", "this", "->", "get", "(", "'campaignchain.core.location'", ")", ";", "try", "{", "$", "status", "=", "$", "service", "->", "toggleStatus", "(", "$", "id", ")", ";", "$", "response", "=", "$", "this", "->", "forward", "(", "'CampaignChainCoreBundle:REST/Location:getLocations'", ",", "array", "(", "'id'", "=>", "$", "request", "->", "request", "->", "get", "(", "'id'", ")", ")", ")", ";", "return", "$", "response", "->", "setStatusCode", "(", "Response", "::", "HTTP_CREATED", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "errorResponse", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Toggle the status of a Location to active or inactive. Example Request =============== POST /api/v1/location/toggle-status Example Input ============= { "id": "42" } Example Response ================ See: GET /api/v1/locations/{id} @ApiDoc( section="Core", requirements={ { "name"="id", "requirement"="\d+", "description" = "Location ID" } } ) @REST\Post("/toggle-status") @return \Symfony\Component\HttpFoundation\Response
[ "Toggle", "the", "status", "of", "a", "Location", "to", "active", "or", "inactive", "." ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/LocationController.php#L128-L146
233,390
kasparsklavins/Hunter
src/Hunter.php
Hunter.getIdFromUsername
public function getIdFromUsername($username) { $id = $this->load('uname2uid', $username); return ($id === 0) ? null : (int) $id; }
php
public function getIdFromUsername($username) { $id = $this->load('uname2uid', $username); return ($id === 0) ? null : (int) $id; }
[ "public", "function", "getIdFromUsername", "(", "$", "username", ")", "{", "$", "id", "=", "$", "this", "->", "load", "(", "'uname2uid'", ",", "$", "username", ")", ";", "return", "(", "$", "id", "===", "0", ")", "?", "null", ":", "(", "int", ")", "$", "id", ";", "}" ]
Service will return the user ID of given username. @param string $username @return int
[ "Service", "will", "return", "the", "user", "ID", "of", "given", "username", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L44-L49
233,391
kasparsklavins/Hunter
src/Hunter.php
Hunter.problems
public function problems() { $rawProblems = $this->load('p'); $problems = array(); foreach ($rawProblems as $problem) { $problems[] = Helper\formatProblem($problem, false); } return $problems; }
php
public function problems() { $rawProblems = $this->load('p'); $problems = array(); foreach ($rawProblems as $problem) { $problems[] = Helper\formatProblem($problem, false); } return $problems; }
[ "public", "function", "problems", "(", ")", "{", "$", "rawProblems", "=", "$", "this", "->", "load", "(", "'p'", ")", ";", "$", "problems", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawProblems", "as", "$", "problem", ")", "{", "$", "problems", "[", "]", "=", "Helper", "\\", "formatProblem", "(", "$", "problem", ",", "false", ")", ";", "}", "return", "$", "problems", ";", "}" ]
Returns the list of problems at UVa. @return array
[ "Returns", "the", "list", "of", "problems", "at", "UVa", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L56-L66
233,392
kasparsklavins/Hunter
src/Hunter.php
Hunter.problem
public function problem($id, $type = 'id') { $problem = $this->load('p', array($type, $id)); return Helper\formatProblem($problem); }
php
public function problem($id, $type = 'id') { $problem = $this->load('p', array($type, $id)); return Helper\formatProblem($problem); }
[ "public", "function", "problem", "(", "$", "id", ",", "$", "type", "=", "'id'", ")", "{", "$", "problem", "=", "$", "this", "->", "load", "(", "'p'", ",", "array", "(", "$", "type", ",", "$", "id", ")", ")", ";", "return", "Helper", "\\", "formatProblem", "(", "$", "problem", ")", ";", "}" ]
View a specific problem. @param int $id @param string $type accepted values are 'id' and 'num'. @return array
[ "View", "a", "specific", "problem", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L76-L81
233,393
kasparsklavins/Hunter
src/Hunter.php
Hunter.problemSubmissions
public function problemSubmissions($problems, $start = 0, $end = 2147483648) { if (is_array($problems) === false) { $problems = array($problems); } $rawSubmissions = $this->load('p/subs', array($problems, $start, $end)); $submissions = array(); foreach ($rawSubmissions as $submission) { $submissions[] = Helper\formatSubmission($submission); } return $submissions; }
php
public function problemSubmissions($problems, $start = 0, $end = 2147483648) { if (is_array($problems) === false) { $problems = array($problems); } $rawSubmissions = $this->load('p/subs', array($problems, $start, $end)); $submissions = array(); foreach ($rawSubmissions as $submission) { $submissions[] = Helper\formatSubmission($submission); } return $submissions; }
[ "public", "function", "problemSubmissions", "(", "$", "problems", ",", "$", "start", "=", "0", ",", "$", "end", "=", "2147483648", ")", "{", "if", "(", "is_array", "(", "$", "problems", ")", "===", "false", ")", "{", "$", "problems", "=", "array", "(", "$", "problems", ")", ";", "}", "$", "rawSubmissions", "=", "$", "this", "->", "load", "(", "'p/subs'", ",", "array", "(", "$", "problems", ",", "$", "start", ",", "$", "end", ")", ")", ";", "$", "submissions", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawSubmissions", "as", "$", "submission", ")", "{", "$", "submissions", "[", "]", "=", "Helper", "\\", "formatSubmission", "(", "$", "submission", ")", ";", "}", "return", "$", "submissions", ";", "}" ]
View submissions to specific problems on a given submission date range. @param array|int $problems @param int $start Unix timestamp. @param int $end Unix timestamp. @return array
[ "View", "submissions", "to", "specific", "problems", "on", "a", "given", "submission", "date", "range", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L92-L106
233,394
kasparsklavins/Hunter
src/Hunter.php
Hunter.userSubmissions
public function userSubmissions($user, $min = null) { if (is_null($min)) { $rawSubmissions = $this->load('subs-user', $user); } else { $rawSubmissions = $this->load('subs-user', array($user, $min)); } $submissions = array(); foreach ($rawSubmissions['subs'] as $submission) { $submissions[] = Helper\formatUserSubmission( $submission, $user, $rawSubmissions['name'], $rawSubmissions['name'] ); } return $submissions; }
php
public function userSubmissions($user, $min = null) { if (is_null($min)) { $rawSubmissions = $this->load('subs-user', $user); } else { $rawSubmissions = $this->load('subs-user', array($user, $min)); } $submissions = array(); foreach ($rawSubmissions['subs'] as $submission) { $submissions[] = Helper\formatUserSubmission( $submission, $user, $rawSubmissions['name'], $rawSubmissions['name'] ); } return $submissions; }
[ "public", "function", "userSubmissions", "(", "$", "user", ",", "$", "min", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "min", ")", ")", "{", "$", "rawSubmissions", "=", "$", "this", "->", "load", "(", "'subs-user'", ",", "$", "user", ")", ";", "}", "else", "{", "$", "rawSubmissions", "=", "$", "this", "->", "load", "(", "'subs-user'", ",", "array", "(", "$", "user", ",", "$", "min", ")", ")", ";", "}", "$", "submissions", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawSubmissions", "[", "'subs'", "]", "as", "$", "submission", ")", "{", "$", "submissions", "[", "]", "=", "Helper", "\\", "formatUserSubmission", "(", "$", "submission", ",", "$", "user", ",", "$", "rawSubmissions", "[", "'name'", "]", ",", "$", "rawSubmissions", "[", "'name'", "]", ")", ";", "}", "return", "$", "submissions", ";", "}" ]
Returns all of the submissions of a particular user. @param int $user @param int $min @return array
[ "Returns", "all", "of", "the", "submissions", "of", "a", "particular", "user", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L154-L174
233,395
kasparsklavins/Hunter
src/Hunter.php
Hunter.userProblemSubmissions
public function userProblemSubmissions($users, $problems, $min = 0, $type = 'id') { if (!is_array($users)) { $users = array($users); } if (!is_array($problems)) { $problems = array($problems); } if ($type === 'id') { $rawSubmissions = $this->load('subs-pids', array($users, $problems, $min)); } else { $rawSubmissions = $this->load('subs-nums', array($users, $problems, $min)); } $users = array(); foreach ($rawSubmissions as $id => $user) { foreach ($user['subs'] as $submission) { $users[$id][] = Helper\formatUserSubmission( $submission, $id, $user['name'], $user['uname'] ); } } return $users; }
php
public function userProblemSubmissions($users, $problems, $min = 0, $type = 'id') { if (!is_array($users)) { $users = array($users); } if (!is_array($problems)) { $problems = array($problems); } if ($type === 'id') { $rawSubmissions = $this->load('subs-pids', array($users, $problems, $min)); } else { $rawSubmissions = $this->load('subs-nums', array($users, $problems, $min)); } $users = array(); foreach ($rawSubmissions as $id => $user) { foreach ($user['subs'] as $submission) { $users[$id][] = Helper\formatUserSubmission( $submission, $id, $user['name'], $user['uname'] ); } } return $users; }
[ "public", "function", "userProblemSubmissions", "(", "$", "users", ",", "$", "problems", ",", "$", "min", "=", "0", ",", "$", "type", "=", "'id'", ")", "{", "if", "(", "!", "is_array", "(", "$", "users", ")", ")", "{", "$", "users", "=", "array", "(", "$", "users", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "problems", ")", ")", "{", "$", "problems", "=", "array", "(", "$", "problems", ")", ";", "}", "if", "(", "$", "type", "===", "'id'", ")", "{", "$", "rawSubmissions", "=", "$", "this", "->", "load", "(", "'subs-pids'", ",", "array", "(", "$", "users", ",", "$", "problems", ",", "$", "min", ")", ")", ";", "}", "else", "{", "$", "rawSubmissions", "=", "$", "this", "->", "load", "(", "'subs-nums'", ",", "array", "(", "$", "users", ",", "$", "problems", ",", "$", "min", ")", ")", ";", "}", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawSubmissions", "as", "$", "id", "=>", "$", "user", ")", "{", "foreach", "(", "$", "user", "[", "'subs'", "]", "as", "$", "submission", ")", "{", "$", "users", "[", "$", "id", "]", "[", "]", "=", "Helper", "\\", "formatUserSubmission", "(", "$", "submission", ",", "$", "id", ",", "$", "user", "[", "'name'", "]", ",", "$", "user", "[", "'uname'", "]", ")", ";", "}", "}", "return", "$", "users", ";", "}" ]
Returns all the submissions of the users on specific problems. @param array|int $users @param array|int $problems @param int $min @param string $type @return array
[ "Returns", "all", "the", "submissions", "of", "the", "users", "on", "specific", "problems", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L212-L241
233,396
kasparsklavins/Hunter
src/Hunter.php
Hunter.userSolvedProblems
public function userSolvedProblems($users) { if (is_array($users) === false) { $users = array($users); } $rawSolved = $this->load('solved-bits', array($users)); $users = array(); foreach ($rawSolved as $user) { $users[$user['uid']] = $user['solved']; } return $users; }
php
public function userSolvedProblems($users) { if (is_array($users) === false) { $users = array($users); } $rawSolved = $this->load('solved-bits', array($users)); $users = array(); foreach ($rawSolved as $user) { $users[$user['uid']] = $user['solved']; } return $users; }
[ "public", "function", "userSolvedProblems", "(", "$", "users", ")", "{", "if", "(", "is_array", "(", "$", "users", ")", "===", "false", ")", "{", "$", "users", "=", "array", "(", "$", "users", ")", ";", "}", "$", "rawSolved", "=", "$", "this", "->", "load", "(", "'solved-bits'", ",", "array", "(", "$", "users", ")", ")", ";", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawSolved", "as", "$", "user", ")", "{", "$", "users", "[", "$", "user", "[", "'uid'", "]", "]", "=", "$", "user", "[", "'solved'", "]", ";", "}", "return", "$", "users", ";", "}" ]
Get The Bit-Encoded-Problem IDs that Has Been Solved by Some Authors. @param array|int $users @return array
[ "Get", "The", "Bit", "-", "Encoded", "-", "Problem", "IDs", "that", "Has", "Been", "Solved", "by", "Some", "Authors", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L250-L263
233,397
kasparsklavins/Hunter
src/Hunter.php
Hunter.userRanklist
public function userRanklist($user, $above = 10, $below = 10) { $rawUsers = $this->load('ranklist', array($user, $above, $below)); $users = array(); foreach ($rawUsers as $user) { $users[] = Helper\formatRanklist($user); } return $users; }
php
public function userRanklist($user, $above = 10, $below = 10) { $rawUsers = $this->load('ranklist', array($user, $above, $below)); $users = array(); foreach ($rawUsers as $user) { $users[] = Helper\formatRanklist($user); } return $users; }
[ "public", "function", "userRanklist", "(", "$", "user", ",", "$", "above", "=", "10", ",", "$", "below", "=", "10", ")", "{", "$", "rawUsers", "=", "$", "this", "->", "load", "(", "'ranklist'", ",", "array", "(", "$", "user", ",", "$", "above", ",", "$", "below", ")", ")", ";", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawUsers", "as", "$", "user", ")", "{", "$", "users", "[", "]", "=", "Helper", "\\", "formatRanklist", "(", "$", "user", ")", ";", "}", "return", "$", "users", ";", "}" ]
Returns the user's ranklist and their neighbors. @param int $user @param int $above @param int $below @return array
[ "Returns", "the", "user", "s", "ranklist", "and", "their", "neighbors", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L274-L284
233,398
kasparsklavins/Hunter
src/Hunter.php
Hunter.ranklist
public function ranklist($pos = 1, $count = 10) { $rawUsers = $this->load('rank', array($pos, $count)); $users = array(); foreach ($rawUsers as $user) { $users[] = Helper\formatRanklist($user); } return $users; }
php
public function ranklist($pos = 1, $count = 10) { $rawUsers = $this->load('rank', array($pos, $count)); $users = array(); foreach ($rawUsers as $user) { $users[] = Helper\formatRanklist($user); } return $users; }
[ "public", "function", "ranklist", "(", "$", "pos", "=", "1", ",", "$", "count", "=", "10", ")", "{", "$", "rawUsers", "=", "$", "this", "->", "load", "(", "'rank'", ",", "array", "(", "$", "pos", ",", "$", "count", ")", ")", ";", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawUsers", "as", "$", "user", ")", "{", "$", "users", "[", "]", "=", "Helper", "\\", "formatRanklist", "(", "$", "user", ")", ";", "}", "return", "$", "users", ";", "}" ]
Global ranklist. @param int $pos @param int $count @return array
[ "Global", "ranklist", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L294-L304
233,399
kasparsklavins/Hunter
src/Hunter.php
Hunter.load
protected function load($node, $arguments = array()) { if (is_array($arguments) === false) { $arguments = array($arguments); } if (empty($arguments)) { $response = file_get_contents($this->source . $node); } else { foreach ($arguments as &$argument) { if (is_array($argument)) { $argument = implode(',', $argument); } } $response = file_get_contents($this->source . $node . '/' . implode('/', $arguments)); } return json_decode($response, true); }
php
protected function load($node, $arguments = array()) { if (is_array($arguments) === false) { $arguments = array($arguments); } if (empty($arguments)) { $response = file_get_contents($this->source . $node); } else { foreach ($arguments as &$argument) { if (is_array($argument)) { $argument = implode(',', $argument); } } $response = file_get_contents($this->source . $node . '/' . implode('/', $arguments)); } return json_decode($response, true); }
[ "protected", "function", "load", "(", "$", "node", ",", "$", "arguments", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "arguments", ")", "===", "false", ")", "{", "$", "arguments", "=", "array", "(", "$", "arguments", ")", ";", "}", "if", "(", "empty", "(", "$", "arguments", ")", ")", "{", "$", "response", "=", "file_get_contents", "(", "$", "this", "->", "source", ".", "$", "node", ")", ";", "}", "else", "{", "foreach", "(", "$", "arguments", "as", "&", "$", "argument", ")", "{", "if", "(", "is_array", "(", "$", "argument", ")", ")", "{", "$", "argument", "=", "implode", "(", "','", ",", "$", "argument", ")", ";", "}", "}", "$", "response", "=", "file_get_contents", "(", "$", "this", "->", "source", ".", "$", "node", ".", "'/'", ".", "implode", "(", "'/'", ",", "$", "arguments", ")", ")", ";", "}", "return", "json_decode", "(", "$", "response", ",", "true", ")", ";", "}" ]
Reads & decodes data from the specified node. @param string $node @param array|int $arguments @return mixed
[ "Reads", "&", "decodes", "data", "from", "the", "specified", "node", "." ]
89758ff1e1e361f2be763548ab91e01a632fa569
https://github.com/kasparsklavins/Hunter/blob/89758ff1e1e361f2be763548ab91e01a632fa569/src/Hunter.php#L314-L331