repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.getDrupalUuid
protected function getDrupalUuid() { $uuid = null; $version = $this->getProjectVersion(); if ($version >= 8) { $result = $this->runDrushCommand('cget system.site uuid', true); if ($result->getExitCode() === ResultData::EXITCODE_OK) { $message = $result->getMessage(); if ($colon_pos = strrpos($message, ':')) { $uuid = trim(substr($message, $colon_pos + 1)); } } } return $uuid; }
php
protected function getDrupalUuid() { $uuid = null; $version = $this->getProjectVersion(); if ($version >= 8) { $result = $this->runDrushCommand('cget system.site uuid', true); if ($result->getExitCode() === ResultData::EXITCODE_OK) { $message = $result->getMessage(); if ($colon_pos = strrpos($message, ':')) { $uuid = trim(substr($message, $colon_pos + 1)); } } } return $uuid; }
[ "protected", "function", "getDrupalUuid", "(", ")", "{", "$", "uuid", "=", "null", ";", "$", "version", "=", "$", "this", "->", "getProjectVersion", "(", ")", ";", "if", "(", "$", "version", ">=", "8", ")", "{", "$", "result", "=", "$", "this", "->...
Get Drupal UUID. @return string The Drupal UUID.
[ "Get", "Drupal", "UUID", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1427-L1445
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.saveDrupalUuid
protected function saveDrupalUuid() { $config = ProjectX::getProjectConfig(); $options[static::getTypeId()] = [ 'build_info' => [ 'uuid' => $this->getDrupalUuid() ] ]; $config ->setOptions($options) ->save(ProjectX::getProjectPath()); return $this; }
php
protected function saveDrupalUuid() { $config = ProjectX::getProjectConfig(); $options[static::getTypeId()] = [ 'build_info' => [ 'uuid' => $this->getDrupalUuid() ] ]; $config ->setOptions($options) ->save(ProjectX::getProjectPath()); return $this; }
[ "protected", "function", "saveDrupalUuid", "(", ")", "{", "$", "config", "=", "ProjectX", "::", "getProjectConfig", "(", ")", ";", "$", "options", "[", "static", "::", "getTypeId", "(", ")", "]", "=", "[", "'build_info'", "=>", "[", "'uuid'", "=>", "$", ...
Save Drupal UUID to configuration. @return $this
[ "Save", "Drupal", "UUID", "to", "configuration", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1452-L1466
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.drushInstallCommonStack
protected function drushInstallCommonStack( $executable, $drupal_root, DatabaseInterface $database ) { $options = $this->getInstallOptions(); $db_user = $database->getUser(); $db_port = $database->getPort(); $db_pass = $database->getPassword(); $db_name = $database->getDatabase(); $db_host = $database->getHostname(); $db_protocol = $database->getProtocol(); return $this->taskDrushStack($executable) ->drupalRootDirectory($drupal_root) ->siteName($options['site']['name']) ->accountMail($options['account']['mail']) ->accountName($options['account']['name']) ->accountPass($options['account']['pass']) ->dbUrl("$db_protocol://$db_user:$db_pass@$db_host:$db_port/$db_name") ->siteInstall($options['site']['profile']); }
php
protected function drushInstallCommonStack( $executable, $drupal_root, DatabaseInterface $database ) { $options = $this->getInstallOptions(); $db_user = $database->getUser(); $db_port = $database->getPort(); $db_pass = $database->getPassword(); $db_name = $database->getDatabase(); $db_host = $database->getHostname(); $db_protocol = $database->getProtocol(); return $this->taskDrushStack($executable) ->drupalRootDirectory($drupal_root) ->siteName($options['site']['name']) ->accountMail($options['account']['mail']) ->accountName($options['account']['name']) ->accountPass($options['account']['pass']) ->dbUrl("$db_protocol://$db_user:$db_pass@$db_host:$db_port/$db_name") ->siteInstall($options['site']['profile']); }
[ "protected", "function", "drushInstallCommonStack", "(", "$", "executable", ",", "$", "drupal_root", ",", "DatabaseInterface", "$", "database", ")", "{", "$", "options", "=", "$", "this", "->", "getInstallOptions", "(", ")", ";", "$", "db_user", "=", "$", "d...
Drush install common command. @param $executable The drush executable. @param $drupal_root The drupal install root. @param DatabaseInterface $database The database object. @return DrushStack
[ "Drush", "install", "common", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1480-L1502
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.drushAliasFileContent
protected function drushAliasFileContent($name, $uri, $root, array $options = [], $include_opentag = true) { $name = Utility::machineName($name); $content = $include_opentag ? "<?php\n\n" : ''; $content .= "\$aliases['$name'] = ["; $content .= "\n\t'uri' => '$uri',"; $content .= "\n\t'root' => '$root',"; // Add remote host to output if defined. if (isset($options['remote_host']) && $remote_host = $options['remote_host']) { $content .= "\n\t'remote-host' => '$remote_host',"; } // Add remote user to output if defined. if (isset($options['remote_user']) && $remote_user = $options['remote_user']) { $content .= "\n\t'remote-user' => '$remote_user',"; } $content .= "\n\t'path-aliases' => ["; $content .= "\n\t\t'%dump-dir' => '/tmp',"; $content .= "\n\t]"; $content .= "\n];"; return $content; }
php
protected function drushAliasFileContent($name, $uri, $root, array $options = [], $include_opentag = true) { $name = Utility::machineName($name); $content = $include_opentag ? "<?php\n\n" : ''; $content .= "\$aliases['$name'] = ["; $content .= "\n\t'uri' => '$uri',"; $content .= "\n\t'root' => '$root',"; // Add remote host to output if defined. if (isset($options['remote_host']) && $remote_host = $options['remote_host']) { $content .= "\n\t'remote-host' => '$remote_host',"; } // Add remote user to output if defined. if (isset($options['remote_user']) && $remote_user = $options['remote_user']) { $content .= "\n\t'remote-user' => '$remote_user',"; } $content .= "\n\t'path-aliases' => ["; $content .= "\n\t\t'%dump-dir' => '/tmp',"; $content .= "\n\t]"; $content .= "\n];"; return $content; }
[ "protected", "function", "drushAliasFileContent", "(", "$", "name", ",", "$", "uri", ",", "$", "root", ",", "array", "$", "options", "=", "[", "]", ",", "$", "include_opentag", "=", "true", ")", "{", "$", "name", "=", "Utility", "::", "machineName", "(...
Drupal alias PHP file content. @param string $name The alias name. @param string $uri The drush alias URI. @param string $root The root to the drupal project. @param array $options An array of optional options. @param boolean $include_opentag A flag to determine if the opening php tag should be rendered. @return string A string representation of the drush $aliases array.
[ "Drupal", "alias", "PHP", "file", "content", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1553-L1580
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrupalSettingsLocalInclude
protected function setupDrupalSettingsLocalInclude() { $this->taskWriteToFile($this->settingFile) ->append() ->appendUnlessMatches( '/if.+\/settings\.local\.php.+{\n.+\n\}/', $this->drupalSettingsLocalInclude() ) ->run(); return $this; }
php
protected function setupDrupalSettingsLocalInclude() { $this->taskWriteToFile($this->settingFile) ->append() ->appendUnlessMatches( '/if.+\/settings\.local\.php.+{\n.+\n\}/', $this->drupalSettingsLocalInclude() ) ->run(); return $this; }
[ "protected", "function", "setupDrupalSettingsLocalInclude", "(", ")", "{", "$", "this", "->", "taskWriteToFile", "(", "$", "this", "->", "settingFile", ")", "->", "append", "(", ")", "->", "appendUnlessMatches", "(", "'/if.+\\/settings\\.local\\.php.+{\\n.+\\n\\}/'", ...
Setup Drupal settings local include. @return $this
[ "Setup", "Drupal", "settings", "local", "include", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1587-L1598
train
krystal-framework/krystal.framework
src/Krystal/Http/FileTransfer/UploadChain.php
UploadChain.upload
public function upload($id, array $files) { foreach ($this->uploaders as $uploader) { if (!$uploader->upload($id, $files)) { return false; } } return true; }
php
public function upload($id, array $files) { foreach ($this->uploaders as $uploader) { if (!$uploader->upload($id, $files)) { return false; } } return true; }
[ "public", "function", "upload", "(", "$", "id", ",", "array", "$", "files", ")", "{", "foreach", "(", "$", "this", "->", "uploaders", "as", "$", "uploader", ")", "{", "if", "(", "!", "$", "uploader", "->", "upload", "(", "$", "id", ",", "$", "fil...
Uploads via all defined uploaders @param string $id Nested directory's id @param array $files An array of file entities @return boolean
[ "Uploads", "via", "all", "defined", "uploaders" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/UploadChain.php#L70-L79
train
droath/project-x
src/Engine/DockerServices/PhpService.php
PhpService.getDockerfileVariables
protected function getDockerfileVariables() { // Merge service OS packages definition. if ($os_packages = $this->getInfoProperty('packages')) { $this->mergeConfigVariable('PACKAGE_INSTALL', $os_packages); } // Merge service PHP pecl packages definition. if ($pecl_packages = $this->getInfoProperty('pecl_packages')) { $this->mergeConfigVariable('PHP_PECL', $pecl_packages); } // Merge service PHP extensions definition. if ($php_extensions = $this->getInfoProperty('extensions')) { $this->mergeConfigVariable('PHP_EXT_INSTALL', $php_extensions); } // Merge service PHP docker command definition. if ($php_command = $this->getInfoProperty('commands')) { $this->mergeConfigVariable('PHP_COMMANDS', $php_command); } return $this->processDockerfileVariables(); }
php
protected function getDockerfileVariables() { // Merge service OS packages definition. if ($os_packages = $this->getInfoProperty('packages')) { $this->mergeConfigVariable('PACKAGE_INSTALL', $os_packages); } // Merge service PHP pecl packages definition. if ($pecl_packages = $this->getInfoProperty('pecl_packages')) { $this->mergeConfigVariable('PHP_PECL', $pecl_packages); } // Merge service PHP extensions definition. if ($php_extensions = $this->getInfoProperty('extensions')) { $this->mergeConfigVariable('PHP_EXT_INSTALL', $php_extensions); } // Merge service PHP docker command definition. if ($php_command = $this->getInfoProperty('commands')) { $this->mergeConfigVariable('PHP_COMMANDS', $php_command); } return $this->processDockerfileVariables(); }
[ "protected", "function", "getDockerfileVariables", "(", ")", "{", "// Merge service OS packages definition.", "if", "(", "$", "os_packages", "=", "$", "this", "->", "getInfoProperty", "(", "'packages'", ")", ")", "{", "$", "this", "->", "mergeConfigVariable", "(", ...
Get dockerfile variables. @return array
[ "Get", "dockerfile", "variables", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/PhpService.php#L101-L124
train
droath/project-x
src/Engine/DockerServices/PhpService.php
PhpService.processDockerfileVariables
protected function processDockerfileVariables() { $variables = []; $variables['PHP_VERSION'] = $this->getVersion(); foreach ($this->configs as $key => $values) { if (!in_array($key, static::DOCKER_VARIABLES)) { continue; } if ($key === 'PHP_EXT_ENABLE' && !empty($this->configs['PHP_PECL'])) { $php_pecl = $this->configs['PHP_PECL']; // Remove the version from the PECL package. array_walk($php_pecl, function (&$name) { $pos = strpos($name, ':'); if ($pos !== false) { $name = substr($name, 0, $pos); } }); $values = array_merge($php_pecl, $values); } if (empty($values)) { continue; } $variables[$key] = $this->formatVariables($key, $values); } return $variables; }
php
protected function processDockerfileVariables() { $variables = []; $variables['PHP_VERSION'] = $this->getVersion(); foreach ($this->configs as $key => $values) { if (!in_array($key, static::DOCKER_VARIABLES)) { continue; } if ($key === 'PHP_EXT_ENABLE' && !empty($this->configs['PHP_PECL'])) { $php_pecl = $this->configs['PHP_PECL']; // Remove the version from the PECL package. array_walk($php_pecl, function (&$name) { $pos = strpos($name, ':'); if ($pos !== false) { $name = substr($name, 0, $pos); } }); $values = array_merge($php_pecl, $values); } if (empty($values)) { continue; } $variables[$key] = $this->formatVariables($key, $values); } return $variables; }
[ "protected", "function", "processDockerfileVariables", "(", ")", "{", "$", "variables", "=", "[", "]", ";", "$", "variables", "[", "'PHP_VERSION'", "]", "=", "$", "this", "->", "getVersion", "(", ")", ";", "foreach", "(", "$", "this", "->", "configs", "a...
Process dockerfile variables.
[ "Process", "dockerfile", "variables", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/PhpService.php#L129-L161
train
droath/project-x
src/Engine/DockerServices/PhpService.php
PhpService.formatVariables
protected function formatVariables($key, array $values) { switch ($key) { case 'PHP_PECL': return $this->formatPeclPackages($values); case 'PHP_COMMANDS': return $this->formatRunCommand($values); case 'PHP_EXT_CONFIG': case 'PHP_EXT_ENABLE': case 'PHP_EXT_INSTALL': case 'PACKAGE_INSTALL': return $this->formatValueDelimiter($values); } }
php
protected function formatVariables($key, array $values) { switch ($key) { case 'PHP_PECL': return $this->formatPeclPackages($values); case 'PHP_COMMANDS': return $this->formatRunCommand($values); case 'PHP_EXT_CONFIG': case 'PHP_EXT_ENABLE': case 'PHP_EXT_INSTALL': case 'PACKAGE_INSTALL': return $this->formatValueDelimiter($values); } }
[ "protected", "function", "formatVariables", "(", "$", "key", ",", "array", "$", "values", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'PHP_PECL'", ":", "return", "$", "this", "->", "formatPeclPackages", "(", "$", "values", ")", ";", "case", ...
Format docker variables. @param $key @param array $values @return null|string
[ "Format", "docker", "variables", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/PhpService.php#L170-L183
train
droath/project-x
src/Engine/DockerServices/PhpService.php
PhpService.formatPeclPackages
protected function formatPeclPackages(array $values) { $packages = []; foreach ($values as $package) { list($name, $version) = strpos($package, ':') !== false ? explode(':', $package) : [$package, null]; if ($name === 'xdebug' && !isset($version)) { $version = version_compare($this->getVersion(), 7.0, '<') ? '2.5.5' : null; } $version = isset($version) ? "-{$version}" : null; $packages[] = "pecl install {$name}{$version} \\" ; } if (empty($packages)) { return null; } return "&& " . implode("\r\n && ", $packages); }
php
protected function formatPeclPackages(array $values) { $packages = []; foreach ($values as $package) { list($name, $version) = strpos($package, ':') !== false ? explode(':', $package) : [$package, null]; if ($name === 'xdebug' && !isset($version)) { $version = version_compare($this->getVersion(), 7.0, '<') ? '2.5.5' : null; } $version = isset($version) ? "-{$version}" : null; $packages[] = "pecl install {$name}{$version} \\" ; } if (empty($packages)) { return null; } return "&& " . implode("\r\n && ", $packages); }
[ "protected", "function", "formatPeclPackages", "(", "array", "$", "values", ")", "{", "$", "packages", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "package", ")", "{", "list", "(", "$", "name", ",", "$", "version", ")", "=", "strpos...
Format PECL packages. @param array $values @return null|string
[ "Format", "PECL", "packages", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/PhpService.php#L191-L214
train
Droeftoeter/pokapi
src/Pokapi/Hashing/Native.php
Native.generateLocationAuth
protected function generateLocationAuth(string $authTicket, float $latitude, float $longitude, float $altitude = 0.0) { $seed = hexdec(xxhash32($authTicket, 0x1B845238)); return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), (int)$seed)); }
php
protected function generateLocationAuth(string $authTicket, float $latitude, float $longitude, float $altitude = 0.0) { $seed = hexdec(xxhash32($authTicket, 0x1B845238)); return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), (int)$seed)); }
[ "protected", "function", "generateLocationAuth", "(", "string", "$", "authTicket", ",", "float", "$", "latitude", ",", "float", "$", "longitude", ",", "float", "$", "altitude", "=", "0.0", ")", "{", "$", "seed", "=", "hexdec", "(", "xxhash32", "(", "$", ...
Generate location auth hash @param string $authTicket @param float $latitude @param float $longitude @param float $altitude @return number
[ "Generate", "location", "auth", "hash" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Hashing/Native.php#L82-L86
train
Droeftoeter/pokapi
src/Pokapi/Hashing/Native.php
Native.generateLocation
protected function generateLocation(float $latitude, float $longitude, float $altitude = 0.0) : int { return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), 0x1B845238)); }
php
protected function generateLocation(float $latitude, float $longitude, float $altitude = 0.0) : int { return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), 0x1B845238)); }
[ "protected", "function", "generateLocation", "(", "float", "$", "latitude", ",", "float", "$", "longitude", ",", "float", "$", "altitude", "=", "0.0", ")", ":", "int", "{", "return", "(", "int", ")", "hexdec", "(", "xxhash32", "(", "$", "this", "->", "...
Generate location hash @param float $latitude @param float $longitude @param float $altitude @return int
[ "Generate", "location", "hash" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Hashing/Native.php#L97-L100
train
Droeftoeter/pokapi
src/Pokapi/Hashing/Native.php
Native.generateRequestHash
protected function generateRequestHash(string $authTicket, string $request) : int { $seed = (unpack("J", pack("H*", xxhash64($authTicket, 0x1B845238))))[1]; return (unpack("J", pack("H*", xxhash64($request, $seed))))[1]; }
php
protected function generateRequestHash(string $authTicket, string $request) : int { $seed = (unpack("J", pack("H*", xxhash64($authTicket, 0x1B845238))))[1]; return (unpack("J", pack("H*", xxhash64($request, $seed))))[1]; }
[ "protected", "function", "generateRequestHash", "(", "string", "$", "authTicket", ",", "string", "$", "request", ")", ":", "int", "{", "$", "seed", "=", "(", "unpack", "(", "\"J\"", ",", "pack", "(", "\"H*\"", ",", "xxhash64", "(", "$", "authTicket", ","...
Generate request hash @param string $authTicket @param string $request @return int
[ "Generate", "request", "hash" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Hashing/Native.php#L110-L114
train
Droeftoeter/pokapi
src/Pokapi/Hashing/Native.php
Native.getLocationBytes
protected function getLocationBytes(float $latitude, float $longitude, float $altitude) : string { return Hex::d2h($latitude) . Hex::d2h($longitude) . Hex::d2h($altitude); }
php
protected function getLocationBytes(float $latitude, float $longitude, float $altitude) : string { return Hex::d2h($latitude) . Hex::d2h($longitude) . Hex::d2h($altitude); }
[ "protected", "function", "getLocationBytes", "(", "float", "$", "latitude", ",", "float", "$", "longitude", ",", "float", "$", "altitude", ")", ":", "string", "{", "return", "Hex", "::", "d2h", "(", "$", "latitude", ")", ".", "Hex", "::", "d2h", "(", "...
Get the location as bytes @param float $latitude @param float $longitude @param float $altitude @return string
[ "Get", "the", "location", "as", "bytes" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Hashing/Native.php#L125-L128
train
krystal-framework/krystal.framework
src/Krystal/Config/Sql/SqlConfigServiceFactory.php
SqlConfigServiceFactory.build
public static function build($pdo, $table) { $configMapper = new ConfigMapper(new Serializer(), $pdo, $table); return new SqlConfigService($configMapper, new ArrayConfig()); }
php
public static function build($pdo, $table) { $configMapper = new ConfigMapper(new Serializer(), $pdo, $table); return new SqlConfigService($configMapper, new ArrayConfig()); }
[ "public", "static", "function", "build", "(", "$", "pdo", ",", "$", "table", ")", "{", "$", "configMapper", "=", "new", "ConfigMapper", "(", "new", "Serializer", "(", ")", ",", "$", "pdo", ",", "$", "table", ")", ";", "return", "new", "SqlConfigService...
Builds configuration service @param \PDO $pdo Prepared PDO instance @param string $table Table name to work with @return \Krystal\Config\Sql\SqlConfigService
[ "Builds", "configuration", "service" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigServiceFactory.php#L25-L29
train
signifly/shopify-php-sdk
src/Actions/Action.php
Action.destroy
public function destroy($id) { $this->guardAgainstMissingParent('destroy'); $this->shopify->delete($this->path($id)); }
php
public function destroy($id) { $this->guardAgainstMissingParent('destroy'); $this->shopify->delete($this->path($id)); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "$", "this", "->", "guardAgainstMissingParent", "(", "'destroy'", ")", ";", "$", "this", "->", "shopify", "->", "delete", "(", "$", "this", "->", "path", "(", "$", "id", ")", ")", ";", "}" ]
Destroy the specified resource. @param [type] $id [description] @return void
[ "Destroy", "the", "specified", "resource", "." ]
0935b242d00653440e5571fb7901370b2869b99a
https://github.com/signifly/shopify-php-sdk/blob/0935b242d00653440e5571fb7901370b2869b99a/src/Actions/Action.php#L67-L72
train
signifly/shopify-php-sdk
src/Actions/Action.php
Action.requiresParent
protected function requiresParent(string $methodName) { if (in_array('*', $this->requiresParent)) { return true; } return in_array($methodName, $this->requiresParent); }
php
protected function requiresParent(string $methodName) { if (in_array('*', $this->requiresParent)) { return true; } return in_array($methodName, $this->requiresParent); }
[ "protected", "function", "requiresParent", "(", "string", "$", "methodName", ")", "{", "if", "(", "in_array", "(", "'*'", ",", "$", "this", "->", "requiresParent", ")", ")", "{", "return", "true", ";", "}", "return", "in_array", "(", "$", "methodName", "...
Check if the action requires a parent resource. @param string $methodName @return bool
[ "Check", "if", "the", "action", "requires", "a", "parent", "resource", "." ]
0935b242d00653440e5571fb7901370b2869b99a
https://github.com/signifly/shopify-php-sdk/blob/0935b242d00653440e5571fb7901370b2869b99a/src/Actions/Action.php#L152-L159
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.getGitRepositoryFor
protected function getGitRepositoryFor($path) { $git = new GitRepository($this->determineGitRoot($path)); if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) { $git->getConfig()->setLogger( new ConsoleLogger($this->output) ); } return $git; }
php
protected function getGitRepositoryFor($path) { $git = new GitRepository($this->determineGitRoot($path)); if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) { $git->getConfig()->setLogger( new ConsoleLogger($this->output) ); } return $git; }
[ "protected", "function", "getGitRepositoryFor", "(", "$", "path", ")", "{", "$", "git", "=", "new", "GitRepository", "(", "$", "this", "->", "determineGitRoot", "(", "$", "path", ")", ")", ";", "if", "(", "$", "this", "->", "output", "->", "getVerbosity"...
Create a git repository instance. @param string $path A path within a git repository. @return GitRepository.
[ "Create", "a", "git", "repository", "instance", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L45-L55
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.getAllFilesFromGit
private function getAllFilesFromGit($git) { $gitDir = $git->getRepositoryPath(); // Sadly no command in our git library for this. $arguments = [ $git->getConfig()->getGitExecutablePath(), 'ls-tree', 'HEAD', '-r', '--full-name', '--name-only' ]; $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $output = \rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } $files = []; foreach (\explode(PHP_EOL, $output) as $file) { $absolutePath = $gitDir . '/' . $file; if (!$this->config->isPathExcluded($absolutePath)) { $files[\trim($absolutePath)] = \trim($absolutePath); } } return $files; }
php
private function getAllFilesFromGit($git) { $gitDir = $git->getRepositoryPath(); // Sadly no command in our git library for this. $arguments = [ $git->getConfig()->getGitExecutablePath(), 'ls-tree', 'HEAD', '-r', '--full-name', '--name-only' ]; $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $output = \rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } $files = []; foreach (\explode(PHP_EOL, $output) as $file) { $absolutePath = $gitDir . '/' . $file; if (!$this->config->isPathExcluded($absolutePath)) { $files[\trim($absolutePath)] = \trim($absolutePath); } } return $files; }
[ "private", "function", "getAllFilesFromGit", "(", "$", "git", ")", "{", "$", "gitDir", "=", "$", "git", "->", "getRepositoryPath", "(", ")", ";", "// Sadly no command in our git library for this.", "$", "arguments", "=", "[", "$", "git", "->", "getConfig", "(", ...
Retrieve a list of all files within a git repository. @param GitRepository $git The repository to extract all files from. @return string[] @throws GitException When the git execution failed. @throws \ReflectionException Thrown if the class does not exist.
[ "Retrieve", "a", "list", "of", "all", "files", "within", "a", "git", "repository", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L67-L102
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.getFilePaths
public function getFilePaths() { $files = []; foreach ($this->config->getIncludedPaths() as $path) { $files[] = $this->getAllFilesFromGit($this->getGitRepositoryFor($path)); } return array_merge(...$files); }
php
public function getFilePaths() { $files = []; foreach ($this->config->getIncludedPaths() as $path) { $files[] = $this->getAllFilesFromGit($this->getGitRepositoryFor($path)); } return array_merge(...$files); }
[ "public", "function", "getFilePaths", "(", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "config", "->", "getIncludedPaths", "(", ")", "as", "$", "path", ")", "{", "$", "files", "[", "]", "=", "$", "this", "->", "...
Retrieve the file path to use in reporting. @return array @throws \ReflectionException Thrown if the class does not exist.
[ "Retrieve", "the", "file", "path", "to", "use", "in", "reporting", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L111-L119
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.determineGitRoot
private function determineGitRoot($path) { // @codingStandardsIgnoreStart while (\strlen($path) > 1) { // @codingStandardsIgnoreEnd if (\is_dir($path . DIRECTORY_SEPARATOR . '.git')) { return $path; } $path = \dirname($path); } throw new \RuntimeException('Could not determine git root, starting from ' . \func_get_arg(0)); }
php
private function determineGitRoot($path) { // @codingStandardsIgnoreStart while (\strlen($path) > 1) { // @codingStandardsIgnoreEnd if (\is_dir($path . DIRECTORY_SEPARATOR . '.git')) { return $path; } $path = \dirname($path); } throw new \RuntimeException('Could not determine git root, starting from ' . \func_get_arg(0)); }
[ "private", "function", "determineGitRoot", "(", "$", "path", ")", "{", "// @codingStandardsIgnoreStart", "while", "(", "\\", "strlen", "(", "$", "path", ")", ">", "1", ")", "{", "// @codingStandardsIgnoreEnd", "if", "(", "\\", "is_dir", "(", "$", "path", "."...
Determine the git root, starting from arbitrary directory. @param string $path The start path. @return string The git root path. @throws \RuntimeException If the git root could not determined.
[ "Determine", "the", "git", "root", "starting", "from", "arbitrary", "directory", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L130-L143
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.getCurrentUserInfo
protected function getCurrentUserInfo($git) { // Sadly no command in our git library for this. $arguments = [ $git->getConfig()->getGitExecutablePath(), 'config', '--get-regexp', 'user.[name|email]' ]; $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $output = \rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } $config = array(); foreach (\explode(PHP_EOL, $output) as $line) { list($name, $value) = \explode(' ', $line, 2); $config[\trim($name)] = \trim($value); } if (isset($config['user.name']) && $config['user.email']) { return \sprintf('%s <%s>', $config['user.name'], $config['user.email']); } return ''; }
php
protected function getCurrentUserInfo($git) { // Sadly no command in our git library for this. $arguments = [ $git->getConfig()->getGitExecutablePath(), 'config', '--get-regexp', 'user.[name|email]' ]; $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $output = \rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } $config = array(); foreach (\explode(PHP_EOL, $output) as $line) { list($name, $value) = \explode(' ', $line, 2); $config[\trim($name)] = \trim($value); } if (isset($config['user.name']) && $config['user.email']) { return \sprintf('%s <%s>', $config['user.name'], $config['user.email']); } return ''; }
[ "protected", "function", "getCurrentUserInfo", "(", "$", "git", ")", "{", "// Sadly no command in our git library for this.", "$", "arguments", "=", "[", "$", "git", "->", "getConfig", "(", ")", "->", "getGitExecutablePath", "(", ")", ",", "'config'", ",", "'--get...
Retrieve the data of the current user on the system. @param GitRepository $git The repository to extract all files from. @return string @throws GitException When the git execution failed. @throws \ReflectionException Thrown if the class does not exist.
[ "Retrieve", "the", "data", "of", "the", "current", "user", "on", "the", "system", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L155-L189
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.runCustomGit
private function runCustomGit(array $arguments, GitRepository $git) { $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $result = rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } return $result; }
php
private function runCustomGit(array $arguments, GitRepository $git) { $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath()); $git->getConfig()->getLogger()->debug( \sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()) ); $process->run(); $result = rtrim($process->getOutput(), "\r\n"); if (!$process->isSuccessful()) { throw GitException::createFromProcess('Could not execute git command', $process); } return $result; }
[ "private", "function", "runCustomGit", "(", "array", "$", "arguments", ",", "GitRepository", "$", "git", ")", "{", "$", "process", "=", "new", "Process", "(", "$", "this", "->", "prepareProcessArguments", "(", "$", "arguments", ")", ",", "$", "git", "->", ...
Run a custom git process. @param array $arguments A list of git arguments. @param GitRepository $git The git repository. @return string @throws GitException When the git execution failed. @throws \ReflectionException Thrown if the class does not exist.
[ "Run", "a", "custom", "git", "process", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L202-L217
train
phpcq/author-validation
src/AuthorExtractor/GitAuthorExtractorTrait.php
GitAuthorExtractorTrait.prepareProcessArguments
protected function prepareProcessArguments(array $arguments) { $reflection = new \ReflectionClass(ProcessUtils::class); if (!$reflection->hasMethod('escapeArgument')) { return $arguments; } return \implode(' ', \array_map([ProcessUtils::class, 'escapeArgument'], $arguments)); }
php
protected function prepareProcessArguments(array $arguments) { $reflection = new \ReflectionClass(ProcessUtils::class); if (!$reflection->hasMethod('escapeArgument')) { return $arguments; } return \implode(' ', \array_map([ProcessUtils::class, 'escapeArgument'], $arguments)); }
[ "protected", "function", "prepareProcessArguments", "(", "array", "$", "arguments", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "ProcessUtils", "::", "class", ")", ";", "if", "(", "!", "$", "reflection", "->", "hasMethod", "(", "'e...
Prepare the command line arguments for the symfony process. @param array $arguments The command line arguments for the symfony process. @return array|string @throws \ReflectionException Thrown if the class does not exist.
[ "Prepare", "the", "command", "line", "arguments", "for", "the", "symfony", "process", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractorTrait.php#L228-L237
train
opdavies/gmail-filter-builder
src/Service/Addresses.php
Addresses.load
public static function load(string $filename = 'my-addresses.php'): array { $file = (new static())->getDirectoryPaths() ->map(function ($path) use ($filename) { return $path . $filename; }) ->first(function ($file) { return file_exists($file); }); if (!$file) { throw new PartialNotFoundException(vsprintf('%s does not exist.', [ $filename, ])); } return include $file; }
php
public static function load(string $filename = 'my-addresses.php'): array { $file = (new static())->getDirectoryPaths() ->map(function ($path) use ($filename) { return $path . $filename; }) ->first(function ($file) { return file_exists($file); }); if (!$file) { throw new PartialNotFoundException(vsprintf('%s does not exist.', [ $filename, ])); } return include $file; }
[ "public", "static", "function", "load", "(", "string", "$", "filename", "=", "'my-addresses.php'", ")", ":", "array", "{", "$", "file", "=", "(", "new", "static", "(", ")", ")", "->", "getDirectoryPaths", "(", ")", "->", "map", "(", "function", "(", "$...
Load addresses from a file. @param string $filename The filename to load. @return array
[ "Load", "addresses", "from", "a", "file", "." ]
22b696d47c40c918c88e8050c277580008e3ba53
https://github.com/opdavies/gmail-filter-builder/blob/22b696d47c40c918c88e8050c277580008e3ba53/src/Service/Addresses.php#L20-L37
train
jer-lim/Telegram-Bot-Core
src/InteractiveMessage.php
InteractiveMessage.setReplyMarkup
public function setReplyMarkup(\KeythKatz\TelegramBotCore\Type\InlineKeyboardMarkup $keyboard): void { $this->baseMethod->setReplyMarkup($keyboard); }
php
public function setReplyMarkup(\KeythKatz\TelegramBotCore\Type\InlineKeyboardMarkup $keyboard): void { $this->baseMethod->setReplyMarkup($keyboard); }
[ "public", "function", "setReplyMarkup", "(", "\\", "KeythKatz", "\\", "TelegramBotCore", "\\", "Type", "\\", "InlineKeyboardMarkup", "$", "keyboard", ")", ":", "void", "{", "$", "this", "->", "baseMethod", "->", "setReplyMarkup", "(", "$", "keyboard", ")", ";"...
Set the inline keyboard for the message. @param \KeythKatz\TelegramBotCore\Type\InlineKeyboardMarkup $keyboard InlineKeyboardMarkup to send with the message.
[ "Set", "the", "inline", "keyboard", "for", "the", "message", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/InteractiveMessage.php#L52-L55
train
jer-lim/Telegram-Bot-Core
src/InteractiveMessage.php
InteractiveMessage.send
public function send(): void { $sentMessage = $this->baseMethod->send(); $this->messageId = $sentMessage->getMessageId(); $this->chatId = $sentMessage->getChat()->getId(); $this->saveState(); }
php
public function send(): void { $sentMessage = $this->baseMethod->send(); $this->messageId = $sentMessage->getMessageId(); $this->chatId = $sentMessage->getChat()->getId(); $this->saveState(); }
[ "public", "function", "send", "(", ")", ":", "void", "{", "$", "sentMessage", "=", "$", "this", "->", "baseMethod", "->", "send", "(", ")", ";", "$", "this", "->", "messageId", "=", "$", "sentMessage", "->", "getMessageId", "(", ")", ";", "$", "this"...
Send the message. The InteractiveMessage and its data will then be saved locally.
[ "Send", "the", "message", ".", "The", "InteractiveMessage", "and", "its", "data", "will", "then", "be", "saved", "locally", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/InteractiveMessage.php#L60-L67
train
krystal-framework/krystal.framework
src/Krystal/Widget/ListView/ListViewMaker.php
ListViewMaker.render
public function render() { $data = $this->createData(); $table = $this->createTable($data, $this->options[self::LISTVIEW_PARAM_TABLE_CLASS]); return $table->render(); }
php
public function render() { $data = $this->createData(); $table = $this->createTable($data, $this->options[self::LISTVIEW_PARAM_TABLE_CLASS]); return $table->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "data", "=", "$", "this", "->", "createData", "(", ")", ";", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "data", ",", "$", "this", "->", "options", "[", "self", "::", "LISTVIEW_...
Renders the list grid @return string
[ "Renders", "the", "list", "grid" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Widget/ListView/ListViewMaker.php#L88-L93
train
krystal-framework/krystal.framework
src/Krystal/Widget/ListView/ListViewMaker.php
ListViewMaker.createData
private function createData() { $output = array(); $hasTranslator = $this->translator instanceof TranslatorInterface; foreach ($this->options[self::LISTVIEW_PARAM_COLUMNS] as $configuration) { // Do processing only if column available if (isset($this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]])) { if (isset($configuration[self::LISTVIEW_PARAM_VALUE]) && is_callable($configuration[self::LISTVIEW_PARAM_VALUE])) { // Grab value from returned value $value = $configuration[self::LISTVIEW_PARAM_VALUE]($configuration[self::LISTVIEW_PARAM_COLUMN], $this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]]); } else { $value = $this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]]; } // Need to translate? if (isset($configuration[self::LISTVIEW_PARAM_TRANSLATE]) && $configuration[self::LISTVIEW_PARAM_TRANSLATE] == true) { $value = $this->translator->translate($value); } // Title if (isset($configuration[self::LISTVIEW_PARAM_TITLE])) { $key = $configuration[self::LISTVIEW_PARAM_TITLE]; } else { // Fallback to column name $key = TextUtils::normalizeColumn($configuration[self::LISTVIEW_PARAM_COLUMN]); } // Prepare key $key = $hasTranslator ? $this->translator->translate($key) : $key; $output[$key] = $value; } } return $output; }
php
private function createData() { $output = array(); $hasTranslator = $this->translator instanceof TranslatorInterface; foreach ($this->options[self::LISTVIEW_PARAM_COLUMNS] as $configuration) { // Do processing only if column available if (isset($this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]])) { if (isset($configuration[self::LISTVIEW_PARAM_VALUE]) && is_callable($configuration[self::LISTVIEW_PARAM_VALUE])) { // Grab value from returned value $value = $configuration[self::LISTVIEW_PARAM_VALUE]($configuration[self::LISTVIEW_PARAM_COLUMN], $this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]]); } else { $value = $this->data[$configuration[self::LISTVIEW_PARAM_COLUMN]]; } // Need to translate? if (isset($configuration[self::LISTVIEW_PARAM_TRANSLATE]) && $configuration[self::LISTVIEW_PARAM_TRANSLATE] == true) { $value = $this->translator->translate($value); } // Title if (isset($configuration[self::LISTVIEW_PARAM_TITLE])) { $key = $configuration[self::LISTVIEW_PARAM_TITLE]; } else { // Fallback to column name $key = TextUtils::normalizeColumn($configuration[self::LISTVIEW_PARAM_COLUMN]); } // Prepare key $key = $hasTranslator ? $this->translator->translate($key) : $key; $output[$key] = $value; } } return $output; }
[ "private", "function", "createData", "(", ")", "{", "$", "output", "=", "array", "(", ")", ";", "$", "hasTranslator", "=", "$", "this", "->", "translator", "instanceof", "TranslatorInterface", ";", "foreach", "(", "$", "this", "->", "options", "[", "self",...
Prepares data by reading from configuration @return array
[ "Prepares", "data", "by", "reading", "from", "configuration" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Widget/ListView/ListViewMaker.php#L100-L136
train
krystal-framework/krystal.framework
src/Krystal/Widget/ListView/ListViewMaker.php
ListViewMaker.createRow
private function createRow($key, $value) { $tr = new NodeElement(); $tr->openTag('tr'); $first = new NodeElement(); $first->openTag('td') ->finalize() ->setText($key) ->closeTag(); $second = new NodeElement(); $second->openTag('td') ->finalize() ->setText($value) ->closeTag(); $tr->appendChildren(array($first, $second)); $tr->closeTag(); return $tr; }
php
private function createRow($key, $value) { $tr = new NodeElement(); $tr->openTag('tr'); $first = new NodeElement(); $first->openTag('td') ->finalize() ->setText($key) ->closeTag(); $second = new NodeElement(); $second->openTag('td') ->finalize() ->setText($value) ->closeTag(); $tr->appendChildren(array($first, $second)); $tr->closeTag(); return $tr; }
[ "private", "function", "createRow", "(", "$", "key", ",", "$", "value", ")", "{", "$", "tr", "=", "new", "NodeElement", "(", ")", ";", "$", "tr", "->", "openTag", "(", "'tr'", ")", ";", "$", "first", "=", "new", "NodeElement", "(", ")", ";", "$",...
Creates table row @param string $key @param string $value @return Krystal\Form\NodeElement
[ "Creates", "table", "row" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Widget/ListView/ListViewMaker.php#L173-L194
train
opdavies/gmail-filter-builder
src/Service/Builder.php
Builder.build
private function build(): void { $prefix = "<?xml version='1.0' encoding='UTF-8'?>" . $this->glue() . "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>"; $suffix = '</feed>'; $xml = collect($this->filters)->map(function ($items) { return $this->buildEntry($items); })->implode($this->glue()); $this->xml = collect([$prefix, $xml, $suffix])->implode($this->glue()); if ($this->writeFile) { $this->filesystem->dumpFile($this->outputFile, $this->xml); } }
php
private function build(): void { $prefix = "<?xml version='1.0' encoding='UTF-8'?>" . $this->glue() . "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>"; $suffix = '</feed>'; $xml = collect($this->filters)->map(function ($items) { return $this->buildEntry($items); })->implode($this->glue()); $this->xml = collect([$prefix, $xml, $suffix])->implode($this->glue()); if ($this->writeFile) { $this->filesystem->dumpFile($this->outputFile, $this->xml); } }
[ "private", "function", "build", "(", ")", ":", "void", "{", "$", "prefix", "=", "\"<?xml version='1.0' encoding='UTF-8'?>\"", ".", "$", "this", "->", "glue", "(", ")", ".", "\"<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>\"", ";...
Build XML for a set of filters. @return string
[ "Build", "XML", "for", "a", "set", "of", "filters", "." ]
22b696d47c40c918c88e8050c277580008e3ba53
https://github.com/opdavies/gmail-filter-builder/blob/22b696d47c40c918c88e8050c277580008e3ba53/src/Service/Builder.php#L66-L80
train
opdavies/gmail-filter-builder
src/Service/Builder.php
Builder.buildEntry
private function buildEntry(Filter $filter): string { $entry = collect($filter->toArray()) ->map(function ($value, $key): string { return $this->buildProperty($value, $key); }) ->implode($this->glue()); return collect(['<entry>', $entry, '</entry>'])->implode($this->glue()); }
php
private function buildEntry(Filter $filter): string { $entry = collect($filter->toArray()) ->map(function ($value, $key): string { return $this->buildProperty($value, $key); }) ->implode($this->glue()); return collect(['<entry>', $entry, '</entry>'])->implode($this->glue()); }
[ "private", "function", "buildEntry", "(", "Filter", "$", "filter", ")", ":", "string", "{", "$", "entry", "=", "collect", "(", "$", "filter", "->", "toArray", "(", ")", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "key", ")", ":"...
Build XML for an filter. @param Filter $filter @return string
[ "Build", "XML", "for", "an", "filter", "." ]
22b696d47c40c918c88e8050c277580008e3ba53
https://github.com/opdavies/gmail-filter-builder/blob/22b696d47c40c918c88e8050c277580008e3ba53/src/Service/Builder.php#L89-L98
train
opdavies/gmail-filter-builder
src/Service/Builder.php
Builder.buildProperty
private function buildProperty($value, $key): string { if (collect(['from', 'to'])->contains($key)) { $value = $this->implode($value); } return vsprintf("<apps:property name='%s' value='%s'/>", [ $key, htmlentities($this->implode($value)), ]); }
php
private function buildProperty($value, $key): string { if (collect(['from', 'to'])->contains($key)) { $value = $this->implode($value); } return vsprintf("<apps:property name='%s' value='%s'/>", [ $key, htmlentities($this->implode($value)), ]); }
[ "private", "function", "buildProperty", "(", "$", "value", ",", "$", "key", ")", ":", "string", "{", "if", "(", "collect", "(", "[", "'from'", ",", "'to'", "]", ")", "->", "contains", "(", "$", "key", ")", ")", "{", "$", "value", "=", "$", "this"...
Build XML for a property. @param string $value @param string $key @return string
[ "Build", "XML", "for", "a", "property", "." ]
22b696d47c40c918c88e8050c277580008e3ba53
https://github.com/opdavies/gmail-filter-builder/blob/22b696d47c40c918c88e8050c277580008e3ba53/src/Service/Builder.php#L108-L118
train
opdavies/gmail-filter-builder
src/Service/Builder.php
Builder.implode
private function implode($value, $separator = '|'): string { if (is_string($value)) { return $value; } if (is_array($value) && count($value) === 1) { return reset($value); } return sprintf('(%s)', collect($value)->implode($separator)); }
php
private function implode($value, $separator = '|'): string { if (is_string($value)) { return $value; } if (is_array($value) && count($value) === 1) { return reset($value); } return sprintf('(%s)', collect($value)->implode($separator)); }
[ "private", "function", "implode", "(", "$", "value", ",", "$", "separator", "=", "'|'", ")", ":", "string", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", ...
Implode values with the appropriate prefix, suffix and separator.
[ "Implode", "values", "with", "the", "appropriate", "prefix", "suffix", "and", "separator", "." ]
22b696d47c40c918c88e8050c277580008e3ba53
https://github.com/opdavies/gmail-filter-builder/blob/22b696d47c40c918c88e8050c277580008e3ba53/src/Service/Builder.php#L123-L134
train
Tecnocreaciones/ToolsBundle
Controller/Admin/ConfigurationAdminController.php
ConfigurationAdminController.clearCacheAction
public function clearCacheAction() { $this->getConfigurationManager()->clearCache(); $this->addFlash('sonata_flash_success', 'Cache clear successfully'); return new \Symfony\Component\HttpFoundation\RedirectResponse($this->admin->generateUrl('list')); }
php
public function clearCacheAction() { $this->getConfigurationManager()->clearCache(); $this->addFlash('sonata_flash_success', 'Cache clear successfully'); return new \Symfony\Component\HttpFoundation\RedirectResponse($this->admin->generateUrl('list')); }
[ "public", "function", "clearCacheAction", "(", ")", "{", "$", "this", "->", "getConfigurationManager", "(", ")", "->", "clearCache", "(", ")", ";", "$", "this", "->", "addFlash", "(", "'sonata_flash_success'", ",", "'Cache clear successfully'", ")", ";", "return...
Limplia la cache @return \Tecnocreaciones\Bundle\ToolsBundle\Controller\Admin\RedirectResponse
[ "Limplia", "la", "cache" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Controller/Admin/ConfigurationAdminController.php#L27-L32
train
axllent/silverstripe-email-obfuscator
src/Control/EmailObfuscatorRequestProcessor.php
EmailObfuscatorRequestProcessor.encode
protected function encode($originalString) { $encodedString = ''; $nowCodeString = ''; $originalLength = strlen($originalString); for ($i = 0; $i < $originalLength; $i++) { $encodeMode = ($i % 2 == 0) ? 1 : 2; // Switch encoding odd/even switch ($encodeMode) { case 1: // Decimal code $nowCodeString = '&#' . ord($originalString[$i]) . ';'; break; case 2: // Hexadecimal code $nowCodeString = '&#x' . dechex(ord($originalString[$i])) . ';'; break; default: return 'ERROR: wrong encoding mode.'; } $encodedString .= $nowCodeString; } return $encodedString; }
php
protected function encode($originalString) { $encodedString = ''; $nowCodeString = ''; $originalLength = strlen($originalString); for ($i = 0; $i < $originalLength; $i++) { $encodeMode = ($i % 2 == 0) ? 1 : 2; // Switch encoding odd/even switch ($encodeMode) { case 1: // Decimal code $nowCodeString = '&#' . ord($originalString[$i]) . ';'; break; case 2: // Hexadecimal code $nowCodeString = '&#x' . dechex(ord($originalString[$i])) . ';'; break; default: return 'ERROR: wrong encoding mode.'; } $encodedString .= $nowCodeString; } return $encodedString; }
[ "protected", "function", "encode", "(", "$", "originalString", ")", "{", "$", "encodedString", "=", "''", ";", "$", "nowCodeString", "=", "''", ";", "$", "originalLength", "=", "strlen", "(", "$", "originalString", ")", ";", "for", "(", "$", "i", "=", ...
Obscure email address. @param string The email address @return string The encoded (ASCII & hexadecimal) email address
[ "Obscure", "email", "address", "." ]
1365eb8376a12e311353f5f3869f3ef974a3db54
https://github.com/axllent/silverstripe-email-obfuscator/blob/1365eb8376a12e311353f5f3869f3ef974a3db54/src/Control/EmailObfuscatorRequestProcessor.php#L70-L90
train
krystal-framework/krystal.framework
src/Krystal/Tree/AdjacencyList/RelationBuilder.php
RelationBuilder.build
public function build(array $data) { $relations = array( self::TREE_PARAM_ITEMS => array(), self::TREE_PARAM_PARENTS => array() ); foreach ($data as $row) { $relations[self::TREE_PARAM_ITEMS][$row[self::TREE_PARAM_ID]] = $row; $relations[self::TREE_PARAM_PARENTS][$row[self::TREE_PARAM_PARENT_ID]][] = $row[self::TREE_PARAM_ID]; } return $relations; }
php
public function build(array $data) { $relations = array( self::TREE_PARAM_ITEMS => array(), self::TREE_PARAM_PARENTS => array() ); foreach ($data as $row) { $relations[self::TREE_PARAM_ITEMS][$row[self::TREE_PARAM_ID]] = $row; $relations[self::TREE_PARAM_PARENTS][$row[self::TREE_PARAM_PARENT_ID]][] = $row[self::TREE_PARAM_ID]; } return $relations; }
[ "public", "function", "build", "(", "array", "$", "data", ")", "{", "$", "relations", "=", "array", "(", "self", "::", "TREE_PARAM_ITEMS", "=>", "array", "(", ")", ",", "self", "::", "TREE_PARAM_PARENTS", "=>", "array", "(", ")", ")", ";", "foreach", "...
Builds a relational tree @param array $data Raw data @return array
[ "Builds", "a", "relational", "tree" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Tree/AdjacencyList/RelationBuilder.php#L28-L41
train
localheinz/test-util
src/Helper.php
Helper.faker
final protected function faker(string $locale = 'en_US'): Generator { static $fakers = []; if (!\array_key_exists($locale, $fakers)) { $faker = Factory::create($locale); $faker->seed(9001); $fakers[$locale] = $faker; } return $fakers[$locale]; }
php
final protected function faker(string $locale = 'en_US'): Generator { static $fakers = []; if (!\array_key_exists($locale, $fakers)) { $faker = Factory::create($locale); $faker->seed(9001); $fakers[$locale] = $faker; } return $fakers[$locale]; }
[ "final", "protected", "function", "faker", "(", "string", "$", "locale", "=", "'en_US'", ")", ":", "Generator", "{", "static", "$", "fakers", "=", "[", "]", ";", "if", "(", "!", "\\", "array_key_exists", "(", "$", "locale", ",", "$", "fakers", ")", "...
Returns a localized instance of Faker\Generator. Useful for generating fake data in tests. @see https://github.com/fzaninotto/Faker @param string $locale @return Generator
[ "Returns", "a", "localized", "instance", "of", "Faker", "\\", "Generator", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L34-L47
train
localheinz/test-util
src/Helper.php
Helper.assertClassesAreAbstractOrFinal
final protected function assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = []): void { $this->assertClassyConstructsSatisfySpecification( static function (string $className): bool { $reflection = new \ReflectionClass($className); return $reflection->isAbstract() || $reflection->isFinal() || $reflection->isInterface() || $reflection->isTrait(); }, $directory, $excludeClassNames, "Failed asserting that the classes\n\n%s\n\nare abstract or final." ); }
php
final protected function assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = []): void { $this->assertClassyConstructsSatisfySpecification( static function (string $className): bool { $reflection = new \ReflectionClass($className); return $reflection->isAbstract() || $reflection->isFinal() || $reflection->isInterface() || $reflection->isTrait(); }, $directory, $excludeClassNames, "Failed asserting that the classes\n\n%s\n\nare abstract or final." ); }
[ "final", "protected", "function", "assertClassesAreAbstractOrFinal", "(", "string", "$", "directory", ",", "array", "$", "excludeClassNames", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "assertClassyConstructsSatisfySpecification", "(", "static", "funct...
Asserts that classes in a directory are either abstract or final. Useful to prevent long inheritance chains. @param string $directory @param string[] $excludeClassNames @throws Exception\NonExistentDirectory @throws Exception\InvalidExcludeClassName @throws Exception\NonExistentExcludeClass @throws Classy\Exception\MultipleDefinitionsFound
[ "Asserts", "that", "classes", "in", "a", "directory", "are", "either", "abstract", "or", "final", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L62-L77
train
localheinz/test-util
src/Helper.php
Helper.assertClassyConstructsSatisfySpecification
final protected function assertClassyConstructsSatisfySpecification(callable $specification, string $directory, array $excludeClassyNames = [], string $message = ''): void { if (!\is_dir($directory)) { throw Exception\NonExistentDirectory::fromDirectory($directory); } \array_walk($excludeClassyNames, static function ($excludeClassyName): void { if (!\is_string($excludeClassyName)) { throw Exception\InvalidExcludeClassName::fromClassName($excludeClassyName); } if (!\class_exists($excludeClassyName)) { throw Exception\NonExistentExcludeClass::fromClassName($excludeClassyName); } }); $constructs = Classy\Constructs::fromDirectory($directory); $classyNames = \array_diff( $constructs, $excludeClassyNames ); $classyNamesNotSatisfyingSpecification = \array_filter($classyNames, static function (string $className) use ($specification) { return false === $specification($className); }); self::assertEmpty($classyNamesNotSatisfyingSpecification, \sprintf( '' !== $message ? $message : "Failed asserting that the classy constructs\n\n%s\n\nsatisfy a specification.", ' - ' . \implode("\n - ", $classyNamesNotSatisfyingSpecification) )); }
php
final protected function assertClassyConstructsSatisfySpecification(callable $specification, string $directory, array $excludeClassyNames = [], string $message = ''): void { if (!\is_dir($directory)) { throw Exception\NonExistentDirectory::fromDirectory($directory); } \array_walk($excludeClassyNames, static function ($excludeClassyName): void { if (!\is_string($excludeClassyName)) { throw Exception\InvalidExcludeClassName::fromClassName($excludeClassyName); } if (!\class_exists($excludeClassyName)) { throw Exception\NonExistentExcludeClass::fromClassName($excludeClassyName); } }); $constructs = Classy\Constructs::fromDirectory($directory); $classyNames = \array_diff( $constructs, $excludeClassyNames ); $classyNamesNotSatisfyingSpecification = \array_filter($classyNames, static function (string $className) use ($specification) { return false === $specification($className); }); self::assertEmpty($classyNamesNotSatisfyingSpecification, \sprintf( '' !== $message ? $message : "Failed asserting that the classy constructs\n\n%s\n\nsatisfy a specification.", ' - ' . \implode("\n - ", $classyNamesNotSatisfyingSpecification) )); }
[ "final", "protected", "function", "assertClassyConstructsSatisfySpecification", "(", "callable", "$", "specification", ",", "string", "$", "directory", ",", "array", "$", "excludeClassyNames", "=", "[", "]", ",", "string", "$", "message", "=", "''", ")", ":", "v...
Asserts that all classes, interfaces, and traits found in a directory satisfy a specification. Useful for asserting that production and test code conforms to certain requirements. The specification will be invoked with a single argument, the class name, and should return true or false. @param callable $specification @param string $directory @param string[] $excludeClassyNames @param string $message @throws Exception\NonExistentDirectory @throws Exception\InvalidExcludeClassName @throws Exception\NonExistentExcludeClass @throws Classy\Exception\MultipleDefinitionsFound
[ "Asserts", "that", "all", "classes", "interfaces", "and", "traits", "found", "in", "a", "directory", "satisfy", "a", "specification", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L193-L224
train
localheinz/test-util
src/Helper.php
Helper.assertClassExists
final protected function assertClassExists(string $className): void { self::assertTrue(\class_exists($className), \sprintf( 'Failed asserting that a class "%s" exists.', $className )); }
php
final protected function assertClassExists(string $className): void { self::assertTrue(\class_exists($className), \sprintf( 'Failed asserting that a class "%s" exists.', $className )); }
[ "final", "protected", "function", "assertClassExists", "(", "string", "$", "className", ")", ":", "void", "{", "self", "::", "assertTrue", "(", "\\", "class_exists", "(", "$", "className", ")", ",", "\\", "sprintf", "(", "'Failed asserting that a class \"%s\" exis...
Asserts that a class exists. @param string $className
[ "Asserts", "that", "a", "class", "exists", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L231-L237
train
localheinz/test-util
src/Helper.php
Helper.assertClassExtends
final protected function assertClassExtends(string $parentClassName, string $className): void { $this->assertClassExists($parentClassName); $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isSubclassOf($parentClassName), \sprintf( 'Failed asserting that class "%s" extends "%s".', $className, $parentClassName )); }
php
final protected function assertClassExtends(string $parentClassName, string $className): void { $this->assertClassExists($parentClassName); $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isSubclassOf($parentClassName), \sprintf( 'Failed asserting that class "%s" extends "%s".', $className, $parentClassName )); }
[ "final", "protected", "function", "assertClassExtends", "(", "string", "$", "parentClassName", ",", "string", "$", "className", ")", ":", "void", "{", "$", "this", "->", "assertClassExists", "(", "$", "parentClassName", ")", ";", "$", "this", "->", "assertClas...
Asserts that a class extends from a parent class. @param string $parentClassName @param string $className
[ "Asserts", "that", "a", "class", "extends", "from", "a", "parent", "class", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L245-L257
train
localheinz/test-util
src/Helper.php
Helper.assertClassImplementsInterface
final protected function assertClassImplementsInterface(string $interfaceName, string $className): void { $this->assertInterfaceExists($interfaceName); $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->implementsInterface($interfaceName), \sprintf( 'Failed asserting that class "%s" implements interface "%s".', $className, $interfaceName )); }
php
final protected function assertClassImplementsInterface(string $interfaceName, string $className): void { $this->assertInterfaceExists($interfaceName); $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->implementsInterface($interfaceName), \sprintf( 'Failed asserting that class "%s" implements interface "%s".', $className, $interfaceName )); }
[ "final", "protected", "function", "assertClassImplementsInterface", "(", "string", "$", "interfaceName", ",", "string", "$", "className", ")", ":", "void", "{", "$", "this", "->", "assertInterfaceExists", "(", "$", "interfaceName", ")", ";", "$", "this", "->", ...
Asserts that a class implements an interface. @param string $interfaceName @param string $className
[ "Asserts", "that", "a", "class", "implements", "an", "interface", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L265-L277
train
localheinz/test-util
src/Helper.php
Helper.assertClassIsAbstract
final protected function assertClassIsAbstract(string $className): void { $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isAbstract(), \sprintf( 'Failed asserting that class "%s" is abstract.', $className )); }
php
final protected function assertClassIsAbstract(string $className): void { $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isAbstract(), \sprintf( 'Failed asserting that class "%s" is abstract.', $className )); }
[ "final", "protected", "function", "assertClassIsAbstract", "(", "string", "$", "className", ")", ":", "void", "{", "$", "this", "->", "assertClassExists", "(", "$", "className", ")", ";", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "cla...
Asserts that a class is abstract. @param string $className
[ "Asserts", "that", "a", "class", "is", "abstract", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L284-L294
train
localheinz/test-util
src/Helper.php
Helper.assertClassIsFinal
final protected function assertClassIsFinal(string $className): void { $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isFinal(), \sprintf( 'Failed asserting that class "%s" is final.', $className )); }
php
final protected function assertClassIsFinal(string $className): void { $this->assertClassExists($className); $reflection = new \ReflectionClass($className); self::assertTrue($reflection->isFinal(), \sprintf( 'Failed asserting that class "%s" is final.', $className )); }
[ "final", "protected", "function", "assertClassIsFinal", "(", "string", "$", "className", ")", ":", "void", "{", "$", "this", "->", "assertClassExists", "(", "$", "className", ")", ";", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "classN...
Asserts that a class is final. Useful to prevent long inheritance chains. @param string $className
[ "Asserts", "that", "a", "class", "is", "final", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L303-L313
train
localheinz/test-util
src/Helper.php
Helper.assertClassSatisfiesSpecification
final protected function assertClassSatisfiesSpecification(callable $specification, string $className, string $message = ''): void { $this->assertClassExists($className); self::assertTrue($specification($className), \sprintf( '' !== $message ? $message : 'Failed asserting that class "%s" satisfies a specification.', $className )); }
php
final protected function assertClassSatisfiesSpecification(callable $specification, string $className, string $message = ''): void { $this->assertClassExists($className); self::assertTrue($specification($className), \sprintf( '' !== $message ? $message : 'Failed asserting that class "%s" satisfies a specification.', $className )); }
[ "final", "protected", "function", "assertClassSatisfiesSpecification", "(", "callable", "$", "specification", ",", "string", "$", "className", ",", "string", "$", "message", "=", "''", ")", ":", "void", "{", "$", "this", "->", "assertClassExists", "(", "$", "c...
Asserts that a class satisfies a specification. The specification will be invoked with a single argument, the class name, and should return true or false. @param callable $specification @param string $className @param string $message
[ "Asserts", "that", "a", "class", "satisfies", "a", "specification", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L324-L332
train
localheinz/test-util
src/Helper.php
Helper.assertClassUsesTrait
final protected function assertClassUsesTrait(string $traitName, string $className): void { $this->assertTraitExists($traitName); $this->assertClassExists($className); self::assertContains($traitName, \class_uses($className), \sprintf( 'Failed asserting that class "%s" uses trait "%s".', $className, $traitName )); }
php
final protected function assertClassUsesTrait(string $traitName, string $className): void { $this->assertTraitExists($traitName); $this->assertClassExists($className); self::assertContains($traitName, \class_uses($className), \sprintf( 'Failed asserting that class "%s" uses trait "%s".', $className, $traitName )); }
[ "final", "protected", "function", "assertClassUsesTrait", "(", "string", "$", "traitName", ",", "string", "$", "className", ")", ":", "void", "{", "$", "this", "->", "assertTraitExists", "(", "$", "traitName", ")", ";", "$", "this", "->", "assertClassExists", ...
Asserts that a class uses a trait. @param string $traitName @param string $className
[ "Asserts", "that", "a", "class", "uses", "a", "trait", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L340-L350
train
localheinz/test-util
src/Helper.php
Helper.assertInterfaceExists
final protected function assertInterfaceExists(string $interfaceName): void { self::assertTrue(\interface_exists($interfaceName), \sprintf( 'Failed asserting that an interface "%s" exists.', $interfaceName )); }
php
final protected function assertInterfaceExists(string $interfaceName): void { self::assertTrue(\interface_exists($interfaceName), \sprintf( 'Failed asserting that an interface "%s" exists.', $interfaceName )); }
[ "final", "protected", "function", "assertInterfaceExists", "(", "string", "$", "interfaceName", ")", ":", "void", "{", "self", "::", "assertTrue", "(", "\\", "interface_exists", "(", "$", "interfaceName", ")", ",", "\\", "sprintf", "(", "'Failed asserting that an ...
Asserts that an interface exists. @param string $interfaceName
[ "Asserts", "that", "an", "interface", "exists", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L357-L363
train
localheinz/test-util
src/Helper.php
Helper.assertInterfaceExtends
final protected function assertInterfaceExtends(string $parentInterfaceName, string $interfaceName): void { $this->assertInterfaceExists($parentInterfaceName); $this->assertInterfaceExists($interfaceName); $reflection = new \ReflectionClass($interfaceName); self::assertTrue($reflection->isSubclassOf($parentInterfaceName), \sprintf( 'Failed asserting that interface "%s" extends "%s".', $interfaceName, $parentInterfaceName )); }
php
final protected function assertInterfaceExtends(string $parentInterfaceName, string $interfaceName): void { $this->assertInterfaceExists($parentInterfaceName); $this->assertInterfaceExists($interfaceName); $reflection = new \ReflectionClass($interfaceName); self::assertTrue($reflection->isSubclassOf($parentInterfaceName), \sprintf( 'Failed asserting that interface "%s" extends "%s".', $interfaceName, $parentInterfaceName )); }
[ "final", "protected", "function", "assertInterfaceExtends", "(", "string", "$", "parentInterfaceName", ",", "string", "$", "interfaceName", ")", ":", "void", "{", "$", "this", "->", "assertInterfaceExists", "(", "$", "parentInterfaceName", ")", ";", "$", "this", ...
Asserts that an interface extends a parent interface. @param string $parentInterfaceName @param string $interfaceName
[ "Asserts", "that", "an", "interface", "extends", "a", "parent", "interface", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L371-L383
train
localheinz/test-util
src/Helper.php
Helper.assertInterfaceSatisfiesSpecification
final protected function assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = ''): void { $this->assertInterfaceExists($interfaceName); self::assertTrue($specification($interfaceName), \sprintf( '' !== $message ? $message : 'Failed asserting that interface "%s" satisfies a specification.', $interfaceName )); }
php
final protected function assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = ''): void { $this->assertInterfaceExists($interfaceName); self::assertTrue($specification($interfaceName), \sprintf( '' !== $message ? $message : 'Failed asserting that interface "%s" satisfies a specification.', $interfaceName )); }
[ "final", "protected", "function", "assertInterfaceSatisfiesSpecification", "(", "callable", "$", "specification", ",", "string", "$", "interfaceName", ",", "string", "$", "message", "=", "''", ")", ":", "void", "{", "$", "this", "->", "assertInterfaceExists", "(",...
Asserts that an interface satisfies a specification. The specification will be invoked with a single argument, the class name, and should return true or false. @param callable $specification @param string $interfaceName @param string $message
[ "Asserts", "that", "an", "interface", "satisfies", "a", "specification", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L394-L402
train
localheinz/test-util
src/Helper.php
Helper.assertTraitExists
final protected function assertTraitExists(string $traitName): void { self::assertTrue(\trait_exists($traitName), \sprintf( 'Failed asserting that a trait "%s" exists.', $traitName )); }
php
final protected function assertTraitExists(string $traitName): void { self::assertTrue(\trait_exists($traitName), \sprintf( 'Failed asserting that a trait "%s" exists.', $traitName )); }
[ "final", "protected", "function", "assertTraitExists", "(", "string", "$", "traitName", ")", ":", "void", "{", "self", "::", "assertTrue", "(", "\\", "trait_exists", "(", "$", "traitName", ")", ",", "\\", "sprintf", "(", "'Failed asserting that a trait \"%s\" exis...
Asserts that a trait exists. @param string $traitName
[ "Asserts", "that", "a", "trait", "exists", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L409-L415
train
localheinz/test-util
src/Helper.php
Helper.assertTraitSatisfiesSpecification
final protected function assertTraitSatisfiesSpecification(callable $specification, string $traitName, string $message = ''): void { $this->assertTraitExists($traitName); self::assertTrue($specification($traitName), \sprintf( '' !== $message ? $message : 'Failed asserting that trait "%s" satisfies a specification.', $traitName )); }
php
final protected function assertTraitSatisfiesSpecification(callable $specification, string $traitName, string $message = ''): void { $this->assertTraitExists($traitName); self::assertTrue($specification($traitName), \sprintf( '' !== $message ? $message : 'Failed asserting that trait "%s" satisfies a specification.', $traitName )); }
[ "final", "protected", "function", "assertTraitSatisfiesSpecification", "(", "callable", "$", "specification", ",", "string", "$", "traitName", ",", "string", "$", "message", "=", "''", ")", ":", "void", "{", "$", "this", "->", "assertTraitExists", "(", "$", "t...
Asserts that a trait satisfies a specification. The specification will be invoked with a single argument, the class name, and should return true or false. @param callable $specification @param string $traitName @param string $message
[ "Asserts", "that", "a", "trait", "satisfies", "a", "specification", "." ]
a75e155976b5a2103806cdd0bbff91da8ca064e9
https://github.com/localheinz/test-util/blob/a75e155976b5a2103806cdd0bbff91da8ca064e9/src/Helper.php#L426-L434
train
bookboon/api-php
src/Entity/Category.php
Category.get
public static function get(Bookboon $bookboon, string $categoryId, array $bookTypes = ['pdf']) : BookboonResponse { $bResponse = $bookboon->rawRequest("/categories/$categoryId", ['bookType' => join(',', $bookTypes)]); $bResponse->setEntityStore( new EntityStore( [ new static($bResponse->getReturnArray()) ] ) ); return $bResponse; }
php
public static function get(Bookboon $bookboon, string $categoryId, array $bookTypes = ['pdf']) : BookboonResponse { $bResponse = $bookboon->rawRequest("/categories/$categoryId", ['bookType' => join(',', $bookTypes)]); $bResponse->setEntityStore( new EntityStore( [ new static($bResponse->getReturnArray()) ] ) ); return $bResponse; }
[ "public", "static", "function", "get", "(", "Bookboon", "$", "bookboon", ",", "string", "$", "categoryId", ",", "array", "$", "bookTypes", "=", "[", "'pdf'", "]", ")", ":", "BookboonResponse", "{", "$", "bResponse", "=", "$", "bookboon", "->", "rawRequest"...
Get Category. @param Bookboon $bookboon @param string $categoryId @param array $bookTypes @return BookboonResponse @throws \Bookboon\Api\Exception\ApiDecodeException @throws \Bookboon\Api\Exception\EntityDataException @throws \Bookboon\Api\Exception\UsageException
[ "Get", "Category", "." ]
dc386b94dd21589606335a5d16a5300c226ecc21
https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Entity/Category.php#L25-L38
train
bookboon/api-php
src/Entity/Category.php
Category.getTree
public static function getTree( Bookboon $bookboon, array $blacklistedCategoryIds = [], int $depth = 2 ) : BookboonResponse { $bResponse = $bookboon->rawRequest('/categories', ['depth' => $depth]); $categories = $bResponse->getReturnArray(); if (count($blacklistedCategoryIds) !== 0) { self::recursiveBlacklist($categories, $blacklistedCategoryIds); } $bResponse->setEntityStore( new EntityStore(Category::getEntitiesFromArray($categories)) ); return $bResponse; }
php
public static function getTree( Bookboon $bookboon, array $blacklistedCategoryIds = [], int $depth = 2 ) : BookboonResponse { $bResponse = $bookboon->rawRequest('/categories', ['depth' => $depth]); $categories = $bResponse->getReturnArray(); if (count($blacklistedCategoryIds) !== 0) { self::recursiveBlacklist($categories, $blacklistedCategoryIds); } $bResponse->setEntityStore( new EntityStore(Category::getEntitiesFromArray($categories)) ); return $bResponse; }
[ "public", "static", "function", "getTree", "(", "Bookboon", "$", "bookboon", ",", "array", "$", "blacklistedCategoryIds", "=", "[", "]", ",", "int", "$", "depth", "=", "2", ")", ":", "BookboonResponse", "{", "$", "bResponse", "=", "$", "bookboon", "->", ...
Returns the entire Category structure. @param Bookboon $bookboon @param array $blacklistedCategoryIds @param int $depth level of recursion (default 2 maximum, 0 no recursion) @return BookboonResponse @throws \Bookboon\Api\Exception\UsageException
[ "Returns", "the", "entire", "Category", "structure", "." ]
dc386b94dd21589606335a5d16a5300c226ecc21
https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Entity/Category.php#L49-L67
train
bookboon/api-php
src/Client/Headers.php
Headers.set
public function set(string $header, string $value) : void { $this->headers[$header] = $value; }
php
public function set(string $header, string $value) : void { $this->headers[$header] = $value; }
[ "public", "function", "set", "(", "string", "$", "header", ",", "string", "$", "value", ")", ":", "void", "{", "$", "this", "->", "headers", "[", "$", "header", "]", "=", "$", "value", ";", "}" ]
Set or override header. @param string $header @param string $value @return void
[ "Set", "or", "override", "header", "." ]
dc386b94dd21589606335a5d16a5300c226ecc21
https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Client/Headers.php#L29-L32
train
bookboon/api-php
src/Client/Headers.php
Headers.getAll
public function getAll() : array { $headers = []; foreach ($this->headers as $h => $v) { $headers[] = $h.': '.$v; } return $headers; }
php
public function getAll() : array { $headers = []; foreach ($this->headers as $h => $v) { $headers[] = $h.': '.$v; } return $headers; }
[ "public", "function", "getAll", "(", ")", ":", "array", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "h", "=>", "$", "v", ")", "{", "$", "headers", "[", "]", "=", "$", "h", ".", "': '", "."...
Get all headers in CURL format. @return array
[ "Get", "all", "headers", "in", "CURL", "format", "." ]
dc386b94dd21589606335a5d16a5300c226ecc21
https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Client/Headers.php#L51-L59
train
bookboon/api-php
src/Client/Headers.php
Headers.getRemoteAddress
private function getRemoteAddress() : ?string { $hostname = null; if (isset($_SERVER['REMOTE_ADDR'])) { $hostname = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); if (false === $hostname) { $hostname = null; } } if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); if ($headers === false) { return $hostname; } foreach ($headers as $k => $v) { if (strcasecmp($k, 'x-forwarded-for')) { continue; } $hostname = explode(',', $v); $hostname = trim($hostname[0]); break; } } return $hostname; }
php
private function getRemoteAddress() : ?string { $hostname = null; if (isset($_SERVER['REMOTE_ADDR'])) { $hostname = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); if (false === $hostname) { $hostname = null; } } if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); if ($headers === false) { return $hostname; } foreach ($headers as $k => $v) { if (strcasecmp($k, 'x-forwarded-for')) { continue; } $hostname = explode(',', $v); $hostname = trim($hostname[0]); break; } } return $hostname; }
[ "private", "function", "getRemoteAddress", "(", ")", ":", "?", "string", "{", "$", "hostname", "=", "null", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", ")", "{", "$", "hostname", "=", "filter_var", "(", "$", "_SERVER",...
Returns the remote address either directly or if set XFF header value. @return string|null The ip address
[ "Returns", "the", "remote", "address", "either", "directly", "or", "if", "set", "XFF", "header", "value", "." ]
dc386b94dd21589606335a5d16a5300c226ecc21
https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Client/Headers.php#L74-L105
train
mosbth/cdatabase
src/Database/CDatabaseBasic.php
CDatabaseBasic.loadHistory
public function loadHistory() { $key = $this->options['session_key']; if (isset($_SESSION['CDatabase'])) { self::$numQueries = $_SESSION[$key]['numQueries']; self::$queries = $_SESSION[$key]['queries']; self::$params = $_SESSION[$key]['params']; unset($_SESSION[$key]); } }
php
public function loadHistory() { $key = $this->options['session_key']; if (isset($_SESSION['CDatabase'])) { self::$numQueries = $_SESSION[$key]['numQueries']; self::$queries = $_SESSION[$key]['queries']; self::$params = $_SESSION[$key]['params']; unset($_SESSION[$key]); } }
[ "public", "function", "loadHistory", "(", ")", "{", "$", "key", "=", "$", "this", "->", "options", "[", "'session_key'", "]", ";", "if", "(", "isset", "(", "$", "_SESSION", "[", "'CDatabase'", "]", ")", ")", "{", "self", "::", "$", "numQueries", "=",...
Load query-history from session if available. @return int number of database queries made.
[ "Load", "query", "-", "history", "from", "session", "if", "available", "." ]
8d90b46bc233b1a73975fe4f4002303e24f4c397
https://github.com/mosbth/cdatabase/blob/8d90b46bc233b1a73975fe4f4002303e24f4c397/src/Database/CDatabaseBasic.php#L171-L180
train
mosbth/cdatabase
src/Database/CDatabaseBasic.php
CDatabaseBasic.saveHistory
public function saveHistory($extra = null) { if (!is_null($extra)) { self::$queries[] = $extra; self::$params[] = null; } self::$queries[] = 'Saved query-history to session.'; self::$params[] = null; $key = $this->options['session_key']; $_SESSION[$key]['numQueries'] = self::$numQueries; $_SESSION[$key]['queries'] = self::$queries; $_SESSION[$key]['params'] = self::$params; }
php
public function saveHistory($extra = null) { if (!is_null($extra)) { self::$queries[] = $extra; self::$params[] = null; } self::$queries[] = 'Saved query-history to session.'; self::$params[] = null; $key = $this->options['session_key']; $_SESSION[$key]['numQueries'] = self::$numQueries; $_SESSION[$key]['queries'] = self::$queries; $_SESSION[$key]['params'] = self::$params; }
[ "public", "function", "saveHistory", "(", "$", "extra", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "extra", ")", ")", "{", "self", "::", "$", "queries", "[", "]", "=", "$", "extra", ";", "self", "::", "$", "params", "[", "]", "...
Save query-history in session, useful as a flashmemory when redirecting to another page. @param string $extra enables to save some extra debug information. @return void
[ "Save", "query", "-", "history", "in", "session", "useful", "as", "a", "flashmemory", "when", "redirecting", "to", "another", "page", "." ]
8d90b46bc233b1a73975fe4f4002303e24f4c397
https://github.com/mosbth/cdatabase/blob/8d90b46bc233b1a73975fe4f4002303e24f4c397/src/Database/CDatabaseBasic.php#L191-L205
train
mosbth/cdatabase
src/Database/CDatabaseBasic.php
CDatabaseBasic.executeFetchAll
public function executeFetchAll( $query = null, $params = [] ) { $this->execute($query, $params); return $this->fetchAll(); }
php
public function executeFetchAll( $query = null, $params = [] ) { $this->execute($query, $params); return $this->fetchAll(); }
[ "public", "function", "executeFetchAll", "(", "$", "query", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "execute", "(", "$", "query", ",", "$", "params", ")", ";", "return", "$", "this", "->", "fetchAll", "(", ")", ...
Execute a select-query with arguments and return all resultset. @param string $query the SQL query with ?. @param array $params array which contains the argument to replace ?. @return array with resultset.
[ "Execute", "a", "select", "-", "query", "with", "arguments", "and", "return", "all", "resultset", "." ]
8d90b46bc233b1a73975fe4f4002303e24f4c397
https://github.com/mosbth/cdatabase/blob/8d90b46bc233b1a73975fe4f4002303e24f4c397/src/Database/CDatabaseBasic.php#L297-L304
train
mosbth/cdatabase
src/Database/CDatabaseBasic.php
CDatabaseBasic.executeFetchOne
public function executeFetchOne( $query = null, $params = [] ) { $this->execute($query, $params); return $this->fetchOne(); }
php
public function executeFetchOne( $query = null, $params = [] ) { $this->execute($query, $params); return $this->fetchOne(); }
[ "public", "function", "executeFetchOne", "(", "$", "query", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "execute", "(", "$", "query", ",", "$", "params", ")", ";", "return", "$", "this", "->", "fetchOne", "(", ")", ...
Execute a select-query with arguments and return one resultset. @param string $query the SQL query with ?. @param array $params array which contains the argument to replace ?. @return array with resultset.
[ "Execute", "a", "select", "-", "query", "with", "arguments", "and", "return", "one", "resultset", "." ]
8d90b46bc233b1a73975fe4f4002303e24f4c397
https://github.com/mosbth/cdatabase/blob/8d90b46bc233b1a73975fe4f4002303e24f4c397/src/Database/CDatabaseBasic.php#L316-L323
train
mosbth/cdatabase
src/Database/CDatabaseBasic.php
CDatabaseBasic.fetchInto
public function fetchInto($object) { $this->stmt->setFetchMode(\PDO::FETCH_INTO, $object); return $this->stmt->fetch(); }
php
public function fetchInto($object) { $this->stmt->setFetchMode(\PDO::FETCH_INTO, $object); return $this->stmt->fetch(); }
[ "public", "function", "fetchInto", "(", "$", "object", ")", "{", "$", "this", "->", "stmt", "->", "setFetchMode", "(", "\\", "PDO", "::", "FETCH_INTO", ",", "$", "object", ")", ";", "return", "$", "this", "->", "stmt", "->", "fetch", "(", ")", ";", ...
Fetch one resultset from previous select statement as an object. @param object $object to insert values into. @return array with resultset.
[ "Fetch", "one", "resultset", "from", "previous", "select", "statement", "as", "an", "object", "." ]
8d90b46bc233b1a73975fe4f4002303e24f4c397
https://github.com/mosbth/cdatabase/blob/8d90b46bc233b1a73975fe4f4002303e24f4c397/src/Database/CDatabaseBasic.php#L372-L376
train
droath/project-x
src/Utility.php
Utility.machineName
public static function machineName($string, $pattern = '/[^a-zA-Z0-9\-]/') { if (!is_string($string)) { throw new \InvalidArgumentException( 'A non string argument has been given.' ); } $string = strtr($string, ' ', '-'); return strtolower(self::cleanString($string, $pattern)); }
php
public static function machineName($string, $pattern = '/[^a-zA-Z0-9\-]/') { if (!is_string($string)) { throw new \InvalidArgumentException( 'A non string argument has been given.' ); } $string = strtr($string, ' ', '-'); return strtolower(self::cleanString($string, $pattern)); }
[ "public", "static", "function", "machineName", "(", "$", "string", ",", "$", "pattern", "=", "'/[^a-zA-Z0-9\\-]/'", ")", "{", "if", "(", "!", "is_string", "(", "$", "string", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A non strin...
Machine name from string. @param string $string The machine name input. @param string $pattern The pattern on which characters are allowed. @return string The formatted machine name.
[ "Machine", "name", "from", "string", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Utility.php#L42-L52
train
krystal-framework/krystal.framework
src/Krystal/Text/CsvManager.php
CsvManager.hasDuplicates
public function hasDuplicates($target) { if ($this->exists($target)) { $duplicates = $this->getDuplicates(); return (int) $duplicates[$target] > 1; } else { throw new RuntimeException(sprintf( 'Attempted to read non-existing value %s', $target )); } }
php
public function hasDuplicates($target) { if ($this->exists($target)) { $duplicates = $this->getDuplicates(); return (int) $duplicates[$target] > 1; } else { throw new RuntimeException(sprintf( 'Attempted to read non-existing value %s', $target )); } }
[ "public", "function", "hasDuplicates", "(", "$", "target", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "target", ")", ")", "{", "$", "duplicates", "=", "$", "this", "->", "getDuplicates", "(", ")", ";", "return", "(", "int", ")", "$...
Checks if a value has duplicates in a sequence @param string $target @throws \RuntimeException if $target does not belong to the collection @return boolean
[ "Checks", "if", "a", "value", "has", "duplicates", "in", "a", "sequence" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CsvManager.php#L117-L128
train
krystal-framework/krystal.framework
src/Krystal/Text/CsvManager.php
CsvManager.append
public function append($value) { if (strpos($value, self::SEPARATOR) !== false) { throw new LogicException('A value cannot contain delimiter'); } array_push($this->collection, $value); return $this; }
php
public function append($value) { if (strpos($value, self::SEPARATOR) !== false) { throw new LogicException('A value cannot contain delimiter'); } array_push($this->collection, $value); return $this; }
[ "public", "function", "append", "(", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "value", ",", "self", "::", "SEPARATOR", ")", "!==", "false", ")", "{", "throw", "new", "LogicException", "(", "'A value cannot contain delimiter'", ")", ";", "}", ...
Appends one more value @param string $value @throws \LogicException if $value contains a delimiter @return \Krystal\Text\CsvManager
[ "Appends", "one", "more", "value" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CsvManager.php#L162-L170
train
krystal-framework/krystal.framework
src/Krystal/Text/CsvManager.php
CsvManager.exists
public function exists() { foreach (func_get_args() as $value) { if (!in_array($value, $this->collection)) { return false; } } return true; }
php
public function exists() { foreach (func_get_args() as $value) { if (!in_array($value, $this->collection)) { return false; } } return true; }
[ "public", "function", "exists", "(", ")", "{", "foreach", "(", "func_get_args", "(", ")", "as", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "$", "this", "->", "collection", ")", ")", "{", "return", "false", ";", "}",...
Checks whether value exists in a stack @param string $value [...] @return boolean
[ "Checks", "whether", "value", "exists", "in", "a", "stack" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CsvManager.php#L193-L202
train
krystal-framework/krystal.framework
src/Krystal/Text/CsvManager.php
CsvManager.delete
public function delete($target, $keepDuplicates = true) { // We need a copy of $this->collection, not itself: $array = $this->collection; foreach ($array as $index => $value) { if ($value == $target) { unset($array[$index]); if ($keepDuplicates === true) { break; } } } // Now override original stack with replaced one $this->collection = $array; }
php
public function delete($target, $keepDuplicates = true) { // We need a copy of $this->collection, not itself: $array = $this->collection; foreach ($array as $index => $value) { if ($value == $target) { unset($array[$index]); if ($keepDuplicates === true) { break; } } } // Now override original stack with replaced one $this->collection = $array; }
[ "public", "function", "delete", "(", "$", "target", ",", "$", "keepDuplicates", "=", "true", ")", "{", "// We need a copy of $this->collection, not itself:\r", "$", "array", "=", "$", "this", "->", "collection", ";", "foreach", "(", "$", "array", "as", "$", "i...
Deletes a value from the stack @param string $target @param boolean $keepDuplicates Whether to keep duplicate values @return void
[ "Deletes", "a", "value", "from", "the", "stack" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CsvManager.php#L211-L228
train
krystal-framework/krystal.framework
src/Krystal/Text/CsvManager.php
CsvManager.loadFromString
public function loadFromString($string) { $target = array(); $array = explode(self::SEPARATOR, $string); foreach ($array as $index => $value) { // Additional check if (!empty($value)) { // Ensure we have only clean values if (strpos(self::SEPARATOR, $value) === false) { array_push($target, $value); } } } // Override with modified one $this->collection = $target; }
php
public function loadFromString($string) { $target = array(); $array = explode(self::SEPARATOR, $string); foreach ($array as $index => $value) { // Additional check if (!empty($value)) { // Ensure we have only clean values if (strpos(self::SEPARATOR, $value) === false) { array_push($target, $value); } } } // Override with modified one $this->collection = $target; }
[ "public", "function", "loadFromString", "(", "$", "string", ")", "{", "$", "target", "=", "array", "(", ")", ";", "$", "array", "=", "explode", "(", "self", "::", "SEPARATOR", ",", "$", "string", ")", ";", "foreach", "(", "$", "array", "as", "$", "...
Builds an array from a string @param string $string @return void
[ "Builds", "an", "array", "from", "a", "string" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CsvManager.php#L257-L274
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/AbstractMediaElement.php
AbstractMediaElement.createSourceElements
final protected function createSourceElements(array $sources) { // To be returned $output = array(); foreach ($sources as $type => $src) { $output[] = $this->createSourceElement($type, $src); } return $output; }
php
final protected function createSourceElements(array $sources) { // To be returned $output = array(); foreach ($sources as $type => $src) { $output[] = $this->createSourceElement($type, $src); } return $output; }
[ "final", "protected", "function", "createSourceElements", "(", "array", "$", "sources", ")", "{", "// To be returned", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "sources", "as", "$", "type", "=>", "$", "src", ")", "{", "$", "output...
Create source node elements @param array $sources @return array
[ "Create", "source", "node", "elements" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/AbstractMediaElement.php#L55-L65
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/AbstractMediaElement.php
AbstractMediaElement.createSourceElement
final protected function createSourceElement($type, $src) { // Tag attributes $attrs = array( 'src' => $src, 'type' => $type ); $node = new NodeElement(); return $node->openTag('source') ->addAttributes($attrs) ->finalize(true); }
php
final protected function createSourceElement($type, $src) { // Tag attributes $attrs = array( 'src' => $src, 'type' => $type ); $node = new NodeElement(); return $node->openTag('source') ->addAttributes($attrs) ->finalize(true); }
[ "final", "protected", "function", "createSourceElement", "(", "$", "type", ",", "$", "src", ")", "{", "// Tag attributes", "$", "attrs", "=", "array", "(", "'src'", "=>", "$", "src", ",", "'type'", "=>", "$", "type", ")", ";", "$", "node", "=", "new", ...
Create inner source node element @param string $type MIME-type @param string $src Path to audio file @return \Krystal\Form\NodeElement
[ "Create", "inner", "source", "node", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/AbstractMediaElement.php#L74-L87
train
manusreload/GLFramework
src/Module/Module.php
Module.getViews
public function getViews() { $config = $this->config; $directories = array(); $dir = $this->directory; if (isset($config['app']['views'])) { $directoriesTmp = $config['app']['views']; if (!is_array($directoriesTmp)) { $directoriesTmp = array($directoriesTmp); } foreach ($directoriesTmp as $directory) { $this->addFolder($directories, $dir . '/' . $directory); } } return $directories; }
php
public function getViews() { $config = $this->config; $directories = array(); $dir = $this->directory; if (isset($config['app']['views'])) { $directoriesTmp = $config['app']['views']; if (!is_array($directoriesTmp)) { $directoriesTmp = array($directoriesTmp); } foreach ($directoriesTmp as $directory) { $this->addFolder($directories, $dir . '/' . $directory); } } return $directories; }
[ "public", "function", "getViews", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "$", "directories", "=", "array", "(", ")", ";", "$", "dir", "=", "$", "this", "->", "directory", ";", "if", "(", "isset", "(", "$", "config", ...
Return folder to find views @return array
[ "Return", "folder", "to", "find", "views" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/Module.php#L357-L372
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.addIgnoredProperty
public function addIgnoredProperty(string $type, $propertyNames): void { if (!is_string($propertyNames) && !is_array($propertyNames)) { throw new InvalidArgumentException('Property name must be a string or array of strings'); } if (!isset($this->ignoredEncodedPropertyNamesByType[$type])) { $this->ignoredEncodedPropertyNamesByType[$type] = []; } foreach ((array)$propertyNames as $propertyName) { $this->ignoredEncodedPropertyNamesByType[$type][$this->normalizePropertyName($propertyName)] = true; } }
php
public function addIgnoredProperty(string $type, $propertyNames): void { if (!is_string($propertyNames) && !is_array($propertyNames)) { throw new InvalidArgumentException('Property name must be a string or array of strings'); } if (!isset($this->ignoredEncodedPropertyNamesByType[$type])) { $this->ignoredEncodedPropertyNamesByType[$type] = []; } foreach ((array)$propertyNames as $propertyName) { $this->ignoredEncodedPropertyNamesByType[$type][$this->normalizePropertyName($propertyName)] = true; } }
[ "public", "function", "addIgnoredProperty", "(", "string", "$", "type", ",", "$", "propertyNames", ")", ":", "void", "{", "if", "(", "!", "is_string", "(", "$", "propertyNames", ")", "&&", "!", "is_array", "(", "$", "propertyNames", ")", ")", "{", "throw...
Adds a property to ignore during encoding @param string $type The type whose property we're ignoring @param string|string[] $propertyNames The name or list of names of the properties to ignore @throws InvalidArgumentException Thrown if the property names were not a string or array
[ "Adds", "a", "property", "to", "ignore", "during", "encoding" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L52-L65
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.decodeArrayOrVariadicConstructorParamValue
protected function decodeArrayOrVariadicConstructorParamValue( ReflectionParameter $constructorParam, $constructorParamValue, EncodingContext $context ) { if (!is_array($constructorParamValue)) { throw new EncodingException('Value must be an array'); } if (count($constructorParamValue) === 0) { return []; } if ($constructorParam->isVariadic() && $constructorParam->hasType()) { $type = $constructorParam->getType() . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } if (is_object($constructorParamValue[0])) { $type = get_class($constructorParamValue[0]) . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } $type = gettype($constructorParamValue[0]) . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); }
php
protected function decodeArrayOrVariadicConstructorParamValue( ReflectionParameter $constructorParam, $constructorParamValue, EncodingContext $context ) { if (!is_array($constructorParamValue)) { throw new EncodingException('Value must be an array'); } if (count($constructorParamValue) === 0) { return []; } if ($constructorParam->isVariadic() && $constructorParam->hasType()) { $type = $constructorParam->getType() . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } if (is_object($constructorParamValue[0])) { $type = get_class($constructorParamValue[0]) . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } $type = gettype($constructorParamValue[0]) . '[]'; return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); }
[ "protected", "function", "decodeArrayOrVariadicConstructorParamValue", "(", "ReflectionParameter", "$", "constructorParam", ",", "$", "constructorParamValue", ",", "EncodingContext", "$", "context", ")", "{", "if", "(", "!", "is_array", "(", "$", "constructorParamValue", ...
Decodes a variadic constructor parameter value @param ReflectionParameter $constructorParam The constructor parameter to decode @param mixed $constructorParamValue The encoded constructor parameter value @param EncodingContext $context The encoding context @return mixed The decoded value @throws EncodingException Thrown if the value was not an array
[ "Decodes", "a", "variadic", "constructor", "parameter", "value" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L190-L221
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.decodeConstructorParamValue
private function decodeConstructorParamValue( ReflectionParameter $constructorParam, $constructorParamValue, ReflectionClass $reflectionClass, string $normalizedHashPropertyName, EncodingContext $context ) { if ($constructorParam->hasType() && !$constructorParam->isArray() && !$constructorParam->isVariadic()) { $constructorParamType = (string)$constructorParam->getType(); return $this->encoders->getEncoderForType($constructorParamType) ->decode($constructorParamValue, $constructorParamType, $context); } if ($constructorParam->isVariadic() || $constructorParam->isArray()) { return $this->decodeArrayOrVariadicConstructorParamValue( $constructorParam, $constructorParamValue, $context ); } $decodedValue = null; if ( $this->tryDecodeValueFromGetterType( $reflectionClass, $normalizedHashPropertyName, $constructorParamValue, $context, $decodedValue ) ) { return $decodedValue; } // At this point, let's just check if the value we're trying to decode is a scalar, and if so, just return it if (is_scalar($constructorParamValue)) { $type = gettype($constructorParamValue); return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } throw new EncodingException("Failed to decode constructor parameter {$constructorParam->getName()}"); }
php
private function decodeConstructorParamValue( ReflectionParameter $constructorParam, $constructorParamValue, ReflectionClass $reflectionClass, string $normalizedHashPropertyName, EncodingContext $context ) { if ($constructorParam->hasType() && !$constructorParam->isArray() && !$constructorParam->isVariadic()) { $constructorParamType = (string)$constructorParam->getType(); return $this->encoders->getEncoderForType($constructorParamType) ->decode($constructorParamValue, $constructorParamType, $context); } if ($constructorParam->isVariadic() || $constructorParam->isArray()) { return $this->decodeArrayOrVariadicConstructorParamValue( $constructorParam, $constructorParamValue, $context ); } $decodedValue = null; if ( $this->tryDecodeValueFromGetterType( $reflectionClass, $normalizedHashPropertyName, $constructorParamValue, $context, $decodedValue ) ) { return $decodedValue; } // At this point, let's just check if the value we're trying to decode is a scalar, and if so, just return it if (is_scalar($constructorParamValue)) { $type = gettype($constructorParamValue); return $this->encoders->getEncoderForType($type) ->decode($constructorParamValue, $type, $context); } throw new EncodingException("Failed to decode constructor parameter {$constructorParam->getName()}"); }
[ "private", "function", "decodeConstructorParamValue", "(", "ReflectionParameter", "$", "constructorParam", ",", "$", "constructorParamValue", ",", "ReflectionClass", "$", "reflectionClass", ",", "string", "$", "normalizedHashPropertyName", ",", "EncodingContext", "$", "cont...
Decodes a constructor parameter value @param ReflectionParameter $constructorParam The constructor parameter to decode @param mixed $constructorParamValue The encoded constructor parameter value @param ReflectionClass $reflectionClass The reflection class we're trying to instantiate @param string $normalizedHashPropertyName The encoded property name from the hash @param EncodingContext $context The encoding context @return mixed The decoded constructor parameter value @throws EncodingException Thrown if the value could not be automatically decoded
[ "Decodes", "a", "constructor", "parameter", "value" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L234-L279
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.normalizeHashProperties
private function normalizeHashProperties(array $objectHash): array { $encodedHashProperties = []; foreach ($objectHash as $propertyName => $propertyValue) { $encodedHashProperties[$this->normalizePropertyName($propertyName)] = $propertyName; } return $encodedHashProperties; }
php
private function normalizeHashProperties(array $objectHash): array { $encodedHashProperties = []; foreach ($objectHash as $propertyName => $propertyValue) { $encodedHashProperties[$this->normalizePropertyName($propertyName)] = $propertyName; } return $encodedHashProperties; }
[ "private", "function", "normalizeHashProperties", "(", "array", "$", "objectHash", ")", ":", "array", "{", "$", "encodedHashProperties", "=", "[", "]", ";", "foreach", "(", "$", "objectHash", "as", "$", "propertyName", "=>", "$", "propertyValue", ")", "{", "...
Gets the normalized hash property names to original names @param array $objectHash The object hash whose properties we're normalizing @return array The mapping of normalized names to original names
[ "Gets", "the", "normalized", "hash", "property", "names", "to", "original", "names" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L287-L296
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.propertyIsIgnored
private function propertyIsIgnored(string $type, string $propertyName): bool { return isset($this->ignoredEncodedPropertyNamesByType[$type][$this->normalizePropertyName($propertyName)]); }
php
private function propertyIsIgnored(string $type, string $propertyName): bool { return isset($this->ignoredEncodedPropertyNamesByType[$type][$this->normalizePropertyName($propertyName)]); }
[ "private", "function", "propertyIsIgnored", "(", "string", "$", "type", ",", "string", "$", "propertyName", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "ignoredEncodedPropertyNamesByType", "[", "$", "type", "]", "[", "$", "this", "->", ...
Checks whether or not a property on a type is ignored @param string $type The type to check @param string $propertyName The property name to check @return bool True if the property should be ignored, otherwise false
[ "Checks", "whether", "or", "not", "a", "property", "on", "a", "type", "is", "ignored" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L316-L319
train
aphiria/serialization
src/Encoding/ObjectEncoder.php
ObjectEncoder.tryDecodeValueFromGetterType
private function tryDecodeValueFromGetterType( ReflectionClass $reflectionClass, string $normalizedPropertyName, $encodedValue, EncodingContext $context, &$decodedValue ): bool { // Check if we can infer the type from any getters or setters foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { if ( !$reflectionMethod->hasReturnType() || $reflectionMethod->getReturnType() === 'array' || $reflectionMethod->isConstructor() || $reflectionMethod->isDestructor() || $reflectionMethod->getNumberOfRequiredParameters() > 0 ) { continue; } $propertyName = null; // Try to extract the property name from the getter/has-er/is-er if (strpos($reflectionMethod->name, 'get') === 0 || strpos($reflectionMethod->name, 'has') === 0) { $propertyName = lcfirst(substr($reflectionMethod->name, 3)); } elseif (strpos($reflectionMethod->name, 'is') === 0) { $propertyName = lcfirst(substr($reflectionMethod->name, 2)); } if ($propertyName === null) { continue; } $encodedPropertyName = $this->normalizePropertyName($propertyName); // This getter matches the property name we're looking for if ($encodedPropertyName === $normalizedPropertyName) { try { $reflectionMethodReturnType = (string)$reflectionMethod->getReturnType(); $decodedValue = $this->encoders->getEncoderForType($reflectionMethodReturnType) ->decode($encodedValue, $reflectionMethodReturnType, $context); return true; } catch (EncodingException $ex) { return false; } } } return false; }
php
private function tryDecodeValueFromGetterType( ReflectionClass $reflectionClass, string $normalizedPropertyName, $encodedValue, EncodingContext $context, &$decodedValue ): bool { // Check if we can infer the type from any getters or setters foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { if ( !$reflectionMethod->hasReturnType() || $reflectionMethod->getReturnType() === 'array' || $reflectionMethod->isConstructor() || $reflectionMethod->isDestructor() || $reflectionMethod->getNumberOfRequiredParameters() > 0 ) { continue; } $propertyName = null; // Try to extract the property name from the getter/has-er/is-er if (strpos($reflectionMethod->name, 'get') === 0 || strpos($reflectionMethod->name, 'has') === 0) { $propertyName = lcfirst(substr($reflectionMethod->name, 3)); } elseif (strpos($reflectionMethod->name, 'is') === 0) { $propertyName = lcfirst(substr($reflectionMethod->name, 2)); } if ($propertyName === null) { continue; } $encodedPropertyName = $this->normalizePropertyName($propertyName); // This getter matches the property name we're looking for if ($encodedPropertyName === $normalizedPropertyName) { try { $reflectionMethodReturnType = (string)$reflectionMethod->getReturnType(); $decodedValue = $this->encoders->getEncoderForType($reflectionMethodReturnType) ->decode($encodedValue, $reflectionMethodReturnType, $context); return true; } catch (EncodingException $ex) { return false; } } } return false; }
[ "private", "function", "tryDecodeValueFromGetterType", "(", "ReflectionClass", "$", "reflectionClass", ",", "string", "$", "normalizedPropertyName", ",", "$", "encodedValue", ",", "EncodingContext", "$", "context", ",", "&", "$", "decodedValue", ")", ":", "bool", "{...
Decodes a value using the type info from get, is, or has methods @param ReflectionClass $reflectionClass The reflection class @param string $normalizedPropertyName The normalized property name @param mixed $encodedValue The encoded value @param EncodingContext $context The encoding context @param mixed The decoded value @return bool Returns true if the value was successfully decoded, otherwise false
[ "Decodes", "a", "value", "using", "the", "type", "info", "from", "get", "is", "or", "has", "methods" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/ObjectEncoder.php#L331-L380
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/MagicQuotesFilter.php
MagicQuotesFilter.filter
public function filter($value) { return is_array($value) ? array_map(array($this, __FUNCTION__), $value) : stripslashes($value); }
php
public function filter($value) { return is_array($value) ? array_map(array($this, __FUNCTION__), $value) : stripslashes($value); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "return", "is_array", "(", "$", "value", ")", "?", "array_map", "(", "array", "(", "$", "this", ",", "__FUNCTION__", ")", ",", "$", "value", ")", ":", "stripslashes", "(", "$", "value", ")"...
Recursively filter slashes in array @param mixed $value @return array
[ "Recursively", "filter", "slashes", "in", "array" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/MagicQuotesFilter.php#L45-L48
train
krystal-framework/krystal.framework
src/Krystal/Form/Gadget/LastCategoryKeeper.php
LastCategoryKeeper.getLastCategoryId
public function getLastCategoryId() { $value = $this->getData(); if ($this->flashed === true) { // Clear data $this->clearData(); } return $value; }
php
public function getLastCategoryId() { $value = $this->getData(); if ($this->flashed === true) { // Clear data $this->clearData(); } return $value; }
[ "public", "function", "getLastCategoryId", "(", ")", "{", "$", "value", "=", "$", "this", "->", "getData", "(", ")", ";", "if", "(", "$", "this", "->", "flashed", "===", "true", ")", "{", "// Clear data", "$", "this", "->", "clearData", "(", ")", ";"...
Returns last category id @return string
[ "Returns", "last", "category", "id" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Gadget/LastCategoryKeeper.php#L67-L77
train
rocketweb-fed/module-checkout-enhancement
Model/EnhancementConfigProvider.php
EnhancementConfigProvider.getDefaultPaymentConfig
public function getDefaultPaymentConfig() { $configuration = []; $isActive = $this->enhancementHelper->isActiveDefaultPayment(); $configuration['isActiveDefaultPayment'] = $isActive; if ($isActive) { $configuration['defaultMethod'] = $this->enhancementHelper->getDefaultMethod(); } return $configuration; }
php
public function getDefaultPaymentConfig() { $configuration = []; $isActive = $this->enhancementHelper->isActiveDefaultPayment(); $configuration['isActiveDefaultPayment'] = $isActive; if ($isActive) { $configuration['defaultMethod'] = $this->enhancementHelper->getDefaultMethod(); } return $configuration; }
[ "public", "function", "getDefaultPaymentConfig", "(", ")", "{", "$", "configuration", "=", "[", "]", ";", "$", "isActive", "=", "$", "this", "->", "enhancementHelper", "->", "isActiveDefaultPayment", "(", ")", ";", "$", "configuration", "[", "'isActiveDefaultPay...
Returns default payment config @return array
[ "Returns", "default", "payment", "config" ]
04e83847f817687b6c59e49f5bc330f57f5d636b
https://github.com/rocketweb-fed/module-checkout-enhancement/blob/04e83847f817687b6c59e49f5bc330f57f5d636b/Model/EnhancementConfigProvider.php#L70-L81
train
rocketweb-fed/module-checkout-enhancement
Model/EnhancementConfigProvider.php
EnhancementConfigProvider.getGoogleAddressConfig
public function getGoogleAddressConfig() { $configuration = []; $isActive = $this->enhancementHelper->isActiveGoogleAddress(); $configuration['isActiveGoogleAddress'] = $isActive; if ($isActive) { $configuration['googleAddressCountry'] = $this->enhancementHelper->getGoogleMapAddressCountries(); } return $configuration; }
php
public function getGoogleAddressConfig() { $configuration = []; $isActive = $this->enhancementHelper->isActiveGoogleAddress(); $configuration['isActiveGoogleAddress'] = $isActive; if ($isActive) { $configuration['googleAddressCountry'] = $this->enhancementHelper->getGoogleMapAddressCountries(); } return $configuration; }
[ "public", "function", "getGoogleAddressConfig", "(", ")", "{", "$", "configuration", "=", "[", "]", ";", "$", "isActive", "=", "$", "this", "->", "enhancementHelper", "->", "isActiveGoogleAddress", "(", ")", ";", "$", "configuration", "[", "'isActiveGoogleAddres...
Returns Google Maps Search Address config @return array
[ "Returns", "Google", "Maps", "Search", "Address", "config" ]
04e83847f817687b6c59e49f5bc330f57f5d636b
https://github.com/rocketweb-fed/module-checkout-enhancement/blob/04e83847f817687b6c59e49f5bc330f57f5d636b/Model/EnhancementConfigProvider.php#L88-L99
train
krystal-framework/krystal.framework
src/Krystal/Application/View/PartialBag.php
PartialBag.getPartialFile
public function getPartialFile($name) { $file = $this->findPartialFile($name); if (is_file($file)) { return $file; } else if ($this->hasStaticPartial($name)) { return $this->getStaticFile($name); } else { throw new LogicException(sprintf('Could not find a registered partial called %s', $name)); } }
php
public function getPartialFile($name) { $file = $this->findPartialFile($name); if (is_file($file)) { return $file; } else if ($this->hasStaticPartial($name)) { return $this->getStaticFile($name); } else { throw new LogicException(sprintf('Could not find a registered partial called %s', $name)); } }
[ "public", "function", "getPartialFile", "(", "$", "name", ")", "{", "$", "file", "=", "$", "this", "->", "findPartialFile", "(", "$", "name", ")", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "else", ...
Attempts to return partial file path @param string $name Partial name @throws \LogicException If can't find partials file by its name @return string
[ "Attempts", "to", "return", "partial", "file", "path" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/View/PartialBag.php#L39-L52
train
krystal-framework/krystal.framework
src/Krystal/Application/View/PartialBag.php
PartialBag.addStaticPartial
public function addStaticPartial($baseDir, $name) { $file = $this->createPartialPath($baseDir, $name); if (!is_file($file)) { throw new LogicException(sprintf('Invalid base directory or file name provided "%s"', $file)); } $this->staticPartials[$name] = $file; return $this; }
php
public function addStaticPartial($baseDir, $name) { $file = $this->createPartialPath($baseDir, $name); if (!is_file($file)) { throw new LogicException(sprintf('Invalid base directory or file name provided "%s"', $file)); } $this->staticPartials[$name] = $file; return $this; }
[ "public", "function", "addStaticPartial", "(", "$", "baseDir", ",", "$", "name", ")", "{", "$", "file", "=", "$", "this", "->", "createPartialPath", "(", "$", "baseDir", ",", "$", "name", ")", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ...
Adds new static partial to collection @param string $name @param string $baseDir @throws \LogicException if wrong data supplied @return \Krystal\Application\View\PartialBag
[ "Adds", "new", "static", "partial", "to", "collection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/View/PartialBag.php#L62-L72
train
krystal-framework/krystal.framework
src/Krystal/Application/View/PartialBag.php
PartialBag.addStaticPartials
public function addStaticPartials(array $collection) { foreach ($collection as $baseDir => $name) { $this->addStaticPartial($baseDir, $name); } return $this; }
php
public function addStaticPartials(array $collection) { foreach ($collection as $baseDir => $name) { $this->addStaticPartial($baseDir, $name); } return $this; }
[ "public", "function", "addStaticPartials", "(", "array", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "baseDir", "=>", "$", "name", ")", "{", "$", "this", "->", "addStaticPartial", "(", "$", "baseDir", ",", "$", "name", ")",...
Adds a collection of static partials @param array $collection @return \Krystal\Application\View\PartialBag
[ "Adds", "a", "collection", "of", "static", "partials" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/View/PartialBag.php#L80-L87
train
krystal-framework/krystal.framework
src/Krystal/Application/View/PartialBag.php
PartialBag.findPartialFile
private function findPartialFile($name) { foreach ($this->partialDirs as $dir) { $file = $this->createPartialPath($dir, $name); if (is_file($file)) { return $file; } } return false; }
php
private function findPartialFile($name) { foreach ($this->partialDirs as $dir) { $file = $this->createPartialPath($dir, $name); if (is_file($file)) { return $file; } } return false; }
[ "private", "function", "findPartialFile", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "partialDirs", "as", "$", "dir", ")", "{", "$", "file", "=", "$", "this", "->", "createPartialPath", "(", "$", "dir", ",", "$", "name", ")", ";",...
Tries to find a partial within registered directories @param string $name Partial name @return mixed
[ "Tries", "to", "find", "a", "partial", "within", "registered", "directories" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/View/PartialBag.php#L122-L133
train
AOEpeople/Aoe_Api2
app/code/community/Aoe/Api2/Model/Acl.php
Aoe_Api2_Model_Acl._setRules
protected function _setRules() { $resources = $this->getResources(); /** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $rulesCollection */ $rulesCollection = Mage::getResourceModel('api2/acl_global_rule_collection'); foreach ($rulesCollection as $rule) { /** @var Mage_Api2_Model_Acl_Global_Rule $rule */ if (Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL === $rule->getResourceId()) { if (in_array($rule->getRoleId(), Mage_Api2_Model_Acl_Global_Role::getSystemRoles())) { /** @var Mage_Api2_Model_Acl_Global_Role $role */ $role = $this->_getRolesCollection()->getItemById($rule->getRoleId()); $privileges = $this->_getConfig()->getResourceUserPrivileges( $this->_resourceType, $role->getConfigNodeName() ); if (!array_key_exists($this->_operation, $privileges)) { continue; } } $this->allow($rule->getRoleId()); } elseif (in_array($rule->getResourceId(), $resources)) { $this->allow($rule->getRoleId(), $rule->getResourceId(), $rule->getPrivilege()); } } return $this; }
php
protected function _setRules() { $resources = $this->getResources(); /** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $rulesCollection */ $rulesCollection = Mage::getResourceModel('api2/acl_global_rule_collection'); foreach ($rulesCollection as $rule) { /** @var Mage_Api2_Model_Acl_Global_Rule $rule */ if (Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL === $rule->getResourceId()) { if (in_array($rule->getRoleId(), Mage_Api2_Model_Acl_Global_Role::getSystemRoles())) { /** @var Mage_Api2_Model_Acl_Global_Role $role */ $role = $this->_getRolesCollection()->getItemById($rule->getRoleId()); $privileges = $this->_getConfig()->getResourceUserPrivileges( $this->_resourceType, $role->getConfigNodeName() ); if (!array_key_exists($this->_operation, $privileges)) { continue; } } $this->allow($rule->getRoleId()); } elseif (in_array($rule->getResourceId(), $resources)) { $this->allow($rule->getRoleId(), $rule->getResourceId(), $rule->getPrivilege()); } } return $this; }
[ "protected", "function", "_setRules", "(", ")", "{", "$", "resources", "=", "$", "this", "->", "getResources", "(", ")", ";", "/** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $rulesCollection */", "$", "rulesCollection", "=", "Mage", "::", "getResourceModel",...
Retrieve rules data from DB and inject it into ACL @return Mage_Api2_Model_Acl
[ "Retrieve", "rules", "data", "from", "DB", "and", "inject", "it", "into", "ACL" ]
d770221bcc4d6820e8e52f6a67a66191424c8e1a
https://github.com/AOEpeople/Aoe_Api2/blob/d770221bcc4d6820e8e52f6a67a66191424c8e1a/app/code/community/Aoe/Api2/Model/Acl.php#L10-L39
train
krystal-framework/krystal.framework
src/Krystal/Http/HeaderBag.php
HeaderBag.getRequestHeader
public function getRequestHeader($header, $default = false) { if ($this->hasRequestHeader($header)) { $headers = $this->getAllRequestHeaders(); return $headers[$header]; } else { return $default; } }
php
public function getRequestHeader($header, $default = false) { if ($this->hasRequestHeader($header)) { $headers = $this->getAllRequestHeaders(); return $headers[$header]; } else { return $default; } }
[ "public", "function", "getRequestHeader", "(", "$", "header", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "this", "->", "hasRequestHeader", "(", "$", "header", ")", ")", "{", "$", "headers", "=", "$", "this", "->", "getAllRequestHeaders"...
Returns request header if present @param string $header @param boolean $default Default value to be returned in case requested one doesn't exist @return string
[ "Returns", "request", "header", "if", "present" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/HeaderBag.php#L53-L61
train
krystal-framework/krystal.framework
src/Krystal/Http/HeaderBag.php
HeaderBag.setStatusCode
public function setStatusCode($code) { static $sg = null; if (is_null($sg)) { $sg = new StatusGenerator(); } $status = $sg->generate($code); if ($status !== false) { $this->append($status); } return $this; }
php
public function setStatusCode($code) { static $sg = null; if (is_null($sg)) { $sg = new StatusGenerator(); } $status = $sg->generate($code); if ($status !== false) { $this->append($status); } return $this; }
[ "public", "function", "setStatusCode", "(", "$", "code", ")", "{", "static", "$", "sg", "=", "null", ";", "if", "(", "is_null", "(", "$", "sg", ")", ")", "{", "$", "sg", "=", "new", "StatusGenerator", "(", ")", ";", "}", "$", "status", "=", "$", ...
Sets status code @param integer $code @return \Krystal\Http\HeaderBag
[ "Sets", "status", "code" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/HeaderBag.php#L69-L84
train
krystal-framework/krystal.framework
src/Krystal/Http/HeaderBag.php
HeaderBag.setMany
public function setMany(array $headers) { $this->clear(); foreach ($headers as $header) { $this->append($header); } return $this; }
php
public function setMany(array $headers) { $this->clear(); foreach ($headers as $header) { $this->append($header); } return $this; }
[ "public", "function", "setMany", "(", "array", "$", "headers", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "this", "->", "append", "(", "$", "header", ")", ";", "}", "re...
Set many headers at once and clear all previous ones @param array $headers @return \Krystal\Http\HeaderBag
[ "Set", "many", "headers", "at", "once", "and", "clear", "all", "previous", "ones" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/HeaderBag.php#L92-L101
train
krystal-framework/krystal.framework
src/Krystal/Http/HeaderBag.php
HeaderBag.appendPair
public function appendPair($key, $value) { $header = sprintf('%s: %s', $key, $value); $this->append($header); return $this; }
php
public function appendPair($key, $value) { $header = sprintf('%s: %s', $key, $value); $this->append($header); return $this; }
[ "public", "function", "appendPair", "(", "$", "key", ",", "$", "value", ")", "{", "$", "header", "=", "sprintf", "(", "'%s: %s'", ",", "$", "key", ",", "$", "value", ")", ";", "$", "this", "->", "append", "(", "$", "header", ")", ";", "return", "...
Appends a pair @param string $key @param string $value @return \Krystal\Http\HeaderBag
[ "Appends", "a", "pair" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/HeaderBag.php#L139-L145
train
krystal-framework/krystal.framework
src/Krystal/Http/HeaderBag.php
HeaderBag.appendPairs
public function appendPairs(array $headers) { foreach ($headers as $key => $value) { $this->appendPair($key, $value); } return $this; }
php
public function appendPairs(array $headers) { foreach ($headers as $key => $value) { $this->appendPair($key, $value); } return $this; }
[ "public", "function", "appendPairs", "(", "array", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "appendPair", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return...
Append several pairs @param array $headers @return \Krystal\Http\HeaderBag
[ "Append", "several", "pairs" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/HeaderBag.php#L153-L160
train
manusreload/GLFramework
src/Response.php
Response.display
public function display() { \http_response_code($this->getResponseCode()); if ($this->contentType) { header('Content-Type: ' . $this->contentType); } // header('Content-Length: ' . strlen($this->content)); if ($this->redirection) { header('Location: ' . $this->redirection); } Events::dispatch('beforeResponseSend', array($this)); session_write_close(); print $this->content; Profiler::dump(); Events::dispatch('afterResponseSend', array($this)); }
php
public function display() { \http_response_code($this->getResponseCode()); if ($this->contentType) { header('Content-Type: ' . $this->contentType); } // header('Content-Length: ' . strlen($this->content)); if ($this->redirection) { header('Location: ' . $this->redirection); } Events::dispatch('beforeResponseSend', array($this)); session_write_close(); print $this->content; Profiler::dump(); Events::dispatch('afterResponseSend', array($this)); }
[ "public", "function", "display", "(", ")", "{", "\\", "http_response_code", "(", "$", "this", "->", "getResponseCode", "(", ")", ")", ";", "if", "(", "$", "this", "->", "contentType", ")", "{", "header", "(", "'Content-Type: '", ".", "$", "this", "->", ...
Envia la respuesta al cliente
[ "Envia", "la", "respuesta", "al", "cliente" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Response.php#L107-L122
train
krystal-framework/krystal.framework
src/Krystal/Form/Compressor/HtmlCompressor.php
HtmlCompressor.compress
public function compress($content) { // Increment recursion level only before doing a compression ini_set('pcre.recursion_limit', '16777'); $content = $this->removeSpaces($content); $content = $this->removeComments($content); return $content; }
php
public function compress($content) { // Increment recursion level only before doing a compression ini_set('pcre.recursion_limit', '16777'); $content = $this->removeSpaces($content); $content = $this->removeComments($content); return $content; }
[ "public", "function", "compress", "(", "$", "content", ")", "{", "// Increment recursion level only before doing a compression", "ini_set", "(", "'pcre.recursion_limit'", ",", "'16777'", ")", ";", "$", "content", "=", "$", "this", "->", "removeSpaces", "(", "$", "co...
Compresses the string @param string $content @return string
[ "Compresses", "the", "string" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Compressor/HtmlCompressor.php#L22-L31
train
droath/project-x
src/Project/Command/DrushCommand.php
DrushCommand.findDrupalDocroot
protected function findDrupalDocroot() { /** @var EngineType $engine */ $engine = $this->engineInstance(); /** @var DrupalProjectType $project */ $project = $this->projectInstance(); if ($engine instanceof DockerEngineType && !$this->localhost) { return "/var/www/html/{$project->getInstallRoot(true)}"; } return $project->getInstallPath(); }
php
protected function findDrupalDocroot() { /** @var EngineType $engine */ $engine = $this->engineInstance(); /** @var DrupalProjectType $project */ $project = $this->projectInstance(); if ($engine instanceof DockerEngineType && !$this->localhost) { return "/var/www/html/{$project->getInstallRoot(true)}"; } return $project->getInstallPath(); }
[ "protected", "function", "findDrupalDocroot", "(", ")", "{", "/** @var EngineType $engine */", "$", "engine", "=", "$", "this", "->", "engineInstance", "(", ")", ";", "/** @var DrupalProjectType $project */", "$", "project", "=", "$", "this", "->", "projectInstance", ...
Find Drupal docroot. @return string
[ "Find", "Drupal", "docroot", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Command/DrushCommand.php#L87-L100
train
Firesphere/silverstripe-newsmodule
code/admins/NewsAdmin.php
NewsAdmin.getEditForm
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $siteConfig = SiteConfig::current_site_config(); /** * SortOrder is ignored unless sortable is enabled. */ if ($this->modelClass === "Tag" && $siteConfig->AllowTags) { $form->Fields() ->fieldByName('Tag') ->getConfig() ->addComponent( new GridFieldOrderableRows( 'SortOrder' ) ); } if ($this->modelClass === "News" && !$siteConfig->AllowExport) { $form->Fields() ->fieldByName("News") ->getConfig() ->removeComponentsByType('GridFieldExportButton') ->addComponent( new GridfieldNewsPublishAction() ); } return $form; }
php
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $siteConfig = SiteConfig::current_site_config(); /** * SortOrder is ignored unless sortable is enabled. */ if ($this->modelClass === "Tag" && $siteConfig->AllowTags) { $form->Fields() ->fieldByName('Tag') ->getConfig() ->addComponent( new GridFieldOrderableRows( 'SortOrder' ) ); } if ($this->modelClass === "News" && !$siteConfig->AllowExport) { $form->Fields() ->fieldByName("News") ->getConfig() ->removeComponentsByType('GridFieldExportButton') ->addComponent( new GridfieldNewsPublishAction() ); } return $form; }
[ "public", "function", "getEditForm", "(", "$", "id", "=", "null", ",", "$", "fields", "=", "null", ")", "{", "$", "form", "=", "parent", "::", "getEditForm", "(", "$", "id", ",", "$", "fields", ")", ";", "$", "siteConfig", "=", "SiteConfig", "::", ...
Add the sortorder to tags. I guess tags are sortable now. @param Int $id (No idea) @param FieldList $fields because I can @return Form $form, because it comes in handy.
[ "Add", "the", "sortorder", "to", "tags", ".", "I", "guess", "tags", "are", "sortable", "now", "." ]
98c501bf940878ed9c044124409b85a3e3c4265c
https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/admins/NewsAdmin.php#L29-L57
train
Firesphere/silverstripe-newsmodule
code/admins/NewsAdmin.php
NewsAdmin.getList
public function getList() { /** @var DataList $list */ $list = parent::getList(); if ($this->modelClass === 'News' && class_exists('Subsite') && Subsite::currentSubsiteID() > 0) { $pages = NewsHolderPage::get()->filter(array('SubsiteID' => (int)Subsite::currentSubsiteID())); $filter = $pages->column('ID'); /* Manual join needed because otherwise no items are found. Unknown why. */ $list = $list->innerJoin('NewsHolderPage_Newsitems', 'NewsHolderPage_Newsitems.NewsID = News.ID') ->filter(array('NewsHolderPage_Newsitems.NewsHolderPageID' => $filter)); } return $list; }
php
public function getList() { /** @var DataList $list */ $list = parent::getList(); if ($this->modelClass === 'News' && class_exists('Subsite') && Subsite::currentSubsiteID() > 0) { $pages = NewsHolderPage::get()->filter(array('SubsiteID' => (int)Subsite::currentSubsiteID())); $filter = $pages->column('ID'); /* Manual join needed because otherwise no items are found. Unknown why. */ $list = $list->innerJoin('NewsHolderPage_Newsitems', 'NewsHolderPage_Newsitems.NewsID = News.ID') ->filter(array('NewsHolderPage_Newsitems.NewsHolderPageID' => $filter)); } return $list; }
[ "public", "function", "getList", "(", ")", "{", "/** @var DataList $list */", "$", "list", "=", "parent", "::", "getList", "(", ")", ";", "if", "(", "$", "this", "->", "modelClass", "===", "'News'", "&&", "class_exists", "(", "'Subsite'", ")", "&&", "Subsi...
List only newsitems from current subsite. @author Marcio Barrientos @return ArrayList $list
[ "List", "only", "newsitems", "from", "current", "subsite", "." ]
98c501bf940878ed9c044124409b85a3e3c4265c
https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/admins/NewsAdmin.php#L65-L78
train
Riimu/Kit-BaseConversion
src/DigitList/ArrayDigitList.php
ArrayDigitList.validateDigits
private function validateDigits(& $digits) { ksort($digits); if (count($digits) < 2) { throw new \InvalidArgumentException('Number base must have at least 2 digits'); } elseif (array_keys($digits) !== range(0, count($digits) - 1)) { throw new \InvalidArgumentException('Invalid digit values in the number base'); } elseif ($this->detectDuplicates($digits)) { throw new \InvalidArgumentException('Number base cannot have duplicate digits'); } }
php
private function validateDigits(& $digits) { ksort($digits); if (count($digits) < 2) { throw new \InvalidArgumentException('Number base must have at least 2 digits'); } elseif (array_keys($digits) !== range(0, count($digits) - 1)) { throw new \InvalidArgumentException('Invalid digit values in the number base'); } elseif ($this->detectDuplicates($digits)) { throw new \InvalidArgumentException('Number base cannot have duplicate digits'); } }
[ "private", "function", "validateDigits", "(", "&", "$", "digits", ")", "{", "ksort", "(", "$", "digits", ")", ";", "if", "(", "count", "(", "$", "digits", ")", "<", "2", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Number base must ...
Validates and sorts the list of digits. @param array $digits The list of digits for the numeral system @throws \InvalidArgumentException If the digit list is invalid
[ "Validates", "and", "sorts", "the", "list", "of", "digits", "." ]
e0f486759590b69126c83622edd309217f783324
https://github.com/Riimu/Kit-BaseConversion/blob/e0f486759590b69126c83622edd309217f783324/src/DigitList/ArrayDigitList.php#L47-L58
train
Riimu/Kit-BaseConversion
src/DigitList/ArrayDigitList.php
ArrayDigitList.detectDuplicates
private function detectDuplicates(array $digits) { for ($i = count($digits); $i > 0; $i--) { if (array_search(array_pop($digits), $digits) !== false) { return true; } } return false; }
php
private function detectDuplicates(array $digits) { for ($i = count($digits); $i > 0; $i--) { if (array_search(array_pop($digits), $digits) !== false) { return true; } } return false; }
[ "private", "function", "detectDuplicates", "(", "array", "$", "digits", ")", "{", "for", "(", "$", "i", "=", "count", "(", "$", "digits", ")", ";", "$", "i", ">", "0", ";", "$", "i", "--", ")", "{", "if", "(", "array_search", "(", "array_pop", "(...
Tells if the list of digits has duplicate values. @param array $digits The list of digits for the numeral system @return bool True if the list contains duplicate digits, false if not
[ "Tells", "if", "the", "list", "of", "digits", "has", "duplicate", "values", "." ]
e0f486759590b69126c83622edd309217f783324
https://github.com/Riimu/Kit-BaseConversion/blob/e0f486759590b69126c83622edd309217f783324/src/DigitList/ArrayDigitList.php#L65-L74
train
Riimu/Kit-BaseConversion
src/DigitList/ArrayDigitList.php
ArrayDigitList.detectConflict
private function detectConflict(array $digits, callable $detect) { foreach ($digits as $digit) { if ($this->inDigits($digit, $digits, $detect)) { return true; } } return false; }
php
private function detectConflict(array $digits, callable $detect) { foreach ($digits as $digit) { if ($this->inDigits($digit, $digits, $detect)) { return true; } } return false; }
[ "private", "function", "detectConflict", "(", "array", "$", "digits", ",", "callable", "$", "detect", ")", "{", "foreach", "(", "$", "digits", "as", "$", "digit", ")", "{", "if", "(", "$", "this", "->", "inDigits", "(", "$", "digit", ",", "$", "digit...
Tells if a conflict exists between string values. @param string[] $digits The list of digits for the numeral system @param callable $detect Function used to detect the conflict @return bool True if a conflict exists, false if not
[ "Tells", "if", "a", "conflict", "exists", "between", "string", "values", "." ]
e0f486759590b69126c83622edd309217f783324
https://github.com/Riimu/Kit-BaseConversion/blob/e0f486759590b69126c83622edd309217f783324/src/DigitList/ArrayDigitList.php#L92-L101
train
Riimu/Kit-BaseConversion
src/DigitList/ArrayDigitList.php
ArrayDigitList.inDigits
private function inDigits($digit, array $digits, callable $detect) { foreach ($digits as $haystack) { if ($digit !== $haystack && $detect($haystack, $digit) !== false) { return true; } } return false; }
php
private function inDigits($digit, array $digits, callable $detect) { foreach ($digits as $haystack) { if ($digit !== $haystack && $detect($haystack, $digit) !== false) { return true; } } return false; }
[ "private", "function", "inDigits", "(", "$", "digit", ",", "array", "$", "digits", ",", "callable", "$", "detect", ")", "{", "foreach", "(", "$", "digits", "as", "$", "haystack", ")", "{", "if", "(", "$", "digit", "!==", "$", "haystack", "&&", "$", ...
Tells if a conflict exists for a digit in a list of digits. @param string $digit A single digit to test @param string[] $digits The list of digits for the numeral system @param callable $detect Function used to detect the conflict @return bool True if a conflict exists, false if not
[ "Tells", "if", "a", "conflict", "exists", "for", "a", "digit", "in", "a", "list", "of", "digits", "." ]
e0f486759590b69126c83622edd309217f783324
https://github.com/Riimu/Kit-BaseConversion/blob/e0f486759590b69126c83622edd309217f783324/src/DigitList/ArrayDigitList.php#L110-L119
train