repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
jfusion/org.jfusion.framework
src/Installer/Plugin.php
Plugin.uninstall
function uninstall($name) { $result = array(); $result['status'] = false; try { $JFusionAdmin = Factory::getAdmin($name); if ($JFusionAdmin->isConfigured()) { //if this plugin had been valid, call its uninstall function if it exists $success = 0; try { list($success, $reasons) = $JFusionAdmin->uninstall(); $reason = ''; if (is_array($reasons)) { $reason = implode('</li><li>' . $name . ': ', $reasons); } else { $reason = $name . ': ' . $reasons; } } catch (Exception $e) { $reason = $e->getMessage(); } if (!$success) { throw new RuntimeException(Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ' ' . Text::_('FAILED') . ': ' . $reason); } } $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('name , original_name') ->from('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $plugin = $db->loadObject(); // delete raw $query = $db->getQuery(true) ->delete('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $db->execute(); $query = $db->getQuery(true) ->delete('#__jfusion_users') ->where('jname = ' . $db->quote($name)); $db->setQuery($query); $db->execute(); $event = new Event('onInstallerPluginUninstall'); $event->addArgument('name', $name); Factory::getDispatcher()->triggerEvent($event); if ($plugin || !$plugin->original_name) { $dir = JFusionFramework::getPluginPath($name); if (!$name || !is_dir(Path::clean($dir))) { throw new RuntimeException(Text::_('UNINSTALL_ERROR_PATH')); } else { /** * --------------------------------------------------------------------------------------------- * Remove Language files Processing Section * --------------------------------------------------------------------------------------------- */ // Get the extension manifest object $manifest = $this->getManifest($dir); if (is_null($manifest)) { throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN')); } else { $this->manifest = $manifest; // remove files if (!Folder::delete($dir)) { throw new RuntimeException(Text::_('UNINSTALL_ERROR_DELETE')); } else { //return success $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ': ' . Text::_('SUCCESS'); $result['message'] = $msg; $result['status'] = true; } } } } } catch (Exception $e) { $result['message'] = $name . ' ' . $e->getMessage(); $this->installer->abort($e->getMessage()); } return $result; }
php
function uninstall($name) { $result = array(); $result['status'] = false; try { $JFusionAdmin = Factory::getAdmin($name); if ($JFusionAdmin->isConfigured()) { //if this plugin had been valid, call its uninstall function if it exists $success = 0; try { list($success, $reasons) = $JFusionAdmin->uninstall(); $reason = ''; if (is_array($reasons)) { $reason = implode('</li><li>' . $name . ': ', $reasons); } else { $reason = $name . ': ' . $reasons; } } catch (Exception $e) { $reason = $e->getMessage(); } if (!$success) { throw new RuntimeException(Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ' ' . Text::_('FAILED') . ': ' . $reason); } } $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('name , original_name') ->from('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $plugin = $db->loadObject(); // delete raw $query = $db->getQuery(true) ->delete('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $db->execute(); $query = $db->getQuery(true) ->delete('#__jfusion_users') ->where('jname = ' . $db->quote($name)); $db->setQuery($query); $db->execute(); $event = new Event('onInstallerPluginUninstall'); $event->addArgument('name', $name); Factory::getDispatcher()->triggerEvent($event); if ($plugin || !$plugin->original_name) { $dir = JFusionFramework::getPluginPath($name); if (!$name || !is_dir(Path::clean($dir))) { throw new RuntimeException(Text::_('UNINSTALL_ERROR_PATH')); } else { /** * --------------------------------------------------------------------------------------------- * Remove Language files Processing Section * --------------------------------------------------------------------------------------------- */ // Get the extension manifest object $manifest = $this->getManifest($dir); if (is_null($manifest)) { throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN')); } else { $this->manifest = $manifest; // remove files if (!Folder::delete($dir)) { throw new RuntimeException(Text::_('UNINSTALL_ERROR_DELETE')); } else { //return success $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ': ' . Text::_('SUCCESS'); $result['message'] = $msg; $result['status'] = true; } } } } } catch (Exception $e) { $result['message'] = $name . ' ' . $e->getMessage(); $this->installer->abort($e->getMessage()); } return $result; }
[ "function", "uninstall", "(", "$", "name", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'status'", "]", "=", "false", ";", "try", "{", "$", "JFusionAdmin", "=", "Factory", "::", "getAdmin", "(", "$", "name", ")", ";", "if", "(", "$", "JFusionAdmin", "->", "isConfigured", "(", ")", ")", "{", "//if this plugin had been valid, call its uninstall function if it exists", "$", "success", "=", "0", ";", "try", "{", "list", "(", "$", "success", ",", "$", "reasons", ")", "=", "$", "JFusionAdmin", "->", "uninstall", "(", ")", ";", "$", "reason", "=", "''", ";", "if", "(", "is_array", "(", "$", "reasons", ")", ")", "{", "$", "reason", "=", "implode", "(", "'</li><li>'", ".", "$", "name", ".", "': '", ",", "$", "reasons", ")", ";", "}", "else", "{", "$", "reason", "=", "$", "name", ".", "': '", ".", "$", "reasons", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "reason", "=", "$", "e", "->", "getMessage", "(", ")", ";", "}", "if", "(", "!", "$", "success", ")", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'PLUGIN'", ")", ".", "' '", ".", "$", "name", ".", "' '", ".", "Text", "::", "_", "(", "'UNINSTALL'", ")", ".", "' '", ".", "Text", "::", "_", "(", "'FAILED'", ")", ".", "': '", ".", "$", "reason", ")", ";", "}", "}", "$", "db", "=", "Factory", "::", "getDBO", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'name , original_name'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "plugin", "=", "$", "db", "->", "loadObject", "(", ")", ";", "// delete raw", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "delete", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "db", "->", "execute", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "delete", "(", "'#__jfusion_users'", ")", "->", "where", "(", "'jname = '", ".", "$", "db", "->", "quote", "(", "$", "name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "db", "->", "execute", "(", ")", ";", "$", "event", "=", "new", "Event", "(", "'onInstallerPluginUninstall'", ")", ";", "$", "event", "->", "addArgument", "(", "'name'", ",", "$", "name", ")", ";", "Factory", "::", "getDispatcher", "(", ")", "->", "triggerEvent", "(", "$", "event", ")", ";", "if", "(", "$", "plugin", "||", "!", "$", "plugin", "->", "original_name", ")", "{", "$", "dir", "=", "JFusionFramework", "::", "getPluginPath", "(", "$", "name", ")", ";", "if", "(", "!", "$", "name", "||", "!", "is_dir", "(", "Path", "::", "clean", "(", "$", "dir", ")", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'UNINSTALL_ERROR_PATH'", ")", ")", ";", "}", "else", "{", "/**\n\t\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t\t * Remove Language files Processing Section\n\t\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t\t */", "// Get the extension manifest object", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "$", "dir", ")", ";", "if", "(", "is_null", "(", "$", "manifest", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'INSTALL_NOT_VALID_PLUGIN'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "manifest", "=", "$", "manifest", ";", "// remove files", "if", "(", "!", "Folder", "::", "delete", "(", "$", "dir", ")", ")", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'UNINSTALL_ERROR_DELETE'", ")", ")", ";", "}", "else", "{", "//return success", "$", "msg", "=", "Text", "::", "_", "(", "'PLUGIN'", ")", ".", "' '", ".", "$", "name", ".", "' '", ".", "Text", "::", "_", "(", "'UNINSTALL'", ")", ".", "': '", ".", "Text", "::", "_", "(", "'SUCCESS'", ")", ";", "$", "result", "[", "'message'", "]", "=", "$", "msg", ";", "$", "result", "[", "'status'", "]", "=", "true", ";", "}", "}", "}", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "result", "[", "'message'", "]", "=", "$", "name", ".", "' '", ".", "$", "e", "->", "getMessage", "(", ")", ";", "$", "this", "->", "installer", "->", "abort", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
handles JFusion plugin un-installation @param string $name name of the JFusion plugin used @return array
[ "handles", "JFusion", "plugin", "un", "-", "installation" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L233-L320
jfusion/org.jfusion.framework
src/Installer/Plugin.php
Plugin.copy
function copy($name, $new_name, $update = false) { //replace not-allowed characters with _ $new_name = preg_replace('/([^a-zA-Z0-9_])/', '_', $new_name); //initialise response element $result = array(); $result['status'] = false; if ($name && $new_name) { //check to see if an integration was selected $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('count(*)') ->from('#__jfusion') ->where('original_name IS NULL') ->where('name LIKE ' . $db->quote($name)); $db->setQuery($query); $record = $db->loadResult(); $query = $db->getQuery(true) ->select('id') ->from('#__jfusion') ->where('name = ' . $db->quote($new_name)); $db->setQuery($query); $exsist = $db->loadResult(); if ($exsist) { throw new RuntimeException($new_name . ' ' . Text::_('ALREADY_IN_USE')); } else if ($record) { $JFusionPlugin = Factory::getAdmin($name); if ($JFusionPlugin->multiInstance()) { $db = Factory::getDBO(); if (!$update) { //add the new entry in the JFusion plugin table $query = $db->getQuery(true) ->select('*') ->from('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $plugin_entry = $db->loadObject(); $plugin_entry->name = $new_name; $plugin_entry->id = null; //only change the original name if this is not a copy itself if (empty($plugin_entry->original_name)) { $plugin_entry->original_name = $name; } $db->insertObject('#__jfusion', $plugin_entry, 'id'); } $result['message'] = $new_name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('COPY') . ' ' . Text::_('SUCCESS'); $result['status'] = true; } else { throw new RuntimeException(Text::_('CANT_COPY')); } } else { throw new RuntimeException(Text::_('INVALID_SELECTED')); } } else { throw new RuntimeException(Text::_('NONE_SELECTED')); } return $result; }
php
function copy($name, $new_name, $update = false) { //replace not-allowed characters with _ $new_name = preg_replace('/([^a-zA-Z0-9_])/', '_', $new_name); //initialise response element $result = array(); $result['status'] = false; if ($name && $new_name) { //check to see if an integration was selected $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('count(*)') ->from('#__jfusion') ->where('original_name IS NULL') ->where('name LIKE ' . $db->quote($name)); $db->setQuery($query); $record = $db->loadResult(); $query = $db->getQuery(true) ->select('id') ->from('#__jfusion') ->where('name = ' . $db->quote($new_name)); $db->setQuery($query); $exsist = $db->loadResult(); if ($exsist) { throw new RuntimeException($new_name . ' ' . Text::_('ALREADY_IN_USE')); } else if ($record) { $JFusionPlugin = Factory::getAdmin($name); if ($JFusionPlugin->multiInstance()) { $db = Factory::getDBO(); if (!$update) { //add the new entry in the JFusion plugin table $query = $db->getQuery(true) ->select('*') ->from('#__jfusion') ->where('name = ' . $db->quote($name)); $db->setQuery($query); $plugin_entry = $db->loadObject(); $plugin_entry->name = $new_name; $plugin_entry->id = null; //only change the original name if this is not a copy itself if (empty($plugin_entry->original_name)) { $plugin_entry->original_name = $name; } $db->insertObject('#__jfusion', $plugin_entry, 'id'); } $result['message'] = $new_name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('COPY') . ' ' . Text::_('SUCCESS'); $result['status'] = true; } else { throw new RuntimeException(Text::_('CANT_COPY')); } } else { throw new RuntimeException(Text::_('INVALID_SELECTED')); } } else { throw new RuntimeException(Text::_('NONE_SELECTED')); } return $result; }
[ "function", "copy", "(", "$", "name", ",", "$", "new_name", ",", "$", "update", "=", "false", ")", "{", "//replace not-allowed characters with _", "$", "new_name", "=", "preg_replace", "(", "'/([^a-zA-Z0-9_])/'", ",", "'_'", ",", "$", "new_name", ")", ";", "//initialise response element", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'status'", "]", "=", "false", ";", "if", "(", "$", "name", "&&", "$", "new_name", ")", "{", "//check to see if an integration was selected", "$", "db", "=", "Factory", "::", "getDBO", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'count(*)'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'original_name IS NULL'", ")", "->", "where", "(", "'name LIKE '", ".", "$", "db", "->", "quote", "(", "$", "name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "record", "=", "$", "db", "->", "loadResult", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'id'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "new_name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "exsist", "=", "$", "db", "->", "loadResult", "(", ")", ";", "if", "(", "$", "exsist", ")", "{", "throw", "new", "RuntimeException", "(", "$", "new_name", ".", "' '", ".", "Text", "::", "_", "(", "'ALREADY_IN_USE'", ")", ")", ";", "}", "else", "if", "(", "$", "record", ")", "{", "$", "JFusionPlugin", "=", "Factory", "::", "getAdmin", "(", "$", "name", ")", ";", "if", "(", "$", "JFusionPlugin", "->", "multiInstance", "(", ")", ")", "{", "$", "db", "=", "Factory", "::", "getDBO", "(", ")", ";", "if", "(", "!", "$", "update", ")", "{", "//add the new entry in the JFusion plugin table", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'*'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "name", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "plugin_entry", "=", "$", "db", "->", "loadObject", "(", ")", ";", "$", "plugin_entry", "->", "name", "=", "$", "new_name", ";", "$", "plugin_entry", "->", "id", "=", "null", ";", "//only change the original name if this is not a copy itself", "if", "(", "empty", "(", "$", "plugin_entry", "->", "original_name", ")", ")", "{", "$", "plugin_entry", "->", "original_name", "=", "$", "name", ";", "}", "$", "db", "->", "insertObject", "(", "'#__jfusion'", ",", "$", "plugin_entry", ",", "'id'", ")", ";", "}", "$", "result", "[", "'message'", "]", "=", "$", "new_name", ".", "': '", ".", "Text", "::", "_", "(", "'PLUGIN'", ")", ".", "' '", ".", "$", "name", ".", "' '", ".", "Text", "::", "_", "(", "'COPY'", ")", ".", "' '", ".", "Text", "::", "_", "(", "'SUCCESS'", ")", ";", "$", "result", "[", "'status'", "]", "=", "true", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'CANT_COPY'", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'INVALID_SELECTED'", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "Text", "::", "_", "(", "'NONE_SELECTED'", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
handles copying JFusion plugins @param string $name name of the JFusion plugin used @param string $new_name name of the copied plugin @param boolean $update mark if we updating a copied plugin @throws RuntimeException @return boolean
[ "handles", "copying", "JFusion", "plugins" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L332-L396
jfusion/org.jfusion.framework
src/Installer/Plugin.php
Plugin.getManifest
function getManifest($dir) { $file = $dir . '/jfusion.xml'; $this->installer->setPath('manifest', $file); // If we cannot load the xml file return null $xml = JFusionFramework::getXml($file); if (!($xml instanceof SimpleXMLElement) || ($xml->getName() != 'extension')) { // Free up xml parser memory and return null unset($xml); $xml = null; } else { /** * Check that the plugin is an actual JFusion plugin */ $type = $this->getAttribute($xml, 'type'); if ($type !== 'jfusion') { //Free up xml parser memory and return null unset ($xml); $xml = null; } } // Valid manifest file return the object return $xml; }
php
function getManifest($dir) { $file = $dir . '/jfusion.xml'; $this->installer->setPath('manifest', $file); // If we cannot load the xml file return null $xml = JFusionFramework::getXml($file); if (!($xml instanceof SimpleXMLElement) || ($xml->getName() != 'extension')) { // Free up xml parser memory and return null unset($xml); $xml = null; } else { /** * Check that the plugin is an actual JFusion plugin */ $type = $this->getAttribute($xml, 'type'); if ($type !== 'jfusion') { //Free up xml parser memory and return null unset ($xml); $xml = null; } } // Valid manifest file return the object return $xml; }
[ "function", "getManifest", "(", "$", "dir", ")", "{", "$", "file", "=", "$", "dir", ".", "'/jfusion.xml'", ";", "$", "this", "->", "installer", "->", "setPath", "(", "'manifest'", ",", "$", "file", ")", ";", "// If we cannot load the xml file return null", "$", "xml", "=", "JFusionFramework", "::", "getXml", "(", "$", "file", ")", ";", "if", "(", "!", "(", "$", "xml", "instanceof", "SimpleXMLElement", ")", "||", "(", "$", "xml", "->", "getName", "(", ")", "!=", "'extension'", ")", ")", "{", "// Free up xml parser memory and return null", "unset", "(", "$", "xml", ")", ";", "$", "xml", "=", "null", ";", "}", "else", "{", "/**\n * Check that the plugin is an actual JFusion plugin\n */", "$", "type", "=", "$", "this", "->", "getAttribute", "(", "$", "xml", ",", "'type'", ")", ";", "if", "(", "$", "type", "!==", "'jfusion'", ")", "{", "//Free up xml parser memory and return null", "unset", "(", "$", "xml", ")", ";", "$", "xml", "=", "null", ";", "}", "}", "// Valid manifest file return the object", "return", "$", "xml", ";", "}" ]
load manifest file with installation information @param string $dir Directory @return SimpleXMLElement object (or null)
[ "load", "manifest", "file", "with", "installation", "information" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L405-L432
jfusion/org.jfusion.framework
src/Installer/Plugin.php
Plugin.getFiles
function getFiles($folder, $name) { $filesArray = array(); $files = Folder::files($folder, null, false, true); $path = JFusionFramework::getPluginPath($name); foreach ($files as $file) { $file = str_replace($path . '/', '', $file); $file = str_replace($path . '\\', '', $file); $data = file_get_contents($file); $filesArray[] = array('name' => $file, 'data' => $data); } $folders = Folder::folders($folder, null, false, true); if (!empty($folders)) { foreach ($folders as $f) { $filesArray = array_merge($filesArray, $this->getFiles($f, $name)); } } return $filesArray; }
php
function getFiles($folder, $name) { $filesArray = array(); $files = Folder::files($folder, null, false, true); $path = JFusionFramework::getPluginPath($name); foreach ($files as $file) { $file = str_replace($path . '/', '', $file); $file = str_replace($path . '\\', '', $file); $data = file_get_contents($file); $filesArray[] = array('name' => $file, 'data' => $data); } $folders = Folder::folders($folder, null, false, true); if (!empty($folders)) { foreach ($folders as $f) { $filesArray = array_merge($filesArray, $this->getFiles($f, $name)); } } return $filesArray; }
[ "function", "getFiles", "(", "$", "folder", ",", "$", "name", ")", "{", "$", "filesArray", "=", "array", "(", ")", ";", "$", "files", "=", "Folder", "::", "files", "(", "$", "folder", ",", "null", ",", "false", ",", "true", ")", ";", "$", "path", "=", "JFusionFramework", "::", "getPluginPath", "(", "$", "name", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "file", "=", "str_replace", "(", "$", "path", ".", "'/'", ",", "''", ",", "$", "file", ")", ";", "$", "file", "=", "str_replace", "(", "$", "path", ".", "'\\\\'", ",", "''", ",", "$", "file", ")", ";", "$", "data", "=", "file_get_contents", "(", "$", "file", ")", ";", "$", "filesArray", "[", "]", "=", "array", "(", "'name'", "=>", "$", "file", ",", "'data'", "=>", "$", "data", ")", ";", "}", "$", "folders", "=", "Folder", "::", "folders", "(", "$", "folder", ",", "null", ",", "false", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "folders", ")", ")", "{", "foreach", "(", "$", "folders", "as", "$", "f", ")", "{", "$", "filesArray", "=", "array_merge", "(", "$", "filesArray", ",", "$", "this", "->", "getFiles", "(", "$", "f", ",", "$", "name", ")", ")", ";", "}", "}", "return", "$", "filesArray", ";", "}" ]
get files function @param string $folder folder name @param string $name name @return array files
[ "get", "files", "function" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L442-L462
jfusion/org.jfusion.framework
src/Installer/Plugin.php
Plugin.getAttribute
function getAttribute($xml, $attribute) { if($xml instanceof SimpleXMLElement) { $attributes = $xml->attributes(); if (isset($attributes[$attribute])) { $xml = (string)$attributes[$attribute]; } else { $xml = null; } } else { $xml = null; } return $xml; }
php
function getAttribute($xml, $attribute) { if($xml instanceof SimpleXMLElement) { $attributes = $xml->attributes(); if (isset($attributes[$attribute])) { $xml = (string)$attributes[$attribute]; } else { $xml = null; } } else { $xml = null; } return $xml; }
[ "function", "getAttribute", "(", "$", "xml", ",", "$", "attribute", ")", "{", "if", "(", "$", "xml", "instanceof", "SimpleXMLElement", ")", "{", "$", "attributes", "=", "$", "xml", "->", "attributes", "(", ")", ";", "if", "(", "isset", "(", "$", "attributes", "[", "$", "attribute", "]", ")", ")", "{", "$", "xml", "=", "(", "string", ")", "$", "attributes", "[", "$", "attribute", "]", ";", "}", "else", "{", "$", "xml", "=", "null", ";", "}", "}", "else", "{", "$", "xml", "=", "null", ";", "}", "return", "$", "xml", ";", "}" ]
getAttribute @param SimpleXMLElement $xml xml object @param string $attribute attribute name @return string result
[ "getAttribute" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L472-L485
phug-php/formatter
src/Phug/Formatter/Element/AbstractAssignmentContainerElement.php
AbstractAssignmentContainerElement.addAssignment
public function addAssignment(AssignmentElement $element) { $element->setContainer($this); $this->getAssignments()->attach($element); return $this; }
php
public function addAssignment(AssignmentElement $element) { $element->setContainer($this); $this->getAssignments()->attach($element); return $this; }
[ "public", "function", "addAssignment", "(", "AssignmentElement", "$", "element", ")", "{", "$", "element", "->", "setContainer", "(", "$", "this", ")", ";", "$", "this", "->", "getAssignments", "(", ")", "->", "attach", "(", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Add assignment to the markup. @param AssignmentElement $element @return $this
[ "Add", "assignment", "to", "the", "markup", "." ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/Element/AbstractAssignmentContainerElement.php#L20-L26
phug-php/formatter
src/Phug/Formatter/Element/AbstractAssignmentContainerElement.php
AbstractAssignmentContainerElement.getAssignmentsByName
public function getAssignmentsByName($name) { $result = []; foreach ($this->getAssignments() as $assignment) { /* @var AssignmentElement $assignment */ if ($assignment->getName() === $name) { $result[] = $assignment; } } return $result; }
php
public function getAssignmentsByName($name) { $result = []; foreach ($this->getAssignments() as $assignment) { /* @var AssignmentElement $assignment */ if ($assignment->getName() === $name) { $result[] = $assignment; } } return $result; }
[ "public", "function", "getAssignmentsByName", "(", "$", "name", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getAssignments", "(", ")", "as", "$", "assignment", ")", "{", "/* @var AssignmentElement $assignment */", "if", "(", "$", "assignment", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "$", "result", "[", "]", "=", "$", "assignment", ";", "}", "}", "return", "$", "result", ";", "}" ]
Return markup assignments list of a specific name. @param $name @return AssignmentElement[]
[ "Return", "markup", "assignments", "list", "of", "a", "specific", "name", "." ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/Element/AbstractAssignmentContainerElement.php#L63-L75
qcubed/orm
src/Codegen/TypeTable.php
TypeTable.literal
public static function literal($mixColValue) { if (is_null($mixColValue)) { return 'null'; } elseif (is_integer($mixColValue)) { return $mixColValue; } elseif (is_bool($mixColValue)) { return ($mixColValue ? 'true' : 'false'); } elseif (is_float($mixColValue)) { return "(float)$mixColValue"; } elseif (is_object($mixColValue)) { return "t('" . $mixColValue->_toString() . "')"; } // whatever is suitable for the constructor of the object else { return "t('" . str_replace("'", "\\'", $mixColValue) . "')"; } }
php
public static function literal($mixColValue) { if (is_null($mixColValue)) { return 'null'; } elseif (is_integer($mixColValue)) { return $mixColValue; } elseif (is_bool($mixColValue)) { return ($mixColValue ? 'true' : 'false'); } elseif (is_float($mixColValue)) { return "(float)$mixColValue"; } elseif (is_object($mixColValue)) { return "t('" . $mixColValue->_toString() . "')"; } // whatever is suitable for the constructor of the object else { return "t('" . str_replace("'", "\\'", $mixColValue) . "')"; } }
[ "public", "static", "function", "literal", "(", "$", "mixColValue", ")", "{", "if", "(", "is_null", "(", "$", "mixColValue", ")", ")", "{", "return", "'null'", ";", "}", "elseif", "(", "is_integer", "(", "$", "mixColValue", ")", ")", "{", "return", "$", "mixColValue", ";", "}", "elseif", "(", "is_bool", "(", "$", "mixColValue", ")", ")", "{", "return", "(", "$", "mixColValue", "?", "'true'", ":", "'false'", ")", ";", "}", "elseif", "(", "is_float", "(", "$", "mixColValue", ")", ")", "{", "return", "\"(float)$mixColValue\"", ";", "}", "elseif", "(", "is_object", "(", "$", "mixColValue", ")", ")", "{", "return", "\"t('\"", ".", "$", "mixColValue", "->", "_toString", "(", ")", ".", "\"')\"", ";", "}", "// whatever is suitable for the constructor of the object", "else", "{", "return", "\"t('\"", ".", "str_replace", "(", "\"'\"", ",", "\"\\\\'\"", ",", "$", "mixColValue", ")", ".", "\"')\"", ";", "}", "}" ]
Returns the string that will be used to represent the literal value given when codegenning a type table @param mixed $mixColValue @return string
[ "Returns", "the", "string", "that", "will", "be", "used", "to", "represent", "the", "literal", "value", "given", "when", "codegenning", "a", "type", "table" ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/TypeTable.php#L99-L115
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.initOutputConfig
private function initOutputConfig(array $outputOptions) { $this->scanFailure = false; $this->outputFormat = $outputOptions['out_format']; $this->outputLevel = $outputOptions['out_level']; $this->preventAnsiColors = $outputOptions['out_no_ansi']; $this->preventEcho = $outputOptions['out_no_echo']; if ($this->outputFormat === 'json') { $this->outputFormatText = false; $this->outputFormatJson = true; $this->preventAnsiColors = true; } if ($this->outputLevel > 0) { $this->writeResultHeadlines(); } }
php
private function initOutputConfig(array $outputOptions) { $this->scanFailure = false; $this->outputFormat = $outputOptions['out_format']; $this->outputLevel = $outputOptions['out_level']; $this->preventAnsiColors = $outputOptions['out_no_ansi']; $this->preventEcho = $outputOptions['out_no_echo']; if ($this->outputFormat === 'json') { $this->outputFormatText = false; $this->outputFormatJson = true; $this->preventAnsiColors = true; } if ($this->outputLevel > 0) { $this->writeResultHeadlines(); } }
[ "private", "function", "initOutputConfig", "(", "array", "$", "outputOptions", ")", "{", "$", "this", "->", "scanFailure", "=", "false", ";", "$", "this", "->", "outputFormat", "=", "$", "outputOptions", "[", "'out_format'", "]", ";", "$", "this", "->", "outputLevel", "=", "$", "outputOptions", "[", "'out_level'", "]", ";", "$", "this", "->", "preventAnsiColors", "=", "$", "outputOptions", "[", "'out_no_ansi'", "]", ";", "$", "this", "->", "preventEcho", "=", "$", "outputOptions", "[", "'out_no_echo'", "]", ";", "if", "(", "$", "this", "->", "outputFormat", "===", "'json'", ")", "{", "$", "this", "->", "outputFormatText", "=", "false", ";", "$", "this", "->", "outputFormatJson", "=", "true", ";", "$", "this", "->", "preventAnsiColors", "=", "true", ";", "}", "if", "(", "$", "this", "->", "outputLevel", ">", "0", ")", "{", "$", "this", "->", "writeResultHeadlines", "(", ")", ";", "}", "}" ]
@param array $outputOptions @codeCoverageIgnore
[ "@param", "array", "$outputOptions" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L44-L61
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.writeSingleMappingResult
private function writeSingleMappingResult( CoverFishPHPUnitTest $coverFishTest, CoverFishResult $coverFishResult ) { /** @var CoverFishMapping $coverMappings */ foreach ($coverFishTest->getCoverMappings() as $coverMappings) { $coverFishResult->addTestCount(); if (false === $coverMappings->getValidatorResult()->isPass()) { $this->scanFailure = true; $this->writeFailureStream($coverFishResult, $coverFishTest, $coverMappings); $this->writeProgress(self::MACRO_FAILURE); // stop on failure defined? break ... do not check further methods, exit! if ($this->scanner->isStopOnFailure()) { break; } } else { $coverFishResult->addPassCount(); $this->writeProgress(self::MACRO_PASS); } } if (count($coverFishTest->getCoverMappings()) === 0) { $this->writeProgress(self::MACRO_SKIPPED); } }
php
private function writeSingleMappingResult( CoverFishPHPUnitTest $coverFishTest, CoverFishResult $coverFishResult ) { /** @var CoverFishMapping $coverMappings */ foreach ($coverFishTest->getCoverMappings() as $coverMappings) { $coverFishResult->addTestCount(); if (false === $coverMappings->getValidatorResult()->isPass()) { $this->scanFailure = true; $this->writeFailureStream($coverFishResult, $coverFishTest, $coverMappings); $this->writeProgress(self::MACRO_FAILURE); // stop on failure defined? break ... do not check further methods, exit! if ($this->scanner->isStopOnFailure()) { break; } } else { $coverFishResult->addPassCount(); $this->writeProgress(self::MACRO_PASS); } } if (count($coverFishTest->getCoverMappings()) === 0) { $this->writeProgress(self::MACRO_SKIPPED); } }
[ "private", "function", "writeSingleMappingResult", "(", "CoverFishPHPUnitTest", "$", "coverFishTest", ",", "CoverFishResult", "$", "coverFishResult", ")", "{", "/** @var CoverFishMapping $coverMappings */", "foreach", "(", "$", "coverFishTest", "->", "getCoverMappings", "(", ")", "as", "$", "coverMappings", ")", "{", "$", "coverFishResult", "->", "addTestCount", "(", ")", ";", "if", "(", "false", "===", "$", "coverMappings", "->", "getValidatorResult", "(", ")", "->", "isPass", "(", ")", ")", "{", "$", "this", "->", "scanFailure", "=", "true", ";", "$", "this", "->", "writeFailureStream", "(", "$", "coverFishResult", ",", "$", "coverFishTest", ",", "$", "coverMappings", ")", ";", "$", "this", "->", "writeProgress", "(", "self", "::", "MACRO_FAILURE", ")", ";", "// stop on failure defined? break ... do not check further methods, exit!", "if", "(", "$", "this", "->", "scanner", "->", "isStopOnFailure", "(", ")", ")", "{", "break", ";", "}", "}", "else", "{", "$", "coverFishResult", "->", "addPassCount", "(", ")", ";", "$", "this", "->", "writeProgress", "(", "self", "::", "MACRO_PASS", ")", ";", "}", "}", "if", "(", "count", "(", "$", "coverFishTest", "->", "getCoverMappings", "(", ")", ")", "===", "0", ")", "{", "$", "this", "->", "writeProgress", "(", "self", "::", "MACRO_SKIPPED", ")", ";", "}", "}" ]
output mapping/scanning result of each scanned file @param CoverFishPHPUnitTest $coverFishTest @param CoverFishResult $coverFishResult
[ "output", "mapping", "/", "scanning", "result", "of", "each", "scanned", "file" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L138-L163
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.writeResult
public function writeResult(CoverFishResult $coverFishResult) { /** @var CoverFishPHPUnitFile $coverFishUnitFile */ foreach ($coverFishResult->getUnits() as $coverFishUnitFile) { $this->scanFailure = false; $coverFishResult->setFailureStream(null); if (false === $this->checkForEmptyUnitTestClass($coverFishUnitFile)) { continue; } $this->writeSingleTestResult($coverFishUnitFile, $coverFishResult); $this->writeFinalCheckResults($coverFishResult); } return $this->outputResult($coverFishResult); }
php
public function writeResult(CoverFishResult $coverFishResult) { /** @var CoverFishPHPUnitFile $coverFishUnitFile */ foreach ($coverFishResult->getUnits() as $coverFishUnitFile) { $this->scanFailure = false; $coverFishResult->setFailureStream(null); if (false === $this->checkForEmptyUnitTestClass($coverFishUnitFile)) { continue; } $this->writeSingleTestResult($coverFishUnitFile, $coverFishResult); $this->writeFinalCheckResults($coverFishResult); } return $this->outputResult($coverFishResult); }
[ "public", "function", "writeResult", "(", "CoverFishResult", "$", "coverFishResult", ")", "{", "/** @var CoverFishPHPUnitFile $coverFishUnitFile */", "foreach", "(", "$", "coverFishResult", "->", "getUnits", "(", ")", "as", "$", "coverFishUnitFile", ")", "{", "$", "this", "->", "scanFailure", "=", "false", ";", "$", "coverFishResult", "->", "setFailureStream", "(", "null", ")", ";", "if", "(", "false", "===", "$", "this", "->", "checkForEmptyUnitTestClass", "(", "$", "coverFishUnitFile", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "writeSingleTestResult", "(", "$", "coverFishUnitFile", ",", "$", "coverFishResult", ")", ";", "$", "this", "->", "writeFinalCheckResults", "(", "$", "coverFishResult", ")", ";", "}", "return", "$", "this", "->", "outputResult", "(", "$", "coverFishResult", ")", ";", "}" ]
handle single file/unit test result (process/failureStream and final check result) @param CoverFishResult $coverFishResult @return null|string
[ "handle", "single", "file", "/", "unit", "test", "result", "(", "process", "/", "failureStream", "and", "final", "check", "result", ")" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L172-L188
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.writeFinalCheckResults
private function writeFinalCheckResults(CoverFishResult $coverFishResult) { if (false === $this->scanFailure) { $this->writeFileResult(self::FILE_PASS, null); } else { $this->writeFileResult(self::FILE_FAILURE, $coverFishResult->getFailureStream()); } $this->jsonResults[] = $this->jsonResult; }
php
private function writeFinalCheckResults(CoverFishResult $coverFishResult) { if (false === $this->scanFailure) { $this->writeFileResult(self::FILE_PASS, null); } else { $this->writeFileResult(self::FILE_FAILURE, $coverFishResult->getFailureStream()); } $this->jsonResults[] = $this->jsonResult; }
[ "private", "function", "writeFinalCheckResults", "(", "CoverFishResult", "$", "coverFishResult", ")", "{", "if", "(", "false", "===", "$", "this", "->", "scanFailure", ")", "{", "$", "this", "->", "writeFileResult", "(", "self", "::", "FILE_PASS", ",", "null", ")", ";", "}", "else", "{", "$", "this", "->", "writeFileResult", "(", "self", "::", "FILE_FAILURE", ",", "$", "coverFishResult", "->", "getFailureStream", "(", ")", ")", ";", "}", "$", "this", "->", "jsonResults", "[", "]", "=", "$", "this", "->", "jsonResult", ";", "}" ]
write single file check result @param CoverFishResult $coverFishResult
[ "write", "single", "file", "check", "result" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L217-L226
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.writeJsonFailureStream
private function writeJsonFailureStream( CoverFishResult $coverFishResult, CoverFishPHPUnitTest $unitTest, CoverFishMessageError $mappingError, $coverLine ) { $this->jsonResult['errorCount'] = $coverFishResult->getFailureCount(); $this->jsonResult['errorMessage'] = $mappingError->getMessageTitle(); $this->jsonResult['errorCode'] = $mappingError->getMessageCode(); $this->jsonResult['cover'] = $coverLine; $this->jsonResult['method'] = $unitTest->getSignature(); $this->jsonResult['line'] = $unitTest->getLine(); $this->jsonResult['file'] = $unitTest->getFile(); }
php
private function writeJsonFailureStream( CoverFishResult $coverFishResult, CoverFishPHPUnitTest $unitTest, CoverFishMessageError $mappingError, $coverLine ) { $this->jsonResult['errorCount'] = $coverFishResult->getFailureCount(); $this->jsonResult['errorMessage'] = $mappingError->getMessageTitle(); $this->jsonResult['errorCode'] = $mappingError->getMessageCode(); $this->jsonResult['cover'] = $coverLine; $this->jsonResult['method'] = $unitTest->getSignature(); $this->jsonResult['line'] = $unitTest->getLine(); $this->jsonResult['file'] = $unitTest->getFile(); }
[ "private", "function", "writeJsonFailureStream", "(", "CoverFishResult", "$", "coverFishResult", ",", "CoverFishPHPUnitTest", "$", "unitTest", ",", "CoverFishMessageError", "$", "mappingError", ",", "$", "coverLine", ")", "{", "$", "this", "->", "jsonResult", "[", "'errorCount'", "]", "=", "$", "coverFishResult", "->", "getFailureCount", "(", ")", ";", "$", "this", "->", "jsonResult", "[", "'errorMessage'", "]", "=", "$", "mappingError", "->", "getMessageTitle", "(", ")", ";", "$", "this", "->", "jsonResult", "[", "'errorCode'", "]", "=", "$", "mappingError", "->", "getMessageCode", "(", ")", ";", "$", "this", "->", "jsonResult", "[", "'cover'", "]", "=", "$", "coverLine", ";", "$", "this", "->", "jsonResult", "[", "'method'", "]", "=", "$", "unitTest", "->", "getSignature", "(", ")", ";", "$", "this", "->", "jsonResult", "[", "'line'", "]", "=", "$", "unitTest", "->", "getLine", "(", ")", ";", "$", "this", "->", "jsonResult", "[", "'file'", "]", "=", "$", "unitTest", "->", "getFile", "(", ")", ";", "}" ]
write single json error line @param CoverFishResult $coverFishResult @param CoverFishPHPUnitTest $unitTest @param CoverFishMessageError $mappingError @param $coverLine
[ "write", "single", "json", "error", "line" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L236-L249
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.getMacroLineInfo
protected function getMacroLineInfo($failureCount, CoverFishPHPUnitTest $unitTest) { $lineInfoMacro = '%sError #%s in method "%s" (L:~%s)'; if ($this->outputLevel > 1) { $lineInfoMacro = '%sError #%s in method "%s", Line ~%s'; } return sprintf($lineInfoMacro, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplWhiteColor($failureCount) : $failureCount, (false === $this->preventAnsiColors) ? Color::tplWhiteColor($unitTest->getSignature()) : $unitTest->getSignature(), (false === $this->preventAnsiColors) ? Color::tplWhiteColor($unitTest->getLine()) : $unitTest->getLine(), PHP_EOL ); }
php
protected function getMacroLineInfo($failureCount, CoverFishPHPUnitTest $unitTest) { $lineInfoMacro = '%sError #%s in method "%s" (L:~%s)'; if ($this->outputLevel > 1) { $lineInfoMacro = '%sError #%s in method "%s", Line ~%s'; } return sprintf($lineInfoMacro, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplWhiteColor($failureCount) : $failureCount, (false === $this->preventAnsiColors) ? Color::tplWhiteColor($unitTest->getSignature()) : $unitTest->getSignature(), (false === $this->preventAnsiColors) ? Color::tplWhiteColor($unitTest->getLine()) : $unitTest->getLine(), PHP_EOL ); }
[ "protected", "function", "getMacroLineInfo", "(", "$", "failureCount", ",", "CoverFishPHPUnitTest", "$", "unitTest", ")", "{", "$", "lineInfoMacro", "=", "'%sError #%s in method \"%s\" (L:~%s)'", ";", "if", "(", "$", "this", "->", "outputLevel", ">", "1", ")", "{", "$", "lineInfoMacro", "=", "'%sError #%s in method \"%s\", Line ~%s'", ";", "}", "return", "sprintf", "(", "$", "lineInfoMacro", ",", "$", "this", "->", "setIndent", "(", "self", "::", "MACRO_CONFIG_DETAIL_LINE_INDENT", ")", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplWhiteColor", "(", "$", "failureCount", ")", ":", "$", "failureCount", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplWhiteColor", "(", "$", "unitTest", "->", "getSignature", "(", ")", ")", ":", "$", "unitTest", "->", "getSignature", "(", ")", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplWhiteColor", "(", "$", "unitTest", "->", "getLine", "(", ")", ")", ":", "$", "unitTest", "->", "getLine", "(", ")", ",", "PHP_EOL", ")", ";", "}" ]
message block macro, line 01, message title @param int $failureCount @param CoverFishPHPUnitTest $unitTest @return string
[ "message", "block", "macro", "line", "01", "message", "title" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L269-L289
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.getMacroFileInfo
protected function getMacroFileInfo(CoverFishPHPUnitTest $unitTest) { $fileInfoMacro = '%s%s%s: %s'; return sprintf($fileInfoMacro, PHP_EOL, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('File') : 'File' , $unitTest->getFileAndPath() ); }
php
protected function getMacroFileInfo(CoverFishPHPUnitTest $unitTest) { $fileInfoMacro = '%s%s%s: %s'; return sprintf($fileInfoMacro, PHP_EOL, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('File') : 'File' , $unitTest->getFileAndPath() ); }
[ "protected", "function", "getMacroFileInfo", "(", "CoverFishPHPUnitTest", "$", "unitTest", ")", "{", "$", "fileInfoMacro", "=", "'%s%s%s: %s'", ";", "return", "sprintf", "(", "$", "fileInfoMacro", ",", "PHP_EOL", ",", "$", "this", "->", "setIndent", "(", "self", "::", "MACRO_CONFIG_DETAIL_LINE_INDENT", ")", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplDarkGrayColor", "(", "'File'", ")", ":", "'File'", ",", "$", "unitTest", "->", "getFileAndPath", "(", ")", ")", ";", "}" ]
message block macro, line 02, cover/annotation line @param CoverFishPHPUnitTest $unitTest @return string
[ "message", "block", "macro", "line", "02", "cover", "/", "annotation", "line" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L298-L310
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.getMacroCoverInfo
protected function getMacroCoverInfo($coverLine) { $lineCoverMacro = '%s%s%s: %s%s'; return sprintf($lineCoverMacro, PHP_EOL, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('Annotation') : 'Annotation' , $coverLine, PHP_EOL ); }
php
protected function getMacroCoverInfo($coverLine) { $lineCoverMacro = '%s%s%s: %s%s'; return sprintf($lineCoverMacro, PHP_EOL, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('Annotation') : 'Annotation' , $coverLine, PHP_EOL ); }
[ "protected", "function", "getMacroCoverInfo", "(", "$", "coverLine", ")", "{", "$", "lineCoverMacro", "=", "'%s%s%s: %s%s'", ";", "return", "sprintf", "(", "$", "lineCoverMacro", ",", "PHP_EOL", ",", "$", "this", "->", "setIndent", "(", "self", "::", "MACRO_CONFIG_DETAIL_LINE_INDENT", ")", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplDarkGrayColor", "(", "'Annotation'", ")", ":", "'Annotation'", ",", "$", "coverLine", ",", "PHP_EOL", ")", ";", "}" ]
message block macro, line 03, cover/annotation line @param string $coverLine @return string
[ "message", "block", "macro", "line", "03", "cover", "/", "annotation", "line" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L318-L331
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.getMacroCoverErrorMessage
protected function getMacroCoverErrorMessage(CoverFishMessageError $mappingError) { $lineMessageMacro = '%s%s: %s '; if ($this->outputLevel > 1) { $lineMessageMacro = '%s%s: %s (ErrorCode: %s)'; } return sprintf($lineMessageMacro, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('Message') : 'Message', $mappingError->getMessageTitle(), $mappingError->getMessageCode() ); }
php
protected function getMacroCoverErrorMessage(CoverFishMessageError $mappingError) { $lineMessageMacro = '%s%s: %s '; if ($this->outputLevel > 1) { $lineMessageMacro = '%s%s: %s (ErrorCode: %s)'; } return sprintf($lineMessageMacro, $this->setIndent(self::MACRO_CONFIG_DETAIL_LINE_INDENT), (false === $this->preventAnsiColors) ? Color::tplDarkGrayColor('Message') : 'Message', $mappingError->getMessageTitle(), $mappingError->getMessageCode() ); }
[ "protected", "function", "getMacroCoverErrorMessage", "(", "CoverFishMessageError", "$", "mappingError", ")", "{", "$", "lineMessageMacro", "=", "'%s%s: %s '", ";", "if", "(", "$", "this", "->", "outputLevel", ">", "1", ")", "{", "$", "lineMessageMacro", "=", "'%s%s: %s (ErrorCode: %s)'", ";", "}", "return", "sprintf", "(", "$", "lineMessageMacro", ",", "$", "this", "->", "setIndent", "(", "self", "::", "MACRO_CONFIG_DETAIL_LINE_INDENT", ")", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplDarkGrayColor", "(", "'Message'", ")", ":", "'Message'", ",", "$", "mappingError", "->", "getMessageTitle", "(", ")", ",", "$", "mappingError", "->", "getMessageCode", "(", ")", ")", ";", "}" ]
message block macro, line 04, error message @param CoverFishMessageError $mappingError @return string
[ "message", "block", "macro", "line", "04", "error", "message" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L340-L356
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishOutput.php
CoverFishOutput.writeFailureStream
private function writeFailureStream( CoverFishResult $coverFishResult, CoverFishPHPUnitTest $unitTest, CoverFishMapping $coverMapping ) { /** @var CoverFishMessageError $mappingError */ foreach ($coverMapping->getValidatorResult()->getErrors() as $mappingError) { $coverFishResult->addFailureCount(); $coverLine = $mappingError->getErrorStreamTemplate($coverMapping, $this->preventAnsiColors); $this->writeJsonFailureStream($coverFishResult, $unitTest, $mappingError, $coverLine); if (0 === $this->outputLevel) { continue; } $coverFishResult->addFailureToStream(PHP_EOL); $lineInfo = $this->getMacroLineInfo($coverFishResult->getFailureCount(), $unitTest); $fileInfo = $this->getMacroFileInfo($unitTest); $lineCover = $this->getMacroCoverInfo($coverLine); $lineMessage = $this->getMacroCoverErrorMessage($mappingError); $coverFishResult->addFailureToStream($lineInfo); if ($this->outputLevel > 1) { $coverFishResult->addFailureToStream($fileInfo); } $coverFishResult->addFailureToStream($lineCover); $coverFishResult->addFailureToStream($lineMessage); $coverFishResult->addFailureToStream(PHP_EOL); } }
php
private function writeFailureStream( CoverFishResult $coverFishResult, CoverFishPHPUnitTest $unitTest, CoverFishMapping $coverMapping ) { /** @var CoverFishMessageError $mappingError */ foreach ($coverMapping->getValidatorResult()->getErrors() as $mappingError) { $coverFishResult->addFailureCount(); $coverLine = $mappingError->getErrorStreamTemplate($coverMapping, $this->preventAnsiColors); $this->writeJsonFailureStream($coverFishResult, $unitTest, $mappingError, $coverLine); if (0 === $this->outputLevel) { continue; } $coverFishResult->addFailureToStream(PHP_EOL); $lineInfo = $this->getMacroLineInfo($coverFishResult->getFailureCount(), $unitTest); $fileInfo = $this->getMacroFileInfo($unitTest); $lineCover = $this->getMacroCoverInfo($coverLine); $lineMessage = $this->getMacroCoverErrorMessage($mappingError); $coverFishResult->addFailureToStream($lineInfo); if ($this->outputLevel > 1) { $coverFishResult->addFailureToStream($fileInfo); } $coverFishResult->addFailureToStream($lineCover); $coverFishResult->addFailureToStream($lineMessage); $coverFishResult->addFailureToStream(PHP_EOL); } }
[ "private", "function", "writeFailureStream", "(", "CoverFishResult", "$", "coverFishResult", ",", "CoverFishPHPUnitTest", "$", "unitTest", ",", "CoverFishMapping", "$", "coverMapping", ")", "{", "/** @var CoverFishMessageError $mappingError */", "foreach", "(", "$", "coverMapping", "->", "getValidatorResult", "(", ")", "->", "getErrors", "(", ")", "as", "$", "mappingError", ")", "{", "$", "coverFishResult", "->", "addFailureCount", "(", ")", ";", "$", "coverLine", "=", "$", "mappingError", "->", "getErrorStreamTemplate", "(", "$", "coverMapping", ",", "$", "this", "->", "preventAnsiColors", ")", ";", "$", "this", "->", "writeJsonFailureStream", "(", "$", "coverFishResult", ",", "$", "unitTest", ",", "$", "mappingError", ",", "$", "coverLine", ")", ";", "if", "(", "0", "===", "$", "this", "->", "outputLevel", ")", "{", "continue", ";", "}", "$", "coverFishResult", "->", "addFailureToStream", "(", "PHP_EOL", ")", ";", "$", "lineInfo", "=", "$", "this", "->", "getMacroLineInfo", "(", "$", "coverFishResult", "->", "getFailureCount", "(", ")", ",", "$", "unitTest", ")", ";", "$", "fileInfo", "=", "$", "this", "->", "getMacroFileInfo", "(", "$", "unitTest", ")", ";", "$", "lineCover", "=", "$", "this", "->", "getMacroCoverInfo", "(", "$", "coverLine", ")", ";", "$", "lineMessage", "=", "$", "this", "->", "getMacroCoverErrorMessage", "(", "$", "mappingError", ")", ";", "$", "coverFishResult", "->", "addFailureToStream", "(", "$", "lineInfo", ")", ";", "if", "(", "$", "this", "->", "outputLevel", ">", "1", ")", "{", "$", "coverFishResult", "->", "addFailureToStream", "(", "$", "fileInfo", ")", ";", "}", "$", "coverFishResult", "->", "addFailureToStream", "(", "$", "lineCover", ")", ";", "$", "coverFishResult", "->", "addFailureToStream", "(", "$", "lineMessage", ")", ";", "$", "coverFishResult", "->", "addFailureToStream", "(", "PHP_EOL", ")", ";", "}", "}" ]
@param CoverFishResult $coverFishResult @param CoverFishPHPUnitTest $unitTest @param CoverFishMapping $coverMapping @return null
[ "@param", "CoverFishResult", "$coverFishResult", "@param", "CoverFishPHPUnitTest", "$unitTest", "@param", "CoverFishMapping", "$coverMapping" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishOutput.php#L365-L398
webforge-labs/psc-cms
lib/Psc/JS/Helper.php
Helper.convertHashMap
public static function convertHashMap(\stdClass $object, $quote = self::QUOTE_SINGLE) { $hash = '{'; $vars = get_object_vars($object); if (count($vars) > 0) { foreach ($vars as $key =>$value) { $hash .= sprintf('"%s": %s,', $key, self::convertValue($value,$quote)); // json encode kanns auch wenn wir statt single quotes double quotes für die keys nehmen } $hash = mb_substr($hash,0,-1); // letzte komma } $hash .= '}'; return $hash; }
php
public static function convertHashMap(\stdClass $object, $quote = self::QUOTE_SINGLE) { $hash = '{'; $vars = get_object_vars($object); if (count($vars) > 0) { foreach ($vars as $key =>$value) { $hash .= sprintf('"%s": %s,', $key, self::convertValue($value,$quote)); // json encode kanns auch wenn wir statt single quotes double quotes für die keys nehmen } $hash = mb_substr($hash,0,-1); // letzte komma } $hash .= '}'; return $hash; }
[ "public", "static", "function", "convertHashMap", "(", "\\", "stdClass", "$", "object", ",", "$", "quote", "=", "self", "::", "QUOTE_SINGLE", ")", "{", "$", "hash", "=", "'{'", ";", "$", "vars", "=", "get_object_vars", "(", "$", "object", ")", ";", "if", "(", "count", "(", "$", "vars", ")", ">", "0", ")", "{", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "hash", ".=", "sprintf", "(", "'\"%s\": %s,'", ",", "$", "key", ",", "self", "::", "convertValue", "(", "$", "value", ",", "$", "quote", ")", ")", ";", "// json encode kanns auch wenn wir statt single quotes double quotes für die keys nehmen", "}", "$", "hash", "=", "mb_substr", "(", "$", "hash", ",", "0", ",", "-", "1", ")", ";", "// letzte komma", "}", "$", "hash", ".=", "'}'", ";", "return", "$", "hash", ";", "}" ]
Wandelt ein Object in ein Javascript Object-Literal um @return string
[ "Wandelt", "ein", "Object", "in", "ein", "Javascript", "Object", "-", "Literal", "um" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/Helper.php#L91-L104
webforge-labs/psc-cms
lib/Psc/JS/Helper.php
Helper.requireLoad
public static function requireLoad(Array $requirements, Array $alias, $jsCode) { return sprintf( "requireLoad([%s], function (main%s) { // main is unshifted automatically\n %s\n});", self::buildRequirements($requirements), count($alias) > 0 ? ', '.implode(', ', $alias) : '', self::convertJSCode($jsCode) ); }
php
public static function requireLoad(Array $requirements, Array $alias, $jsCode) { return sprintf( "requireLoad([%s], function (main%s) { // main is unshifted automatically\n %s\n});", self::buildRequirements($requirements), count($alias) > 0 ? ', '.implode(', ', $alias) : '', self::convertJSCode($jsCode) ); }
[ "public", "static", "function", "requireLoad", "(", "Array", "$", "requirements", ",", "Array", "$", "alias", ",", "$", "jsCode", ")", "{", "return", "sprintf", "(", "\"requireLoad([%s], function (main%s) { // main is unshifted automatically\\n %s\\n});\"", ",", "self", "::", "buildRequirements", "(", "$", "requirements", ")", ",", "count", "(", "$", "alias", ")", ">", "0", "?", "', '", ".", "implode", "(", "', '", ",", "$", "alias", ")", ":", "''", ",", "self", "::", "convertJSCode", "(", "$", "jsCode", ")", ")", ";", "}" ]
This function loads inline script in blocking mode the application has to inject window.requireLoad this is a blocking way to load, because there is the requireLoad() function which is directly called, which concatenates the job to the boot.getLoader() the jobs can then be loaded with boot.getLoader().finished()
[ "This", "function", "loads", "inline", "script", "in", "blocking", "mode" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/Helper.php#L157-L164
webforge-labs/psc-cms
lib/Psc/JS/Helper.php
Helper.bootLoad
public static function bootLoad(Array $requirements, $alias = array(), $jsCode) { return self::requirejs('boot', 'boot', sprintf( "boot.getLoader().onRequire([%s], function (%s) {\n %s\n });", self::buildRequirements($requirements), implode(', ', $alias), self::convertJSCode($jsCode) )); }
php
public static function bootLoad(Array $requirements, $alias = array(), $jsCode) { return self::requirejs('boot', 'boot', sprintf( "boot.getLoader().onRequire([%s], function (%s) {\n %s\n });", self::buildRequirements($requirements), implode(', ', $alias), self::convertJSCode($jsCode) )); }
[ "public", "static", "function", "bootLoad", "(", "Array", "$", "requirements", ",", "$", "alias", "=", "array", "(", ")", ",", "$", "jsCode", ")", "{", "return", "self", "::", "requirejs", "(", "'boot'", ",", "'boot'", ",", "sprintf", "(", "\"boot.getLoader().onRequire([%s], function (%s) {\\n %s\\n });\"", ",", "self", "::", "buildRequirements", "(", "$", "requirements", ")", ",", "implode", "(", "', '", ",", "$", "alias", ")", ",", "self", "::", "convertJSCode", "(", "$", "jsCode", ")", ")", ")", ";", "}" ]
This function loads inline script in an HTML-page this is NON blocking way to load, because there the require is nested here use it in inline scripts which are directly loaded from the HTML on the index page (and only there) boot is required boot should have .getLoader() to attach the requirements and loading callback to @return string
[ "This", "function", "loads", "inline", "script", "in", "an", "HTML", "-", "page" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/Helper.php#L176-L183
Chill-project/Main
Form/Type/AppendScopeChoiceTypeTrait.php
AppendScopeChoiceTypeTrait.appendScopeChoices
protected function appendScopeChoices(FormBuilderInterface $builder, Role $role, Center $center, User $user, AuthorizationHelper $authorizationHelper, TranslatableStringHelper $translatableStringHelper, ObjectManager $om, $name = 'scope') { $reachableScopes = $authorizationHelper ->getReachableScopes($user, $role, $center); $choices = array(); foreach($reachableScopes as $scope) { $choices[$scope->getId()] = $translatableStringHelper ->localize($scope->getName()); } $dataTransformer = new ScopeTransformer($om); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) { $form = $event->getForm(); $form->add( $builder ->create($name, 'choice', array( 'choices' => $choices, 'auto_initialize' => false ) ) ->addModelTransformer($dataTransformer) ->getForm() ); }); }
php
protected function appendScopeChoices(FormBuilderInterface $builder, Role $role, Center $center, User $user, AuthorizationHelper $authorizationHelper, TranslatableStringHelper $translatableStringHelper, ObjectManager $om, $name = 'scope') { $reachableScopes = $authorizationHelper ->getReachableScopes($user, $role, $center); $choices = array(); foreach($reachableScopes as $scope) { $choices[$scope->getId()] = $translatableStringHelper ->localize($scope->getName()); } $dataTransformer = new ScopeTransformer($om); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($choices, $name, $dataTransformer, $builder) { $form = $event->getForm(); $form->add( $builder ->create($name, 'choice', array( 'choices' => $choices, 'auto_initialize' => false ) ) ->addModelTransformer($dataTransformer) ->getForm() ); }); }
[ "protected", "function", "appendScopeChoices", "(", "FormBuilderInterface", "$", "builder", ",", "Role", "$", "role", ",", "Center", "$", "center", ",", "User", "$", "user", ",", "AuthorizationHelper", "$", "authorizationHelper", ",", "TranslatableStringHelper", "$", "translatableStringHelper", ",", "ObjectManager", "$", "om", ",", "$", "name", "=", "'scope'", ")", "{", "$", "reachableScopes", "=", "$", "authorizationHelper", "->", "getReachableScopes", "(", "$", "user", ",", "$", "role", ",", "$", "center", ")", ";", "$", "choices", "=", "array", "(", ")", ";", "foreach", "(", "$", "reachableScopes", "as", "$", "scope", ")", "{", "$", "choices", "[", "$", "scope", "->", "getId", "(", ")", "]", "=", "$", "translatableStringHelper", "->", "localize", "(", "$", "scope", "->", "getName", "(", ")", ")", ";", "}", "$", "dataTransformer", "=", "new", "ScopeTransformer", "(", "$", "om", ")", ";", "$", "builder", "->", "addEventListener", "(", "FormEvents", "::", "PRE_SET_DATA", ",", "function", "(", "FormEvent", "$", "event", ")", "use", "(", "$", "choices", ",", "$", "name", ",", "$", "dataTransformer", ",", "$", "builder", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "form", "->", "add", "(", "$", "builder", "->", "create", "(", "$", "name", ",", "'choice'", ",", "array", "(", "'choices'", "=>", "$", "choices", ",", "'auto_initialize'", "=>", "false", ")", ")", "->", "addModelTransformer", "(", "$", "dataTransformer", ")", "->", "getForm", "(", ")", ")", ";", "}", ")", ";", "}" ]
Append a scope choice field, with the scopes reachable by given user for the given role and center. The field is added on event FormEvents::PRE_SET_DATA @param FormBuilderInterface $builder @param Role $role @param Center $center @param User $user @param AuthorizationHelper $authorizationHelper @param TranslatableStringHelper $translatableStringHelper @param string $name
[ "Append", "a", "scope", "choice", "field", "with", "the", "scopes", "reachable", "by", "given", "user", "for", "the", "given", "role", "and", "center", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Form/Type/AppendScopeChoiceTypeTrait.php#L100-L131
rayrutjes/domain-foundation
src/Contract/Contract.php
Contract.createFromObject
public static function createFromObject($object) { if (!is_object($object)) { throw new \InvalidArgumentException('Object was expected.'); } $className = get_class($object); return new self($className); }
php
public static function createFromObject($object) { if (!is_object($object)) { throw new \InvalidArgumentException('Object was expected.'); } $className = get_class($object); return new self($className); }
[ "public", "static", "function", "createFromObject", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Object was expected.'", ")", ";", "}", "$", "className", "=", "get_class", "(", "$", "object", ")", ";", "return", "new", "self", "(", "$", "className", ")", ";", "}" ]
@param object $object @return Contract
[ "@param", "object", "$object" ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Contract/Contract.php#L39-L48
shrink0r/workflux
src/Error/CorruptExecutionFlow.php
CorruptExecutionFlow.fromExecutionTracker
public static function fromExecutionTracker(ExecutionTracker $execution_tracker, int $max_cycles): self { $cycle_crumbs = $execution_tracker->detectExecutionLoop(); $message = sprintf("Trying to execute more than the allowed number of %d workflow steps.\n", $max_cycles); if (count($cycle_crumbs) === count($execution_tracker->getBreadcrumbs())) { $message .= "It is likely that an intentional cycle inside the workflow isn't properly exiting.\n". "The executed states where:\n"; } else { $message .= "Looks like there is a loop between: "; } $message .= implode(' -> ', $cycle_crumbs->toArray()); return new self($message); }
php
public static function fromExecutionTracker(ExecutionTracker $execution_tracker, int $max_cycles): self { $cycle_crumbs = $execution_tracker->detectExecutionLoop(); $message = sprintf("Trying to execute more than the allowed number of %d workflow steps.\n", $max_cycles); if (count($cycle_crumbs) === count($execution_tracker->getBreadcrumbs())) { $message .= "It is likely that an intentional cycle inside the workflow isn't properly exiting.\n". "The executed states where:\n"; } else { $message .= "Looks like there is a loop between: "; } $message .= implode(' -> ', $cycle_crumbs->toArray()); return new self($message); }
[ "public", "static", "function", "fromExecutionTracker", "(", "ExecutionTracker", "$", "execution_tracker", ",", "int", "$", "max_cycles", ")", ":", "self", "{", "$", "cycle_crumbs", "=", "$", "execution_tracker", "->", "detectExecutionLoop", "(", ")", ";", "$", "message", "=", "sprintf", "(", "\"Trying to execute more than the allowed number of %d workflow steps.\\n\"", ",", "$", "max_cycles", ")", ";", "if", "(", "count", "(", "$", "cycle_crumbs", ")", "===", "count", "(", "$", "execution_tracker", "->", "getBreadcrumbs", "(", ")", ")", ")", "{", "$", "message", ".=", "\"It is likely that an intentional cycle inside the workflow isn't properly exiting.\\n\"", ".", "\"The executed states where:\\n\"", ";", "}", "else", "{", "$", "message", ".=", "\"Looks like there is a loop between: \"", ";", "}", "$", "message", ".=", "implode", "(", "' -> '", ",", "$", "cycle_crumbs", "->", "toArray", "(", ")", ")", ";", "return", "new", "self", "(", "$", "message", ")", ";", "}" ]
@param ExecutionTracker $execution_tracker @param int $max_cycles @return self
[ "@param", "ExecutionTracker", "$execution_tracker", "@param", "int", "$max_cycles" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Error/CorruptExecutionFlow.php#L17-L29
laraning/surveyor
src/Traits/UsesProfiles.php
UsesProfiles.hasProfile
public function hasProfile($profiles) : bool { $profiles = (array) $profiles; return count(array_intersect($this->profiles->pluck('code')->toArray(), $profiles)) > 0; }
php
public function hasProfile($profiles) : bool { $profiles = (array) $profiles; return count(array_intersect($this->profiles->pluck('code')->toArray(), $profiles)) > 0; }
[ "public", "function", "hasProfile", "(", "$", "profiles", ")", ":", "bool", "{", "$", "profiles", "=", "(", "array", ")", "$", "profiles", ";", "return", "count", "(", "array_intersect", "(", "$", "this", "->", "profiles", "->", "pluck", "(", "'code'", ")", "->", "toArray", "(", ")", ",", "$", "profiles", ")", ")", ">", "0", ";", "}" ]
Matches at least one user profile. @param array $profiles The user profile string array. @return bool True in case it finds at least one.
[ "Matches", "at", "least", "one", "user", "profile", "." ]
train
https://github.com/laraning/surveyor/blob/d845b74d20f9a4a307991019502c1b14b1730e86/src/Traits/UsesProfiles.php#L23-L28
laraning/surveyor
src/Traits/UsesProfiles.php
UsesProfiles.hasAllProfiles
public function hasAllProfiles($profiles) : bool { $profiles = (array) $profiles; return count(array_intersect($this->profiles->pluck('code')->toArray(), $profiles)) == count($profiles); }
php
public function hasAllProfiles($profiles) : bool { $profiles = (array) $profiles; return count(array_intersect($this->profiles->pluck('code')->toArray(), $profiles)) == count($profiles); }
[ "public", "function", "hasAllProfiles", "(", "$", "profiles", ")", ":", "bool", "{", "$", "profiles", "=", "(", "array", ")", "$", "profiles", ";", "return", "count", "(", "array_intersect", "(", "$", "this", "->", "profiles", "->", "pluck", "(", "'code'", ")", "->", "toArray", "(", ")", ",", "$", "profiles", ")", ")", "==", "count", "(", "$", "profiles", ")", ";", "}" ]
Matches ALL user profiles. @param array $profiles The user profile string array. @return bool True in case it finds ALL of them.
[ "Matches", "ALL", "user", "profiles", "." ]
train
https://github.com/laraning/surveyor/blob/d845b74d20f9a4a307991019502c1b14b1730e86/src/Traits/UsesProfiles.php#L37-L42
laraning/surveyor
src/Traits/UsesProfiles.php
UsesProfiles.assignProfiles
public function assignProfiles($profiles) : void { $profiles = (array) $profiles; foreach ($profiles as $profile) { $electedProfile = Profile::where('code', $profile)->first(); // Profile exists and not assigned to user? if (!is_null($electedProfile) && !$this->hasProfile($profile)) { // Assign both role and permissions defined for this user profile. // Into the Spatie Permissions. $this->assignRole(Role::find([$electedProfile->role_id])->first()->name); $this->givePermissionTo(Permission::find([$electedProfile->permission_id])->first()->name); // Assign user profile into the profiles table. $this->profiles()->save($electedProfile); } } }
php
public function assignProfiles($profiles) : void { $profiles = (array) $profiles; foreach ($profiles as $profile) { $electedProfile = Profile::where('code', $profile)->first(); // Profile exists and not assigned to user? if (!is_null($electedProfile) && !$this->hasProfile($profile)) { // Assign both role and permissions defined for this user profile. // Into the Spatie Permissions. $this->assignRole(Role::find([$electedProfile->role_id])->first()->name); $this->givePermissionTo(Permission::find([$electedProfile->permission_id])->first()->name); // Assign user profile into the profiles table. $this->profiles()->save($electedProfile); } } }
[ "public", "function", "assignProfiles", "(", "$", "profiles", ")", ":", "void", "{", "$", "profiles", "=", "(", "array", ")", "$", "profiles", ";", "foreach", "(", "$", "profiles", "as", "$", "profile", ")", "{", "$", "electedProfile", "=", "Profile", "::", "where", "(", "'code'", ",", "$", "profile", ")", "->", "first", "(", ")", ";", "// Profile exists and not assigned to user?", "if", "(", "!", "is_null", "(", "$", "electedProfile", ")", "&&", "!", "$", "this", "->", "hasProfile", "(", "$", "profile", ")", ")", "{", "// Assign both role and permissions defined for this user profile.", "// Into the Spatie Permissions.", "$", "this", "->", "assignRole", "(", "Role", "::", "find", "(", "[", "$", "electedProfile", "->", "role_id", "]", ")", "->", "first", "(", ")", "->", "name", ")", ";", "$", "this", "->", "givePermissionTo", "(", "Permission", "::", "find", "(", "[", "$", "electedProfile", "->", "permission_id", "]", ")", "->", "first", "(", ")", "->", "name", ")", ";", "// Assign user profile into the profiles table.", "$", "this", "->", "profiles", "(", ")", "->", "save", "(", "$", "electedProfile", ")", ";", "}", "}", "}" ]
Assigns profiles to the current model. @param string|array $profiles The profile name(s) from the profiles table. @return void
[ "Assigns", "profiles", "to", "the", "current", "model", "." ]
train
https://github.com/laraning/surveyor/blob/d845b74d20f9a4a307991019502c1b14b1730e86/src/Traits/UsesProfiles.php#L51-L68
RobinDumontChaponet/TransitiveCore
src/simple/Front.php
Front.getContent
public function getContent(string $contentType = null): string { /* if(null == $contentType) $contentType = $this->contentType; */ switch($contentType) { case 'application/vnd.transitive.document+json': return $this->route->getDocument(); break; case 'application/vnd.transitive.document+xml': return $this->route->getDocument()->asXML('document'); break; case 'application/vnd.transitive.document+yaml': return $this->route->getDocument()->asYAML(); break; case 'application/vnd.transitive.head+json': return $this->route->getHead()->asJson(); break; case 'application/vnd.transitive.head+xml': return $this->route->getHead()->asXML('head'); break; case 'application/vnd.transitive.head+yaml': return $this->route->getHead()->asYAML(); break; case 'application/vnd.transitive.content+xhtml': case 'application/vnd.transitive.content+html': return $this->route->getContent(); break; case 'application/vnd.transitive.content+json': return $this->route->getContent()->asJson(); break; case 'application/vnd.transitive.content+xml': return $this->route->getContent()->asXML('content'); break; case 'application/vnd.transitive.content+yaml': return $this->route->getContent()->asYAML(); break; case 'text/plain': return $this->layout->getContent()->asString(); break; case 'application/json': if($this->route->hasContent('application/json')) return $this->route->getContentByType('application/json')->asJson(); elseif(404 != http_response_code()) { http_response_code(404); $_SERVER['REDIRECT_STATUS'] = 404; return ''; } break; case 'application/xml': if($this->route->hasContent('application/xml')) return $this->route->getContentByType('application/xml')->asJson(); elseif(404 != http_response_code()) { http_response_code(404); $_SERVER['REDIRECT_STATUS'] = 404; return ''; } break; default: return $this->layout->getView(); } }
php
public function getContent(string $contentType = null): string { /* if(null == $contentType) $contentType = $this->contentType; */ switch($contentType) { case 'application/vnd.transitive.document+json': return $this->route->getDocument(); break; case 'application/vnd.transitive.document+xml': return $this->route->getDocument()->asXML('document'); break; case 'application/vnd.transitive.document+yaml': return $this->route->getDocument()->asYAML(); break; case 'application/vnd.transitive.head+json': return $this->route->getHead()->asJson(); break; case 'application/vnd.transitive.head+xml': return $this->route->getHead()->asXML('head'); break; case 'application/vnd.transitive.head+yaml': return $this->route->getHead()->asYAML(); break; case 'application/vnd.transitive.content+xhtml': case 'application/vnd.transitive.content+html': return $this->route->getContent(); break; case 'application/vnd.transitive.content+json': return $this->route->getContent()->asJson(); break; case 'application/vnd.transitive.content+xml': return $this->route->getContent()->asXML('content'); break; case 'application/vnd.transitive.content+yaml': return $this->route->getContent()->asYAML(); break; case 'text/plain': return $this->layout->getContent()->asString(); break; case 'application/json': if($this->route->hasContent('application/json')) return $this->route->getContentByType('application/json')->asJson(); elseif(404 != http_response_code()) { http_response_code(404); $_SERVER['REDIRECT_STATUS'] = 404; return ''; } break; case 'application/xml': if($this->route->hasContent('application/xml')) return $this->route->getContentByType('application/xml')->asJson(); elseif(404 != http_response_code()) { http_response_code(404); $_SERVER['REDIRECT_STATUS'] = 404; return ''; } break; default: return $this->layout->getView(); } }
[ "public", "function", "getContent", "(", "string", "$", "contentType", "=", "null", ")", ":", "string", "{", "/*\n if(null == $contentType)\n $contentType = $this->contentType;\n*/", "switch", "(", "$", "contentType", ")", "{", "case", "'application/vnd.transitive.document+json'", ":", "return", "$", "this", "->", "route", "->", "getDocument", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.document+xml'", ":", "return", "$", "this", "->", "route", "->", "getDocument", "(", ")", "->", "asXML", "(", "'document'", ")", ";", "break", ";", "case", "'application/vnd.transitive.document+yaml'", ":", "return", "$", "this", "->", "route", "->", "getDocument", "(", ")", "->", "asYAML", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.head+json'", ":", "return", "$", "this", "->", "route", "->", "getHead", "(", ")", "->", "asJson", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.head+xml'", ":", "return", "$", "this", "->", "route", "->", "getHead", "(", ")", "->", "asXML", "(", "'head'", ")", ";", "break", ";", "case", "'application/vnd.transitive.head+yaml'", ":", "return", "$", "this", "->", "route", "->", "getHead", "(", ")", "->", "asYAML", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.content+xhtml'", ":", "case", "'application/vnd.transitive.content+html'", ":", "return", "$", "this", "->", "route", "->", "getContent", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.content+json'", ":", "return", "$", "this", "->", "route", "->", "getContent", "(", ")", "->", "asJson", "(", ")", ";", "break", ";", "case", "'application/vnd.transitive.content+xml'", ":", "return", "$", "this", "->", "route", "->", "getContent", "(", ")", "->", "asXML", "(", "'content'", ")", ";", "break", ";", "case", "'application/vnd.transitive.content+yaml'", ":", "return", "$", "this", "->", "route", "->", "getContent", "(", ")", "->", "asYAML", "(", ")", ";", "break", ";", "case", "'text/plain'", ":", "return", "$", "this", "->", "layout", "->", "getContent", "(", ")", "->", "asString", "(", ")", ";", "break", ";", "case", "'application/json'", ":", "if", "(", "$", "this", "->", "route", "->", "hasContent", "(", "'application/json'", ")", ")", "return", "$", "this", "->", "route", "->", "getContentByType", "(", "'application/json'", ")", "->", "asJson", "(", ")", ";", "elseif", "(", "404", "!=", "http_response_code", "(", ")", ")", "{", "http_response_code", "(", "404", ")", ";", "$", "_SERVER", "[", "'REDIRECT_STATUS'", "]", "=", "404", ";", "return", "''", ";", "}", "break", ";", "case", "'application/xml'", ":", "if", "(", "$", "this", "->", "route", "->", "hasContent", "(", "'application/xml'", ")", ")", "return", "$", "this", "->", "route", "->", "getContentByType", "(", "'application/xml'", ")", "->", "asJson", "(", ")", ";", "elseif", "(", "404", "!=", "http_response_code", "(", ")", ")", "{", "http_response_code", "(", "404", ")", ";", "$", "_SERVER", "[", "'REDIRECT_STATUS'", "]", "=", "404", ";", "return", "''", ";", "}", "break", ";", "default", ":", "return", "$", "this", "->", "layout", "->", "getView", "(", ")", ";", "}", "}" ]
Return processed content from current route. @return string @param string $contentType = null
[ "Return", "processed", "content", "from", "current", "route", "." ]
train
https://github.com/RobinDumontChaponet/TransitiveCore/blob/b83dd6fe0e49b8773de0f60861e5a5c306e2a38d/src/simple/Front.php#L182-L249
alphayax/phpdoc_md
src/models/ClassMd.php
ClassMd.computeType
protected function computeType(){ if( interface_exists( $this->class, false)){ $this->type = 'Interface'; return; } if( trait_exists( $this->class, false)){ $this->type = 'Trait'; return; } $this->type = 'Class'; }
php
protected function computeType(){ if( interface_exists( $this->class, false)){ $this->type = 'Interface'; return; } if( trait_exists( $this->class, false)){ $this->type = 'Trait'; return; } $this->type = 'Class'; }
[ "protected", "function", "computeType", "(", ")", "{", "if", "(", "interface_exists", "(", "$", "this", "->", "class", ",", "false", ")", ")", "{", "$", "this", "->", "type", "=", "'Interface'", ";", "return", ";", "}", "if", "(", "trait_exists", "(", "$", "this", "->", "class", ",", "false", ")", ")", "{", "$", "this", "->", "type", "=", "'Trait'", ";", "return", ";", "}", "$", "this", "->", "type", "=", "'Class'", ";", "}" ]
Determine the type of class
[ "Determine", "the", "type", "of", "class" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/models/ClassMd.php#L53-L63
alphayax/phpdoc_md
src/models/ClassMd.php
ClassMd.getNextComponent
public function getNextComponent( $namespace) { $namespaceComponents = explode( '\\', $namespace); $class_x = explode( '\\', $this->class); while( array_shift( $namespaceComponents)){ array_shift( $class_x); } return array_shift( $class_x); }
php
public function getNextComponent( $namespace) { $namespaceComponents = explode( '\\', $namespace); $class_x = explode( '\\', $this->class); while( array_shift( $namespaceComponents)){ array_shift( $class_x); } return array_shift( $class_x); }
[ "public", "function", "getNextComponent", "(", "$", "namespace", ")", "{", "$", "namespaceComponents", "=", "explode", "(", "'\\\\'", ",", "$", "namespace", ")", ";", "$", "class_x", "=", "explode", "(", "'\\\\'", ",", "$", "this", "->", "class", ")", ";", "while", "(", "array_shift", "(", "$", "namespaceComponents", ")", ")", "{", "array_shift", "(", "$", "class_x", ")", ";", "}", "return", "array_shift", "(", "$", "class_x", ")", ";", "}" ]
Get the next namespace component (according the NS given) @param string $namespace @return string
[ "Get", "the", "next", "namespace", "component", "(", "according", "the", "NS", "given", ")" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/models/ClassMd.php#L70-L79
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.getFieldNames
public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) { if (!array_key_exists($type, ApiLogPeer::$fieldNames)) { throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); } return ApiLogPeer::$fieldNames[$type]; }
php
public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) { if (!array_key_exists($type, ApiLogPeer::$fieldNames)) { throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); } return ApiLogPeer::$fieldNames[$type]; }
[ "public", "static", "function", "getFieldNames", "(", "$", "type", "=", "BasePeer", "::", "TYPE_PHPNAME", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "ApiLogPeer", "::", "$", "fieldNames", ")", ")", "{", "throw", "new", "PropelException", "(", "'Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. '", ".", "$", "type", ".", "' was given.'", ")", ";", "}", "return", "ApiLogPeer", "::", "$", "fieldNames", "[", "$", "type", "]", ";", "}" ]
Returns an array of field names. @param string $type The type of fieldnames to return: One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM @return array A list of field names @throws PropelException - if the type is not valid.
[ "Returns", "an", "array", "of", "field", "names", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L128-L135
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.addSelectColumns
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(ApiLogPeer::ID); $criteria->addSelectColumn(ApiLogPeer::DT_CALL); $criteria->addSelectColumn(ApiLogPeer::REMOTE_APP_ID); $criteria->addSelectColumn(ApiLogPeer::STATUSCODE); $criteria->addSelectColumn(ApiLogPeer::LAST_RESPONSE); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.dt_call'); $criteria->addSelectColumn($alias . '.remote_app_id'); $criteria->addSelectColumn($alias . '.statuscode'); $criteria->addSelectColumn($alias . '.last_response'); } }
php
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(ApiLogPeer::ID); $criteria->addSelectColumn(ApiLogPeer::DT_CALL); $criteria->addSelectColumn(ApiLogPeer::REMOTE_APP_ID); $criteria->addSelectColumn(ApiLogPeer::STATUSCODE); $criteria->addSelectColumn(ApiLogPeer::LAST_RESPONSE); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.dt_call'); $criteria->addSelectColumn($alias . '.remote_app_id'); $criteria->addSelectColumn($alias . '.statuscode'); $criteria->addSelectColumn($alias . '.last_response'); } }
[ "public", "static", "function", "addSelectColumns", "(", "Criteria", "$", "criteria", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "criteria", "->", "addSelectColumn", "(", "ApiLogPeer", "::", "ID", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "ApiLogPeer", "::", "DT_CALL", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "ApiLogPeer", "::", "STATUSCODE", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ")", ";", "}", "else", "{", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.id'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.dt_call'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.remote_app_id'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.statuscode'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.last_response'", ")", ";", "}", "}" ]
Add all the columns needed to create a new object. Note: any columns that were marked with lazyLoad="true" in the XML schema will not be added to the select list and only loaded on demand. @param Criteria $criteria object containing the columns to add. @param string $alias optional table alias @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Add", "all", "the", "columns", "needed", "to", "create", "a", "new", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L166-L181
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.doSelectOne
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) { $critcopy = clone $criteria; $critcopy->setLimit(1); $objects = ApiLogPeer::doSelect($critcopy, $con); if ($objects) { return $objects[0]; } return null; }
php
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) { $critcopy = clone $criteria; $critcopy->setLimit(1); $objects = ApiLogPeer::doSelect($critcopy, $con); if ($objects) { return $objects[0]; } return null; }
[ "public", "static", "function", "doSelectOne", "(", "Criteria", "$", "criteria", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "critcopy", "=", "clone", "$", "criteria", ";", "$", "critcopy", "->", "setLimit", "(", "1", ")", ";", "$", "objects", "=", "ApiLogPeer", "::", "doSelect", "(", "$", "critcopy", ",", "$", "con", ")", ";", "if", "(", "$", "objects", ")", "{", "return", "$", "objects", "[", "0", "]", ";", "}", "return", "null", ";", "}" ]
Selects one object from the DB. @param Criteria $criteria object used to create the SELECT statement. @param PropelPDO $con @return ApiLog @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Selects", "one", "object", "from", "the", "DB", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L236-L246
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.doSelect
public static function doSelect(Criteria $criteria, PropelPDO $con = null) { return ApiLogPeer::populateObjects(ApiLogPeer::doSelectStmt($criteria, $con)); }
php
public static function doSelect(Criteria $criteria, PropelPDO $con = null) { return ApiLogPeer::populateObjects(ApiLogPeer::doSelectStmt($criteria, $con)); }
[ "public", "static", "function", "doSelect", "(", "Criteria", "$", "criteria", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "return", "ApiLogPeer", "::", "populateObjects", "(", "ApiLogPeer", "::", "doSelectStmt", "(", "$", "criteria", ",", "$", "con", ")", ")", ";", "}" ]
Selects several row from the DB. @param Criteria $criteria The Criteria object used to build the SELECT statement. @param PropelPDO $con @return array Array of selected Objects @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Selects", "several", "row", "from", "the", "DB", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L256-L259
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.getInstanceFromPool
public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ApiLogPeer::$instances[$key])) { return ApiLogPeer::$instances[$key]; } } return null; // just to be explicit }
php
public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ApiLogPeer::$instances[$key])) { return ApiLogPeer::$instances[$key]; } } return null; // just to be explicit }
[ "public", "static", "function", "getInstanceFromPool", "(", "$", "key", ")", "{", "if", "(", "Propel", "::", "isInstancePoolingEnabled", "(", ")", ")", "{", "if", "(", "isset", "(", "ApiLogPeer", "::", "$", "instances", "[", "$", "key", "]", ")", ")", "{", "return", "ApiLogPeer", "::", "$", "instances", "[", "$", "key", "]", ";", "}", "}", "return", "null", ";", "// just to be explicit", "}" ]
Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. For tables with a single-column primary key, that simple pkey value will be returned. For tables with a multi-column primary key, a serialize()d version of the primary key will be returned. @param string $key The key (@see getPrimaryKeyHash()) for this instance. @return ApiLog Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. @see getPrimaryKeyHash()
[ "Retrieves", "a", "string", "version", "of", "the", "primary", "key", "from", "the", "DB", "resultset", "row", "that", "can", "be", "used", "to", "uniquely", "identify", "a", "row", "in", "this", "table", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L352-L361
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php
BaseApiLogPeer.buildTableMap
public static function buildTableMap() { $dbMap = Propel::getDatabaseMap(BaseApiLogPeer::DATABASE_NAME); if (!$dbMap->hasTable(BaseApiLogPeer::TABLE_NAME)) { $dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\ApiLogTableMap()); } }
php
public static function buildTableMap() { $dbMap = Propel::getDatabaseMap(BaseApiLogPeer::DATABASE_NAME); if (!$dbMap->hasTable(BaseApiLogPeer::TABLE_NAME)) { $dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\ApiLogTableMap()); } }
[ "public", "static", "function", "buildTableMap", "(", ")", "{", "$", "dbMap", "=", "Propel", "::", "getDatabaseMap", "(", "BaseApiLogPeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "!", "$", "dbMap", "->", "hasTable", "(", "BaseApiLogPeer", "::", "TABLE_NAME", ")", ")", "{", "$", "dbMap", "->", "addTableObject", "(", "new", "\\", "Slashworks", "\\", "AppBundle", "\\", "Model", "\\", "map", "\\", "ApiLogTableMap", "(", ")", ")", ";", "}", "}" ]
Add a TableMap instance to the database for this peer class.
[ "Add", "a", "TableMap", "instance", "to", "the", "database", "for", "this", "peer", "class", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogPeer.php#L733-L739
aedart/laravel-helpers
src/Traits/Auth/PasswordTrait.php
PasswordTrait.getPassword
public function getPassword(): ?PasswordBroker { if (!$this->hasPassword()) { $this->setPassword($this->getDefaultPassword()); } return $this->password; }
php
public function getPassword(): ?PasswordBroker { if (!$this->hasPassword()) { $this->setPassword($this->getDefaultPassword()); } return $this->password; }
[ "public", "function", "getPassword", "(", ")", ":", "?", "PasswordBroker", "{", "if", "(", "!", "$", "this", "->", "hasPassword", "(", ")", ")", "{", "$", "this", "->", "setPassword", "(", "$", "this", "->", "getDefaultPassword", "(", ")", ")", ";", "}", "return", "$", "this", "->", "password", ";", "}" ]
Get password If no password has been set, this method will set and return a default password, if any such value is available @see getDefaultPassword() @return PasswordBroker|null password or null if none password has been set
[ "Get", "password" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/PasswordTrait.php#L53-L59
aedart/laravel-helpers
src/Traits/Auth/PasswordTrait.php
PasswordTrait.getDefaultPassword
public function getDefaultPassword(): ?PasswordBroker { // By default, the Password Facade does not return the // any actual password broker, but rather an // instance of \Illuminate\Auth\Passwords\PasswordBrokerManager. // Therefore, we make sure only to obtain its // "default broker", to make sure that its only the guard // instance that we obtain. $manager = Password::getFacadeRoot(); if (isset($manager)) { return $manager->broker(); } return $manager; }
php
public function getDefaultPassword(): ?PasswordBroker { // By default, the Password Facade does not return the // any actual password broker, but rather an // instance of \Illuminate\Auth\Passwords\PasswordBrokerManager. // Therefore, we make sure only to obtain its // "default broker", to make sure that its only the guard // instance that we obtain. $manager = Password::getFacadeRoot(); if (isset($manager)) { return $manager->broker(); } return $manager; }
[ "public", "function", "getDefaultPassword", "(", ")", ":", "?", "PasswordBroker", "{", "// By default, the Password Facade does not return the", "// any actual password broker, but rather an", "// instance of \\Illuminate\\Auth\\Passwords\\PasswordBrokerManager.", "// Therefore, we make sure only to obtain its", "// \"default broker\", to make sure that its only the guard", "// instance that we obtain.", "$", "manager", "=", "Password", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "manager", ")", ")", "{", "return", "$", "manager", "->", "broker", "(", ")", ";", "}", "return", "$", "manager", ";", "}" ]
Get a default password value, if any is available @return PasswordBroker|null A default password value or Null if no default value is available
[ "Get", "a", "default", "password", "value", "if", "any", "is", "available" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/PasswordTrait.php#L76-L89
webforge-labs/psc-cms
lib/Psc/UI/FormInputSet.php
FormInputSet.setStyle
public function setStyle($style,$value) { if ($this->morphed) { throw new Exception('setStyle() vor dem morphen aufrufen!'); } $this->styles[$style] = $value; return $this; }
php
public function setStyle($style,$value) { if ($this->morphed) { throw new Exception('setStyle() vor dem morphen aufrufen!'); } $this->styles[$style] = $value; return $this; }
[ "public", "function", "setStyle", "(", "$", "style", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "morphed", ")", "{", "throw", "new", "Exception", "(", "'setStyle() vor dem morphen aufrufen!'", ")", ";", "}", "$", "this", "->", "styles", "[", "$", "style", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Setzt einen HTML-Style für alle Elemente
[ "Setzt", "einen", "HTML", "-", "Style", "für", "alle", "Elemente" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/FormInputSet.php#L66-L72
webforge-labs/psc-cms
lib/Psc/UI/FormInputSet.php
FormInputSet.html
public function html() { if (!$this->isMorphed()) $this->morph(); $html = NULL; foreach ($this->elements as $el) { $html .= $el->html()."\n"; } return $html; }
php
public function html() { if (!$this->isMorphed()) $this->morph(); $html = NULL; foreach ($this->elements as $el) { $html .= $el->html()."\n"; } return $html; }
[ "public", "function", "html", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isMorphed", "(", ")", ")", "$", "this", "->", "morph", "(", ")", ";", "$", "html", "=", "NULL", ";", "foreach", "(", "$", "this", "->", "elements", "as", "$", "el", ")", "{", "$", "html", ".=", "$", "el", "->", "html", "(", ")", ".", "\"\\n\"", ";", "}", "return", "$", "html", ";", "}" ]
Wenn noch nicht gemorphed, wird das getan
[ "Wenn", "noch", "nicht", "gemorphed", "wird", "das", "getan" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/FormInputSet.php#L77-L87
webtown-php/KunstmaanExtensionBundle
src/Translation/Extraction/File/OriginalTranslationsYmlExtractor.php
OriginalTranslationsYmlExtractor.visitFile
public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue) { if ('.yml' !== substr($file, -4)) { return; } if ($this->skipThisLocale($file, $catalogue->getLocale())) { return; } $domain = substr($file->getFilename(), 0, -7); $parser = $this->getYmlParser(); $translationsArray = $parser->parse(file_get_contents($file)); $translationIds = $this->getChildrenKeys($translationsArray); $fileLocale = $this->getFilePiece($file, self::FILE_PIECE_LOCALE); $catalogueLocale = $catalogue->getLocale(); foreach ($translationIds as $id => $translation) { $message = new Message($id, $domain); $message->addSource(new FileSource((string) $file)); switch ($fileLocale) { case $catalogueLocale: $message->setLocaleString($translation); break; case 'en': $message->setMeaning(sprintf('En: `%s`', $translation)); break; } $catalogue->add($message); } }
php
public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue) { if ('.yml' !== substr($file, -4)) { return; } if ($this->skipThisLocale($file, $catalogue->getLocale())) { return; } $domain = substr($file->getFilename(), 0, -7); $parser = $this->getYmlParser(); $translationsArray = $parser->parse(file_get_contents($file)); $translationIds = $this->getChildrenKeys($translationsArray); $fileLocale = $this->getFilePiece($file, self::FILE_PIECE_LOCALE); $catalogueLocale = $catalogue->getLocale(); foreach ($translationIds as $id => $translation) { $message = new Message($id, $domain); $message->addSource(new FileSource((string) $file)); switch ($fileLocale) { case $catalogueLocale: $message->setLocaleString($translation); break; case 'en': $message->setMeaning(sprintf('En: `%s`', $translation)); break; } $catalogue->add($message); } }
[ "public", "function", "visitFile", "(", "\\", "SplFileInfo", "$", "file", ",", "MessageCatalogue", "$", "catalogue", ")", "{", "if", "(", "'.yml'", "!==", "substr", "(", "$", "file", ",", "-", "4", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "skipThisLocale", "(", "$", "file", ",", "$", "catalogue", "->", "getLocale", "(", ")", ")", ")", "{", "return", ";", "}", "$", "domain", "=", "substr", "(", "$", "file", "->", "getFilename", "(", ")", ",", "0", ",", "-", "7", ")", ";", "$", "parser", "=", "$", "this", "->", "getYmlParser", "(", ")", ";", "$", "translationsArray", "=", "$", "parser", "->", "parse", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "$", "translationIds", "=", "$", "this", "->", "getChildrenKeys", "(", "$", "translationsArray", ")", ";", "$", "fileLocale", "=", "$", "this", "->", "getFilePiece", "(", "$", "file", ",", "self", "::", "FILE_PIECE_LOCALE", ")", ";", "$", "catalogueLocale", "=", "$", "catalogue", "->", "getLocale", "(", ")", ";", "foreach", "(", "$", "translationIds", "as", "$", "id", "=>", "$", "translation", ")", "{", "$", "message", "=", "new", "Message", "(", "$", "id", ",", "$", "domain", ")", ";", "$", "message", "->", "addSource", "(", "new", "FileSource", "(", "(", "string", ")", "$", "file", ")", ")", ";", "switch", "(", "$", "fileLocale", ")", "{", "case", "$", "catalogueLocale", ":", "$", "message", "->", "setLocaleString", "(", "$", "translation", ")", ";", "break", ";", "case", "'en'", ":", "$", "message", "->", "setMeaning", "(", "sprintf", "(", "'En: `%s`'", ",", "$", "translation", ")", ")", ";", "break", ";", "}", "$", "catalogue", "->", "add", "(", "$", "message", ")", ";", "}", "}" ]
Called for non-specially handled files. This is not called if handled by a more specific method. @param \SplFileInfo $file @param MessageCatalogue $catalogue
[ "Called", "for", "non", "-", "specially", "handled", "files", "." ]
train
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Translation/Extraction/File/OriginalTranslationsYmlExtractor.php#L50-L79
webtown-php/KunstmaanExtensionBundle
src/Translation/Extraction/File/OriginalTranslationsYmlExtractor.php
OriginalTranslationsYmlExtractor.getFilePieces
protected function getFilePieces(\SplFileInfo $file) { $key = $file->getBasename(); if (!array_key_exists($key, $this->filePieces)) { $pieces = explode('.', $file->getBasename()); if (count($pieces) < 3) { return true; } $extension = array_pop($pieces); $locale = array_pop($pieces); $domain = implode('.', $pieces); $this->filePieces[$key] = [ self::FILE_PIECE_DOMAIN => $domain, self::FILE_PIECE_LOCALE => $locale, self::FILE_PIECE_EXTENSION => $extension, ]; } return $this->filePieces[$key]; }
php
protected function getFilePieces(\SplFileInfo $file) { $key = $file->getBasename(); if (!array_key_exists($key, $this->filePieces)) { $pieces = explode('.', $file->getBasename()); if (count($pieces) < 3) { return true; } $extension = array_pop($pieces); $locale = array_pop($pieces); $domain = implode('.', $pieces); $this->filePieces[$key] = [ self::FILE_PIECE_DOMAIN => $domain, self::FILE_PIECE_LOCALE => $locale, self::FILE_PIECE_EXTENSION => $extension, ]; } return $this->filePieces[$key]; }
[ "protected", "function", "getFilePieces", "(", "\\", "SplFileInfo", "$", "file", ")", "{", "$", "key", "=", "$", "file", "->", "getBasename", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "filePieces", ")", ")", "{", "$", "pieces", "=", "explode", "(", "'.'", ",", "$", "file", "->", "getBasename", "(", ")", ")", ";", "if", "(", "count", "(", "$", "pieces", ")", "<", "3", ")", "{", "return", "true", ";", "}", "$", "extension", "=", "array_pop", "(", "$", "pieces", ")", ";", "$", "locale", "=", "array_pop", "(", "$", "pieces", ")", ";", "$", "domain", "=", "implode", "(", "'.'", ",", "$", "pieces", ")", ";", "$", "this", "->", "filePieces", "[", "$", "key", "]", "=", "[", "self", "::", "FILE_PIECE_DOMAIN", "=>", "$", "domain", ",", "self", "::", "FILE_PIECE_LOCALE", "=>", "$", "locale", ",", "self", "::", "FILE_PIECE_EXTENSION", "=>", "$", "extension", ",", "]", ";", "}", "return", "$", "this", "->", "filePieces", "[", "$", "key", "]", ";", "}" ]
@param \SplFileInfo $file @return array
[ "@param", "\\", "SplFileInfo", "$file" ]
train
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Translation/Extraction/File/OriginalTranslationsYmlExtractor.php#L117-L137
yuncms/framework
src/rest/models/NicknameForm.php
NicknameForm.save
public function save() { if ($this->validate() && (bool)$this->getUser()->updateAttributes(['nickname' => $this->nickname])) { return $this->getUser(); } return false; }
php
public function save() { if ($this->validate() && (bool)$this->getUser()->updateAttributes(['nickname' => $this->nickname])) { return $this->getUser(); } return false; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "validate", "(", ")", "&&", "(", "bool", ")", "$", "this", "->", "getUser", "(", ")", "->", "updateAttributes", "(", "[", "'nickname'", "=>", "$", "this", "->", "nickname", "]", ")", ")", "{", "return", "$", "this", "->", "getUser", "(", ")", ";", "}", "return", "false", ";", "}" ]
保存昵称 @return boolean
[ "保存昵称" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/models/NicknameForm.php#L47-L53
factorio-item-browser/export-data
src/Registry/ModRegistry.php
ModRegistry.set
public function set(Mod $mod): void { $this->loadMods(); $this->mods[$mod->getName()] = $mod; }
php
public function set(Mod $mod): void { $this->loadMods(); $this->mods[$mod->getName()] = $mod; }
[ "public", "function", "set", "(", "Mod", "$", "mod", ")", ":", "void", "{", "$", "this", "->", "loadMods", "(", ")", ";", "$", "this", "->", "mods", "[", "$", "mod", "->", "getName", "(", ")", "]", "=", "$", "mod", ";", "}" ]
Sets a mod into the registry. @param Mod $mod
[ "Sets", "a", "mod", "into", "the", "registry", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ModRegistry.php#L54-L58
factorio-item-browser/export-data
src/Registry/ModRegistry.php
ModRegistry.get
public function get(string $modName): ?Mod { $this->loadMods(); return $this->mods[$modName] ?? null; }
php
public function get(string $modName): ?Mod { $this->loadMods(); return $this->mods[$modName] ?? null; }
[ "public", "function", "get", "(", "string", "$", "modName", ")", ":", "?", "Mod", "{", "$", "this", "->", "loadMods", "(", ")", ";", "return", "$", "this", "->", "mods", "[", "$", "modName", "]", "??", "null", ";", "}" ]
Returns a mod from the registry. @param string $modName @return Mod|null
[ "Returns", "a", "mod", "from", "the", "registry", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ModRegistry.php#L65-L69
factorio-item-browser/export-data
src/Registry/ModRegistry.php
ModRegistry.saveMods
public function saveMods(): void { $mods = []; foreach ($this->mods as $mod) { $mods[] = $mod->writeData(); } $this->saveContent(self::HASH_FILE_MODS, $this->encodeContent($mods)); }
php
public function saveMods(): void { $mods = []; foreach ($this->mods as $mod) { $mods[] = $mod->writeData(); } $this->saveContent(self::HASH_FILE_MODS, $this->encodeContent($mods)); }
[ "public", "function", "saveMods", "(", ")", ":", "void", "{", "$", "mods", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "mods", "as", "$", "mod", ")", "{", "$", "mods", "[", "]", "=", "$", "mod", "->", "writeData", "(", ")", ";", "}", "$", "this", "->", "saveContent", "(", "self", "::", "HASH_FILE_MODS", ",", "$", "this", "->", "encodeContent", "(", "$", "mods", ")", ")", ";", "}" ]
Saves the currently known mod to the adapter.
[ "Saves", "the", "currently", "known", "mod", "to", "the", "adapter", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ModRegistry.php#L84-L91
factorio-item-browser/export-data
src/Registry/ModRegistry.php
ModRegistry.loadMods
protected function loadMods(): void { if (!$this->isLoaded) { $this->mods = []; foreach ($this->decodeContent((string) $this->loadContent(self::HASH_FILE_MODS)) as $modData) { if (is_array($modData)) { $mod = new Mod(); $mod->readData(new DataContainer($modData)); $this->mods[$mod->getName()] = $mod; } } $this->isLoaded = true; } }
php
protected function loadMods(): void { if (!$this->isLoaded) { $this->mods = []; foreach ($this->decodeContent((string) $this->loadContent(self::HASH_FILE_MODS)) as $modData) { if (is_array($modData)) { $mod = new Mod(); $mod->readData(new DataContainer($modData)); $this->mods[$mod->getName()] = $mod; } } $this->isLoaded = true; } }
[ "protected", "function", "loadMods", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isLoaded", ")", "{", "$", "this", "->", "mods", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "decodeContent", "(", "(", "string", ")", "$", "this", "->", "loadContent", "(", "self", "::", "HASH_FILE_MODS", ")", ")", "as", "$", "modData", ")", "{", "if", "(", "is_array", "(", "$", "modData", ")", ")", "{", "$", "mod", "=", "new", "Mod", "(", ")", ";", "$", "mod", "->", "readData", "(", "new", "DataContainer", "(", "$", "modData", ")", ")", ";", "$", "this", "->", "mods", "[", "$", "mod", "->", "getName", "(", ")", "]", "=", "$", "mod", ";", "}", "}", "$", "this", "->", "isLoaded", "=", "true", ";", "}", "}" ]
Loads the mods from the file.
[ "Loads", "the", "mods", "from", "the", "file", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ModRegistry.php#L96-L109
webforge-labs/psc-cms
lib/Psc/UI/Accordion.php
Accordion.appendSection
public function appendSection($index, $snippet) { $index = $index*2+1; $this->html->content[$index]->content[] = $snippet; //throw new \Psc\Exception('weiss nicht wie ich an '.Code::varInfo($this->html->content[$index]).' appenden soll'); return $this; }
php
public function appendSection($index, $snippet) { $index = $index*2+1; $this->html->content[$index]->content[] = $snippet; //throw new \Psc\Exception('weiss nicht wie ich an '.Code::varInfo($this->html->content[$index]).' appenden soll'); return $this; }
[ "public", "function", "appendSection", "(", "$", "index", ",", "$", "snippet", ")", "{", "$", "index", "=", "$", "index", "*", "2", "+", "1", ";", "$", "this", "->", "html", "->", "content", "[", "$", "index", "]", "->", "content", "[", "]", "=", "$", "snippet", ";", "//throw new \\Psc\\Exception('weiss nicht wie ich an '.Code::varInfo($this->html->content[$index]).' appenden soll');", "return", "$", "this", ";", "}" ]
Fügt Inhalt einer Section hinzu
[ "Fügt", "Inhalt", "einer", "Section", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/Accordion.php#L122-L128
fubhy/graphql-php
src/GraphQL.php
GraphQL.execute
public static function execute(Schema $schema, $request, $root = NULL, $variables = NULL, $operation = NULL) { try { $source = new Source($request ?: '', 'GraphQL request'); $parser = new Parser(); $ast = $parser->parse($source); return Executor::execute($schema, $root, $ast, $operation, $variables); } catch (\Exception $exception) { return ['errors' => $exception->getMessage()]; } }
php
public static function execute(Schema $schema, $request, $root = NULL, $variables = NULL, $operation = NULL) { try { $source = new Source($request ?: '', 'GraphQL request'); $parser = new Parser(); $ast = $parser->parse($source); return Executor::execute($schema, $root, $ast, $operation, $variables); } catch (\Exception $exception) { return ['errors' => $exception->getMessage()]; } }
[ "public", "static", "function", "execute", "(", "Schema", "$", "schema", ",", "$", "request", ",", "$", "root", "=", "NULL", ",", "$", "variables", "=", "NULL", ",", "$", "operation", "=", "NULL", ")", "{", "try", "{", "$", "source", "=", "new", "Source", "(", "$", "request", "?", ":", "''", ",", "'GraphQL request'", ")", ";", "$", "parser", "=", "new", "Parser", "(", ")", ";", "$", "ast", "=", "$", "parser", "->", "parse", "(", "$", "source", ")", ";", "return", "Executor", "::", "execute", "(", "$", "schema", ",", "$", "root", ",", "$", "ast", ",", "$", "operation", ",", "$", "variables", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "return", "[", "'errors'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ";", "}", "}" ]
@param Schema $schema @param $request @param mixed $root @param array|null $variables @param string|null $operation @return array
[ "@param", "Schema", "$schema", "@param", "$request", "@param", "mixed", "$root", "@param", "array|null", "$variables", "@param", "string|null", "$operation" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/GraphQL.php#L20-L31
webforge-labs/psc-cms
lib/Psc/Code/Numbers.php
Numbers.toRoman
public static function toRoman($num) { $conv = array( 10 => array('X', 'C', 'M'), 5 => array('V', 'L', 'D'), 1 => array('I', 'X', 'C')); $roman = ''; if ($num < 0) { return ''; } $num = (int) $num; $digit = (int) ($num / 1000); $num -= $digit * 1000; while ($digit > 0) { $roman .= 'M'; $digit--; } for ($i = 2; $i >= 0; $i--) { $power = pow(10, $i); $digit = (int) ($num / $power); $num -= $digit * $power; if (($digit == 9) || ($digit == 4)) { $roman .= $conv[1][$i] . $conv[$digit+1][$i]; } else { if ($digit >= 5) { $roman .= $conv[5][$i]; $digit -= 5; } while ($digit > 0) { $roman .= $conv[1][$i]; $digit--; } } } return $roman; }
php
public static function toRoman($num) { $conv = array( 10 => array('X', 'C', 'M'), 5 => array('V', 'L', 'D'), 1 => array('I', 'X', 'C')); $roman = ''; if ($num < 0) { return ''; } $num = (int) $num; $digit = (int) ($num / 1000); $num -= $digit * 1000; while ($digit > 0) { $roman .= 'M'; $digit--; } for ($i = 2; $i >= 0; $i--) { $power = pow(10, $i); $digit = (int) ($num / $power); $num -= $digit * $power; if (($digit == 9) || ($digit == 4)) { $roman .= $conv[1][$i] . $conv[$digit+1][$i]; } else { if ($digit >= 5) { $roman .= $conv[5][$i]; $digit -= 5; } while ($digit > 0) { $roman .= $conv[1][$i]; $digit--; } } } return $roman; }
[ "public", "static", "function", "toRoman", "(", "$", "num", ")", "{", "$", "conv", "=", "array", "(", "10", "=>", "array", "(", "'X'", ",", "'C'", ",", "'M'", ")", ",", "5", "=>", "array", "(", "'V'", ",", "'L'", ",", "'D'", ")", ",", "1", "=>", "array", "(", "'I'", ",", "'X'", ",", "'C'", ")", ")", ";", "$", "roman", "=", "''", ";", "if", "(", "$", "num", "<", "0", ")", "{", "return", "''", ";", "}", "$", "num", "=", "(", "int", ")", "$", "num", ";", "$", "digit", "=", "(", "int", ")", "(", "$", "num", "/", "1000", ")", ";", "$", "num", "-=", "$", "digit", "*", "1000", ";", "while", "(", "$", "digit", ">", "0", ")", "{", "$", "roman", ".=", "'M'", ";", "$", "digit", "--", ";", "}", "for", "(", "$", "i", "=", "2", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "power", "=", "pow", "(", "10", ",", "$", "i", ")", ";", "$", "digit", "=", "(", "int", ")", "(", "$", "num", "/", "$", "power", ")", ";", "$", "num", "-=", "$", "digit", "*", "$", "power", ";", "if", "(", "(", "$", "digit", "==", "9", ")", "||", "(", "$", "digit", "==", "4", ")", ")", "{", "$", "roman", ".=", "$", "conv", "[", "1", "]", "[", "$", "i", "]", ".", "$", "conv", "[", "$", "digit", "+", "1", "]", "[", "$", "i", "]", ";", "}", "else", "{", "if", "(", "$", "digit", ">=", "5", ")", "{", "$", "roman", ".=", "$", "conv", "[", "5", "]", "[", "$", "i", "]", ";", "$", "digit", "-=", "5", ";", "}", "while", "(", "$", "digit", ">", "0", ")", "{", "$", "roman", ".=", "$", "conv", "[", "1", "]", "[", "$", "i", "]", ";", "$", "digit", "--", ";", "}", "}", "}", "return", "$", "roman", ";", "}" ]
Converts a number to its roman numeral representation @param integer $num An integer between 0 and 3999 inclusive that should be converted to a roman numeral integers higher than 3999 are supported from version 0.1.2 Note: For an accurate result the integer shouldn't be higher than 5 999 999. Higher integers are still converted but they do not reflect an historically correct Roman Numeral. @param bool $uppercase Uppercase output: default true @param bool $html Enable html overscore required for integers over 3999. default true @return string $roman The corresponding roman numeral @author David Costa <[email protected]> @author Sterling Hughes <[email protected]>
[ "Converts", "a", "number", "to", "its", "roman", "numeral", "representation" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Numbers.php#L63-L103
drupalwxt/pco_cities
src/Composer/Package.php
Package.execute
public static function execute(Event $event) { $composer = $event->getComposer(); $encoder = new IniEncoder(); // Convert the lock file to a make file using Drush's make-convert command. $bin_dir = $composer->getConfig()->get('bin-dir'); $make = NULL; $executor = new ProcessExecutor(); $executor->execute($bin_dir . '/drush make-convert composer.lock', $make); $make = Yaml::parse($make); // Include any drupal-library packages in the make file. $libraries = $composer ->getRepositoryManager() ->getLocalRepository() ->getPackages(); $libraries = array_filter($libraries, function (PackageInterface $package) { return $package->getType() == 'drupal-library'; }); // Drop the vendor prefixes. foreach ($libraries as $library) { $old_key = $library->getName(); $new_key = basename($old_key); $make['libraries'][$new_key] = $make['libraries'][$old_key]; unset($make['libraries'][$old_key]); } if (isset($make['projects']['drupal'])) { // Always use drupal.org's core repository, or patches will not apply. $make['projects']['drupal']['download']['url'] = 'https://git.drupal.org/project/drupal.git'; $core = [ 'api' => 2, 'core' => '8.x', 'projects' => [ 'drupal' => [ 'type' => 'core', 'version' => $make['projects']['drupal']['download']['tag'], ], ], ]; if (isset($make['projects']['drupal']['patch'])) { $core['projects']['drupal']['patch'] = $make['projects']['drupal']['patch']; } file_put_contents('drupal-org-core.make', $encoder->encode($core)); unset($make['projects']['drupal']); } foreach ($make['projects'] as $key => &$project) { if ($project['download']['type'] == 'git') { $tag = !empty($project['download']['tag']) ? $project['download']['tag'] : ''; preg_match('/[0-9]\.x-[0-9]*[0-9]*\.0/', $tag, $match); $tag = str_replace($match, str_replace('x-', NULL, $match), $tag); preg_match('/[0-9]\.[0-9]*[0-9]*\.0/', $tag, $match); if (!empty($match[0])) { $tag = str_replace($match, substr($match[0], 0, -2), $tag); $project['version'] = $tag; unset($project['download']); } } } file_put_contents('drupal-org.make', $encoder->encode($make)); }
php
public static function execute(Event $event) { $composer = $event->getComposer(); $encoder = new IniEncoder(); // Convert the lock file to a make file using Drush's make-convert command. $bin_dir = $composer->getConfig()->get('bin-dir'); $make = NULL; $executor = new ProcessExecutor(); $executor->execute($bin_dir . '/drush make-convert composer.lock', $make); $make = Yaml::parse($make); // Include any drupal-library packages in the make file. $libraries = $composer ->getRepositoryManager() ->getLocalRepository() ->getPackages(); $libraries = array_filter($libraries, function (PackageInterface $package) { return $package->getType() == 'drupal-library'; }); // Drop the vendor prefixes. foreach ($libraries as $library) { $old_key = $library->getName(); $new_key = basename($old_key); $make['libraries'][$new_key] = $make['libraries'][$old_key]; unset($make['libraries'][$old_key]); } if (isset($make['projects']['drupal'])) { // Always use drupal.org's core repository, or patches will not apply. $make['projects']['drupal']['download']['url'] = 'https://git.drupal.org/project/drupal.git'; $core = [ 'api' => 2, 'core' => '8.x', 'projects' => [ 'drupal' => [ 'type' => 'core', 'version' => $make['projects']['drupal']['download']['tag'], ], ], ]; if (isset($make['projects']['drupal']['patch'])) { $core['projects']['drupal']['patch'] = $make['projects']['drupal']['patch']; } file_put_contents('drupal-org-core.make', $encoder->encode($core)); unset($make['projects']['drupal']); } foreach ($make['projects'] as $key => &$project) { if ($project['download']['type'] == 'git') { $tag = !empty($project['download']['tag']) ? $project['download']['tag'] : ''; preg_match('/[0-9]\.x-[0-9]*[0-9]*\.0/', $tag, $match); $tag = str_replace($match, str_replace('x-', NULL, $match), $tag); preg_match('/[0-9]\.[0-9]*[0-9]*\.0/', $tag, $match); if (!empty($match[0])) { $tag = str_replace($match, substr($match[0], 0, -2), $tag); $project['version'] = $tag; unset($project['download']); } } } file_put_contents('drupal-org.make', $encoder->encode($make)); }
[ "public", "static", "function", "execute", "(", "Event", "$", "event", ")", "{", "$", "composer", "=", "$", "event", "->", "getComposer", "(", ")", ";", "$", "encoder", "=", "new", "IniEncoder", "(", ")", ";", "// Convert the lock file to a make file using Drush's make-convert command.", "$", "bin_dir", "=", "$", "composer", "->", "getConfig", "(", ")", "->", "get", "(", "'bin-dir'", ")", ";", "$", "make", "=", "NULL", ";", "$", "executor", "=", "new", "ProcessExecutor", "(", ")", ";", "$", "executor", "->", "execute", "(", "$", "bin_dir", ".", "'/drush make-convert composer.lock'", ",", "$", "make", ")", ";", "$", "make", "=", "Yaml", "::", "parse", "(", "$", "make", ")", ";", "// Include any drupal-library packages in the make file.", "$", "libraries", "=", "$", "composer", "->", "getRepositoryManager", "(", ")", "->", "getLocalRepository", "(", ")", "->", "getPackages", "(", ")", ";", "$", "libraries", "=", "array_filter", "(", "$", "libraries", ",", "function", "(", "PackageInterface", "$", "package", ")", "{", "return", "$", "package", "->", "getType", "(", ")", "==", "'drupal-library'", ";", "}", ")", ";", "// Drop the vendor prefixes.", "foreach", "(", "$", "libraries", "as", "$", "library", ")", "{", "$", "old_key", "=", "$", "library", "->", "getName", "(", ")", ";", "$", "new_key", "=", "basename", "(", "$", "old_key", ")", ";", "$", "make", "[", "'libraries'", "]", "[", "$", "new_key", "]", "=", "$", "make", "[", "'libraries'", "]", "[", "$", "old_key", "]", ";", "unset", "(", "$", "make", "[", "'libraries'", "]", "[", "$", "old_key", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", ")", ")", "{", "// Always use drupal.org's core repository, or patches will not apply.", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", "[", "'download'", "]", "[", "'url'", "]", "=", "'https://git.drupal.org/project/drupal.git'", ";", "$", "core", "=", "[", "'api'", "=>", "2", ",", "'core'", "=>", "'8.x'", ",", "'projects'", "=>", "[", "'drupal'", "=>", "[", "'type'", "=>", "'core'", ",", "'version'", "=>", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", "[", "'download'", "]", "[", "'tag'", "]", ",", "]", ",", "]", ",", "]", ";", "if", "(", "isset", "(", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", "[", "'patch'", "]", ")", ")", "{", "$", "core", "[", "'projects'", "]", "[", "'drupal'", "]", "[", "'patch'", "]", "=", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", "[", "'patch'", "]", ";", "}", "file_put_contents", "(", "'drupal-org-core.make'", ",", "$", "encoder", "->", "encode", "(", "$", "core", ")", ")", ";", "unset", "(", "$", "make", "[", "'projects'", "]", "[", "'drupal'", "]", ")", ";", "}", "foreach", "(", "$", "make", "[", "'projects'", "]", "as", "$", "key", "=>", "&", "$", "project", ")", "{", "if", "(", "$", "project", "[", "'download'", "]", "[", "'type'", "]", "==", "'git'", ")", "{", "$", "tag", "=", "!", "empty", "(", "$", "project", "[", "'download'", "]", "[", "'tag'", "]", ")", "?", "$", "project", "[", "'download'", "]", "[", "'tag'", "]", ":", "''", ";", "preg_match", "(", "'/[0-9]\\.x-[0-9]*[0-9]*\\.0/'", ",", "$", "tag", ",", "$", "match", ")", ";", "$", "tag", "=", "str_replace", "(", "$", "match", ",", "str_replace", "(", "'x-'", ",", "NULL", ",", "$", "match", ")", ",", "$", "tag", ")", ";", "preg_match", "(", "'/[0-9]\\.[0-9]*[0-9]*\\.0/'", ",", "$", "tag", ",", "$", "match", ")", ";", "if", "(", "!", "empty", "(", "$", "match", "[", "0", "]", ")", ")", "{", "$", "tag", "=", "str_replace", "(", "$", "match", ",", "substr", "(", "$", "match", "[", "0", "]", ",", "0", ",", "-", "2", ")", ",", "$", "tag", ")", ";", "$", "project", "[", "'version'", "]", "=", "$", "tag", ";", "unset", "(", "$", "project", "[", "'download'", "]", ")", ";", "}", "}", "}", "file_put_contents", "(", "'drupal-org.make'", ",", "$", "encoder", "->", "encode", "(", "$", "make", ")", ")", ";", "}" ]
Script entry point. @param \Composer\Script\Event $event The script event.
[ "Script", "entry", "point", "." ]
train
https://github.com/drupalwxt/pco_cities/blob/589651ac4478ce629dd9ad9cf2e15ad1a9de368a/src/Composer/Package.php#L22-L87
afrittella/back-project
src/app/BackProjectServiceProvider.php
BackProjectServiceProvider.publishFiles
public function publishFiles() { // publish config file $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config'); // publish lang files $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); // publish public BackProject assets $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public'); // publish views $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views'); // publish error views $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors'); // publish public AdminLTE assets $this->publishes(['vendor/almasaeed2010/adminlte/bower_components/bootstrap/dist' => public_path('vendor/adminlte/bootstrap')], 'adminlte'); $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte'); $this->publishes(['vendor/almasaeed2010/adminlte/plugins' => public_path('vendor/adminlte/plugins')], 'adminlte'); }
php
public function publishFiles() { // publish config file $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config'); // publish lang files $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); // publish public BackProject assets $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public'); // publish views $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views'); // publish error views $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors'); // publish public AdminLTE assets $this->publishes(['vendor/almasaeed2010/adminlte/bower_components/bootstrap/dist' => public_path('vendor/adminlte/bootstrap')], 'adminlte'); $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte'); $this->publishes(['vendor/almasaeed2010/adminlte/plugins' => public_path('vendor/adminlte/plugins')], 'adminlte'); }
[ "public", "function", "publishFiles", "(", ")", "{", "// publish config file", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../config/config.php'", "=>", "config_path", "(", ")", ".", "'/back-project.php'", "]", ",", "'config'", ")", ";", "// publish lang files", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/lang'", "=>", "resource_path", "(", "'lang/vendor/back-project'", ")", "]", ",", "'lang'", ")", ";", "// publish public BackProject assets", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../public'", "=>", "public_path", "(", "'vendor/back-project'", ")", "]", ",", "'public'", ")", ";", "// publish views", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/views'", "=>", "resource_path", "(", "'views/vendor/back-project'", ")", "]", ",", "'views'", ")", ";", "// publish error views", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/error_views'", "=>", "resource_path", "(", "'views/errors'", ")", "]", ",", "'errors'", ")", ";", "// publish public AdminLTE assets", "$", "this", "->", "publishes", "(", "[", "'vendor/almasaeed2010/adminlte/bower_components/bootstrap/dist'", "=>", "public_path", "(", "'vendor/adminlte/bootstrap'", ")", "]", ",", "'adminlte'", ")", ";", "$", "this", "->", "publishes", "(", "[", "'vendor/almasaeed2010/adminlte/dist'", "=>", "public_path", "(", "'vendor/adminlte/dist'", ")", "]", ",", "'adminlte'", ")", ";", "$", "this", "->", "publishes", "(", "[", "'vendor/almasaeed2010/adminlte/plugins'", "=>", "public_path", "(", "'vendor/adminlte/plugins'", ")", "]", ",", "'adminlte'", ")", ";", "}" ]
* Internal function **
[ "*", "Internal", "function", "**" ]
train
https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/BackProjectServiceProvider.php#L105-L121
tompedals/helpscout-dynamic-app
src/AppRequestFactory.php
AppRequestFactory.create
public function create(ServerRequestInterface $request) { $body = (string) $request->getBody(); $data = $this->decodeJsonBody($body); $this->verifySignature($body, $request->getHeaderLine(self::SIGNATURE_HEADER)); return new AppRequest( Customer::create(isset($data['customer']) ? $data['customer'] : []), Mailbox::create(isset($data['mailbox']) ? $data['mailbox'] : []), Ticket::create(isset($data['ticket']) ? $data['ticket'] : []), User::create(isset($data['user']) ? $data['user'] : []) ); }
php
public function create(ServerRequestInterface $request) { $body = (string) $request->getBody(); $data = $this->decodeJsonBody($body); $this->verifySignature($body, $request->getHeaderLine(self::SIGNATURE_HEADER)); return new AppRequest( Customer::create(isset($data['customer']) ? $data['customer'] : []), Mailbox::create(isset($data['mailbox']) ? $data['mailbox'] : []), Ticket::create(isset($data['ticket']) ? $data['ticket'] : []), User::create(isset($data['user']) ? $data['user'] : []) ); }
[ "public", "function", "create", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "body", "=", "(", "string", ")", "$", "request", "->", "getBody", "(", ")", ";", "$", "data", "=", "$", "this", "->", "decodeJsonBody", "(", "$", "body", ")", ";", "$", "this", "->", "verifySignature", "(", "$", "body", ",", "$", "request", "->", "getHeaderLine", "(", "self", "::", "SIGNATURE_HEADER", ")", ")", ";", "return", "new", "AppRequest", "(", "Customer", "::", "create", "(", "isset", "(", "$", "data", "[", "'customer'", "]", ")", "?", "$", "data", "[", "'customer'", "]", ":", "[", "]", ")", ",", "Mailbox", "::", "create", "(", "isset", "(", "$", "data", "[", "'mailbox'", "]", ")", "?", "$", "data", "[", "'mailbox'", "]", ":", "[", "]", ")", ",", "Ticket", "::", "create", "(", "isset", "(", "$", "data", "[", "'ticket'", "]", ")", "?", "$", "data", "[", "'ticket'", "]", ":", "[", "]", ")", ",", "User", "::", "create", "(", "isset", "(", "$", "data", "[", "'user'", "]", ")", "?", "$", "data", "[", "'user'", "]", ":", "[", "]", ")", ")", ";", "}" ]
@param ServerRequestInterface $request @return AppRequest
[ "@param", "ServerRequestInterface", "$request" ]
train
https://github.com/tompedals/helpscout-dynamic-app/blob/450d660db402a6aced0f541b71b89a0fc44d303a/src/AppRequestFactory.php#L35-L47
tompedals/helpscout-dynamic-app
src/AppRequestFactory.php
AppRequestFactory.decodeJsonBody
private function decodeJsonBody($body) { $data = json_decode($body, true); if ($data === null) { throw new InvalidRequestException('The request JSON body could not be decoded'); } return $data; }
php
private function decodeJsonBody($body) { $data = json_decode($body, true); if ($data === null) { throw new InvalidRequestException('The request JSON body could not be decoded'); } return $data; }
[ "private", "function", "decodeJsonBody", "(", "$", "body", ")", "{", "$", "data", "=", "json_decode", "(", "$", "body", ",", "true", ")", ";", "if", "(", "$", "data", "===", "null", ")", "{", "throw", "new", "InvalidRequestException", "(", "'The request JSON body could not be decoded'", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param string $body @return array JSON decoded data @throws InvalidRequestException
[ "@param", "string", "$body" ]
train
https://github.com/tompedals/helpscout-dynamic-app/blob/450d660db402a6aced0f541b71b89a0fc44d303a/src/AppRequestFactory.php#L56-L64
tompedals/helpscout-dynamic-app
src/AppRequestFactory.php
AppRequestFactory.verifySignature
private function verifySignature($body, $signature) { $expectedSignature = base64_encode(hash_hmac('sha1', $body, $this->secretKey, true)); if ($signature !== $expectedSignature) { throw new InvalidSignatureException('The request signature was invalid'); } }
php
private function verifySignature($body, $signature) { $expectedSignature = base64_encode(hash_hmac('sha1', $body, $this->secretKey, true)); if ($signature !== $expectedSignature) { throw new InvalidSignatureException('The request signature was invalid'); } }
[ "private", "function", "verifySignature", "(", "$", "body", ",", "$", "signature", ")", "{", "$", "expectedSignature", "=", "base64_encode", "(", "hash_hmac", "(", "'sha1'", ",", "$", "body", ",", "$", "this", "->", "secretKey", ",", "true", ")", ")", ";", "if", "(", "$", "signature", "!==", "$", "expectedSignature", ")", "{", "throw", "new", "InvalidSignatureException", "(", "'The request signature was invalid'", ")", ";", "}", "}" ]
@param string $body @param string $signature @throws InvalidSignatureException
[ "@param", "string", "$body", "@param", "string", "$signature" ]
train
https://github.com/tompedals/helpscout-dynamic-app/blob/450d660db402a6aced0f541b71b89a0fc44d303a/src/AppRequestFactory.php#L72-L79
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.register
public function register() { // This is the initial activation, save the defaults to the db if(!$this->options->exists()) { $this->reset(); } // Only preprocess if this is the currently viewed page if( $this->page->get_slug() == filter_input(INPUT_GET, 'page') ) { $this->preprocess(); } $this->page->register(); $this->set_global_variable(); $this->do_action('afw_options_init'); }
php
public function register() { // This is the initial activation, save the defaults to the db if(!$this->options->exists()) { $this->reset(); } // Only preprocess if this is the currently viewed page if( $this->page->get_slug() == filter_input(INPUT_GET, 'page') ) { $this->preprocess(); } $this->page->register(); $this->set_global_variable(); $this->do_action('afw_options_init'); }
[ "public", "function", "register", "(", ")", "{", "// This is the initial activation, save the defaults to the db", "if", "(", "!", "$", "this", "->", "options", "->", "exists", "(", ")", ")", "{", "$", "this", "->", "reset", "(", ")", ";", "}", "// Only preprocess if this is the currently viewed page", "if", "(", "$", "this", "->", "page", "->", "get_slug", "(", ")", "==", "filter_input", "(", "INPUT_GET", ",", "'page'", ")", ")", "{", "$", "this", "->", "preprocess", "(", ")", ";", "}", "$", "this", "->", "page", "->", "register", "(", ")", ";", "$", "this", "->", "set_global_variable", "(", ")", ";", "$", "this", "->", "do_action", "(", "'afw_options_init'", ")", ";", "}" ]
Register the options page.
[ "Register", "the", "options", "page", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L85-L102
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.create_page
private function create_page() { $self = $this; $page = new \Amarkal\Extensions\WordPress\Admin\AdminPage(array( 'title' => $this->config->sidebar_title, 'icon' => $this->config->sidebar_icon, 'class' => $this->config->sidebar_icon_class, 'style' => $this->config->sidebar_icon_style )); foreach( $this->config->sections as $section ) { $page->add_page(array( 'title' => $section->title, 'capability' => 'manage_options', 'content' => function() use ( $self ) { $self->render(); } )); } return $page; }
php
private function create_page() { $self = $this; $page = new \Amarkal\Extensions\WordPress\Admin\AdminPage(array( 'title' => $this->config->sidebar_title, 'icon' => $this->config->sidebar_icon, 'class' => $this->config->sidebar_icon_class, 'style' => $this->config->sidebar_icon_style )); foreach( $this->config->sections as $section ) { $page->add_page(array( 'title' => $section->title, 'capability' => 'manage_options', 'content' => function() use ( $self ) { $self->render(); } )); } return $page; }
[ "private", "function", "create_page", "(", ")", "{", "$", "self", "=", "$", "this", ";", "$", "page", "=", "new", "\\", "Amarkal", "\\", "Extensions", "\\", "WordPress", "\\", "Admin", "\\", "AdminPage", "(", "array", "(", "'title'", "=>", "$", "this", "->", "config", "->", "sidebar_title", ",", "'icon'", "=>", "$", "this", "->", "config", "->", "sidebar_icon", ",", "'class'", "=>", "$", "this", "->", "config", "->", "sidebar_icon_class", ",", "'style'", "=>", "$", "this", "->", "config", "->", "sidebar_icon_style", ")", ")", ";", "foreach", "(", "$", "this", "->", "config", "->", "sections", "as", "$", "section", ")", "{", "$", "page", "->", "add_page", "(", "array", "(", "'title'", "=>", "$", "section", "->", "title", ",", "'capability'", "=>", "'manage_options'", ",", "'content'", "=>", "function", "(", ")", "use", "(", "$", "self", ")", "{", "$", "self", "->", "render", "(", ")", ";", "}", ")", ")", ";", "}", "return", "$", "page", ";", "}" ]
Create a new AdminPage. @return \Amarkal\Extensions\WordPress\Admin\AdminPage
[ "Create", "a", "new", "AdminPage", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L109-L127
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.render
private function render() { $this->do_action('afw_options_pre_render'); $layout = new Layout\Layout( $this->config ); $layout->render(true); add_filter('admin_footer_text', array( __CLASS__, 'footer_credits' ) ); $this->do_action('afw_options_post_render'); }
php
private function render() { $this->do_action('afw_options_pre_render'); $layout = new Layout\Layout( $this->config ); $layout->render(true); add_filter('admin_footer_text', array( __CLASS__, 'footer_credits' ) ); $this->do_action('afw_options_post_render'); }
[ "private", "function", "render", "(", ")", "{", "$", "this", "->", "do_action", "(", "'afw_options_pre_render'", ")", ";", "$", "layout", "=", "new", "Layout", "\\", "Layout", "(", "$", "this", "->", "config", ")", ";", "$", "layout", "->", "render", "(", "true", ")", ";", "add_filter", "(", "'admin_footer_text'", ",", "array", "(", "__CLASS__", ",", "'footer_credits'", ")", ")", ";", "$", "this", "->", "do_action", "(", "'afw_options_post_render'", ")", ";", "}" ]
Internally used to render the page. Called by AdminPage to generate the admin page's content.
[ "Internally", "used", "to", "render", "the", "page", ".", "Called", "by", "AdminPage", "to", "generate", "the", "admin", "page", "s", "content", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L133-L140
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.preprocess
private function preprocess() { $this->do_action('afw_options_pre_process'); Notifier::reset(); State::set('errors', array()); $this->update(); $this->do_action('afw_options_post_process'); }
php
private function preprocess() { $this->do_action('afw_options_pre_process'); Notifier::reset(); State::set('errors', array()); $this->update(); $this->do_action('afw_options_post_process'); }
[ "private", "function", "preprocess", "(", ")", "{", "$", "this", "->", "do_action", "(", "'afw_options_pre_process'", ")", ";", "Notifier", "::", "reset", "(", ")", ";", "State", "::", "set", "(", "'errors'", ",", "array", "(", ")", ")", ";", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "do_action", "(", "'afw_options_post_process'", ")", ";", "}" ]
Internally used to update the options page's components.
[ "Internally", "used", "to", "update", "the", "options", "page", "s", "components", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L145-L152
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.update
private function update() { $errors = array(); switch( State::get('action') ) { case 'save': $errors = $this->save(); Notifier::success('Settings saved.'); break; case 'reset-section': $section = $this->config->get_section_by_slug(State::get('active_section')); $this->reset( $section ); Notifier::success('<strong>'.$section->title.'</strong> section was reset to its default settings.'); break; case 'reset-all': $this->reset(); Notifier::success('All sections were reset to their default settings.'); break; // No submission (simple request) default: $this->load(); } $this->set_errors($errors); }
php
private function update() { $errors = array(); switch( State::get('action') ) { case 'save': $errors = $this->save(); Notifier::success('Settings saved.'); break; case 'reset-section': $section = $this->config->get_section_by_slug(State::get('active_section')); $this->reset( $section ); Notifier::success('<strong>'.$section->title.'</strong> section was reset to its default settings.'); break; case 'reset-all': $this->reset(); Notifier::success('All sections were reset to their default settings.'); break; // No submission (simple request) default: $this->load(); } $this->set_errors($errors); }
[ "private", "function", "update", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "switch", "(", "State", "::", "get", "(", "'action'", ")", ")", "{", "case", "'save'", ":", "$", "errors", "=", "$", "this", "->", "save", "(", ")", ";", "Notifier", "::", "success", "(", "'Settings saved.'", ")", ";", "break", ";", "case", "'reset-section'", ":", "$", "section", "=", "$", "this", "->", "config", "->", "get_section_by_slug", "(", "State", "::", "get", "(", "'active_section'", ")", ")", ";", "$", "this", "->", "reset", "(", "$", "section", ")", ";", "Notifier", "::", "success", "(", "'<strong>'", ".", "$", "section", "->", "title", ".", "'</strong> section was reset to its default settings.'", ")", ";", "break", ";", "case", "'reset-all'", ":", "$", "this", "->", "reset", "(", ")", ";", "Notifier", "::", "success", "(", "'All sections were reset to their default settings.'", ")", ";", "break", ";", "// No submission (simple request)", "default", ":", "$", "this", "->", "load", "(", ")", ";", "}", "$", "this", "->", "set_errors", "(", "$", "errors", ")", ";", "}" ]
Save/reset/load component values.
[ "Save", "/", "reset", "/", "load", "component", "values", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L157-L181
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.set_errors
private function set_errors( $errors ) { if( count( $errors ) == 0 ) { return; } $errors_array = array(); foreach( $this->config->get_sections() as $section ) { foreach( $section->get_fields() as $component ) { if( $component instanceof \Amarkal\UI\ValidatableComponentInterface && $errors[$component->get_name()] ) { $errors_array[] = array( 'section'=> $section->get_slug(), 'message'=> $errors[$component->get_name()] ); } } } State::set('errors', $errors_array); }
php
private function set_errors( $errors ) { if( count( $errors ) == 0 ) { return; } $errors_array = array(); foreach( $this->config->get_sections() as $section ) { foreach( $section->get_fields() as $component ) { if( $component instanceof \Amarkal\UI\ValidatableComponentInterface && $errors[$component->get_name()] ) { $errors_array[] = array( 'section'=> $section->get_slug(), 'message'=> $errors[$component->get_name()] ); } } } State::set('errors', $errors_array); }
[ "private", "function", "set_errors", "(", "$", "errors", ")", "{", "if", "(", "count", "(", "$", "errors", ")", "==", "0", ")", "{", "return", ";", "}", "$", "errors_array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "config", "->", "get_sections", "(", ")", "as", "$", "section", ")", "{", "foreach", "(", "$", "section", "->", "get_fields", "(", ")", "as", "$", "component", ")", "{", "if", "(", "$", "component", "instanceof", "\\", "Amarkal", "\\", "UI", "\\", "ValidatableComponentInterface", "&&", "$", "errors", "[", "$", "component", "->", "get_name", "(", ")", "]", ")", "{", "$", "errors_array", "[", "]", "=", "array", "(", "'section'", "=>", "$", "section", "->", "get_slug", "(", ")", ",", "'message'", "=>", "$", "errors", "[", "$", "component", "->", "get_name", "(", ")", "]", ")", ";", "}", "}", "}", "State", "::", "set", "(", "'errors'", ",", "$", "errors_array", ")", ";", "}" ]
Set the state with the given errors. @param array $errors
[ "Set", "the", "state", "with", "the", "given", "errors", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L188-L210
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsPage.php
OptionsPage.set_global_variable
private function set_global_variable() { $var_name = ""; if( null != $this->config->global_variable ) { $var_name = $this->config->global_variable; } else { $var_name = $this->page->get_slug().'_options'; } $GLOBALS[$var_name] = $this->options->get(); }
php
private function set_global_variable() { $var_name = ""; if( null != $this->config->global_variable ) { $var_name = $this->config->global_variable; } else { $var_name = $this->page->get_slug().'_options'; } $GLOBALS[$var_name] = $this->options->get(); }
[ "private", "function", "set_global_variable", "(", ")", "{", "$", "var_name", "=", "\"\"", ";", "if", "(", "null", "!=", "$", "this", "->", "config", "->", "global_variable", ")", "{", "$", "var_name", "=", "$", "this", "->", "config", "->", "global_variable", ";", "}", "else", "{", "$", "var_name", "=", "$", "this", "->", "page", "->", "get_slug", "(", ")", ".", "'_options'", ";", "}", "$", "GLOBALS", "[", "$", "var_name", "]", "=", "$", "this", "->", "options", "->", "get", "(", ")", ";", "}" ]
Set a global variable containing the option values to be used throughout the program.
[ "Set", "a", "global", "variable", "containing", "the", "option", "values", "to", "be", "used", "throughout", "the", "program", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsPage.php#L255-L269
titon/db
src/Titon/Db/Behavior/FilterBehavior.php
FilterBehavior.filter
public function filter($field, $filter, array $options = []) { if (!in_array($filter, [self::HTML, self::NEWLINES, self::WHITESPACE, self::XSS])) { throw new InvalidArgumentException(sprintf('Filter %s does not exist', $filter)); } $this->_filters[$field][$filter] = $options; return $this; }
php
public function filter($field, $filter, array $options = []) { if (!in_array($filter, [self::HTML, self::NEWLINES, self::WHITESPACE, self::XSS])) { throw new InvalidArgumentException(sprintf('Filter %s does not exist', $filter)); } $this->_filters[$field][$filter] = $options; return $this; }
[ "public", "function", "filter", "(", "$", "field", ",", "$", "filter", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "in_array", "(", "$", "filter", ",", "[", "self", "::", "HTML", ",", "self", "::", "NEWLINES", ",", "self", "::", "WHITESPACE", ",", "self", "::", "XSS", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Filter %s does not exist'", ",", "$", "filter", ")", ")", ";", "}", "$", "this", "->", "_filters", "[", "$", "field", "]", "[", "$", "filter", "]", "=", "$", "options", ";", "return", "$", "this", ";", "}" ]
Define a filter for a specific field. @param string $field @param string $filter @param array $options @return $this @throws \Titon\Db\Exception\InvalidArgumentException
[ "Define", "a", "filter", "for", "a", "specific", "field", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/FilterBehavior.php#L44-L52
titon/db
src/Titon/Db/Behavior/FilterBehavior.php
FilterBehavior.preSave
public function preSave(Event $event, Query $query, $id, array &$data) { $filters = $this->getFilters(); foreach ($data as $key => $value) { if (empty($filters[$key])) { continue; } $filter = $filters[$key]; // HTML escape if (isset($filter['html'])) { $value = Sanitize::html($value, $filter['html']); } // Newlines if (isset($filter['newlines'])) { $value = Sanitize::newlines($value, $filter['newlines']); } // Whitespace if (isset($filter['whitespace'])) { $value = Sanitize::whitespace($value, $filter['whitespace']); } // XSS if (isset($filter['xss'])) { $value = Sanitize::xss($value, $filter['xss']); } $data[$key] = $value; } return true; }
php
public function preSave(Event $event, Query $query, $id, array &$data) { $filters = $this->getFilters(); foreach ($data as $key => $value) { if (empty($filters[$key])) { continue; } $filter = $filters[$key]; // HTML escape if (isset($filter['html'])) { $value = Sanitize::html($value, $filter['html']); } // Newlines if (isset($filter['newlines'])) { $value = Sanitize::newlines($value, $filter['newlines']); } // Whitespace if (isset($filter['whitespace'])) { $value = Sanitize::whitespace($value, $filter['whitespace']); } // XSS if (isset($filter['xss'])) { $value = Sanitize::xss($value, $filter['xss']); } $data[$key] = $value; } return true; }
[ "public", "function", "preSave", "(", "Event", "$", "event", ",", "Query", "$", "query", ",", "$", "id", ",", "array", "&", "$", "data", ")", "{", "$", "filters", "=", "$", "this", "->", "getFilters", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "filters", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "filter", "=", "$", "filters", "[", "$", "key", "]", ";", "// HTML escape", "if", "(", "isset", "(", "$", "filter", "[", "'html'", "]", ")", ")", "{", "$", "value", "=", "Sanitize", "::", "html", "(", "$", "value", ",", "$", "filter", "[", "'html'", "]", ")", ";", "}", "// Newlines", "if", "(", "isset", "(", "$", "filter", "[", "'newlines'", "]", ")", ")", "{", "$", "value", "=", "Sanitize", "::", "newlines", "(", "$", "value", ",", "$", "filter", "[", "'newlines'", "]", ")", ";", "}", "// Whitespace", "if", "(", "isset", "(", "$", "filter", "[", "'whitespace'", "]", ")", ")", "{", "$", "value", "=", "Sanitize", "::", "whitespace", "(", "$", "value", ",", "$", "filter", "[", "'whitespace'", "]", ")", ";", "}", "// XSS", "if", "(", "isset", "(", "$", "filter", "[", "'xss'", "]", ")", ")", "{", "$", "value", "=", "Sanitize", "::", "xss", "(", "$", "value", ",", "$", "filter", "[", "'xss'", "]", ")", ";", "}", "$", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "true", ";", "}" ]
Run the filters before each save. @param \Titon\Event\Event $event @param \Titon\Db\Query $query @param int|int[] $id @param array $data @return bool
[ "Run", "the", "filters", "before", "each", "save", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/FilterBehavior.php#L72-L106
tbreuss/pvc
src/Config.php
Config.get
public function get(string $name, $default = null) { $path = explode('.', $name); $current = $this->data; foreach ($path as $field) { if (isset($current) && isset($current[$field])) { $current = $current[$field]; } elseif (is_array($current) && isset($current[$field])) { $current = $current[$field]; } else { return $default; } } return $current; }
php
public function get(string $name, $default = null) { $path = explode('.', $name); $current = $this->data; foreach ($path as $field) { if (isset($current) && isset($current[$field])) { $current = $current[$field]; } elseif (is_array($current) && isset($current[$field])) { $current = $current[$field]; } else { return $default; } } return $current; }
[ "public", "function", "get", "(", "string", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "current", "=", "$", "this", "->", "data", ";", "foreach", "(", "$", "path", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "current", ")", "&&", "isset", "(", "$", "current", "[", "$", "field", "]", ")", ")", "{", "$", "current", "=", "$", "current", "[", "$", "field", "]", ";", "}", "elseif", "(", "is_array", "(", "$", "current", ")", "&&", "isset", "(", "$", "current", "[", "$", "field", "]", ")", ")", "{", "$", "current", "=", "$", "current", "[", "$", "field", "]", ";", "}", "else", "{", "return", "$", "default", ";", "}", "}", "return", "$", "current", ";", "}" ]
Get value by using dot notation for nested arrays. @example $value = $this->get('foo.bar.baz'); @param string $name @param mixed $default @return mixed
[ "Get", "value", "by", "using", "dot", "notation", "for", "nested", "arrays", "." ]
train
https://github.com/tbreuss/pvc/blob/ae100351010a8c9f645ccb918f70a26e167de7a7/src/Config.php#L32-L46
arsengoian/viper-framework
src/Viper/Core/Routing/Router.php
Router.registerCustomRouteClass
public static function registerCustomRouteClass(string $routeKey, string $routeClass) { self::checkRegisterAvailability(); if (!class_exists($routeClass)) throw new AppLogicException('Class '.$routeClass.' does not exist'); self::$customRouteClasses[$routeKey] = $routeClass; }
php
public static function registerCustomRouteClass(string $routeKey, string $routeClass) { self::checkRegisterAvailability(); if (!class_exists($routeClass)) throw new AppLogicException('Class '.$routeClass.' does not exist'); self::$customRouteClasses[$routeKey] = $routeClass; }
[ "public", "static", "function", "registerCustomRouteClass", "(", "string", "$", "routeKey", ",", "string", "$", "routeClass", ")", "{", "self", "::", "checkRegisterAvailability", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "routeClass", ")", ")", "throw", "new", "AppLogicException", "(", "'Class '", ".", "$", "routeClass", ".", "' does not exist'", ")", ";", "self", "::", "$", "customRouteClasses", "[", "$", "routeKey", "]", "=", "$", "routeClass", ";", "}" ]
Can't set custom actions. Only parsable from URL
[ "Can", "t", "set", "custom", "actions", ".", "Only", "parsable", "from", "URL" ]
train
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Core/Routing/Router.php#L59-L64
EvanDotPro/EdpGithub
src/EdpGithub/Http/Client.php
Client.request
public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array()) { $client = $this->getHttpClient($path); $request = $client->getRequest(); $client->setMethod($httpMethod); $client->setHeaders($headers); if ($httpMethod == 'GET') { $query = $request->getQuery(); foreach ($parameters as $key => $value) { $query->set($key, $value); } } elseif ($httpMethod == 'POST') { $request->setContent(json_encode($parameters)); } //Trigger Pre Send Event to modify Request Object $this->getEventManager()->trigger('pre.send', $request); $response = $client->dispatch($request); $this->response = $response; //Trigger Post Send to Modify/Validate Response object $result = $this->getEventManager()->trigger('post.send', $response); if ($result->stopped()) { $response = $result->last(); } $this->request = $request; return $response; }
php
public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array()) { $client = $this->getHttpClient($path); $request = $client->getRequest(); $client->setMethod($httpMethod); $client->setHeaders($headers); if ($httpMethod == 'GET') { $query = $request->getQuery(); foreach ($parameters as $key => $value) { $query->set($key, $value); } } elseif ($httpMethod == 'POST') { $request->setContent(json_encode($parameters)); } //Trigger Pre Send Event to modify Request Object $this->getEventManager()->trigger('pre.send', $request); $response = $client->dispatch($request); $this->response = $response; //Trigger Post Send to Modify/Validate Response object $result = $this->getEventManager()->trigger('post.send', $response); if ($result->stopped()) { $response = $result->last(); } $this->request = $request; return $response; }
[ "public", "function", "request", "(", "$", "path", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "httpMethod", "=", "'GET'", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "client", "=", "$", "this", "->", "getHttpClient", "(", "$", "path", ")", ";", "$", "request", "=", "$", "client", "->", "getRequest", "(", ")", ";", "$", "client", "->", "setMethod", "(", "$", "httpMethod", ")", ";", "$", "client", "->", "setHeaders", "(", "$", "headers", ")", ";", "if", "(", "$", "httpMethod", "==", "'GET'", ")", "{", "$", "query", "=", "$", "request", "->", "getQuery", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "elseif", "(", "$", "httpMethod", "==", "'POST'", ")", "{", "$", "request", "->", "setContent", "(", "json_encode", "(", "$", "parameters", ")", ")", ";", "}", "//Trigger Pre Send Event to modify Request Object", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'pre.send'", ",", "$", "request", ")", ";", "$", "response", "=", "$", "client", "->", "dispatch", "(", "$", "request", ")", ";", "$", "this", "->", "response", "=", "$", "response", ";", "//Trigger Post Send to Modify/Validate Response object", "$", "result", "=", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'post.send'", ",", "$", "response", ")", ";", "if", "(", "$", "result", "->", "stopped", "(", ")", ")", "{", "$", "response", "=", "$", "result", "->", "last", "(", ")", ";", "}", "$", "this", "->", "request", "=", "$", "request", ";", "return", "$", "response", ";", "}" ]
Send Request @param string $path @param array $parameters @param string $httpMethod @param array $headers @return Http\Response
[ "Send", "Request" ]
train
https://github.com/EvanDotPro/EdpGithub/blob/51f3e33e02edbef011103e3c2c1629d46af011a3/src/EdpGithub/Http/Client.php#L112-L143
EvanDotPro/EdpGithub
src/EdpGithub/Http/Client.php
Client.getHttpClient
public function getHttpClient($path) { $this->httpClient = new Http\Client(); $this->httpClient->setAdapter($this->getHttpAdapter()); $this->httpClient->setUri($this->options['base_url'] . $path); return $this->httpClient; }
php
public function getHttpClient($path) { $this->httpClient = new Http\Client(); $this->httpClient->setAdapter($this->getHttpAdapter()); $this->httpClient->setUri($this->options['base_url'] . $path); return $this->httpClient; }
[ "public", "function", "getHttpClient", "(", "$", "path", ")", "{", "$", "this", "->", "httpClient", "=", "new", "Http", "\\", "Client", "(", ")", ";", "$", "this", "->", "httpClient", "->", "setAdapter", "(", "$", "this", "->", "getHttpAdapter", "(", ")", ")", ";", "$", "this", "->", "httpClient", "->", "setUri", "(", "$", "this", "->", "options", "[", "'base_url'", "]", ".", "$", "path", ")", ";", "return", "$", "this", "->", "httpClient", ";", "}" ]
Get Http Client @param string $path @return Http\Client
[ "Get", "Http", "Client" ]
train
https://github.com/EvanDotPro/EdpGithub/blob/51f3e33e02edbef011103e3c2c1629d46af011a3/src/EdpGithub/Http/Client.php#L151-L158
EvanDotPro/EdpGithub
src/EdpGithub/Http/Client.php
Client.getHttpAdapter
public function getHttpAdapter() { if (null === $this->httpAdapter) { $this->httpAdapter = new Http\Client\Adapter\Curl(); $this->httpAdapter->setOptions(array( 'curloptions' => array( CURLOPT_SSL_VERIFYPEER => false, ), )); } return $this->httpAdapter; }
php
public function getHttpAdapter() { if (null === $this->httpAdapter) { $this->httpAdapter = new Http\Client\Adapter\Curl(); $this->httpAdapter->setOptions(array( 'curloptions' => array( CURLOPT_SSL_VERIFYPEER => false, ), )); } return $this->httpAdapter; }
[ "public", "function", "getHttpAdapter", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "httpAdapter", ")", "{", "$", "this", "->", "httpAdapter", "=", "new", "Http", "\\", "Client", "\\", "Adapter", "\\", "Curl", "(", ")", ";", "$", "this", "->", "httpAdapter", "->", "setOptions", "(", "array", "(", "'curloptions'", "=>", "array", "(", "CURLOPT_SSL_VERIFYPEER", "=>", "false", ",", ")", ",", ")", ")", ";", "}", "return", "$", "this", "->", "httpAdapter", ";", "}" ]
Get Http Adapter @return Http\Client\Adapter\Curl
[ "Get", "Http", "Adapter" ]
train
https://github.com/EvanDotPro/EdpGithub/blob/51f3e33e02edbef011103e3c2c1629d46af011a3/src/EdpGithub/Http/Client.php#L164-L176
dandisy/laravel-generator
src/Commands/Publish/GeneratorPublishCommand.php
GeneratorPublishCommand.fillTemplate
private function fillTemplate($templateData) { $apiVersion = config('webcore.laravel_generator.api_version', 'v1'); $apiPrefix = config('webcore.laravel_generator.api_prefix', 'api'); $templateData = str_replace('$API_VERSION$', $apiVersion, $templateData); $templateData = str_replace('$API_PREFIX$', $apiPrefix, $templateData); $appNamespace = $this->getLaravel()->getNamespace(); $appNamespace = substr($appNamespace, 0, strlen($appNamespace) - 1); $templateData = str_replace('$NAMESPACE_APP$', $appNamespace, $templateData); return $templateData; }
php
private function fillTemplate($templateData) { $apiVersion = config('webcore.laravel_generator.api_version', 'v1'); $apiPrefix = config('webcore.laravel_generator.api_prefix', 'api'); $templateData = str_replace('$API_VERSION$', $apiVersion, $templateData); $templateData = str_replace('$API_PREFIX$', $apiPrefix, $templateData); $appNamespace = $this->getLaravel()->getNamespace(); $appNamespace = substr($appNamespace, 0, strlen($appNamespace) - 1); $templateData = str_replace('$NAMESPACE_APP$', $appNamespace, $templateData); return $templateData; }
[ "private", "function", "fillTemplate", "(", "$", "templateData", ")", "{", "$", "apiVersion", "=", "config", "(", "'webcore.laravel_generator.api_version'", ",", "'v1'", ")", ";", "$", "apiPrefix", "=", "config", "(", "'webcore.laravel_generator.api_prefix'", ",", "'api'", ")", ";", "$", "templateData", "=", "str_replace", "(", "'$API_VERSION$'", ",", "$", "apiVersion", ",", "$", "templateData", ")", ";", "$", "templateData", "=", "str_replace", "(", "'$API_PREFIX$'", ",", "$", "apiPrefix", ",", "$", "templateData", ")", ";", "$", "appNamespace", "=", "$", "this", "->", "getLaravel", "(", ")", "->", "getNamespace", "(", ")", ";", "$", "appNamespace", "=", "substr", "(", "$", "appNamespace", ",", "0", ",", "strlen", "(", "$", "appNamespace", ")", "-", "1", ")", ";", "$", "templateData", "=", "str_replace", "(", "'$NAMESPACE_APP$'", ",", "$", "appNamespace", ",", "$", "templateData", ")", ";", "return", "$", "templateData", ";", "}" ]
Replaces dynamic variables of template. @param string $templateData @return string
[ "Replaces", "dynamic", "variables", "of", "template", "." ]
train
https://github.com/dandisy/laravel-generator/blob/742797c8483bc88b54b6302a516a9a85eeb8579b/src/Commands/Publish/GeneratorPublishCommand.php#L41-L53
nodes-php/database
src/Exceptions/SaveFailedException.php
SaveFailedException.setPreviousExceptionMeta
private function setPreviousExceptionMeta() { if ($exception = $this->previousException) { $this->meta['previous_exception'] = [ 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace(), ]; } }
php
private function setPreviousExceptionMeta() { if ($exception = $this->previousException) { $this->meta['previous_exception'] = [ 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace(), ]; } }
[ "private", "function", "setPreviousExceptionMeta", "(", ")", "{", "if", "(", "$", "exception", "=", "$", "this", "->", "previousException", ")", "{", "$", "this", "->", "meta", "[", "'previous_exception'", "]", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'trace'", "=>", "$", "exception", "->", "getTrace", "(", ")", ",", "]", ";", "}", "}" ]
setPreviousExceptionMeta @author Casper Rasmussen <[email protected]> @access private @return void
[ "setPreviousExceptionMeta" ]
train
https://github.com/nodes-php/database/blob/ec58a01a2b966f89efeac58ac9ac633919c04a52/src/Exceptions/SaveFailedException.php#L63-L73
dms-org/package.blog
src/Infrastructure/Persistence/BlogOrm.php
BlogOrm.define
protected function define(OrmDefinition $orm) { $orm->entities([ BlogCategory::class => BlogCategoryMapper::class, BlogAuthor::class => BlogAuthorMapper::class, BlogArticle::class => BlogArticleMapper::class, BlogArticleComment::class => BlogArticleCommentMapper::class, ]); }
php
protected function define(OrmDefinition $orm) { $orm->entities([ BlogCategory::class => BlogCategoryMapper::class, BlogAuthor::class => BlogAuthorMapper::class, BlogArticle::class => BlogArticleMapper::class, BlogArticleComment::class => BlogArticleCommentMapper::class, ]); }
[ "protected", "function", "define", "(", "OrmDefinition", "$", "orm", ")", "{", "$", "orm", "->", "entities", "(", "[", "BlogCategory", "::", "class", "=>", "BlogCategoryMapper", "::", "class", ",", "BlogAuthor", "::", "class", "=>", "BlogAuthorMapper", "::", "class", ",", "BlogArticle", "::", "class", "=>", "BlogArticleMapper", "::", "class", ",", "BlogArticleComment", "::", "class", "=>", "BlogArticleCommentMapper", "::", "class", ",", "]", ")", ";", "}" ]
Defines the object mappers registered in the orm. @param OrmDefinition $orm @return void
[ "Defines", "the", "object", "mappers", "registered", "in", "the", "orm", "." ]
train
https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Infrastructure/Persistence/BlogOrm.php#L35-L43
netgen/ngopengraph
classes/ngopengraphbase.php
ngOpenGraphBase.getInstance
static function getInstance( eZContentObjectAttribute $objectAttribute ) { $datatypeString = $objectAttribute->attribute( 'data_type_string' ); $dataTypeHandlers = self::$ogIni->variable( 'OpenGraph', 'DataTypeHandlers' ); if ( array_key_exists( $datatypeString, $dataTypeHandlers ) ) { if ( class_exists( $dataTypeHandlers[$datatypeString] ) ) { return new $dataTypeHandlers[$datatypeString]( $objectAttribute ); } } return new ngOpenGraphBase( $objectAttribute ); }
php
static function getInstance( eZContentObjectAttribute $objectAttribute ) { $datatypeString = $objectAttribute->attribute( 'data_type_string' ); $dataTypeHandlers = self::$ogIni->variable( 'OpenGraph', 'DataTypeHandlers' ); if ( array_key_exists( $datatypeString, $dataTypeHandlers ) ) { if ( class_exists( $dataTypeHandlers[$datatypeString] ) ) { return new $dataTypeHandlers[$datatypeString]( $objectAttribute ); } } return new ngOpenGraphBase( $objectAttribute ); }
[ "static", "function", "getInstance", "(", "eZContentObjectAttribute", "$", "objectAttribute", ")", "{", "$", "datatypeString", "=", "$", "objectAttribute", "->", "attribute", "(", "'data_type_string'", ")", ";", "$", "dataTypeHandlers", "=", "self", "::", "$", "ogIni", "->", "variable", "(", "'OpenGraph'", ",", "'DataTypeHandlers'", ")", ";", "if", "(", "array_key_exists", "(", "$", "datatypeString", ",", "$", "dataTypeHandlers", ")", ")", "{", "if", "(", "class_exists", "(", "$", "dataTypeHandlers", "[", "$", "datatypeString", "]", ")", ")", "{", "return", "new", "$", "dataTypeHandlers", "[", "$", "datatypeString", "]", "(", "$", "objectAttribute", ")", ";", "}", "}", "return", "new", "ngOpenGraphBase", "(", "$", "objectAttribute", ")", ";", "}" ]
Gets the instance of Open Graph attribute handler for the attribute @param eZContentObjectAttribute $objectAttribute @return ngOpenGraphBase
[ "Gets", "the", "instance", "of", "Open", "Graph", "attribute", "handler", "for", "the", "attribute" ]
train
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/classes/ngopengraphbase.php#L22-L36
ufocoder/yii2-SyncSocial
src/actions/DisconnectAction.php
DisconnectAction.run
public function run( $service ) { return $this->redirectWithMessages( $this->synchronizer->disconnect( $service ), Yii::t( 'SyncSocial', 'Service was successfully disconnected' ), Yii::t( 'SyncSocial', 'There is error in disconnection' ) ); }
php
public function run( $service ) { return $this->redirectWithMessages( $this->synchronizer->disconnect( $service ), Yii::t( 'SyncSocial', 'Service was successfully disconnected' ), Yii::t( 'SyncSocial', 'There is error in disconnection' ) ); }
[ "public", "function", "run", "(", "$", "service", ")", "{", "return", "$", "this", "->", "redirectWithMessages", "(", "$", "this", "->", "synchronizer", "->", "disconnect", "(", "$", "service", ")", ",", "Yii", "::", "t", "(", "'SyncSocial'", ",", "'Service was successfully disconnected'", ")", ",", "Yii", "::", "t", "(", "'SyncSocial'", ",", "'There is error in disconnection'", ")", ")", ";", "}" ]
@param $service @return \yii\web\Response
[ "@param", "$service" ]
train
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/actions/DisconnectAction.php#L18-L25
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.commitChanges
final public function commitChanges() { if (null !== $this->changes) { $this->lastCommittedEventSequenceNumber = $this->changes->lastSequenceNumber(); $this->changes->commit(); } }
php
final public function commitChanges() { if (null !== $this->changes) { $this->lastCommittedEventSequenceNumber = $this->changes->lastSequenceNumber(); $this->changes->commit(); } }
[ "final", "public", "function", "commitChanges", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "changes", ")", "{", "$", "this", "->", "lastCommittedEventSequenceNumber", "=", "$", "this", "->", "changes", "->", "lastSequenceNumber", "(", ")", ";", "$", "this", "->", "changes", "->", "commit", "(", ")", ";", "}", "}" ]
Clears all recorded events.
[ "Clears", "all", "recorded", "events", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L78-L84
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.applyChange
final protected function applyChange(Serializable $payload) { $this->apply($payload); $this->changes()->addEventFromPayload($payload); }
php
final protected function applyChange(Serializable $payload) { $this->apply($payload); $this->changes()->addEventFromPayload($payload); }
[ "final", "protected", "function", "applyChange", "(", "Serializable", "$", "payload", ")", "{", "$", "this", "->", "apply", "(", "$", "payload", ")", ";", "$", "this", "->", "changes", "(", ")", "->", "addEventFromPayload", "(", "$", "payload", ")", ";", "}" ]
Mutate the state of the aggregate by applying a domain event. Keep track of the change until it has been successfully committed. @param Serializable $payload
[ "Mutate", "the", "state", "of", "the", "aggregate", "by", "applying", "a", "domain", "event", ".", "Keep", "track", "of", "the", "change", "until", "it", "has", "been", "successfully", "committed", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L92-L96
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.replayChange
final private function replayChange(Event $event) { $this->apply($event->payload()); $this->lastCommittedEventSequenceNumber = $event->sequenceNumber(); }
php
final private function replayChange(Event $event) { $this->apply($event->payload()); $this->lastCommittedEventSequenceNumber = $event->sequenceNumber(); }
[ "final", "private", "function", "replayChange", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "apply", "(", "$", "event", "->", "payload", "(", ")", ")", ";", "$", "this", "->", "lastCommittedEventSequenceNumber", "=", "$", "event", "->", "sequenceNumber", "(", ")", ";", "}" ]
Mutate the state of the aggregate by applying the domain event contained into the message. Synchronize the aggregate version with the one provided by the message. @param Event $event
[ "Mutate", "the", "state", "of", "the", "aggregate", "by", "applying", "the", "domain", "event", "contained", "into", "the", "message", ".", "Synchronize", "the", "aggregate", "version", "with", "the", "one", "provided", "by", "the", "message", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L104-L108
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.apply
final private function apply(Serializable $payload) { $method = $this->applyMethod($payload); $this->$method($payload); }
php
final private function apply(Serializable $payload) { $method = $this->applyMethod($payload); $this->$method($payload); }
[ "final", "private", "function", "apply", "(", "Serializable", "$", "payload", ")", "{", "$", "method", "=", "$", "this", "->", "applyMethod", "(", "$", "payload", ")", ";", "$", "this", "->", "$", "method", "(", "$", "payload", ")", ";", "}" ]
Mutate the state of the aggregate by applying a domain event. @param Serializable $payload
[ "Mutate", "the", "state", "of", "the", "aggregate", "by", "applying", "a", "domain", "event", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L115-L119
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.applyMethod
protected function applyMethod(Serializable $payload) { $className = get_class($payload); return 'apply'.substr($className, strrpos($className, '\\') + 1); }
php
protected function applyMethod(Serializable $payload) { $className = get_class($payload); return 'apply'.substr($className, strrpos($className, '\\') + 1); }
[ "protected", "function", "applyMethod", "(", "Serializable", "$", "payload", ")", "{", "$", "className", "=", "get_class", "(", "$", "payload", ")", ";", "return", "'apply'", ".", "substr", "(", "$", "className", ",", "strrpos", "(", "$", "className", ",", "'\\\\'", ")", "+", "1", ")", ";", "}" ]
Returns method to call for applying a given domain event to the aggregate. This can be overridden to suit your custom naming convention. @param Serializable $payload @return string
[ "Returns", "method", "to", "call", "for", "applying", "a", "given", "domain", "event", "to", "the", "aggregate", ".", "This", "can", "be", "overridden", "to", "suit", "your", "custom", "naming", "convention", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L129-L134
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.changes
final private function changes() { if (null === $this->changes) { $lastCommittedEventSequenceNumber = $this->lastCommittedEventSequenceNumber(); $this->changes = new DefaultEventContainer($this->identifier(), $lastCommittedEventSequenceNumber); } return $this->changes; }
php
final private function changes() { if (null === $this->changes) { $lastCommittedEventSequenceNumber = $this->lastCommittedEventSequenceNumber(); $this->changes = new DefaultEventContainer($this->identifier(), $lastCommittedEventSequenceNumber); } return $this->changes; }
[ "final", "private", "function", "changes", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "changes", ")", "{", "$", "lastCommittedEventSequenceNumber", "=", "$", "this", "->", "lastCommittedEventSequenceNumber", "(", ")", ";", "$", "this", "->", "changes", "=", "new", "DefaultEventContainer", "(", "$", "this", "->", "identifier", "(", ")", ",", "$", "lastCommittedEventSequenceNumber", ")", ";", "}", "return", "$", "this", "->", "changes", ";", "}" ]
Return the event container containing the uncommitted changes. If there are no pending changes to be committed, a new event container will be initialized. @return EventContainer
[ "Return", "the", "event", "container", "containing", "the", "uncommitted", "changes", ".", "If", "there", "are", "no", "pending", "changes", "to", "be", "committed", "a", "new", "event", "container", "will", "be", "initialized", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L143-L152
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.loadFromHistory
final public static function loadFromHistory(EventStream $eventStream) { $aggregate = new static(); while ($eventStream->hasNext()) { $aggregate->replayChange($eventStream->next()); } return $aggregate; }
php
final public static function loadFromHistory(EventStream $eventStream) { $aggregate = new static(); while ($eventStream->hasNext()) { $aggregate->replayChange($eventStream->next()); } return $aggregate; }
[ "final", "public", "static", "function", "loadFromHistory", "(", "EventStream", "$", "eventStream", ")", "{", "$", "aggregate", "=", "new", "static", "(", ")", ";", "while", "(", "$", "eventStream", "->", "hasNext", "(", ")", ")", "{", "$", "aggregate", "->", "replayChange", "(", "$", "eventStream", "->", "next", "(", ")", ")", ";", "}", "return", "$", "aggregate", ";", "}" ]
Roll-out all events to reconstitute the state of the aggregate. @param EventStream $eventStream @return static
[ "Roll", "-", "out", "all", "events", "to", "reconstitute", "the", "state", "of", "the", "aggregate", "." ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L161-L170
rayrutjes/domain-foundation
src/Domain/AggregateRoot/EventSourcedAggregateRoot.php
EventSourcedAggregateRoot.sameIdentityAs
final public function sameIdentityAs(AggregateRoot $aggregateRoot) { if (!$aggregateRoot instanceof static) { return false; } return $this->identifier()->equals($aggregateRoot->identifier()); }
php
final public function sameIdentityAs(AggregateRoot $aggregateRoot) { if (!$aggregateRoot instanceof static) { return false; } return $this->identifier()->equals($aggregateRoot->identifier()); }
[ "final", "public", "function", "sameIdentityAs", "(", "AggregateRoot", "$", "aggregateRoot", ")", "{", "if", "(", "!", "$", "aggregateRoot", "instanceof", "static", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "identifier", "(", ")", "->", "equals", "(", "$", "aggregateRoot", "->", "identifier", "(", ")", ")", ";", "}" ]
@param AggregateRoot $aggregateRoot @return mixed
[ "@param", "AggregateRoot", "$aggregateRoot" ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Domain/AggregateRoot/EventSourcedAggregateRoot.php#L201-L208
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.addAnnotationsForSource
public function addAnnotationsForSource(DocBlock $docBlock) { extract(Annotation::getClosureHelpers()); $docBlock->addAnnotation($this->getRelation()); if ($this->type === self::MANY_TO_MANY && $this->sourceSide !== self::INVERSE) { // bei unidirectional brauchen wir natürlich auch einen JoinTable $docBlock->addAnnotation($this->getJoinTable()); } if ($this->type === self::MANY_TO_ONE || $this->type === self::ONE_TO_ONE) { $docBlock->addAnnotation($this->getJoinColumn()); } if (($this->type === self::MANY_TO_MANY || $this->type === self::ONE_TO_MANY) && isset($this->orderBy)) { $docBlock->addAnnotation($this->orderBy); } foreach ($this->otherAnnotations as $annotation) { $docBlock->addAnnotation($annotation); } }
php
public function addAnnotationsForSource(DocBlock $docBlock) { extract(Annotation::getClosureHelpers()); $docBlock->addAnnotation($this->getRelation()); if ($this->type === self::MANY_TO_MANY && $this->sourceSide !== self::INVERSE) { // bei unidirectional brauchen wir natürlich auch einen JoinTable $docBlock->addAnnotation($this->getJoinTable()); } if ($this->type === self::MANY_TO_ONE || $this->type === self::ONE_TO_ONE) { $docBlock->addAnnotation($this->getJoinColumn()); } if (($this->type === self::MANY_TO_MANY || $this->type === self::ONE_TO_MANY) && isset($this->orderBy)) { $docBlock->addAnnotation($this->orderBy); } foreach ($this->otherAnnotations as $annotation) { $docBlock->addAnnotation($annotation); } }
[ "public", "function", "addAnnotationsForSource", "(", "DocBlock", "$", "docBlock", ")", "{", "extract", "(", "Annotation", "::", "getClosureHelpers", "(", ")", ")", ";", "$", "docBlock", "->", "addAnnotation", "(", "$", "this", "->", "getRelation", "(", ")", ")", ";", "if", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_MANY", "&&", "$", "this", "->", "sourceSide", "!==", "self", "::", "INVERSE", ")", "{", "// bei unidirectional brauchen wir natürlich auch einen JoinTable", "$", "docBlock", "->", "addAnnotation", "(", "$", "this", "->", "getJoinTable", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_ONE", "||", "$", "this", "->", "type", "===", "self", "::", "ONE_TO_ONE", ")", "{", "$", "docBlock", "->", "addAnnotation", "(", "$", "this", "->", "getJoinColumn", "(", ")", ")", ";", "}", "if", "(", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_MANY", "||", "$", "this", "->", "type", "===", "self", "::", "ONE_TO_MANY", ")", "&&", "isset", "(", "$", "this", "->", "orderBy", ")", ")", "{", "$", "docBlock", "->", "addAnnotation", "(", "$", "this", "->", "orderBy", ")", ";", "}", "foreach", "(", "$", "this", "->", "otherAnnotations", "as", "$", "annotation", ")", "{", "$", "docBlock", "->", "addAnnotation", "(", "$", "annotation", ")", ";", "}", "}" ]
Fügt einem DocBlock die passenden Annotations für die Source Seite der Relation hinzu
[ "Fügt", "einem", "DocBlock", "die", "passenden", "Annotations", "für", "die", "Source", "Seite", "der", "Relation", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L157-L177
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.setRelationType
public function setRelationType($type, $direction = 'bidirectional', $whoIsOwningSide = 'source') { // zuerst setzen wir die direction, denn wenn type nicht gesetzt ist, macht die nichts $this->setDirection($direction); // dann setzen wir den type, dies setzt dann bei one to many und many to one die inverse side und owning side schon korrekt // weil ja direction schon unidirectional oder bidirectional ist $this->setType($type); // fails silently bei oneToMany and ManyToOne (oder halt mal nicht, falls sich das ändert) if (isset($whoIsOwningSide)) $this->setOwningSide($whoIsOwningSide); return $this; }
php
public function setRelationType($type, $direction = 'bidirectional', $whoIsOwningSide = 'source') { // zuerst setzen wir die direction, denn wenn type nicht gesetzt ist, macht die nichts $this->setDirection($direction); // dann setzen wir den type, dies setzt dann bei one to many und many to one die inverse side und owning side schon korrekt // weil ja direction schon unidirectional oder bidirectional ist $this->setType($type); // fails silently bei oneToMany and ManyToOne (oder halt mal nicht, falls sich das ändert) if (isset($whoIsOwningSide)) $this->setOwningSide($whoIsOwningSide); return $this; }
[ "public", "function", "setRelationType", "(", "$", "type", ",", "$", "direction", "=", "'bidirectional'", ",", "$", "whoIsOwningSide", "=", "'source'", ")", "{", "// zuerst setzen wir die direction, denn wenn type nicht gesetzt ist, macht die nichts", "$", "this", "->", "setDirection", "(", "$", "direction", ")", ";", "// dann setzen wir den type, dies setzt dann bei one to many und many to one die inverse side und owning side schon korrekt", "// weil ja direction schon unidirectional oder bidirectional ist", "$", "this", "->", "setType", "(", "$", "type", ")", ";", "// fails silently bei oneToMany and ManyToOne (oder halt mal nicht, falls sich das ändert)", "if", "(", "isset", "(", "$", "whoIsOwningSide", ")", ")", "$", "this", "->", "setOwningSide", "(", "$", "whoIsOwningSide", ")", ";", "return", "$", "this", ";", "}" ]
Setzt alle Eigenschaften der Relation gleichzeitig $whoIsOwningSide wird bei MANY_TO_ONE und ONE_TO_MANY ignoriert (denn dort ist es immer automatisch die MANY Seite) ist $direction nicht bidirectional wird die inverse side der Relation nicht automatisch gesetzt
[ "Setzt", "alle", "Eigenschaften", "der", "Relation", "gleichzeitig" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L193-L207
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.setOwningSide
public function setOwningSide($sourceOrTarget) { Code::value($sourceOrTarget, self::SOURCE, self::TARGET, TRUE); if ($this->type === self::MANY_TO_MANY || $this->type === self::ONE_TO_ONE) { if ($sourceOrTarget === self::SOURCE || $sourceOrTarget === TRUE) { $this->sourceSide = self::OWNING; $this->targetSide = $this->isBidirectional() ? self::INVERSE : self::NONE; // many seite } else { if ($this->isUnidirectional()) { throw new \RuntimeException('Da die Relation unidirectional ist, kann die Owning Side nicht Target sein. (sonst gäbe es gar keine Owning Side)'); } $this->sourceSide = self::INVERSE; $this->targetSide = self::OWNING; } } return $this; }
php
public function setOwningSide($sourceOrTarget) { Code::value($sourceOrTarget, self::SOURCE, self::TARGET, TRUE); if ($this->type === self::MANY_TO_MANY || $this->type === self::ONE_TO_ONE) { if ($sourceOrTarget === self::SOURCE || $sourceOrTarget === TRUE) { $this->sourceSide = self::OWNING; $this->targetSide = $this->isBidirectional() ? self::INVERSE : self::NONE; // many seite } else { if ($this->isUnidirectional()) { throw new \RuntimeException('Da die Relation unidirectional ist, kann die Owning Side nicht Target sein. (sonst gäbe es gar keine Owning Side)'); } $this->sourceSide = self::INVERSE; $this->targetSide = self::OWNING; } } return $this; }
[ "public", "function", "setOwningSide", "(", "$", "sourceOrTarget", ")", "{", "Code", "::", "value", "(", "$", "sourceOrTarget", ",", "self", "::", "SOURCE", ",", "self", "::", "TARGET", ",", "TRUE", ")", ";", "if", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_MANY", "||", "$", "this", "->", "type", "===", "self", "::", "ONE_TO_ONE", ")", "{", "if", "(", "$", "sourceOrTarget", "===", "self", "::", "SOURCE", "||", "$", "sourceOrTarget", "===", "TRUE", ")", "{", "$", "this", "->", "sourceSide", "=", "self", "::", "OWNING", ";", "$", "this", "->", "targetSide", "=", "$", "this", "->", "isBidirectional", "(", ")", "?", "self", "::", "INVERSE", ":", "self", "::", "NONE", ";", "// many seite", "}", "else", "{", "if", "(", "$", "this", "->", "isUnidirectional", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Da die Relation unidirectional ist, kann die Owning Side nicht Target sein. (sonst gäbe es gar keine Owning Side)')", ";", "", "}", "$", "this", "->", "sourceSide", "=", "self", "::", "INVERSE", ";", "$", "this", "->", "targetSide", "=", "self", "::", "OWNING", ";", "}", "}", "return", "$", "this", ";", "}" ]
Setzt die Owning (und ggf. inverse Side) ist die relation bidirectional (default), so wird die inverse side automatisch mitgesetzt @param SOURCE|TARGET $sourceOrTarget
[ "Setzt", "die", "Owning", "(", "und", "ggf", ".", "inverse", "Side", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L215-L232
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.setType
public function setType($type) { Code::value($type, self::MANY_TO_MANY, self::MANY_TO_ONE, self::ONE_TO_MANY, self::ONE_TO_ONE); $this->type = $type; // wir tun immer so, als wären die anderen states schon sinnvoll gesetzt und passen die klasse an unsere ideen an. if ($this->type === self::MANY_TO_ONE) { $this->sourceSide = self::OWNING; // many seite $this->targetSide = $this->isBidirectional() || $this->isSelfReferencing() ? self::INVERSE : self::NONE; // one seite // eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht // denn eigentlich hat die ja die many side die single value $this->source->setValueType(EntityRelationMeta::COLLECTION_VALUED); $this->target->setValueType(EntityRelationMeta::SINGLE_VALUED); } elseif ($this->type === self::ONE_TO_MANY) { $this->sourceSide = self::INVERSE; // one seite $this->targetSide = $this->isBidirectional() || $this->isSelfReferencing() ? self::OWNING : self::NONE; // many seite // eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht // denn eigentlich hat die ja die many side die single value $this->source->setValueType(EntityRelationMeta::SINGLE_VALUED); $this->target->setValueType(EntityRelationMeta::COLLECTION_VALUED); } elseif ($this->type === self::MANY_TO_MANY) { $this->target->setValueType(EntityRelationMeta::COLLECTION_VALUED); $this->source->setValueType(EntityRelationMeta::COLLECTION_VALUED); } elseif ($this->type === self::ONE_TO_ONE) { $this->source->setValueType(EntityRelationMeta::SINGLE_VALUED); $this->target->setValueType(EntityRelationMeta::SINGLE_VALUED); } return $this; }
php
public function setType($type) { Code::value($type, self::MANY_TO_MANY, self::MANY_TO_ONE, self::ONE_TO_MANY, self::ONE_TO_ONE); $this->type = $type; // wir tun immer so, als wären die anderen states schon sinnvoll gesetzt und passen die klasse an unsere ideen an. if ($this->type === self::MANY_TO_ONE) { $this->sourceSide = self::OWNING; // many seite $this->targetSide = $this->isBidirectional() || $this->isSelfReferencing() ? self::INVERSE : self::NONE; // one seite // eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht // denn eigentlich hat die ja die many side die single value $this->source->setValueType(EntityRelationMeta::COLLECTION_VALUED); $this->target->setValueType(EntityRelationMeta::SINGLE_VALUED); } elseif ($this->type === self::ONE_TO_MANY) { $this->sourceSide = self::INVERSE; // one seite $this->targetSide = $this->isBidirectional() || $this->isSelfReferencing() ? self::OWNING : self::NONE; // many seite // eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht // denn eigentlich hat die ja die many side die single value $this->source->setValueType(EntityRelationMeta::SINGLE_VALUED); $this->target->setValueType(EntityRelationMeta::COLLECTION_VALUED); } elseif ($this->type === self::MANY_TO_MANY) { $this->target->setValueType(EntityRelationMeta::COLLECTION_VALUED); $this->source->setValueType(EntityRelationMeta::COLLECTION_VALUED); } elseif ($this->type === self::ONE_TO_ONE) { $this->source->setValueType(EntityRelationMeta::SINGLE_VALUED); $this->target->setValueType(EntityRelationMeta::SINGLE_VALUED); } return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "Code", "::", "value", "(", "$", "type", ",", "self", "::", "MANY_TO_MANY", ",", "self", "::", "MANY_TO_ONE", ",", "self", "::", "ONE_TO_MANY", ",", "self", "::", "ONE_TO_ONE", ")", ";", "$", "this", "->", "type", "=", "$", "type", ";", "// wir tun immer so, als wären die anderen states schon sinnvoll gesetzt und passen die klasse an unsere ideen an.", "if", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_ONE", ")", "{", "$", "this", "->", "sourceSide", "=", "self", "::", "OWNING", ";", "// many seite", "$", "this", "->", "targetSide", "=", "$", "this", "->", "isBidirectional", "(", ")", "||", "$", "this", "->", "isSelfReferencing", "(", ")", "?", "self", "::", "INVERSE", ":", "self", "::", "NONE", ";", "// one seite", "// eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht", "// denn eigentlich hat die ja die many side die single value", "$", "this", "->", "source", "->", "setValueType", "(", "EntityRelationMeta", "::", "COLLECTION_VALUED", ")", ";", "$", "this", "->", "target", "->", "setValueType", "(", "EntityRelationMeta", "::", "SINGLE_VALUED", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "===", "self", "::", "ONE_TO_MANY", ")", "{", "$", "this", "->", "sourceSide", "=", "self", "::", "INVERSE", ";", "// one seite", "$", "this", "->", "targetSide", "=", "$", "this", "->", "isBidirectional", "(", ")", "||", "$", "this", "->", "isSelfReferencing", "(", ")", "?", "self", "::", "OWNING", ":", "self", "::", "NONE", ";", "// many seite", "// eben weil die Properties nicht verdreht sind, ist auch hier single und collection vertauscht", "// denn eigentlich hat die ja die many side die single value", "$", "this", "->", "source", "->", "setValueType", "(", "EntityRelationMeta", "::", "SINGLE_VALUED", ")", ";", "$", "this", "->", "target", "->", "setValueType", "(", "EntityRelationMeta", "::", "COLLECTION_VALUED", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "===", "self", "::", "MANY_TO_MANY", ")", "{", "$", "this", "->", "target", "->", "setValueType", "(", "EntityRelationMeta", "::", "COLLECTION_VALUED", ")", ";", "$", "this", "->", "source", "->", "setValueType", "(", "EntityRelationMeta", "::", "COLLECTION_VALUED", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "===", "self", "::", "ONE_TO_ONE", ")", "{", "$", "this", "->", "source", "->", "setValueType", "(", "EntityRelationMeta", "::", "SINGLE_VALUED", ")", ";", "$", "this", "->", "target", "->", "setValueType", "(", "EntityRelationMeta", "::", "SINGLE_VALUED", ")", ";", "}", "return", "$", "this", ";", "}" ]
Setzt den (Relation-)Type der Relation (aka (MANY|ONE)_TO_(MANY|ONE) Konstante) @param const $type
[ "Setzt", "den", "(", "Relation", "-", ")", "Type", "der", "Relation", "(", "aka", "(", "MANY|ONE", ")", "_TO_", "(", "MANY|ONE", ")", "Konstante", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L281-L311
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.shouldUpdateOtherSide
public function shouldUpdateOtherSide() { if (isset($this->updateOtherSide)) { return $this->updateOtherSide; } return $this->isBidirectional() && $this->getSourceSide() === EntityRelation::OWNING; }
php
public function shouldUpdateOtherSide() { if (isset($this->updateOtherSide)) { return $this->updateOtherSide; } return $this->isBidirectional() && $this->getSourceSide() === EntityRelation::OWNING; }
[ "public", "function", "shouldUpdateOtherSide", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "updateOtherSide", ")", ")", "{", "return", "$", "this", "->", "updateOtherSide", ";", "}", "return", "$", "this", "->", "isBidirectional", "(", ")", "&&", "$", "this", "->", "getSourceSide", "(", ")", "===", "EntityRelation", "::", "OWNING", ";", "}" ]
Gibt zurück ob die Source-Seite im relation interface die andere Seite mit updaten soll @return bool
[ "Gibt", "zurück", "ob", "die", "Source", "-", "Seite", "im", "relation", "interface", "die", "andere", "Seite", "mit", "updaten", "soll" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L403-L409
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityRelation.php
EntityRelation.setJoinColumnNullable
public function setJoinColumnNullable($bool) { $this->nullable = $bool; $this->getJoinColumn()->setNullable($bool); return $this; }
php
public function setJoinColumnNullable($bool) { $this->nullable = $bool; $this->getJoinColumn()->setNullable($bool); return $this; }
[ "public", "function", "setJoinColumnNullable", "(", "$", "bool", ")", "{", "$", "this", "->", "nullable", "=", "$", "bool", ";", "$", "this", "->", "getJoinColumn", "(", ")", "->", "setNullable", "(", "$", "bool", ")", ";", "return", "$", "this", ";", "}" ]
Achtung dies erzeugt die JoinColumn und sollte nur benutzt werdne, wenn die Relation schon korrekt gesetzt ist
[ "Achtung", "dies", "erzeugt", "die", "JoinColumn", "und", "sollte", "nur", "benutzt", "werdne", "wenn", "die", "Relation", "schon", "korrekt", "gesetzt", "ist" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelation.php#L536-L540
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/Alpha.php
Zend_Validate_Alpha.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Alpha */ require_once 'Zend/Filter/Alpha.php'; self::$_filter = new Zend_Filter_Alpha(); } self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_ALPHA); return false; } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Alpha */ require_once 'Zend/Filter/Alpha.php'; self::$_filter = new Zend_Filter_Alpha(); } self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_ALPHA); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "''", "===", "$", "valueString", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "STRING_EMPTY", ")", ";", "return", "false", ";", "}", "if", "(", "null", "===", "self", "::", "$", "_filter", ")", "{", "/**\n * @see Zend_Filter_Alpha\n */", "require_once", "'Zend/Filter/Alpha.php'", ";", "self", "::", "$", "_filter", "=", "new", "Zend_Filter_Alpha", "(", ")", ";", "}", "self", "::", "$", "_filter", "->", "allowWhiteSpace", "=", "$", "this", "->", "allowWhiteSpace", ";", "if", "(", "$", "valueString", "!==", "self", "::", "$", "_filter", "->", "filter", "(", "$", "valueString", ")", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "NOT_ALPHA", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if $value contains only alphabetic characters @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Alpha.php#L114-L141
ipunkt/laravel-package-manager
src/Providers/Traits/PackagePath.php
PackagePath.packagePath
private function packagePath(string $relativePath): string { $packagePath = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $this->packagePath), DIRECTORY_SEPARATOR); $relativePath = ltrim(str_replace('/', DIRECTORY_SEPARATOR, $relativePath), DIRECTORY_SEPARATOR); return realpath($packagePath . DIRECTORY_SEPARATOR . $relativePath); }
php
private function packagePath(string $relativePath): string { $packagePath = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $this->packagePath), DIRECTORY_SEPARATOR); $relativePath = ltrim(str_replace('/', DIRECTORY_SEPARATOR, $relativePath), DIRECTORY_SEPARATOR); return realpath($packagePath . DIRECTORY_SEPARATOR . $relativePath); }
[ "private", "function", "packagePath", "(", "string", "$", "relativePath", ")", ":", "string", "{", "$", "packagePath", "=", "rtrim", "(", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "this", "->", "packagePath", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "relativePath", "=", "ltrim", "(", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "relativePath", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "return", "realpath", "(", "$", "packagePath", ".", "DIRECTORY_SEPARATOR", ".", "$", "relativePath", ")", ";", "}" ]
give relative path from package root and return absolute path @param string $relativePath @return string
[ "give", "relative", "path", "from", "package", "root", "and", "return", "absolute", "path" ]
train
https://github.com/ipunkt/laravel-package-manager/blob/6ecfc9d933c37927e52c441d5019126be69e5817/src/Providers/Traits/PackagePath.php#L22-L28
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/Digits.php
Zend_Validate_Digits.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "''", "===", "$", "valueString", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "STRING_EMPTY", ")", ";", "return", "false", ";", "}", "if", "(", "null", "===", "self", "::", "$", "_filter", ")", "{", "/**\n * @see Zend_Filter_Digits\n */", "require_once", "'Zend/Filter/Digits.php'", ";", "self", "::", "$", "_filter", "=", "new", "Zend_Filter_Digits", "(", ")", ";", "}", "if", "(", "$", "valueString", "!==", "self", "::", "$", "_filter", "->", "filter", "(", "$", "valueString", ")", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "NOT_DIGITS", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if $value only contains digit characters @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Digits.php#L73-L98
shrink0r/workflux
src/Builder/ArrayStateMachineBuilder.php
ArrayStateMachineBuilder.realizeConfig
private function realizeConfig(array $config): array { $states = []; $transitions = []; foreach ($config as $name => $state_config) { $states[] = $this->factory->createState($name, $state_config); if (!is_array($state_config)) { continue; } foreach ($state_config['transitions'] as $key => $transition_config) { if (is_string($transition_config)) { $transition_config = [ 'when' => $transition_config ]; } $transitions[] = $this->factory->createTransition($name, $key, $transition_config); } } return [ $states, $transitions ]; }
php
private function realizeConfig(array $config): array { $states = []; $transitions = []; foreach ($config as $name => $state_config) { $states[] = $this->factory->createState($name, $state_config); if (!is_array($state_config)) { continue; } foreach ($state_config['transitions'] as $key => $transition_config) { if (is_string($transition_config)) { $transition_config = [ 'when' => $transition_config ]; } $transitions[] = $this->factory->createTransition($name, $key, $transition_config); } } return [ $states, $transitions ]; }
[ "private", "function", "realizeConfig", "(", "array", "$", "config", ")", ":", "array", "{", "$", "states", "=", "[", "]", ";", "$", "transitions", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "state_config", ")", "{", "$", "states", "[", "]", "=", "$", "this", "->", "factory", "->", "createState", "(", "$", "name", ",", "$", "state_config", ")", ";", "if", "(", "!", "is_array", "(", "$", "state_config", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "state_config", "[", "'transitions'", "]", "as", "$", "key", "=>", "$", "transition_config", ")", "{", "if", "(", "is_string", "(", "$", "transition_config", ")", ")", "{", "$", "transition_config", "=", "[", "'when'", "=>", "$", "transition_config", "]", ";", "}", "$", "transitions", "[", "]", "=", "$", "this", "->", "factory", "->", "createTransition", "(", "$", "name", ",", "$", "key", ",", "$", "transition_config", ")", ";", "}", "}", "return", "[", "$", "states", ",", "$", "transitions", "]", ";", "}" ]
@param mixed[] $config @return mixed[]
[ "@param", "mixed", "[]", "$config" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/ArrayStateMachineBuilder.php#L59-L76
silverbusters/silverstripe-simplelistfield
model/fieldtypes/SimpleListFieldDB.php
SimpleListFieldDB.getList
public function getList(){ // define an unique key $key = $this->name.'_'.md5($this->value); if( isset(self::$listobj[$key]) ){ return self::$listobj[$key]; } if($this->value){ self::$listobj[$key] = json_decode($this->value); } else{ self::$listobj[$key] = false; } return self::$listobj[$key]; }
php
public function getList(){ // define an unique key $key = $this->name.'_'.md5($this->value); if( isset(self::$listobj[$key]) ){ return self::$listobj[$key]; } if($this->value){ self::$listobj[$key] = json_decode($this->value); } else{ self::$listobj[$key] = false; } return self::$listobj[$key]; }
[ "public", "function", "getList", "(", ")", "{", "// define an unique key", "$", "key", "=", "$", "this", "->", "name", ".", "'_'", ".", "md5", "(", "$", "this", "->", "value", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "listobj", "[", "$", "key", "]", ")", ")", "{", "return", "self", "::", "$", "listobj", "[", "$", "key", "]", ";", "}", "if", "(", "$", "this", "->", "value", ")", "{", "self", "::", "$", "listobj", "[", "$", "key", "]", "=", "json_decode", "(", "$", "this", "->", "value", ")", ";", "}", "else", "{", "self", "::", "$", "listobj", "[", "$", "key", "]", "=", "false", ";", "}", "return", "self", "::", "$", "listobj", "[", "$", "key", "]", ";", "}" ]
Get the list
[ "Get", "the", "list" ]
train
https://github.com/silverbusters/silverstripe-simplelistfield/blob/c883e13b1b877d74e266edf2a646661039803440/model/fieldtypes/SimpleListFieldDB.php#L20-L36
silverbusters/silverstripe-simplelistfield
model/fieldtypes/SimpleListFieldDB.php
SimpleListFieldDB.Count
public function Count(){ $list = $this->getList(); return ( isset($list->items) && !empty($list->items) ) ? count($list->items) : false; }
php
public function Count(){ $list = $this->getList(); return ( isset($list->items) && !empty($list->items) ) ? count($list->items) : false; }
[ "public", "function", "Count", "(", ")", "{", "$", "list", "=", "$", "this", "->", "getList", "(", ")", ";", "return", "(", "isset", "(", "$", "list", "->", "items", ")", "&&", "!", "empty", "(", "$", "list", "->", "items", ")", ")", "?", "count", "(", "$", "list", "->", "items", ")", ":", "false", ";", "}" ]
Count items
[ "Count", "items" ]
train
https://github.com/silverbusters/silverstripe-simplelistfield/blob/c883e13b1b877d74e266edf2a646661039803440/model/fieldtypes/SimpleListFieldDB.php#L50-L54
silverbusters/silverstripe-simplelistfield
model/fieldtypes/SimpleListFieldDB.php
SimpleListFieldDB.getHeading
public function getHeading(){ $list = $this->getList(); if( isset($list->heading) && $list->heading ){ return Convert::html2raw($list->heading); } return null; }
php
public function getHeading(){ $list = $this->getList(); if( isset($list->heading) && $list->heading ){ return Convert::html2raw($list->heading); } return null; }
[ "public", "function", "getHeading", "(", ")", "{", "$", "list", "=", "$", "this", "->", "getList", "(", ")", ";", "if", "(", "isset", "(", "$", "list", "->", "heading", ")", "&&", "$", "list", "->", "heading", ")", "{", "return", "Convert", "::", "html2raw", "(", "$", "list", "->", "heading", ")", ";", "}", "return", "null", ";", "}" ]
Get list heading
[ "Get", "list", "heading" ]
train
https://github.com/silverbusters/silverstripe-simplelistfield/blob/c883e13b1b877d74e266edf2a646661039803440/model/fieldtypes/SimpleListFieldDB.php#L59-L67
silverbusters/silverstripe-simplelistfield
model/fieldtypes/SimpleListFieldDB.php
SimpleListFieldDB.getItems
public function getItems(){ $list = $this->getList(); if( isset($list->items) && !empty($list->items) ) { $arrayList = new ArrayList(); foreach($list->items as $id => $item){ $item->ID = $id; $arrayList->push( new ArrayData($item) ); } return $arrayList; } return false; }
php
public function getItems(){ $list = $this->getList(); if( isset($list->items) && !empty($list->items) ) { $arrayList = new ArrayList(); foreach($list->items as $id => $item){ $item->ID = $id; $arrayList->push( new ArrayData($item) ); } return $arrayList; } return false; }
[ "public", "function", "getItems", "(", ")", "{", "$", "list", "=", "$", "this", "->", "getList", "(", ")", ";", "if", "(", "isset", "(", "$", "list", "->", "items", ")", "&&", "!", "empty", "(", "$", "list", "->", "items", ")", ")", "{", "$", "arrayList", "=", "new", "ArrayList", "(", ")", ";", "foreach", "(", "$", "list", "->", "items", "as", "$", "id", "=>", "$", "item", ")", "{", "$", "item", "->", "ID", "=", "$", "id", ";", "$", "arrayList", "->", "push", "(", "new", "ArrayData", "(", "$", "item", ")", ")", ";", "}", "return", "$", "arrayList", ";", "}", "return", "false", ";", "}" ]
Get list items
[ "Get", "list", "items" ]
train
https://github.com/silverbusters/silverstripe-simplelistfield/blob/c883e13b1b877d74e266edf2a646661039803440/model/fieldtypes/SimpleListFieldDB.php#L72-L89
silverbusters/silverstripe-simplelistfield
model/fieldtypes/SimpleListFieldDB.php
SimpleListFieldDB.forTemplate
public function forTemplate() { $list = $this->getList(); if( isset($list->enable) && $list->enable ) { // Get scenario $scenario = isset($list->scenario) ? $list->scenario : ''; // Get view file to render $template = $this->template ? $this->template : ( $scenario ? 'SimpleListFieldDB_'.$scenario : 'SimpleListFieldDB' ); $template = new SSViewer($template); return $template->process($this->customise(new ArrayData(array( 'FieldName' => $this->name, 'Heading' => $this->getHeading(), 'Items' => $this->getItems() )))); } return false; }
php
public function forTemplate() { $list = $this->getList(); if( isset($list->enable) && $list->enable ) { // Get scenario $scenario = isset($list->scenario) ? $list->scenario : ''; // Get view file to render $template = $this->template ? $this->template : ( $scenario ? 'SimpleListFieldDB_'.$scenario : 'SimpleListFieldDB' ); $template = new SSViewer($template); return $template->process($this->customise(new ArrayData(array( 'FieldName' => $this->name, 'Heading' => $this->getHeading(), 'Items' => $this->getItems() )))); } return false; }
[ "public", "function", "forTemplate", "(", ")", "{", "$", "list", "=", "$", "this", "->", "getList", "(", ")", ";", "if", "(", "isset", "(", "$", "list", "->", "enable", ")", "&&", "$", "list", "->", "enable", ")", "{", "// Get scenario", "$", "scenario", "=", "isset", "(", "$", "list", "->", "scenario", ")", "?", "$", "list", "->", "scenario", ":", "''", ";", "// Get view file to render", "$", "template", "=", "$", "this", "->", "template", "?", "$", "this", "->", "template", ":", "(", "$", "scenario", "?", "'SimpleListFieldDB_'", ".", "$", "scenario", ":", "'SimpleListFieldDB'", ")", ";", "$", "template", "=", "new", "SSViewer", "(", "$", "template", ")", ";", "return", "$", "template", "->", "process", "(", "$", "this", "->", "customise", "(", "new", "ArrayData", "(", "array", "(", "'FieldName'", "=>", "$", "this", "->", "name", ",", "'Heading'", "=>", "$", "this", "->", "getHeading", "(", ")", ",", "'Items'", "=>", "$", "this", "->", "getItems", "(", ")", ")", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
For template
[ "For", "template" ]
train
https://github.com/silverbusters/silverstripe-simplelistfield/blob/c883e13b1b877d74e266edf2a646661039803440/model/fieldtypes/SimpleListFieldDB.php#L112-L132
thiagodp/json
lib/JSON.php
JSON.encode
static function encode( $data, $getterPrefixForObjectMethods = 'get', $ignoreNulls = false ) { $type = gettype( $data ); $isObject = false; switch ( $type ) { case 'string' : return '"' . self::fixString( $data ) . '"'; case 'number' : ; // continue case 'integer' : ; // continue case 'float' : ; // continue case 'double' : return $data; case 'boolean' : return ( $data ) ? 'true' : 'false'; case 'NULL' : return 'null'; case 'object' : { $className = get_class( $data ); if ( array_key_exists( $className, self::$conversions ) && is_callable( self::$conversions[ $className ] ) ) { $function = self::$conversions[ $className ]; $convertedValue = call_user_func( $function, $data ); return self::encode( $convertedValue ); } $data = RTTI::getAttributes( $data, RTTI::anyVisibility(), $getterPrefixForObjectMethods ); $isObject = true; // continue } case 'array' : { $output = array(); foreach ( $data as $key => $value ) { $encodedValue = self::encode( $value, $getterPrefixForObjectMethods ); if ( $ignoreNulls && 'null' === $encodedValue ) { continue; } if ( is_numeric( $key ) ) { $output []= $encodedValue; } else { $encodedKey = self::encode( $key, $getterPrefixForObjectMethods ); $output []= $encodedKey . ': ' . $encodedValue; } } return $isObject ? '{ ' . implode( ', ', $output ) . ' }' : '[ ' . implode( ', ', $output ) . ' ]'; } default: return ''; // Not supported type } }
php
static function encode( $data, $getterPrefixForObjectMethods = 'get', $ignoreNulls = false ) { $type = gettype( $data ); $isObject = false; switch ( $type ) { case 'string' : return '"' . self::fixString( $data ) . '"'; case 'number' : ; // continue case 'integer' : ; // continue case 'float' : ; // continue case 'double' : return $data; case 'boolean' : return ( $data ) ? 'true' : 'false'; case 'NULL' : return 'null'; case 'object' : { $className = get_class( $data ); if ( array_key_exists( $className, self::$conversions ) && is_callable( self::$conversions[ $className ] ) ) { $function = self::$conversions[ $className ]; $convertedValue = call_user_func( $function, $data ); return self::encode( $convertedValue ); } $data = RTTI::getAttributes( $data, RTTI::anyVisibility(), $getterPrefixForObjectMethods ); $isObject = true; // continue } case 'array' : { $output = array(); foreach ( $data as $key => $value ) { $encodedValue = self::encode( $value, $getterPrefixForObjectMethods ); if ( $ignoreNulls && 'null' === $encodedValue ) { continue; } if ( is_numeric( $key ) ) { $output []= $encodedValue; } else { $encodedKey = self::encode( $key, $getterPrefixForObjectMethods ); $output []= $encodedKey . ': ' . $encodedValue; } } return $isObject ? '{ ' . implode( ', ', $output ) . ' }' : '[ ' . implode( ', ', $output ) . ' ]'; } default: return ''; // Not supported type } }
[ "static", "function", "encode", "(", "$", "data", ",", "$", "getterPrefixForObjectMethods", "=", "'get'", ",", "$", "ignoreNulls", "=", "false", ")", "{", "$", "type", "=", "gettype", "(", "$", "data", ")", ";", "$", "isObject", "=", "false", ";", "switch", "(", "$", "type", ")", "{", "case", "'string'", ":", "return", "'\"'", ".", "self", "::", "fixString", "(", "$", "data", ")", ".", "'\"'", ";", "case", "'number'", ":", ";", "// continue", "case", "'integer'", ":", ";", "// continue", "case", "'float'", ":", ";", "// continue\t\t\t", "case", "'double'", ":", "return", "$", "data", ";", "case", "'boolean'", ":", "return", "(", "$", "data", ")", "?", "'true'", ":", "'false'", ";", "case", "'NULL'", ":", "return", "'null'", ";", "case", "'object'", ":", "{", "$", "className", "=", "get_class", "(", "$", "data", ")", ";", "if", "(", "array_key_exists", "(", "$", "className", ",", "self", "::", "$", "conversions", ")", "&&", "is_callable", "(", "self", "::", "$", "conversions", "[", "$", "className", "]", ")", ")", "{", "$", "function", "=", "self", "::", "$", "conversions", "[", "$", "className", "]", ";", "$", "convertedValue", "=", "call_user_func", "(", "$", "function", ",", "$", "data", ")", ";", "return", "self", "::", "encode", "(", "$", "convertedValue", ")", ";", "}", "$", "data", "=", "RTTI", "::", "getAttributes", "(", "$", "data", ",", "RTTI", "::", "anyVisibility", "(", ")", ",", "$", "getterPrefixForObjectMethods", ")", ";", "$", "isObject", "=", "true", ";", "// continue", "}", "case", "'array'", ":", "{", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "encodedValue", "=", "self", "::", "encode", "(", "$", "value", ",", "$", "getterPrefixForObjectMethods", ")", ";", "if", "(", "$", "ignoreNulls", "&&", "'null'", "===", "$", "encodedValue", ")", "{", "continue", ";", "}", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "output", "[", "]", "=", "$", "encodedValue", ";", "}", "else", "{", "$", "encodedKey", "=", "self", "::", "encode", "(", "$", "key", ",", "$", "getterPrefixForObjectMethods", ")", ";", "$", "output", "[", "]", "=", "$", "encodedKey", ".", "': '", ".", "$", "encodedValue", ";", "}", "}", "return", "$", "isObject", "?", "'{ '", ".", "implode", "(", "', '", ",", "$", "output", ")", ".", "' }'", ":", "'[ '", ".", "implode", "(", "', '", ",", "$", "output", ")", ".", "' ]'", ";", "}", "default", ":", "return", "''", ";", "// Not supported type", "}", "}" ]
Encodes a variable into JSON format. @param mixed $data Data to be encoded. @param string $getterPrefixForObjectMethods Prefix used for getter methods. OPTIONAL. Defaults to 'get'. @param bool $ignoreNulls Ignore null values when encoding. OPTIONAL. Defaults to false. @return string
[ "Encodes", "a", "variable", "into", "JSON", "format", "." ]
train
https://github.com/thiagodp/json/blob/058e07a47ef28983fceb94f98d7edf08983f08ef/lib/JSON.php#L64-L106
thiagodp/json
lib/JSON.php
JSON.decode
static function decode( $json, $convertObjectsToArrays = false, $recursionDepth = 512, // same as PHP default $options = 0 ) { // Just use PHP's decode function return json_decode( $json, $convertObjectsToArrays, $recursionDepth, $options ); }
php
static function decode( $json, $convertObjectsToArrays = false, $recursionDepth = 512, // same as PHP default $options = 0 ) { // Just use PHP's decode function return json_decode( $json, $convertObjectsToArrays, $recursionDepth, $options ); }
[ "static", "function", "decode", "(", "$", "json", ",", "$", "convertObjectsToArrays", "=", "false", ",", "$", "recursionDepth", "=", "512", ",", "// same as PHP default", "$", "options", "=", "0", ")", "{", "// Just use PHP's decode function", "return", "json_decode", "(", "$", "json", ",", "$", "convertObjectsToArrays", ",", "$", "recursionDepth", ",", "$", "options", ")", ";", "}" ]
Decodes a JSON content into an object or an array. @see http://php.net/manual/en/function.json-decode.php @param string $json The JSON content. @param bool $convertObjectsToArrays When true, converts objects to arrays. @param int $recursionDepth Recursion depth. @param int $options Bit mask of JSON options. Currently supports only JSON_BIGINT_AS_STRING. Default is to cast large integers as floats. @return object | array | bool | null NULL is returned if the JSON cannot be decoded or if the encoded data is deeper than the recursion limit.
[ "Decodes", "a", "JSON", "content", "into", "an", "object", "or", "an", "array", "." ]
train
https://github.com/thiagodp/json/blob/058e07a47ef28983fceb94f98d7edf08983f08ef/lib/JSON.php#L125-L133
webforge-labs/psc-cms
lib/Psc/HTML/FrameworkPage.php
FrameworkPage.addCMSRequireJS
public function addCMSRequireJS($assetModus = 'development') { if ($assetModus === 'development') { $this->loadJs('/psc-cms-js/lib/config.js'); $requirejs = '/psc-cms-js/vendor/require.js'; $main = '/js/boot.js'; } else { $requirejs = '/js-built/require.js'; $main = '/js-built/lib/boot.js'; } return $this->addRequireJS($requirejs, $main); }
php
public function addCMSRequireJS($assetModus = 'development') { if ($assetModus === 'development') { $this->loadJs('/psc-cms-js/lib/config.js'); $requirejs = '/psc-cms-js/vendor/require.js'; $main = '/js/boot.js'; } else { $requirejs = '/js-built/require.js'; $main = '/js-built/lib/boot.js'; } return $this->addRequireJS($requirejs, $main); }
[ "public", "function", "addCMSRequireJS", "(", "$", "assetModus", "=", "'development'", ")", "{", "if", "(", "$", "assetModus", "===", "'development'", ")", "{", "$", "this", "->", "loadJs", "(", "'/psc-cms-js/lib/config.js'", ")", ";", "$", "requirejs", "=", "'/psc-cms-js/vendor/require.js'", ";", "$", "main", "=", "'/js/boot.js'", ";", "}", "else", "{", "$", "requirejs", "=", "'/js-built/require.js'", ";", "$", "main", "=", "'/js-built/lib/boot.js'", ";", "}", "return", "$", "this", "->", "addRequireJS", "(", "$", "requirejs", ",", "$", "main", ")", ";", "}" ]
Use development as $assetMode to use non-compiled assets use other values or 'built' to the compiled files and minified js
[ "Use", "development", "as", "$assetMode", "to", "use", "non", "-", "compiled", "assets" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/HTML/FrameworkPage.php#L41-L52