id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
238,200
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.indexAction
public function indexAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $arguments = $this->request->getArguments(); return $this->forward('listAssociations', null, null, $arguments); }
php
public function indexAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $arguments = $this->request->getArguments(); return $this->forward('listAssociations', null, null, $arguments); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "arguments", "=", "$", "this", "->", "request", "->", "getArguments", "(", ")", ";", "return", "$", "this", "->", "forward", "(", "'listAssociations'", ",", "null", ",", "null", ",", "$", "arguments", ")", ";", "}" ]
index action. @return string
[ "index", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L84-L91
238,201
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.listSubAssociationsAction
public function listSubAssociationsAction(string $aID = null, string $filter = null) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FILTER => $this->getAssociationsFilter($filter), self::VIEW_VARIABLE_USER_FILTER => $this->getUserAssociationsFilter($filter) ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function listSubAssociationsAction(string $aID = null, string $filter = null) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FILTER => $this->getAssociationsFilter($filter), self::VIEW_VARIABLE_USER_FILTER => $this->getUserAssociationsFilter($filter) ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "listSubAssociationsAction", "(", "string", "$", "aID", "=", "null", ",", "string", "$", "filter", "=", "null", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW_VARIABLE_ASSOCIATION_ID", "=>", "$", "aID", ",", "self", "::", "VIEW_VARIABLE_FILTER", "=>", "$", "this", "->", "getAssociationsFilter", "(", "$", "filter", ")", ",", "self", "::", "VIEW_VARIABLE_USER_FILTER", "=>", "$", "this", "->", "getUserAssociationsFilter", "(", "$", "filter", ")", "]", ",", "__CLASS__", ",", "__FUNCTION__", ")", ";", "return", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}" ]
list sub associations action. @param string $aID parent associations ID @param string $filter Filter @return string
[ "list", "sub", "associations", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L101-L113
238,202
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailAssociationAction
public function detailAssociationAction(string $aID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailAssociationAction(string $aID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailAssociationAction", "(", "string", "$", "aID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW_VARIABLE_ASSOCIATION_ID", "=>", "$", "aID", "]", ",", "__CLASS__", ",", "__FUNCTION__", ")", ";", "return", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}" ]
detail association action. @param string $aID association ID @return string
[ "detail", "association", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L143-L153
238,203
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailEventAction
public function detailEventAction(string $aID, string $eID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_EVENT_ID => $eID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailEventAction(string $aID, string $eID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_EVENT_ID => $eID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailEventAction", "(", "string", "$", "aID", ",", "string", "$", "eID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW_VARIABLE_ASSOCIATION_ID", "=>", "$", "aID", ",", "self", "::", "VIEW_VARIABLE_EVENT_ID", "=>", "$", "eID", "]", ",", "__CLASS__", ",", "__FUNCTION__", ")", ";", "return", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}" ]
detail event action. @param string $aID association ID @param string $eID event ID @return string
[ "detail", "event", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L163-L174
238,204
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailFunctionaryAction
public function detailFunctionaryAction(string $aID, string $fID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailFunctionaryAction(string $aID, string $fID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailFunctionaryAction", "(", "string", "$", "aID", ",", "string", "$", "fID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW_VARIABLE_ASSOCIATION_ID", "=>", "$", "aID", ",", "self", "::", "VIEW_VARIABLE_FUNCTIONARY_ID", "=>", "$", "fID", "]", ",", "__CLASS__", ",", "__FUNCTION__", ")", ";", "return", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}" ]
detail functionary action. @param string $aID association ID @param string $fID functionary ID @return string
[ "detail", "functionary", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L249-L260
238,205
marando/phpSOFA
src/Marando/IAU/iauCpv.php
iauCpv.Cpv
public static function Cpv(array $pv, array &$c) { // Added in PHP porting... initialize $c array $c[] = [0, 0, 0]; $c[] = [0, 0, 0]; IAU::Cp($pv[0], $c[0]); IAU::Cp($pv[1], $c[1]); return; }
php
public static function Cpv(array $pv, array &$c) { // Added in PHP porting... initialize $c array $c[] = [0, 0, 0]; $c[] = [0, 0, 0]; IAU::Cp($pv[0], $c[0]); IAU::Cp($pv[1], $c[1]); return; }
[ "public", "static", "function", "Cpv", "(", "array", "$", "pv", ",", "array", "&", "$", "c", ")", "{", "// Added in PHP porting... initialize $c array", "$", "c", "[", "]", "=", "[", "0", ",", "0", ",", "0", "]", ";", "$", "c", "[", "]", "=", "[", "0", ",", "0", ",", "0", "]", ";", "IAU", "::", "Cp", "(", "$", "pv", "[", "0", "]", ",", "$", "c", "[", "0", "]", ")", ";", "IAU", "::", "Cp", "(", "$", "pv", "[", "1", "]", ",", "$", "c", "[", "1", "]", ")", ";", "return", ";", "}" ]
- - - - - - - i a u C p v - - - - - - - Copy a position/velocity vector. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: pv double[2][3] position/velocity vector to be copied Returned: c double[2][3] copy Called: iauCp copy p-vector This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "C", "p", "v", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauCpv.php#L34-L43
238,206
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image/imagemagick.php
Image_Imagemagick.exec
protected function exec($program, $params, $passthru = false) { // Determine the path $this->im_path = realpath($this->config['imagemagick_dir'].$program); if ( ! $this->im_path) { $this->im_path = realpath($this->config['imagemagick_dir'].$program.'.exe'); } if ( ! $this->im_path) { throw new \RuntimeException("imagemagick executables not found in ".$this->config['imagemagick_dir']); } $command = $this->im_path." ".$params; $this->debug("Running command: <code>$command</code>"); $code = 0; $output = null; $passthru ? passthru($command) : exec($command, $output, $code); if ($code != 0) { throw new \FuelException("imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>"); } return $output; }
php
protected function exec($program, $params, $passthru = false) { // Determine the path $this->im_path = realpath($this->config['imagemagick_dir'].$program); if ( ! $this->im_path) { $this->im_path = realpath($this->config['imagemagick_dir'].$program.'.exe'); } if ( ! $this->im_path) { throw new \RuntimeException("imagemagick executables not found in ".$this->config['imagemagick_dir']); } $command = $this->im_path." ".$params; $this->debug("Running command: <code>$command</code>"); $code = 0; $output = null; $passthru ? passthru($command) : exec($command, $output, $code); if ($code != 0) { throw new \FuelException("imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>"); } return $output; }
[ "protected", "function", "exec", "(", "$", "program", ",", "$", "params", ",", "$", "passthru", "=", "false", ")", "{", "// Determine the path", "$", "this", "->", "im_path", "=", "realpath", "(", "$", "this", "->", "config", "[", "'imagemagick_dir'", "]", ".", "$", "program", ")", ";", "if", "(", "!", "$", "this", "->", "im_path", ")", "{", "$", "this", "->", "im_path", "=", "realpath", "(", "$", "this", "->", "config", "[", "'imagemagick_dir'", "]", ".", "$", "program", ".", "'.exe'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "im_path", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"imagemagick executables not found in \"", ".", "$", "this", "->", "config", "[", "'imagemagick_dir'", "]", ")", ";", "}", "$", "command", "=", "$", "this", "->", "im_path", ".", "\" \"", ".", "$", "params", ";", "$", "this", "->", "debug", "(", "\"Running command: <code>$command</code>\"", ")", ";", "$", "code", "=", "0", ";", "$", "output", "=", "null", ";", "$", "passthru", "?", "passthru", "(", "$", "command", ")", ":", "exec", "(", "$", "command", ",", "$", "output", ",", "$", "code", ")", ";", "if", "(", "$", "code", "!=", "0", ")", "{", "throw", "new", "\\", "FuelException", "(", "\"imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\\n <code>$command</code>\"", ")", ";", "}", "return", "$", "output", ";", "}" ]
Executes the specified imagemagick executable and returns the output. @param string $program The name of the executable. @param string $params The parameters of the executable. @param boolean $passthru Returns the output if false or pass it to browser. @return mixed Either returns the output or returns nothing.
[ "Executes", "the", "specified", "imagemagick", "executable", "and", "returns", "the", "output", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image/imagemagick.php#L309-L335
238,207
ddehart/dilmun
src/Kishar/Page.php
Page.setContents
public function setContents($contents) { $contents_exist = file_exists($contents); if ($contents_exist) { $this->contents = file_get_contents($contents); $this->updateLog("info", "Page contents set from {$contents}"); } else { $this->contents = false; $this->updateLog("alert", "File {$contents} not found"); } return $contents_exist; }
php
public function setContents($contents) { $contents_exist = file_exists($contents); if ($contents_exist) { $this->contents = file_get_contents($contents); $this->updateLog("info", "Page contents set from {$contents}"); } else { $this->contents = false; $this->updateLog("alert", "File {$contents} not found"); } return $contents_exist; }
[ "public", "function", "setContents", "(", "$", "contents", ")", "{", "$", "contents_exist", "=", "file_exists", "(", "$", "contents", ")", ";", "if", "(", "$", "contents_exist", ")", "{", "$", "this", "->", "contents", "=", "file_get_contents", "(", "$", "contents", ")", ";", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Page contents set from {$contents}\"", ")", ";", "}", "else", "{", "$", "this", "->", "contents", "=", "false", ";", "$", "this", "->", "updateLog", "(", "\"alert\"", ",", "\"File {$contents} not found\"", ")", ";", "}", "return", "$", "contents_exist", ";", "}" ]
Sets the Page's contents to the contents of a file @param string $contents The path to the file containing the page's contents @return bool Returns true if the file exists Returns false if the file does not exist
[ "Sets", "the", "Page", "s", "contents", "to", "the", "contents", "of", "a", "file" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Kishar/Page.php#L24-L39
238,208
slickframework/template
src/Engine/Twig.php
Twig.getTwigEnvironment
private function getTwigEnvironment() { if (null == $this->twigEnvironment) { $this->twigEnvironment = $this->createTwigEnvironment(); } return $this->twigEnvironment; }
php
private function getTwigEnvironment() { if (null == $this->twigEnvironment) { $this->twigEnvironment = $this->createTwigEnvironment(); } return $this->twigEnvironment; }
[ "private", "function", "getTwigEnvironment", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "twigEnvironment", ")", "{", "$", "this", "->", "twigEnvironment", "=", "$", "this", "->", "createTwigEnvironment", "(", ")", ";", "}", "return", "$", "this", "->", "twigEnvironment", ";", "}" ]
Creates a twig environment if not injected @return Twig_Environment
[ "Creates", "a", "twig", "environment", "if", "not", "injected" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L158-L164
238,209
slickframework/template
src/Engine/Twig.php
Twig.createTwigEnvironment
private function createTwigEnvironment() { $twigEnv = new Twig_Environment( $this->getLoader(), $this->getOptions() ); if ($this->options['debug']) { $twigEnv->addExtension(new Twig_Extension_Debug()); } return $twigEnv; }
php
private function createTwigEnvironment() { $twigEnv = new Twig_Environment( $this->getLoader(), $this->getOptions() ); if ($this->options['debug']) { $twigEnv->addExtension(new Twig_Extension_Debug()); } return $twigEnv; }
[ "private", "function", "createTwigEnvironment", "(", ")", "{", "$", "twigEnv", "=", "new", "Twig_Environment", "(", "$", "this", "->", "getLoader", "(", ")", ",", "$", "this", "->", "getOptions", "(", ")", ")", ";", "if", "(", "$", "this", "->", "options", "[", "'debug'", "]", ")", "{", "$", "twigEnv", "->", "addExtension", "(", "new", "Twig_Extension_Debug", "(", ")", ")", ";", "}", "return", "$", "twigEnv", ";", "}" ]
Creates the twig environment @return Twig_Environment
[ "Creates", "the", "twig", "environment" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L171-L183
238,210
slickframework/template
src/Engine/Twig.php
Twig.getLoader
private function getLoader() { if (null == $this->loader) { $this->loader = new Twig_Loader_Filesystem( $this->locations ); } return $this->loader; }
php
private function getLoader() { if (null == $this->loader) { $this->loader = new Twig_Loader_Filesystem( $this->locations ); } return $this->loader; }
[ "private", "function", "getLoader", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "loader", ")", "{", "$", "this", "->", "loader", "=", "new", "Twig_Loader_Filesystem", "(", "$", "this", "->", "locations", ")", ";", "}", "return", "$", "this", "->", "loader", ";", "}" ]
Creates a file system loader @return Twig_Loader_Filesystem
[ "Creates", "a", "file", "system", "loader" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L190-L198
238,211
slickframework/template
src/Engine/Twig.php
Twig.getOptions
private function getOptions() { $options = []; foreach($this->optionsMap as $property => $name) { $options[$name] = $this->options[$property]; } return $options; }
php
private function getOptions() { $options = []; foreach($this->optionsMap as $property => $name) { $options[$name] = $this->options[$property]; } return $options; }
[ "private", "function", "getOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "optionsMap", "as", "$", "property", "=>", "$", "name", ")", "{", "$", "options", "[", "$", "name", "]", "=", "$", "this", "->", "options", "[", "$", "property", "]", ";", "}", "return", "$", "options", ";", "}" ]
Returns current configured options @return array
[ "Returns", "current", "configured", "options" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L205-L212
238,212
thecodingmachine/utils.i18n.fine.file-translator
src/MessageFileLanguage.php
MessageFileLanguage.save
public function save() { if($this->msg) { ksort($this->msg); $file = $this->folder."messages_".$this->language.".php"; $old = umask(00002); if (file_exists($file) && !is_writable($file)) { throw new FileTranslatorException('Cannot write to file "'.$file.'".'); } elseif (!file_exists($file)) { if (!is_dir($this->folder)) { $result = mkdir($this->folder, 0775, true); if (!$result) { throw new FileTranslatorException('Cannot create directory "'.$this->folder.'".'); } } if (!is_writable($this->folder)) { throw new FileTranslatorException('Cannot write to directory "'.$this->folder.'".'); } } $fp = fopen($file, "w"); fwrite($fp, "<?php\n"); fwrite($fp, 'return '); fwrite($fp, var_export($this->msg, true)); fwrite($fp, ";\n"); fclose($fp); umask($old); } }
php
public function save() { if($this->msg) { ksort($this->msg); $file = $this->folder."messages_".$this->language.".php"; $old = umask(00002); if (file_exists($file) && !is_writable($file)) { throw new FileTranslatorException('Cannot write to file "'.$file.'".'); } elseif (!file_exists($file)) { if (!is_dir($this->folder)) { $result = mkdir($this->folder, 0775, true); if (!$result) { throw new FileTranslatorException('Cannot create directory "'.$this->folder.'".'); } } if (!is_writable($this->folder)) { throw new FileTranslatorException('Cannot write to directory "'.$this->folder.'".'); } } $fp = fopen($file, "w"); fwrite($fp, "<?php\n"); fwrite($fp, 'return '); fwrite($fp, var_export($this->msg, true)); fwrite($fp, ";\n"); fclose($fp); umask($old); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "msg", ")", "{", "ksort", "(", "$", "this", "->", "msg", ")", ";", "$", "file", "=", "$", "this", "->", "folder", ".", "\"messages_\"", ".", "$", "this", "->", "language", ".", "\".php\"", ";", "$", "old", "=", "umask", "(", "00002", ")", ";", "if", "(", "file_exists", "(", "$", "file", ")", "&&", "!", "is_writable", "(", "$", "file", ")", ")", "{", "throw", "new", "FileTranslatorException", "(", "'Cannot write to file \"'", ".", "$", "file", ".", "'\".'", ")", ";", "}", "elseif", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "folder", ")", ")", "{", "$", "result", "=", "mkdir", "(", "$", "this", "->", "folder", ",", "0775", ",", "true", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "FileTranslatorException", "(", "'Cannot create directory \"'", ".", "$", "this", "->", "folder", ".", "'\".'", ")", ";", "}", "}", "if", "(", "!", "is_writable", "(", "$", "this", "->", "folder", ")", ")", "{", "throw", "new", "FileTranslatorException", "(", "'Cannot write to directory \"'", ".", "$", "this", "->", "folder", ".", "'\".'", ")", ";", "}", "}", "$", "fp", "=", "fopen", "(", "$", "file", ",", "\"w\"", ")", ";", "fwrite", "(", "$", "fp", ",", "\"<?php\\n\"", ")", ";", "fwrite", "(", "$", "fp", ",", "'return '", ")", ";", "fwrite", "(", "$", "fp", ",", "var_export", "(", "$", "this", "->", "msg", ",", "true", ")", ")", ";", "fwrite", "(", "$", "fp", ",", "\";\\n\"", ")", ";", "fclose", "(", "$", "fp", ")", ";", "umask", "(", "$", "old", ")", ";", "}", "}" ]
Saves the file for current language
[ "Saves", "the", "file", "for", "current", "language" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/MessageFileLanguage.php#L50-L82
238,213
thecodingmachine/utils.i18n.fine.file-translator
src/MessageFileLanguage.php
MessageFileLanguage.deleteMessage
public function deleteMessage($key) { if(isset($this->msg[$key])) { unset($this->msg[$key]); } if(!$this->msg) { $this->deleteFile(); } }
php
public function deleteMessage($key) { if(isset($this->msg[$key])) { unset($this->msg[$key]); } if(!$this->msg) { $this->deleteFile(); } }
[ "public", "function", "deleteMessage", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "msg", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "msg", "[", "$", "key", "]", ")", ";", "}", "if", "(", "!", "$", "this", "->", "msg", ")", "{", "$", "this", "->", "deleteFile", "(", ")", ";", "}", "}" ]
Sets the message @var $key Remove a message for key
[ "Sets", "the", "message" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/MessageFileLanguage.php#L132-L139
238,214
Arbitracker/VCSWrapper
src/main/php/Arbit/VCSWrapper/HgCli/Directory.php
Directory.initializeResouces
protected function initializeResouces() { if ($this->resources !== null) { return; } $this->resources = array(); $contents = dir($this->root . $this->path); while (($path = $contents->read()) !== false) { if (in_array($path, array('.', '..', '.hg'))) { continue; } $this->resources[] = (is_dir($this->root . $this->path . $path) ? new \Arbit\VCSWrapper\HgCli\Directory($this->root, $this->path . $path . '/') : new \Arbit\VCSWrapper\HgCli\File($this->root, $this->path . $path) ); } $contents->close(); }
php
protected function initializeResouces() { if ($this->resources !== null) { return; } $this->resources = array(); $contents = dir($this->root . $this->path); while (($path = $contents->read()) !== false) { if (in_array($path, array('.', '..', '.hg'))) { continue; } $this->resources[] = (is_dir($this->root . $this->path . $path) ? new \Arbit\VCSWrapper\HgCli\Directory($this->root, $this->path . $path . '/') : new \Arbit\VCSWrapper\HgCli\File($this->root, $this->path . $path) ); } $contents->close(); }
[ "protected", "function", "initializeResouces", "(", ")", "{", "if", "(", "$", "this", "->", "resources", "!==", "null", ")", "{", "return", ";", "}", "$", "this", "->", "resources", "=", "array", "(", ")", ";", "$", "contents", "=", "dir", "(", "$", "this", "->", "root", ".", "$", "this", "->", "path", ")", ";", "while", "(", "(", "$", "path", "=", "$", "contents", "->", "read", "(", ")", ")", "!==", "false", ")", "{", "if", "(", "in_array", "(", "$", "path", ",", "array", "(", "'.'", ",", "'..'", ",", "'.hg'", ")", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "resources", "[", "]", "=", "(", "is_dir", "(", "$", "this", "->", "root", ".", "$", "this", "->", "path", ".", "$", "path", ")", "?", "new", "\\", "Arbit", "\\", "VCSWrapper", "\\", "HgCli", "\\", "Directory", "(", "$", "this", "->", "root", ",", "$", "this", "->", "path", ".", "$", "path", ".", "'/'", ")", ":", "new", "\\", "Arbit", "\\", "VCSWrapper", "\\", "HgCli", "\\", "File", "(", "$", "this", "->", "root", ",", "$", "this", "->", "path", ".", "$", "path", ")", ")", ";", "}", "$", "contents", "->", "close", "(", ")", ";", "}" ]
Initialize the resources array. Initilaize the array containing all child elements of the current directly as \Arbit\VCSWrapper\HgCli\Resource objects. @return array(\Arbit\VCSWrapper\HgCli\Resource)
[ "Initialize", "the", "resources", "array", "." ]
64907c0c438600ce67d79a5d17f5155563f2bbf2
https://github.com/Arbitracker/VCSWrapper/blob/64907c0c438600ce67d79a5d17f5155563f2bbf2/src/main/php/Arbit/VCSWrapper/HgCli/Directory.php#L52-L73
238,215
gearhub/tactician-for-laravel
src/Locator.php
Locator.getHandlerForCommand
public function getHandlerForCommand($commandName) { $command = str_replace($this->commandNamespace, '', $commandName); $handlerName = $this->handlerNamespace.'\\'.trim($command, '\\').'Handler'; if (!class_exists($handlerName)) { throw MissingHandlerException::forCommand($commandName); } $handler = $this->container->make($handlerName); return $handler; }
php
public function getHandlerForCommand($commandName) { $command = str_replace($this->commandNamespace, '', $commandName); $handlerName = $this->handlerNamespace.'\\'.trim($command, '\\').'Handler'; if (!class_exists($handlerName)) { throw MissingHandlerException::forCommand($commandName); } $handler = $this->container->make($handlerName); return $handler; }
[ "public", "function", "getHandlerForCommand", "(", "$", "commandName", ")", "{", "$", "command", "=", "str_replace", "(", "$", "this", "->", "commandNamespace", ",", "''", ",", "$", "commandName", ")", ";", "$", "handlerName", "=", "$", "this", "->", "handlerNamespace", ".", "'\\\\'", ".", "trim", "(", "$", "command", ",", "'\\\\'", ")", ".", "'Handler'", ";", "if", "(", "!", "class_exists", "(", "$", "handlerName", ")", ")", "{", "throw", "MissingHandlerException", "::", "forCommand", "(", "$", "commandName", ")", ";", "}", "$", "handler", "=", "$", "this", "->", "container", "->", "make", "(", "$", "handlerName", ")", ";", "return", "$", "handler", ";", "}" ]
Attempts to find the command's respective handler. @param string $commandName @return mixed @throws MissingHandlerException
[ "Attempts", "to", "find", "the", "command", "s", "respective", "handler", "." ]
417bb3683ceefe636ce1cd16ee03031649c80735
https://github.com/gearhub/tactician-for-laravel/blob/417bb3683ceefe636ce1cd16ee03031649c80735/src/Locator.php#L57-L69
238,216
AlexHowansky/ork-phpcs
Ork/Sniffs/Functions/FunctionCallSignatureSniff.php
FunctionCallSignatureSniff.isMultiLineCall
public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { return true; } return false; }
php
public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { return true; } return false; }
[ "public", "function", "isMultiLineCall", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "openBracket", ",", "$", "tokens", ")", "{", "$", "closeBracket", "=", "$", "tokens", "[", "$", "openBracket", "]", "[", "'parenthesis_closer'", "]", ";", "if", "(", "$", "tokens", "[", "$", "openBracket", "]", "[", "'line'", "]", "!==", "$", "tokens", "[", "$", "closeBracket", "]", "[", "'line'", "]", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine if this is a multi-line function call. @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param int $openBracket The position of the opening bracket in the stack passed in $tokens. @param array $tokens The stack of tokens that make up the file. @return void
[ "Determine", "if", "this", "is", "a", "multi", "-", "line", "function", "call", "." ]
2dab6c5c49713158a1895ddacb36030b23672927
https://github.com/AlexHowansky/ork-phpcs/blob/2dab6c5c49713158a1895ddacb36030b23672927/Ork/Sniffs/Functions/FunctionCallSignatureSniff.php#L186-L195
238,217
tonjoo/tiga-framework
src/Template/h2o.php
h2o.addTag
public static function addTag($tag, $class = null) { $tags = array(); if (is_string($tag)) { if (is_null($class)) { $class = ucwords("{$tag}_Tag"); } $tags[$tag] = $class; } elseif (is_array($tag)) { $tags = $tag; } foreach ($tags as $tag => $tagClass) { if (is_integer($tag)) { unset($tags[$tag]); $tag = $tagClass; $tagClass = ucwords("{$tagClass}_Tag"); } if (!class_exists($tagClass, false)) { throw new H2o_Error("{$tagClass} tag is not found"); } $tags[$tag] = $tagClass; } self::$tags = array_merge(self::$tags, $tags); }
php
public static function addTag($tag, $class = null) { $tags = array(); if (is_string($tag)) { if (is_null($class)) { $class = ucwords("{$tag}_Tag"); } $tags[$tag] = $class; } elseif (is_array($tag)) { $tags = $tag; } foreach ($tags as $tag => $tagClass) { if (is_integer($tag)) { unset($tags[$tag]); $tag = $tagClass; $tagClass = ucwords("{$tagClass}_Tag"); } if (!class_exists($tagClass, false)) { throw new H2o_Error("{$tagClass} tag is not found"); } $tags[$tag] = $tagClass; } self::$tags = array_merge(self::$tags, $tags); }
[ "public", "static", "function", "addTag", "(", "$", "tag", ",", "$", "class", "=", "null", ")", "{", "$", "tags", "=", "array", "(", ")", ";", "if", "(", "is_string", "(", "$", "tag", ")", ")", "{", "if", "(", "is_null", "(", "$", "class", ")", ")", "{", "$", "class", "=", "ucwords", "(", "\"{$tag}_Tag\"", ")", ";", "}", "$", "tags", "[", "$", "tag", "]", "=", "$", "class", ";", "}", "elseif", "(", "is_array", "(", "$", "tag", ")", ")", "{", "$", "tags", "=", "$", "tag", ";", "}", "foreach", "(", "$", "tags", "as", "$", "tag", "=>", "$", "tagClass", ")", "{", "if", "(", "is_integer", "(", "$", "tag", ")", ")", "{", "unset", "(", "$", "tags", "[", "$", "tag", "]", ")", ";", "$", "tag", "=", "$", "tagClass", ";", "$", "tagClass", "=", "ucwords", "(", "\"{$tagClass}_Tag\"", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "tagClass", ",", "false", ")", ")", "{", "throw", "new", "H2o_Error", "(", "\"{$tagClass} tag is not found\"", ")", ";", "}", "$", "tags", "[", "$", "tag", "]", "=", "$", "tagClass", ";", "}", "self", "::", "$", "tags", "=", "array_merge", "(", "self", "::", "$", "tags", ",", "$", "tags", ")", ";", "}" ]
Register a new tag. h2o::addTag('tag_name', 'ClassName'); h2o::addTag(array( 'tag_name' => 'MagClass', 'tag_name2' => 'TagClass2' )); h2o::addTag('tag_name'); // Tag_name_Tag h2o::addTag(array('tag_name', @param unknown_type $tag @param unknown_type $class
[ "Register", "a", "new", "tag", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Template/h2o.php#L192-L216
238,218
tonjoo/tiga-framework
src/Template/h2o.php
h2o.addFilter
public static function addFilter($filter, $callback = null) { if (is_array($filter)) { $filters = $filter; foreach ($filters as $key => $filter) { if (is_numeric($key)) { $key = $filter; } self::addFilter($key, $filter); } return true; } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) { foreach (get_class_methods($filter) as $f) { if (is_callable(array($filter, $f))) { self::$filters[$f] = array($filter, $f); } } return true; } if (is_null($callback)) { $callback = $filter; } if (!is_callable($callback)) { return false; } self::$filters[$filter] = $callback; }
php
public static function addFilter($filter, $callback = null) { if (is_array($filter)) { $filters = $filter; foreach ($filters as $key => $filter) { if (is_numeric($key)) { $key = $filter; } self::addFilter($key, $filter); } return true; } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) { foreach (get_class_methods($filter) as $f) { if (is_callable(array($filter, $f))) { self::$filters[$f] = array($filter, $f); } } return true; } if (is_null($callback)) { $callback = $filter; } if (!is_callable($callback)) { return false; } self::$filters[$filter] = $callback; }
[ "public", "static", "function", "addFilter", "(", "$", "filter", ",", "$", "callback", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "filter", ")", ")", "{", "$", "filters", "=", "$", "filter", ";", "foreach", "(", "$", "filters", "as", "$", "key", "=>", "$", "filter", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "filter", ";", "}", "self", "::", "addFilter", "(", "$", "key", ",", "$", "filter", ")", ";", "}", "return", "true", ";", "}", "elseif", "(", "is_string", "(", "$", "filter", ")", "&&", "class_exists", "(", "$", "filter", ",", "false", ")", "&&", "is_subclass_of", "(", "$", "filter", ",", "'FilterCollection'", ")", ")", "{", "foreach", "(", "get_class_methods", "(", "$", "filter", ")", "as", "$", "f", ")", "{", "if", "(", "is_callable", "(", "array", "(", "$", "filter", ",", "$", "f", ")", ")", ")", "{", "self", "::", "$", "filters", "[", "$", "f", "]", "=", "array", "(", "$", "filter", ",", "$", "f", ")", ";", "}", "}", "return", "true", ";", "}", "if", "(", "is_null", "(", "$", "callback", ")", ")", "{", "$", "callback", "=", "$", "filter", ";", "}", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "return", "false", ";", "}", "self", "::", "$", "filters", "[", "$", "filter", "]", "=", "$", "callback", ";", "}" ]
Register a new filter to h2o runtime. @param unknown_type $filter @param unknown_type $callback @return unknown
[ "Register", "a", "new", "filter", "to", "h2o", "runtime", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Template/h2o.php#L226-L255
238,219
l-x/Fna
src/Fna/Wrapper.php
Wrapper.getArrayType
protected function getArrayType(array $array) { $indices = count(array_filter(array_keys($array), 'is_string')); if ($indices == 0) { $type = self::ARRAY_TYPE_LIST; } elseif ($indices == count($array)) { $type = self::ARRAY_TYPE_DICT; } else { $type = self::ARRAY_TYPE_MIXED; } return $type; }
php
protected function getArrayType(array $array) { $indices = count(array_filter(array_keys($array), 'is_string')); if ($indices == 0) { $type = self::ARRAY_TYPE_LIST; } elseif ($indices == count($array)) { $type = self::ARRAY_TYPE_DICT; } else { $type = self::ARRAY_TYPE_MIXED; } return $type; }
[ "protected", "function", "getArrayType", "(", "array", "$", "array", ")", "{", "$", "indices", "=", "count", "(", "array_filter", "(", "array_keys", "(", "$", "array", ")", ",", "'is_string'", ")", ")", ";", "if", "(", "$", "indices", "==", "0", ")", "{", "$", "type", "=", "self", "::", "ARRAY_TYPE_LIST", ";", "}", "elseif", "(", "$", "indices", "==", "count", "(", "$", "array", ")", ")", "{", "$", "type", "=", "self", "::", "ARRAY_TYPE_DICT", ";", "}", "else", "{", "$", "type", "=", "self", "::", "ARRAY_TYPE_MIXED", ";", "}", "return", "$", "type", ";", "}" ]
Determines wether an array is index or key based @param array $array @return int
[ "Determines", "wether", "an", "array", "is", "index", "or", "key", "based" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L96-L108
238,220
l-x/Fna
src/Fna/Wrapper.php
Wrapper.getCallbackReflection
protected function getCallbackReflection($callback) { if (is_string($callback) && strpos($callback, '::') !== false) { $callback = explode('::', $callback, 2); } switch (true) { case is_string($callback) && function_exists($callback): case $callback instanceof \Closure: $reflection_method = new \ReflectionFunction($callback); break; case is_object($callback) && method_exists($callback, '__invoke'): $callback = array($callback, '__invoke'); case is_array($callback): $reflection_method = new \ReflectionMethod($callback[0], $callback[1]); break; // @codeCoverageIgnoreStart default: throw new \LogicException('Found something callable that we can\'t reflect'); } // @codeCoverageIgnoreEnd return $reflection_method; }
php
protected function getCallbackReflection($callback) { if (is_string($callback) && strpos($callback, '::') !== false) { $callback = explode('::', $callback, 2); } switch (true) { case is_string($callback) && function_exists($callback): case $callback instanceof \Closure: $reflection_method = new \ReflectionFunction($callback); break; case is_object($callback) && method_exists($callback, '__invoke'): $callback = array($callback, '__invoke'); case is_array($callback): $reflection_method = new \ReflectionMethod($callback[0], $callback[1]); break; // @codeCoverageIgnoreStart default: throw new \LogicException('Found something callable that we can\'t reflect'); } // @codeCoverageIgnoreEnd return $reflection_method; }
[ "protected", "function", "getCallbackReflection", "(", "$", "callback", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", "&&", "strpos", "(", "$", "callback", ",", "'::'", ")", "!==", "false", ")", "{", "$", "callback", "=", "explode", "(", "'::'", ",", "$", "callback", ",", "2", ")", ";", "}", "switch", "(", "true", ")", "{", "case", "is_string", "(", "$", "callback", ")", "&&", "function_exists", "(", "$", "callback", ")", ":", "case", "$", "callback", "instanceof", "\\", "Closure", ":", "$", "reflection_method", "=", "new", "\\", "ReflectionFunction", "(", "$", "callback", ")", ";", "break", ";", "case", "is_object", "(", "$", "callback", ")", "&&", "method_exists", "(", "$", "callback", ",", "'__invoke'", ")", ":", "$", "callback", "=", "array", "(", "$", "callback", ",", "'__invoke'", ")", ";", "case", "is_array", "(", "$", "callback", ")", ":", "$", "reflection_method", "=", "new", "\\", "ReflectionMethod", "(", "$", "callback", "[", "0", "]", ",", "$", "callback", "[", "1", "]", ")", ";", "break", ";", "// @codeCoverageIgnoreStart", "default", ":", "throw", "new", "\\", "LogicException", "(", "'Found something callable that we can\\'t reflect'", ")", ";", "}", "// @codeCoverageIgnoreEnd", "return", "$", "reflection_method", ";", "}" ]
Returns the reflection instance based on the type of the provided callable @param callable $callback @return \ReflectionFunction|\ReflectionMethod @throws InvalidCallbackException
[ "Returns", "the", "reflection", "instance", "based", "on", "the", "type", "of", "the", "provided", "callable" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L118-L139
238,221
l-x/Fna
src/Fna/Wrapper.php
Wrapper.setCallback
protected function setCallback($callback) { if (!is_callable($callback)) { throw new InvalidCallbackException('Invalid callback'); } $this->reflection_parameter = $this ->getCallbackReflection($callback) ->getParameters() ; $this->callback = $callback; return $this; }
php
protected function setCallback($callback) { if (!is_callable($callback)) { throw new InvalidCallbackException('Invalid callback'); } $this->reflection_parameter = $this ->getCallbackReflection($callback) ->getParameters() ; $this->callback = $callback; return $this; }
[ "protected", "function", "setCallback", "(", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "InvalidCallbackException", "(", "'Invalid callback'", ")", ";", "}", "$", "this", "->", "reflection_parameter", "=", "$", "this", "->", "getCallbackReflection", "(", "$", "callback", ")", "->", "getParameters", "(", ")", ";", "$", "this", "->", "callback", "=", "$", "callback", ";", "return", "$", "this", ";", "}" ]
Gets the reflection class for and sets the callback @param callable $callback @return $this @throws InvalidCallbackException
[ "Gets", "the", "reflection", "class", "for", "and", "sets", "the", "callback" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L149-L161
238,222
l-x/Fna
src/Fna/Wrapper.php
Wrapper.prepareArguments
protected function prepareArguments($reflection_parameter, $arguments) { $array_type = $this->getArrayType($arguments); $prepared = array(); if ($array_type == self::ARRAY_TYPE_LIST) { $prepared = $arguments; } elseif ($array_type == self::ARRAY_TYPE_DICT) { foreach ($reflection_parameter as $parameter) { $name = $parameter->getName(); if (isset($arguments[$name])) { $value = $arguments[$name]; } else if ($parameter->isDefaultValueAvailable()) { $value = $parameter->getDefaultValue(); } else { throw new InvalidParameterException("Missing parameter '$name' on position {$parameter->getPosition()}"); } $prepared[] = $value; } } else { throw new InvalidParameterException('Unable to handle mixed arrays'); } return $prepared; }
php
protected function prepareArguments($reflection_parameter, $arguments) { $array_type = $this->getArrayType($arguments); $prepared = array(); if ($array_type == self::ARRAY_TYPE_LIST) { $prepared = $arguments; } elseif ($array_type == self::ARRAY_TYPE_DICT) { foreach ($reflection_parameter as $parameter) { $name = $parameter->getName(); if (isset($arguments[$name])) { $value = $arguments[$name]; } else if ($parameter->isDefaultValueAvailable()) { $value = $parameter->getDefaultValue(); } else { throw new InvalidParameterException("Missing parameter '$name' on position {$parameter->getPosition()}"); } $prepared[] = $value; } } else { throw new InvalidParameterException('Unable to handle mixed arrays'); } return $prepared; }
[ "protected", "function", "prepareArguments", "(", "$", "reflection_parameter", ",", "$", "arguments", ")", "{", "$", "array_type", "=", "$", "this", "->", "getArrayType", "(", "$", "arguments", ")", ";", "$", "prepared", "=", "array", "(", ")", ";", "if", "(", "$", "array_type", "==", "self", "::", "ARRAY_TYPE_LIST", ")", "{", "$", "prepared", "=", "$", "arguments", ";", "}", "elseif", "(", "$", "array_type", "==", "self", "::", "ARRAY_TYPE_DICT", ")", "{", "foreach", "(", "$", "reflection_parameter", "as", "$", "parameter", ")", "{", "$", "name", "=", "$", "parameter", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "arguments", "[", "$", "name", "]", ")", ")", "{", "$", "value", "=", "$", "arguments", "[", "$", "name", "]", ";", "}", "else", "if", "(", "$", "parameter", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "value", "=", "$", "parameter", "->", "getDefaultValue", "(", ")", ";", "}", "else", "{", "throw", "new", "InvalidParameterException", "(", "\"Missing parameter '$name' on position {$parameter->getPosition()}\"", ")", ";", "}", "$", "prepared", "[", "]", "=", "$", "value", ";", "}", "}", "else", "{", "throw", "new", "InvalidParameterException", "(", "'Unable to handle mixed arrays'", ")", ";", "}", "return", "$", "prepared", ";", "}" ]
Prepares the argument array for use with call_user_func_array @param \ReflectionParameter[] $reflection_parameter @param array $arguments @return array @throws InvalidParameterException
[ "Prepares", "the", "argument", "array", "for", "use", "with", "call_user_func_array" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L172-L197
238,223
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.detailAction
public function detailAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm('EcommerceBundle\Form\CartType', $cart); return array( 'cart' => $cart, 'form' => $form->createView() ); }
php
public function detailAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm('EcommerceBundle\Form\CartType', $cart); return array( 'cart' => $cart, 'form' => $form->createView() ); }
[ "public", "function", "detailAction", "(", "Request", "$", "request", ")", "{", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\CartType'", ",", "$", "cart", ")", ";", "return", "array", "(", "'cart'", "=>", "$", "cart", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ";", "}" ]
Displays current cart summary page. The parameters includes the form . @param Request @return Response @Route("/cart/detail") @Template("EcommerceBundle:Checkout/cart:detail.html.twig")
[ "Displays", "current", "cart", "summary", "page", ".", "The", "parameters", "includes", "the", "form", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L68-L78
238,224
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.addAction
public function addAction(Request $request) { $em = $this->getDoctrine()->getManager(); $coreManager = $this->get('core_manager'); $checkoutManager = $this->get('checkout_manager'); $cart = $this->getCurrentCart(); $emptyItem = new CartItem(); try { $item = $checkoutManager->resolve($emptyItem, $request); } catch (\Exception $exception) { // Write flash message print_r($exception->getMessage());die(); return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } $price = $item->getProduct()->getPrice(); $item->setUnitPrice($price); $freeTransport = $item->getProduct()->isFreeTransport(); $item->setFreeTransport($freeTransport); //add $cart->addItem($item); //refresh $cart->calculateTotal(); $cart->setTotalItems($cart->countItems()); //save $em->persist($cart); $em->flush(); // Write flash message $referer = $coreManager->getRefererPath($request); return $this->redirect($this->generateUrl('ecommerce_checkout_detail').'?referer='.$referer); }
php
public function addAction(Request $request) { $em = $this->getDoctrine()->getManager(); $coreManager = $this->get('core_manager'); $checkoutManager = $this->get('checkout_manager'); $cart = $this->getCurrentCart(); $emptyItem = new CartItem(); try { $item = $checkoutManager->resolve($emptyItem, $request); } catch (\Exception $exception) { // Write flash message print_r($exception->getMessage());die(); return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } $price = $item->getProduct()->getPrice(); $item->setUnitPrice($price); $freeTransport = $item->getProduct()->isFreeTransport(); $item->setFreeTransport($freeTransport); //add $cart->addItem($item); //refresh $cart->calculateTotal(); $cart->setTotalItems($cart->countItems()); //save $em->persist($cart); $em->flush(); // Write flash message $referer = $coreManager->getRefererPath($request); return $this->redirect($this->generateUrl('ecommerce_checkout_detail').'?referer='.$referer); }
[ "public", "function", "addAction", "(", "Request", "$", "request", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "coreManager", "=", "$", "this", "->", "get", "(", "'core_manager'", ")", ";", "$", "checkoutManager", "=", "$", "this", "->", "get", "(", "'checkout_manager'", ")", ";", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "emptyItem", "=", "new", "CartItem", "(", ")", ";", "try", "{", "$", "item", "=", "$", "checkoutManager", "->", "resolve", "(", "$", "emptyItem", ",", "$", "request", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "// Write flash message", "print_r", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "die", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_checkout_detail'", ")", ")", ";", "}", "$", "price", "=", "$", "item", "->", "getProduct", "(", ")", "->", "getPrice", "(", ")", ";", "$", "item", "->", "setUnitPrice", "(", "$", "price", ")", ";", "$", "freeTransport", "=", "$", "item", "->", "getProduct", "(", ")", "->", "isFreeTransport", "(", ")", ";", "$", "item", "->", "setFreeTransport", "(", "$", "freeTransport", ")", ";", "//add", "$", "cart", "->", "addItem", "(", "$", "item", ")", ";", "//refresh", "$", "cart", "->", "calculateTotal", "(", ")", ";", "$", "cart", "->", "setTotalItems", "(", "$", "cart", "->", "countItems", "(", ")", ")", ";", "//save", "$", "em", "->", "persist", "(", "$", "cart", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// Write flash message", "$", "referer", "=", "$", "coreManager", "->", "getRefererPath", "(", "$", "request", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_checkout_detail'", ")", ".", "'?referer='", ".", "$", "referer", ")", ";", "}" ]
Adds item to cart. It uses the resolver service so you can populate the new item instance with proper values based on current request. It redirect to cart summary page by default. @param Request $request @return Response @Route("/cart/add") @Template("EcommerceBundle:Front:detail.html.twig")
[ "Adds", "item", "to", "cart", ".", "It", "uses", "the", "resolver", "service", "so", "you", "can", "populate", "the", "new", "item", "instance", "with", "proper", "values", "based", "on", "current", "request", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L93-L125
238,225
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.saveAction
public function saveAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm(CartType::class, $cart); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($cart); $em->flush(); return $this->redirect($this->generateUrl('ecommerce_checkout_identification')); // $event = new CartEvent($cart); // $event->isFresh(true); // // // Update models // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_INITIALIZE, $event); // // // Write flash message // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent()); } return array( 'cart' => $cart, 'form' => $form->createView() ); }
php
public function saveAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm(CartType::class, $cart); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($cart); $em->flush(); return $this->redirect($this->generateUrl('ecommerce_checkout_identification')); // $event = new CartEvent($cart); // $event->isFresh(true); // // // Update models // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_INITIALIZE, $event); // // // Write flash message // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent()); } return array( 'cart' => $cart, 'form' => $form->createView() ); }
[ "public", "function", "saveAction", "(", "Request", "$", "request", ")", "{", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "CartType", "::", "class", ",", "$", "cart", ")", ";", "if", "(", "$", "form", "->", "handleRequest", "(", "$", "request", ")", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "cart", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_checkout_identification'", ")", ")", ";", "// $event = new CartEvent($cart);", "// $event->isFresh(true);", "//", "// // Update models", "// $this->dispatchEvent(SyliusCartEvents::CART_SAVE_INITIALIZE, $event);", "//", "// // Write flash message", "// $this->dispatchEvent(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent());", "}", "return", "array", "(", "'cart'", "=>", "$", "cart", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ";", "}" ]
This action is used to submit the cart summary form. If the form and updated cart are valid, it refreshes the cart data and saves it using the operator. If there are any errors, it displays the cart detail page. @param Request $request @return Response @Route("/cart/save") @Template("EcommerceBundle:Front:detail.html.twig")
[ "This", "action", "is", "used", "to", "submit", "the", "cart", "summary", "form", ".", "If", "the", "form", "and", "updated", "cart", "are", "valid", "it", "refreshes", "the", "cart", "data", "and", "saves", "it", "using", "the", "operator", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L140-L167
238,226
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.removeAction
public function removeAction($id) { $em = $this->getDoctrine()->getManager(); $cart = $this->getCurrentCart(); $repository = $em->getRepository('EcommerceBundle:CartItem'); $item = $repository->find($id); if (!$item || false === $cart->hasItem($item)) { // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } // Update models $cart->removeItem($item); $cart->setTotalItems(count($cart->getItems())); $em->flush(); // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); }
php
public function removeAction($id) { $em = $this->getDoctrine()->getManager(); $cart = $this->getCurrentCart(); $repository = $em->getRepository('EcommerceBundle:CartItem'); $item = $repository->find($id); if (!$item || false === $cart->hasItem($item)) { // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } // Update models $cart->removeItem($item); $cart->setTotalItems(count($cart->getItems())); $em->flush(); // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); }
[ "public", "function", "removeAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "repository", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:CartItem'", ")", ";", "$", "item", "=", "$", "repository", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "item", "||", "false", "===", "$", "cart", "->", "hasItem", "(", "$", "item", ")", ")", "{", "// Write flash message", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_checkout_detail'", ")", ")", ";", "}", "// Update models", "$", "cart", "->", "removeItem", "(", "$", "item", ")", ";", "$", "cart", "->", "setTotalItems", "(", "count", "(", "$", "cart", "->", "getItems", "(", ")", ")", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// Write flash message", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_checkout_detail'", ")", ")", ";", "}" ]
Removes item from cart. It takes an item id as an argument. If the item is found and the current user cart contains that item, it will be removed and the cart - refreshed and saved. @param mixed $id @return Response @Route("/cart/remove/{id}")
[ "Removes", "item", "from", "cart", ".", "It", "takes", "an", "item", "id", "as", "an", "argument", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L181-L200
238,227
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.editBillingAction
public function editBillingAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $checkoutManager = $this->container->get('checkout_manager'); /** @var Address $address */ $address = $checkoutManager->getBillingAddress(); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array( 'billing_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function editBillingAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $checkoutManager = $this->container->get('checkout_manager'); /** @var Address $address */ $address = $checkoutManager->getBillingAddress(); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array( 'billing_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "editBillingAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "checkoutManager", "=", "$", "this", "->", "container", "->", "get", "(", "'checkout_manager'", ")", ";", "/** @var Address $address */", "$", "address", "=", "$", "checkoutManager", "->", "getBillingAddress", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\AddressType'", ",", "$", "address", ",", "array", "(", "'token_storage'", "=>", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", ")", ")", ";", "if", "(", "'POST'", "===", "$", "request", "->", "getMethod", "(", ")", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "persist", "(", "$", "address", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'core_actor_profile'", ")", ".", "'?billing=1'", ";", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'account.address.added'", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'success'", ",", "'url'", "=>", "$", "url", ")", ")", ";", "}", "else", "{", "$", "template", "=", "$", "this", "->", "container", "->", "get", "(", "'twig'", ")", "->", "render", "(", "\"EcommerceBundle:Profile:Billing/billing.form.html.twig\"", ",", "array", "(", "'billing_form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'address'", "=>", "$", "address", ")", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'error'", ",", "'answer'", "=>", "$", "template", ")", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Only by ajax'", ")", ";", "}", "}" ]
Edit the billing address @param Request $request @Route("/profile/billing/") @Method({"GET","POST"})
[ "Edit", "the", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L601-L632
238,228
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.setBillingAddressAction
public function setBillingAddressAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->getRepository('EcommerceBundle:Address')->removeForBillingToAllAddresses($user->getId()); $address->setForBilling(1); // $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.assigned.for.billing'); return new RedirectResponse($url); }
php
public function setBillingAddressAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->getRepository('EcommerceBundle:Address')->removeForBillingToAllAddresses($user->getId()); $address->setForBilling(1); // $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.assigned.for.billing'); return new RedirectResponse($url); }
[ "public", "function", "setBillingAddressAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "address", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'actor'", "=>", "$", "user", ",", ")", ")", ";", "if", "(", "is_null", "(", "$", "address", ")", ")", "{", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "removeForBillingToAllAddresses", "(", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "address", "->", "setForBilling", "(", "1", ")", ";", "// $em->persist($address);", "$", "em", "->", "flush", "(", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'core_actor_profile'", ")", ".", "'?delivery=1'", ";", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'account.address.assigned.for.billing'", ")", ";", "return", "new", "RedirectResponse", "(", "$", "url", ")", ";", "}" ]
Set the address as the billing address @param integer $id @throws AccessDeniedException @return RedirectResponse @Route("/profile/delivery/{id}/set-for-billing") @Method("GET") @Template("EcommerceBundle:Profile:Delivery/show.html.twig")
[ "Set", "the", "address", "as", "the", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L646-L670
238,229
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.showDeliveryAction
public function showDeliveryAction() { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $addresses = $em->getRepository('EcommerceBundle:Address') ->findBy(array( 'actor' => $user, )); return array( 'user' => $user, 'addresses' => $addresses ); }
php
public function showDeliveryAction() { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $addresses = $em->getRepository('EcommerceBundle:Address') ->findBy(array( 'actor' => $user, )); return array( 'user' => $user, 'addresses' => $addresses ); }
[ "public", "function", "showDeliveryAction", "(", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "addresses", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findBy", "(", "array", "(", "'actor'", "=>", "$", "user", ",", ")", ")", ";", "return", "array", "(", "'user'", "=>", "$", "user", ",", "'addresses'", "=>", "$", "addresses", ")", ";", "}" ]
Show delivery addresses @return Response @Route("/profile/delivery/") @Method({"GET","POST"}) @Template("EcommerceBundle:Profile:Delivery/show.html.twig")
[ "Show", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L681-L694
238,230
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.newDeliveryAction
public function newDeliveryAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $country = $em->getRepository('CoreBundle:Country')->find('es'); $address = new Address(); $address->setForBilling(false); $address->setCountry($country); $address->setActor($user); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/new.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function newDeliveryAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $country = $em->getRepository('CoreBundle:Country')->find('es'); $address = new Address(); $address->setForBilling(false); $address->setCountry($country); $address->setActor($user); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/new.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "newDeliveryAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "/** @var Address $address */", "$", "country", "=", "$", "em", "->", "getRepository", "(", "'CoreBundle:Country'", ")", "->", "find", "(", "'es'", ")", ";", "$", "address", "=", "new", "Address", "(", ")", ";", "$", "address", "->", "setForBilling", "(", "false", ")", ";", "$", "address", "->", "setCountry", "(", "$", "country", ")", ";", "$", "address", "->", "setActor", "(", "$", "user", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\AddressType'", ",", "$", "address", ",", "array", "(", "'token_storage'", "=>", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", ")", ")", ";", "if", "(", "'POST'", "===", "$", "request", "->", "getMethod", "(", ")", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "persist", "(", "$", "address", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'core_actor_profile'", ")", ".", "'?delivery=1'", ";", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'account.address.added'", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'success'", ",", "'url'", "=>", "$", "url", ")", ")", ";", "}", "else", "{", "$", "template", "=", "$", "this", "->", "container", "->", "get", "(", "'twig'", ")", "->", "render", "(", "\"EcommerceBundle:Profile:Delivery/new.html.twig\"", ",", "array", "(", "'delivery_form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'address'", "=>", "$", "address", ")", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'error'", ",", "'answer'", "=>", "$", "template", ")", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Only by ajax'", ")", ";", "}", "}" ]
Add delivery address @param Request $request @return Response @Route("/profile/delivery/new") @Method({"GET","POST"})
[ "Add", "delivery", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L705-L739
238,231
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.editDeliveryAction
public function editDeliveryAction(Request $request, $id) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $address = $em->getRepository('EcommerceBundle:Address')->findOneBy(array( 'id' => $id, 'actor' => $user, )); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.saved'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/edit.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function editDeliveryAction(Request $request, $id) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $address = $em->getRepository('EcommerceBundle:Address')->findOneBy(array( 'id' => $id, 'actor' => $user, )); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.saved'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/edit.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "editDeliveryAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "/** @var Address $address */", "$", "address", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'actor'", "=>", "$", "user", ",", ")", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\AddressType'", ",", "$", "address", ",", "array", "(", "'token_storage'", "=>", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", ")", ")", ";", "if", "(", "'POST'", "===", "$", "request", "->", "getMethod", "(", ")", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "persist", "(", "$", "address", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'core_actor_profile'", ")", ".", "'?delivery=1'", ";", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'account.address.saved'", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'success'", ",", "'url'", "=>", "$", "url", ")", ")", ";", "}", "else", "{", "$", "template", "=", "$", "this", "->", "container", "->", "get", "(", "'twig'", ")", "->", "render", "(", "\"EcommerceBundle:Profile:Delivery/edit.html.twig\"", ",", "array", "(", "'delivery_form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'address'", "=>", "$", "address", ")", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'error'", ",", "'answer'", "=>", "$", "template", ")", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Only by ajax'", ")", ";", "}", "}" ]
Edit delivery addresses @param Request $request @param integer $id @throws AccessDeniedException @return Response @Route("/profile/delivery/{id}/edit") @Method({"GET","POST"})
[ "Edit", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L753-L786
238,232
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.deleteDeliveryAction
public function deleteDeliveryAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->remove($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.deleted'); return new RedirectResponse($url); }
php
public function deleteDeliveryAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->remove($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.deleted'); return new RedirectResponse($url); }
[ "public", "function", "deleteDeliveryAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "address", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'actor'", "=>", "$", "user", ",", ")", ")", ";", "if", "(", "is_null", "(", "$", "address", ")", ")", "{", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "$", "em", "->", "remove", "(", "$", "address", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'core_actor_profile'", ")", ".", "'?delivery=1'", ";", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'account.address.deleted'", ")", ";", "return", "new", "RedirectResponse", "(", "$", "url", ")", ";", "}" ]
Delete delivery addresses @param integer $id @throws AccessDeniedException @return RedirectResponse @Route("/profile/delivery/{id}/delete") @Method({"GET","POST"}) @Template("EcommerceBundle:Profile:Delivery/edit.html.twig")
[ "Delete", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L800-L819
238,233
marando/phpSOFA
src/Marando/IAU/iauBi00.php
iauBi00.Bi00
public static function Bi00(&$dpsibi, &$depsbi, &$dra) { /* The frame bias corrections in longitude and obliquity */ $DPBIAS = -0.041775 * DAS2R; $DEBIAS = -0.0068192 * DAS2R; /* The ICRS RA of the J2000.0 equinox (Chapront et al., 2002) */ $DRA0 = -0.0146 * DAS2R; /* Return the results (which are fixed). */ $dpsibi = $DPBIAS; $depsbi = $DEBIAS; $dra = $DRA0; return; }
php
public static function Bi00(&$dpsibi, &$depsbi, &$dra) { /* The frame bias corrections in longitude and obliquity */ $DPBIAS = -0.041775 * DAS2R; $DEBIAS = -0.0068192 * DAS2R; /* The ICRS RA of the J2000.0 equinox (Chapront et al., 2002) */ $DRA0 = -0.0146 * DAS2R; /* Return the results (which are fixed). */ $dpsibi = $DPBIAS; $depsbi = $DEBIAS; $dra = $DRA0; return; }
[ "public", "static", "function", "Bi00", "(", "&", "$", "dpsibi", ",", "&", "$", "depsbi", ",", "&", "$", "dra", ")", "{", "/* The frame bias corrections in longitude and obliquity */", "$", "DPBIAS", "=", "-", "0.041775", "*", "DAS2R", ";", "$", "DEBIAS", "=", "-", "0.0068192", "*", "DAS2R", ";", "/* The ICRS RA of the J2000.0 equinox (Chapront et al., 2002) */", "$", "DRA0", "=", "-", "0.0146", "*", "DAS2R", ";", "/* Return the results (which are fixed). */", "$", "dpsibi", "=", "$", "DPBIAS", ";", "$", "depsbi", "=", "$", "DEBIAS", ";", "$", "dra", "=", "$", "DRA0", ";", "return", ";", "}" ]
- - - - - - - - i a u B i 0 0 - - - - - - - - Frame bias components of IAU 2000 precession-nutation models (part of MHB2000 with additions). This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: canonical model. Returned: dpsibi,depsbi double longitude and obliquity corrections dra double the ICRS RA of the J2000.0 mean equinox Notes: 1) The frame bias corrections in longitude and obliquity (radians) are required in order to correct for the offset between the GCRS pole and the mean J2000.0 pole. They define, with respect to the GCRS frame, a J2000.0 mean pole that is consistent with the rest of the IAU 2000A precession-nutation model. 2) In addition to the displacement of the pole, the complete description of the frame bias requires also an offset in right ascension. This is not part of the IAU 2000A model, and is from Chapront et al. (2002). It is returned in radians. 3) This is a supplemented implementation of one aspect of the IAU 2000A nutation model, formally adopted by the IAU General Assembly in 2000, namely MHB2000 (Mathews et al. 2002). References: Chapront, J., Chapront-Touze, M. & Francou, G., Astron. Astrophys., 387, 700, 2002. Mathews, P.M., Herring, T.A., Buffet, B.A., "Modeling of nutation and precession New nutation series for nonrigid Earth and insights into the Earth's interior", J.Geophys.Res., 107, B4, 2002. The MHB2000 code itself was obtained on 9th September 2002 from ftp://maia.usno.navy.mil/conv2000/chapter5/IAU2000A. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "B", "i", "0", "0", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauBi00.php#L58-L72
238,234
diskerror/Utilities
src/Stack.php
Stack.offsetSet
final public function offsetSet($key, $value) { $key = (string) $key; if ( array_key_exists($key, $this->_stack) ) { throw new \DomainException('Key already exists.'); } $this->_stack[$key] = $value; }
php
final public function offsetSet($key, $value) { $key = (string) $key; if ( array_key_exists($key, $this->_stack) ) { throw new \DomainException('Key already exists.'); } $this->_stack[$key] = $value; }
[ "final", "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_stack", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Key already exists.'", ")", ";", "}", "$", "this", "->", "_stack", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Sets a value to the new named location with array notation. @param string $key @param mixed $value @throws DomainException
[ "Sets", "a", "value", "to", "the", "new", "named", "location", "with", "array", "notation", "." ]
cc5eec2417f7c2c76a84584ebd5237197dc54236
https://github.com/diskerror/Utilities/blob/cc5eec2417f7c2c76a84584ebd5237197dc54236/src/Stack.php#L100-L109
238,235
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getSiteInfo
protected function getSiteInfo() { if ( null === $this->siteInfo ) { $this->siteInfo = $this->getServiceLocator() ->get( 'SiteInfo' ); } return $this->siteInfo; }
php
protected function getSiteInfo() { if ( null === $this->siteInfo ) { $this->siteInfo = $this->getServiceLocator() ->get( 'SiteInfo' ); } return $this->siteInfo; }
[ "protected", "function", "getSiteInfo", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "siteInfo", ")", "{", "$", "this", "->", "siteInfo", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'SiteInfo'", ")", ";", "}", "return", "$", "this", "->", "siteInfo", ";", "}" ]
Get cached site-info @return \Zork\Db\SiteInfo
[ "Get", "cached", "site", "-", "info" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L35-L44
238,236
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getFallbackUri
protected function getFallbackUri( $paragraphId, $absolute = false ) { $uri = '/app/' . $this->locale . '/paragraph/render/' . $paragraphId; if ( $absolute ) { $uri = $this->getSiteInfo() ->getSubdomainUrl( null, $uri ); } return $uri; }
php
protected function getFallbackUri( $paragraphId, $absolute = false ) { $uri = '/app/' . $this->locale . '/paragraph/render/' . $paragraphId; if ( $absolute ) { $uri = $this->getSiteInfo() ->getSubdomainUrl( null, $uri ); } return $uri; }
[ "protected", "function", "getFallbackUri", "(", "$", "paragraphId", ",", "$", "absolute", "=", "false", ")", "{", "$", "uri", "=", "'/app/'", ".", "$", "this", "->", "locale", ".", "'/paragraph/render/'", ".", "$", "paragraphId", ";", "if", "(", "$", "absolute", ")", "{", "$", "uri", "=", "$", "this", "->", "getSiteInfo", "(", ")", "->", "getSubdomainUrl", "(", "null", ",", "$", "uri", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Get fallback uri for a paragraph @param int $paragraphId @param bool $absolute @return string
[ "Get", "fallback", "uri", "for", "a", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L53-L64
238,237
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getSubdomain
protected function getSubdomain( $subdomainId = null ) { static $subdomains = array(); $siteInfo = $this->getSiteInfo(); if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId ) { return $siteInfo->getSubdomain(); } if ( ! isset( $subdomains[$subdomainId] ) ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\SubDomain\Model' ); $subdomain = $model->find( $subdomainId ); if ( empty( $subdomain ) ) { $subdomains[$subdomainId] = ''; } else { $subdomains[$subdomainId] = $subdomain->subdomain; } } return $subdomains[$subdomainId]; }
php
protected function getSubdomain( $subdomainId = null ) { static $subdomains = array(); $siteInfo = $this->getSiteInfo(); if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId ) { return $siteInfo->getSubdomain(); } if ( ! isset( $subdomains[$subdomainId] ) ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\SubDomain\Model' ); $subdomain = $model->find( $subdomainId ); if ( empty( $subdomain ) ) { $subdomains[$subdomainId] = ''; } else { $subdomains[$subdomainId] = $subdomain->subdomain; } } return $subdomains[$subdomainId]; }
[ "protected", "function", "getSubdomain", "(", "$", "subdomainId", "=", "null", ")", "{", "static", "$", "subdomains", "=", "array", "(", ")", ";", "$", "siteInfo", "=", "$", "this", "->", "getSiteInfo", "(", ")", ";", "if", "(", "empty", "(", "$", "subdomainId", ")", "||", "$", "siteInfo", "->", "getSubdomainId", "(", ")", "==", "$", "subdomainId", ")", "{", "return", "$", "siteInfo", "->", "getSubdomain", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "subdomains", "[", "$", "subdomainId", "]", ")", ")", "{", "/* @var $model \\Grid\\Core\\Model\\Uri\\Model */", "$", "service", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "service", "->", "get", "(", "'Grid\\Core\\Model\\SubDomain\\Model'", ")", ";", "$", "subdomain", "=", "$", "model", "->", "find", "(", "$", "subdomainId", ")", ";", "if", "(", "empty", "(", "$", "subdomain", ")", ")", "{", "$", "subdomains", "[", "$", "subdomainId", "]", "=", "''", ";", "}", "else", "{", "$", "subdomains", "[", "$", "subdomainId", "]", "=", "$", "subdomain", "->", "subdomain", ";", "}", "}", "return", "$", "subdomains", "[", "$", "subdomainId", "]", ";", "}" ]
Get subdomain by subdomain id @staticvar array $subdomains @param int|null $subdomainId @return string
[ "Get", "subdomain", "by", "subdomain", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L73-L101
238,238
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUriForContent
protected function getUriForContent( $contentId, $absolute = false ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\Uri\Model' ); $subdomain = $this->getSiteInfo()->getSubdomainId(); $uri = $model->findDefaultByContentLocale( $contentId, $this->locale, $subdomain ); if ( empty( $uri ) ) { return $this->getFallbackUri( $contentId, $absolute ); } $result = '/' . $uri->safeUri; if ( $absolute || $subdomain != $uri->subdomainId ) { $result = $this->getSiteInfo() ->getSubdomainUrl( $this->getSubdomain( $uri->subdomainId ), $result ); } return $result; }
php
protected function getUriForContent( $contentId, $absolute = false ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\Uri\Model' ); $subdomain = $this->getSiteInfo()->getSubdomainId(); $uri = $model->findDefaultByContentLocale( $contentId, $this->locale, $subdomain ); if ( empty( $uri ) ) { return $this->getFallbackUri( $contentId, $absolute ); } $result = '/' . $uri->safeUri; if ( $absolute || $subdomain != $uri->subdomainId ) { $result = $this->getSiteInfo() ->getSubdomainUrl( $this->getSubdomain( $uri->subdomainId ), $result ); } return $result; }
[ "protected", "function", "getUriForContent", "(", "$", "contentId", ",", "$", "absolute", "=", "false", ")", "{", "/* @var $model \\Grid\\Core\\Model\\Uri\\Model */", "$", "service", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "service", "->", "get", "(", "'Grid\\Core\\Model\\Uri\\Model'", ")", ";", "$", "subdomain", "=", "$", "this", "->", "getSiteInfo", "(", ")", "->", "getSubdomainId", "(", ")", ";", "$", "uri", "=", "$", "model", "->", "findDefaultByContentLocale", "(", "$", "contentId", ",", "$", "this", "->", "locale", ",", "$", "subdomain", ")", ";", "if", "(", "empty", "(", "$", "uri", ")", ")", "{", "return", "$", "this", "->", "getFallbackUri", "(", "$", "contentId", ",", "$", "absolute", ")", ";", "}", "$", "result", "=", "'/'", ".", "$", "uri", "->", "safeUri", ";", "if", "(", "$", "absolute", "||", "$", "subdomain", "!=", "$", "uri", "->", "subdomainId", ")", "{", "$", "result", "=", "$", "this", "->", "getSiteInfo", "(", ")", "->", "getSubdomainUrl", "(", "$", "this", "->", "getSubdomain", "(", "$", "uri", "->", "subdomainId", ")", ",", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get uri for a content paragraph @param int $contentId @param bool $absolute @return string
[ "Get", "uri", "for", "a", "content", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L110-L139
238,239
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUriById
protected function getUriById( $paragraphId, $absolute = false ) { /* @var $model \Grid\Paragraph\Model\Paragraph\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $paragraphId ); if ( empty( $paragraph ) ) { return '#error-paragraph-notFound:' . $paragraphId; } if ( 'content' == $paragraph->type ) { return $this->getUriForContent( $this->contentId, $absolute ); } if ( $paragraph->id == $paragraph->rootId ) { return $this->getFallbackUri( $paragraphId, $absolute ); } return $this->getUriById( $paragraph->rootId, $absolute ) . '#paragraph-' . $paragraph->id; }
php
protected function getUriById( $paragraphId, $absolute = false ) { /* @var $model \Grid\Paragraph\Model\Paragraph\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $paragraphId ); if ( empty( $paragraph ) ) { return '#error-paragraph-notFound:' . $paragraphId; } if ( 'content' == $paragraph->type ) { return $this->getUriForContent( $this->contentId, $absolute ); } if ( $paragraph->id == $paragraph->rootId ) { return $this->getFallbackUri( $paragraphId, $absolute ); } return $this->getUriById( $paragraph->rootId, $absolute ) . '#paragraph-' . $paragraph->id; }
[ "protected", "function", "getUriById", "(", "$", "paragraphId", ",", "$", "absolute", "=", "false", ")", "{", "/* @var $model \\Grid\\Paragraph\\Model\\Paragraph\\Model */", "$", "service", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "service", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", ";", "$", "paragraph", "=", "$", "model", "->", "find", "(", "$", "paragraphId", ")", ";", "if", "(", "empty", "(", "$", "paragraph", ")", ")", "{", "return", "'#error-paragraph-notFound:'", ".", "$", "paragraphId", ";", "}", "if", "(", "'content'", "==", "$", "paragraph", "->", "type", ")", "{", "return", "$", "this", "->", "getUriForContent", "(", "$", "this", "->", "contentId", ",", "$", "absolute", ")", ";", "}", "if", "(", "$", "paragraph", "->", "id", "==", "$", "paragraph", "->", "rootId", ")", "{", "return", "$", "this", "->", "getFallbackUri", "(", "$", "paragraphId", ",", "$", "absolute", ")", ";", "}", "return", "$", "this", "->", "getUriById", "(", "$", "paragraph", "->", "rootId", ",", "$", "absolute", ")", ".", "'#paragraph-'", ".", "$", "paragraph", "->", "id", ";", "}" ]
Get uri by id @param int $paragraphId @param bool $absolute @return string
[ "Get", "uri", "by", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L148-L172
238,240
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUri
public function getUri( $absolute = false ) { if ( empty( $this->contentId ) ) { return '#error-paragraph-missing:contentId'; } if ( 'content' == $this->subType ) { return $this->getUriForContent( $this->contentId, $absolute ); } return $this->getUriById( $this->contentId ); }
php
public function getUri( $absolute = false ) { if ( empty( $this->contentId ) ) { return '#error-paragraph-missing:contentId'; } if ( 'content' == $this->subType ) { return $this->getUriForContent( $this->contentId, $absolute ); } return $this->getUriById( $this->contentId ); }
[ "public", "function", "getUri", "(", "$", "absolute", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "contentId", ")", ")", "{", "return", "'#error-paragraph-missing:contentId'", ";", "}", "if", "(", "'content'", "==", "$", "this", "->", "subType", ")", "{", "return", "$", "this", "->", "getUriForContent", "(", "$", "this", "->", "contentId", ",", "$", "absolute", ")", ";", "}", "return", "$", "this", "->", "getUriById", "(", "$", "this", "->", "contentId", ")", ";", "}" ]
Get uri for a paragraph @param bool $absolute @return string
[ "Get", "uri", "for", "a", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L180-L193
238,241
tigron/skeleton-core
lib/Skeleton/Core/Web/Session.php
Session.set_sticky
public static function set_sticky($key, $value) { if (self::$sticky === null) { self::$sticky = new \Skeleton\Core\Web\Session\Sticky(); } self::$sticky->$key = $value; }
php
public static function set_sticky($key, $value) { if (self::$sticky === null) { self::$sticky = new \Skeleton\Core\Web\Session\Sticky(); } self::$sticky->$key = $value; }
[ "public", "static", "function", "set_sticky", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "self", "::", "$", "sticky", "===", "null", ")", "{", "self", "::", "$", "sticky", "=", "new", "\\", "Skeleton", "\\", "Core", "\\", "Web", "\\", "Session", "\\", "Sticky", "(", ")", ";", "}", "self", "::", "$", "sticky", "->", "$", "key", "=", "$", "value", ";", "}" ]
Set a sticky session variable @access public @param string $key @param mixed $value
[ "Set", "a", "sticky", "session", "variable" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Session.php#L67-L73
238,242
vijityannapon/laravel-logs
src/LogsServiceProvider.php
LogsServiceProvider.registerLogs
protected function registerLogs() { $this->app->singleton('logs', function($app) { $config = $this->app->config->get('logs'); if ($config['adapter'] == 'loggly') { return new Adapters\Loggly(); } elseif ($config['adapter'] == 'stackdriver') { return new Adapters\Stackdriver(); } else { return new Adapters\Monolog(); } }); }
php
protected function registerLogs() { $this->app->singleton('logs', function($app) { $config = $this->app->config->get('logs'); if ($config['adapter'] == 'loggly') { return new Adapters\Loggly(); } elseif ($config['adapter'] == 'stackdriver') { return new Adapters\Stackdriver(); } else { return new Adapters\Monolog(); } }); }
[ "protected", "function", "registerLogs", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'logs'", ",", "function", "(", "$", "app", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "config", "->", "get", "(", "'logs'", ")", ";", "if", "(", "$", "config", "[", "'adapter'", "]", "==", "'loggly'", ")", "{", "return", "new", "Adapters", "\\", "Loggly", "(", ")", ";", "}", "elseif", "(", "$", "config", "[", "'adapter'", "]", "==", "'stackdriver'", ")", "{", "return", "new", "Adapters", "\\", "Stackdriver", "(", ")", ";", "}", "else", "{", "return", "new", "Adapters", "\\", "Monolog", "(", ")", ";", "}", "}", ")", ";", "}" ]
Register logs. @return void
[ "Register", "logs", "." ]
45b29f05b4653ae10cc12ed9c2812a7c06b5b509
https://github.com/vijityannapon/laravel-logs/blob/45b29f05b4653ae10cc12ed9c2812a7c06b5b509/src/LogsServiceProvider.php#L40-L61
238,243
indigophp/indigo-skeleton
classes/Model.php
Model.compile_properties
protected static function compile_properties(array $properties, $defaults = true) { $p = $properties; $properties = []; foreach ($p as $key => $value) { if (is_int($key)) { $key = $value; $value = []; } // Get property defaults if ($defaults and $property = static::property($key, false)) { $value = array_replace_recursive($property, $value); } $properties[$key] = $value; } return $properties; }
php
protected static function compile_properties(array $properties, $defaults = true) { $p = $properties; $properties = []; foreach ($p as $key => $value) { if (is_int($key)) { $key = $value; $value = []; } // Get property defaults if ($defaults and $property = static::property($key, false)) { $value = array_replace_recursive($property, $value); } $properties[$key] = $value; } return $properties; }
[ "protected", "static", "function", "compile_properties", "(", "array", "$", "properties", ",", "$", "defaults", "=", "true", ")", "{", "$", "p", "=", "$", "properties", ";", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "p", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "value", ";", "$", "value", "=", "[", "]", ";", "}", "// Get property defaults", "if", "(", "$", "defaults", "and", "$", "property", "=", "static", "::", "property", "(", "$", "key", ",", "false", ")", ")", "{", "$", "value", "=", "array_replace_recursive", "(", "$", "property", ",", "$", "value", ")", ";", "}", "$", "properties", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "properties", ";", "}" ]
Compiles skeleton properties @param [] $properties @param boolean $defaults @return []
[ "Compiles", "skeleton", "properties" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L52-L75
238,244
indigophp/indigo-skeleton
classes/Model.php
Model.skeleton_properties
public static function skeleton_properties($type) { $class = get_called_class(); if (isset(static::$_skeleton_cached[$class][$type])) { return static::$_skeleton_cached[$class][$type]; } $var = '_' . $type . '_properties'; $properties = []; if (property_exists($class, $var)) { $properties = static::$$var; } return static::$_skeleton_cached[$class][$type] = static::compile_properties($properties); }
php
public static function skeleton_properties($type) { $class = get_called_class(); if (isset(static::$_skeleton_cached[$class][$type])) { return static::$_skeleton_cached[$class][$type]; } $var = '_' . $type . '_properties'; $properties = []; if (property_exists($class, $var)) { $properties = static::$$var; } return static::$_skeleton_cached[$class][$type] = static::compile_properties($properties); }
[ "public", "static", "function", "skeleton_properties", "(", "$", "type", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "_skeleton_cached", "[", "$", "class", "]", "[", "$", "type", "]", ")", ")", "{", "return", "static", "::", "$", "_skeleton_cached", "[", "$", "class", "]", "[", "$", "type", "]", ";", "}", "$", "var", "=", "'_'", ".", "$", "type", ".", "'_properties'", ";", "$", "properties", "=", "[", "]", ";", "if", "(", "property_exists", "(", "$", "class", ",", "$", "var", ")", ")", "{", "$", "properties", "=", "static", "::", "$", "$", "var", ";", "}", "return", "static", "::", "$", "_skeleton_cached", "[", "$", "class", "]", "[", "$", "type", "]", "=", "static", "::", "compile_properties", "(", "$", "properties", ")", ";", "}" ]
Handles property caching @param string $type @return []
[ "Handles", "property", "caching" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L84-L102
238,245
indigophp/indigo-skeleton
classes/Model.php
Model.fieldsets
public static function fieldsets() { $class = get_called_class(); if (array_key_exists($class, static::$_fieldsets_cached)) { return static::$_fieldsets_cached[$class]; } $fieldsets = []; if (property_exists($class, '_fieldsets')) { $fieldsets = []; foreach (static::$_fieldsets as $fieldset => $config) { if (is_int($fieldset)) { $fieldset = $config; $config = null; } if (empty($config)) { $config = [ 'legend' => $fieldset, ]; } elseif (is_string($config)) { $config = [ 'legend' => $config, ]; } $fieldsets[$fieldset] = $config; } } return static::$_fieldsets_cached[$class] = $fieldsets; }
php
public static function fieldsets() { $class = get_called_class(); if (array_key_exists($class, static::$_fieldsets_cached)) { return static::$_fieldsets_cached[$class]; } $fieldsets = []; if (property_exists($class, '_fieldsets')) { $fieldsets = []; foreach (static::$_fieldsets as $fieldset => $config) { if (is_int($fieldset)) { $fieldset = $config; $config = null; } if (empty($config)) { $config = [ 'legend' => $fieldset, ]; } elseif (is_string($config)) { $config = [ 'legend' => $config, ]; } $fieldsets[$fieldset] = $config; } } return static::$_fieldsets_cached[$class] = $fieldsets; }
[ "public", "static", "function", "fieldsets", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "class", ",", "static", "::", "$", "_fieldsets_cached", ")", ")", "{", "return", "static", "::", "$", "_fieldsets_cached", "[", "$", "class", "]", ";", "}", "$", "fieldsets", "=", "[", "]", ";", "if", "(", "property_exists", "(", "$", "class", ",", "'_fieldsets'", ")", ")", "{", "$", "fieldsets", "=", "[", "]", ";", "foreach", "(", "static", "::", "$", "_fieldsets", "as", "$", "fieldset", "=>", "$", "config", ")", "{", "if", "(", "is_int", "(", "$", "fieldset", ")", ")", "{", "$", "fieldset", "=", "$", "config", ";", "$", "config", "=", "null", ";", "}", "if", "(", "empty", "(", "$", "config", ")", ")", "{", "$", "config", "=", "[", "'legend'", "=>", "$", "fieldset", ",", "]", ";", "}", "elseif", "(", "is_string", "(", "$", "config", ")", ")", "{", "$", "config", "=", "[", "'legend'", "=>", "$", "config", ",", "]", ";", "}", "$", "fieldsets", "[", "$", "fieldset", "]", "=", "$", "config", ";", "}", "}", "return", "static", "::", "$", "_fieldsets_cached", "[", "$", "class", "]", "=", "$", "fieldsets", ";", "}" ]
Returns the model fieldsets @return []
[ "Returns", "the", "model", "fieldsets" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L139-L180
238,246
indigophp/indigo-skeleton
classes/Model.php
Model.generateInput
protected static function generateInput($field, array $propertyConfig) { $type = \Arr::get($propertyConfig, 'type', 'text'); // Build up a config array to pass to the parent $config = [ 'name' => $field, 'label' => \Arr::get($propertyConfig, 'label', $field), 'attributes' => \Arr::get($propertyConfig, 'attributes', []), ]; $content = \Arr::get($propertyConfig, 'options', false); if ($content !== false) { foreach ($content as $value => $contentName) { if (is_array($contentName)) { $group = [ 'type' => 'optgroup', 'label' => $value, ]; foreach ($contentName as $optValue => $optName) { $group['content'][] = [ 'type' => 'option', 'value' => $optValue, 'content' => $optName, ]; } $config['content'][] = $group; } else { $config['content'][] = [ 'type' => 'option', 'value' => $value, 'content' => $contentName, // FIXME 'label' => $contentName, ]; } } } $irrelevantKeys = ['attributes', 'label', 'options', 'type']; $meta = \Arr::filter_keys($propertyConfig, $irrelevantKeys, true); $instance = static::$builder->generateInput($type, $config) ->setMeta($meta); return $instance; }
php
protected static function generateInput($field, array $propertyConfig) { $type = \Arr::get($propertyConfig, 'type', 'text'); // Build up a config array to pass to the parent $config = [ 'name' => $field, 'label' => \Arr::get($propertyConfig, 'label', $field), 'attributes' => \Arr::get($propertyConfig, 'attributes', []), ]; $content = \Arr::get($propertyConfig, 'options', false); if ($content !== false) { foreach ($content as $value => $contentName) { if (is_array($contentName)) { $group = [ 'type' => 'optgroup', 'label' => $value, ]; foreach ($contentName as $optValue => $optName) { $group['content'][] = [ 'type' => 'option', 'value' => $optValue, 'content' => $optName, ]; } $config['content'][] = $group; } else { $config['content'][] = [ 'type' => 'option', 'value' => $value, 'content' => $contentName, // FIXME 'label' => $contentName, ]; } } } $irrelevantKeys = ['attributes', 'label', 'options', 'type']; $meta = \Arr::filter_keys($propertyConfig, $irrelevantKeys, true); $instance = static::$builder->generateInput($type, $config) ->setMeta($meta); return $instance; }
[ "protected", "static", "function", "generateInput", "(", "$", "field", ",", "array", "$", "propertyConfig", ")", "{", "$", "type", "=", "\\", "Arr", "::", "get", "(", "$", "propertyConfig", ",", "'type'", ",", "'text'", ")", ";", "// Build up a config array to pass to the parent", "$", "config", "=", "[", "'name'", "=>", "$", "field", ",", "'label'", "=>", "\\", "Arr", "::", "get", "(", "$", "propertyConfig", ",", "'label'", ",", "$", "field", ")", ",", "'attributes'", "=>", "\\", "Arr", "::", "get", "(", "$", "propertyConfig", ",", "'attributes'", ",", "[", "]", ")", ",", "]", ";", "$", "content", "=", "\\", "Arr", "::", "get", "(", "$", "propertyConfig", ",", "'options'", ",", "false", ")", ";", "if", "(", "$", "content", "!==", "false", ")", "{", "foreach", "(", "$", "content", "as", "$", "value", "=>", "$", "contentName", ")", "{", "if", "(", "is_array", "(", "$", "contentName", ")", ")", "{", "$", "group", "=", "[", "'type'", "=>", "'optgroup'", ",", "'label'", "=>", "$", "value", ",", "]", ";", "foreach", "(", "$", "contentName", "as", "$", "optValue", "=>", "$", "optName", ")", "{", "$", "group", "[", "'content'", "]", "[", "]", "=", "[", "'type'", "=>", "'option'", ",", "'value'", "=>", "$", "optValue", ",", "'content'", "=>", "$", "optName", ",", "]", ";", "}", "$", "config", "[", "'content'", "]", "[", "]", "=", "$", "group", ";", "}", "else", "{", "$", "config", "[", "'content'", "]", "[", "]", "=", "[", "'type'", "=>", "'option'", ",", "'value'", "=>", "$", "value", ",", "'content'", "=>", "$", "contentName", ",", "// FIXME", "'label'", "=>", "$", "contentName", ",", "]", ";", "}", "}", "}", "$", "irrelevantKeys", "=", "[", "'attributes'", ",", "'label'", ",", "'options'", ",", "'type'", "]", ";", "$", "meta", "=", "\\", "Arr", "::", "filter_keys", "(", "$", "propertyConfig", ",", "$", "irrelevantKeys", ",", "true", ")", ";", "$", "instance", "=", "static", "::", "$", "builder", "->", "generateInput", "(", "$", "type", ",", "$", "config", ")", "->", "setMeta", "(", "$", "meta", ")", ";", "return", "$", "instance", ";", "}" ]
Processes the given field and returns an element @param string $field Name of the field to add @param [] $propertyConfig Array of any config to be added to the field @return Input Form input
[ "Processes", "the", "given", "field", "and", "returns", "an", "element" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L238-L293
238,247
indigophp/indigo-skeleton
classes/Model.php
Model.generate_filters
public static function generate_filters() { if (static::$builder === null) { static::setBuilder(new Basic); } $form = []; // Loop through and add all fields foreach (static::list_properties() as $field => $config) { $form[] = static::generateInput($field, $config); } return $form; }
php
public static function generate_filters() { if (static::$builder === null) { static::setBuilder(new Basic); } $form = []; // Loop through and add all fields foreach (static::list_properties() as $field => $config) { $form[] = static::generateInput($field, $config); } return $form; }
[ "public", "static", "function", "generate_filters", "(", ")", "{", "if", "(", "static", "::", "$", "builder", "===", "null", ")", "{", "static", "::", "setBuilder", "(", "new", "Basic", ")", ";", "}", "$", "form", "=", "[", "]", ";", "// Loop through and add all fields", "foreach", "(", "static", "::", "list_properties", "(", ")", "as", "$", "field", "=>", "$", "config", ")", "{", "$", "form", "[", "]", "=", "static", "::", "generateInput", "(", "$", "field", ",", "$", "config", ")", ";", "}", "return", "$", "form", ";", "}" ]
Generates filters used in list @return [] Array of form elements
[ "Generates", "filters", "used", "in", "list" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L300-L316
238,248
xcitestudios/php-network
src/Email/EmailBodyPartCollection.php
EmailBodyPartCollection.deserializeJSON
public function deserializeJSON($jsonString) { $data = \json_decode($jsonString); $this->clear(); foreach ($data as $v) { $part = new EmailBodyPart(); $part->updateFromObject($v); $this->add($v); } }
php
public function deserializeJSON($jsonString) { $data = \json_decode($jsonString); $this->clear(); foreach ($data as $v) { $part = new EmailBodyPart(); $part->updateFromObject($v); $this->add($v); } }
[ "public", "function", "deserializeJSON", "(", "$", "jsonString", ")", "{", "$", "data", "=", "\\", "json_decode", "(", "$", "jsonString", ")", ";", "$", "this", "->", "clear", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "v", ")", "{", "$", "part", "=", "new", "EmailBodyPart", "(", ")", ";", "$", "part", "->", "updateFromObject", "(", "$", "v", ")", ";", "$", "this", "->", "add", "(", "$", "v", ")", ";", "}", "}" ]
Updates the element implementing this interface using a JSON representation. This means updating the state of this object with that defined in the JSON as opposed to returning a new instance of this object. @param string $jsonString Representation of the object @return void
[ "Updates", "the", "element", "implementing", "this", "interface", "using", "a", "JSON", "representation", ".", "This", "means", "updating", "the", "state", "of", "this", "object", "with", "that", "defined", "in", "the", "JSON", "as", "opposed", "to", "returning", "a", "new", "instance", "of", "this", "object", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailBodyPartCollection.php#L104-L117
238,249
tux-rampage/rampage-php
library/rampage/core/services/LocaleFactory.php
LocaleFactory.findLocale
protected function findLocale() { $locale = null; if (PHP_SAPI == 'cli') { $locale = getenv('LANG'); } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && extension_loaded('intl')) { $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); } return $locale; }
php
protected function findLocale() { $locale = null; if (PHP_SAPI == 'cli') { $locale = getenv('LANG'); } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && extension_loaded('intl')) { $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); } return $locale; }
[ "protected", "function", "findLocale", "(", ")", "{", "$", "locale", "=", "null", ";", "if", "(", "PHP_SAPI", "==", "'cli'", ")", "{", "$", "locale", "=", "getenv", "(", "'LANG'", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ")", "&&", "extension_loaded", "(", "'intl'", ")", ")", "{", "$", "locale", "=", "\\", "Locale", "::", "acceptFromHttp", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ")", ";", "}", "return", "$", "locale", ";", "}" ]
Find the current locale @return string
[ "Find", "the", "current", "locale" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/services/LocaleFactory.php#L42-L53
238,250
pletfix/core
src/Bootstraps/HandleExceptions.php
HandleExceptions.handleShutdown
public function handleShutdown() { $error = error_get_last(); if ($error !== null && $this->isFatal($error['type'])) { $this->handleException(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); // @codeCoverageIgnore } // @codeCoverageIgnore }
php
public function handleShutdown() { $error = error_get_last(); if ($error !== null && $this->isFatal($error['type'])) { $this->handleException(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); // @codeCoverageIgnore } // @codeCoverageIgnore }
[ "public", "function", "handleShutdown", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "!==", "null", "&&", "$", "this", "->", "isFatal", "(", "$", "error", "[", "'type'", "]", ")", ")", "{", "$", "this", "->", "handleException", "(", "new", "FatalErrorException", "(", "$", "error", "[", "'message'", "]", ",", "$", "error", "[", "'type'", "]", ",", "0", ",", "$", "error", "[", "'file'", "]", ",", "$", "error", "[", "'line'", "]", ")", ")", ";", "// @codeCoverageIgnore", "}", "// @codeCoverageIgnore", "}" ]
Convert an fatal Error to an FatalErrorException. A fatal Error can not be caught because it is not throwable. The application will be shut down immediately. It will be occur e.g. if you try to call a function which does not exists. @see http://php.net/manual/en/function.set-error-handler.php
[ "Convert", "an", "fatal", "Error", "to", "an", "FatalErrorException", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Bootstraps/HandleExceptions.php#L90-L96
238,251
extendsframework/extends-shell
src/Descriptor/Descriptor.php
Descriptor.getOptionNotation
protected function getOptionNotation(OptionInterface $option): string { $multiple = $option->isMultiple(); $short = $option->getShort(); $long = $option->getLong(); $flag = $option->isFlag(); $notation = ''; if ($short !== null) { $notation .= '-' . $short; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } if ($long !== null) { if (strlen($notation) > 0) { $notation .= '|'; } $notation .= '--' . $long; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } return $notation; }
php
protected function getOptionNotation(OptionInterface $option): string { $multiple = $option->isMultiple(); $short = $option->getShort(); $long = $option->getLong(); $flag = $option->isFlag(); $notation = ''; if ($short !== null) { $notation .= '-' . $short; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } if ($long !== null) { if (strlen($notation) > 0) { $notation .= '|'; } $notation .= '--' . $long; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } return $notation; }
[ "protected", "function", "getOptionNotation", "(", "OptionInterface", "$", "option", ")", ":", "string", "{", "$", "multiple", "=", "$", "option", "->", "isMultiple", "(", ")", ";", "$", "short", "=", "$", "option", "->", "getShort", "(", ")", ";", "$", "long", "=", "$", "option", "->", "getLong", "(", ")", ";", "$", "flag", "=", "$", "option", "->", "isFlag", "(", ")", ";", "$", "notation", "=", "''", ";", "if", "(", "$", "short", "!==", "null", ")", "{", "$", "notation", ".=", "'-'", ".", "$", "short", ";", "if", "(", "$", "flag", "===", "false", ")", "{", "$", "notation", ".=", "'='", ";", "}", "elseif", "(", "$", "multiple", "===", "true", ")", "{", "$", "notation", ".=", "'+'", ";", "}", "}", "if", "(", "$", "long", "!==", "null", ")", "{", "if", "(", "strlen", "(", "$", "notation", ")", ">", "0", ")", "{", "$", "notation", ".=", "'|'", ";", "}", "$", "notation", ".=", "'--'", ".", "$", "long", ";", "if", "(", "$", "flag", "===", "false", ")", "{", "$", "notation", ".=", "'='", ";", "}", "elseif", "(", "$", "multiple", "===", "true", ")", "{", "$", "notation", ".=", "'+'", ";", "}", "}", "return", "$", "notation", ";", "}" ]
Get option notation. @param OptionInterface $option @return string
[ "Get", "option", "notation", "." ]
115a38dd7e2af82d56d15407d7955da2d382521b
https://github.com/extendsframework/extends-shell/blob/115a38dd7e2af82d56d15407d7955da2d382521b/src/Descriptor/Descriptor.php#L273-L306
238,252
dotronglong/titan-common
src/Stream.php
Stream.calculateSize
private function calculateSize() { // Clear the stat cache if the stream has a URI if ($this->uri) { clearstatcache(true, $this->uri); } $stats = fstat($this->stream); if (isset($stats[static::META_SIZE])) { $this->size = $stats[static::META_SIZE]; return $this->size; } return null; }
php
private function calculateSize() { // Clear the stat cache if the stream has a URI if ($this->uri) { clearstatcache(true, $this->uri); } $stats = fstat($this->stream); if (isset($stats[static::META_SIZE])) { $this->size = $stats[static::META_SIZE]; return $this->size; } return null; }
[ "private", "function", "calculateSize", "(", ")", "{", "// Clear the stat cache if the stream has a URI", "if", "(", "$", "this", "->", "uri", ")", "{", "clearstatcache", "(", "true", ",", "$", "this", "->", "uri", ")", ";", "}", "$", "stats", "=", "fstat", "(", "$", "this", "->", "stream", ")", ";", "if", "(", "isset", "(", "$", "stats", "[", "static", "::", "META_SIZE", "]", ")", ")", "{", "$", "this", "->", "size", "=", "$", "stats", "[", "static", "::", "META_SIZE", "]", ";", "return", "$", "this", "->", "size", ";", "}", "return", "null", ";", "}" ]
Calculate current size of stream @return int|null
[ "Calculate", "current", "size", "of", "stream" ]
2970334da25b70100ac15d8fc1459e3a8b8b2a3e
https://github.com/dotronglong/titan-common/blob/2970334da25b70100ac15d8fc1459e3a8b8b2a3e/src/Stream.php#L240-L255
238,253
erikkubica/netlime-theme-megamenu
Menu_Item_Megamenu_Fields_Walker.php
Menu_Item_Megamenu_Fields_Walker.get_fields
protected function get_fields($item, $depth, $args = array(), $id = 0) { ob_start(); /** * Get menu item custom fields from plugins/themes * * @since 0.1.0 * @since 1.0.0 Pass correct parameters. * * @param int $item_id Menu item ID. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Menu item args. * @param int $id Nav menu ID. * * @return string Custom fields HTML. */ do_action('wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id); return ob_get_clean(); }
php
protected function get_fields($item, $depth, $args = array(), $id = 0) { ob_start(); /** * Get menu item custom fields from plugins/themes * * @since 0.1.0 * @since 1.0.0 Pass correct parameters. * * @param int $item_id Menu item ID. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Menu item args. * @param int $id Nav menu ID. * * @return string Custom fields HTML. */ do_action('wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id); return ob_get_clean(); }
[ "protected", "function", "get_fields", "(", "$", "item", ",", "$", "depth", ",", "$", "args", "=", "array", "(", ")", ",", "$", "id", "=", "0", ")", "{", "ob_start", "(", ")", ";", "/**\n * Get menu item custom fields from plugins/themes\n *\n * @since 0.1.0\n * @since 1.0.0 Pass correct parameters.\n *\n * @param int $item_id Menu item ID.\n * @param object $item Menu item data object.\n * @param int $depth Depth of menu item. Used for padding.\n * @param array $args Menu item args.\n * @param int $id Nav menu ID.\n *\n * @return string Custom fields HTML.\n */", "do_action", "(", "'wp_nav_menu_item_custom_fields'", ",", "$", "item", "->", "ID", ",", "$", "item", ",", "$", "depth", ",", "$", "args", ",", "$", "id", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Get custom fields @access protected @since 0.1.0 @uses add_action() Calls 'menu_item_custom_fields' hook @param object $item Menu item data object. @param int $depth Depth of menu item. Used for padding. @param array $args Menu item args. @param int $id Nav menu ID. @return string Form fields
[ "Get", "custom", "fields" ]
cd9c364fa8fcf9ca63bb17935f5af215ad234cf1
https://github.com/erikkubica/netlime-theme-megamenu/blob/cd9c364fa8fcf9ca63bb17935f5af215ad234cf1/Menu_Item_Megamenu_Fields_Walker.php#L49-L70
238,254
polary/polary
extensions/yii2-deploy/commands/DeployController.php
DeployController.actionInstall
public function actionInstall() { $this->stdout("Run composer dump-autoload ... "); $this->executeCommand('$ composer dump-autoload'); $this->stdout("[DONE]\n"); $scriptComponent = $this->getScript(); if ($scripts = $scriptComponent->getScript('yii2-yiithings-install-cmd')) { if ( ! $this->runScripts($scripts)) { return 1; } } return 0; }
php
public function actionInstall() { $this->stdout("Run composer dump-autoload ... "); $this->executeCommand('$ composer dump-autoload'); $this->stdout("[DONE]\n"); $scriptComponent = $this->getScript(); if ($scripts = $scriptComponent->getScript('yii2-yiithings-install-cmd')) { if ( ! $this->runScripts($scripts)) { return 1; } } return 0; }
[ "public", "function", "actionInstall", "(", ")", "{", "$", "this", "->", "stdout", "(", "\"Run composer dump-autoload ... \"", ")", ";", "$", "this", "->", "executeCommand", "(", "'$ composer dump-autoload'", ")", ";", "$", "this", "->", "stdout", "(", "\"[DONE]\\n\"", ")", ";", "$", "scriptComponent", "=", "$", "this", "->", "getScript", "(", ")", ";", "if", "(", "$", "scripts", "=", "$", "scriptComponent", "->", "getScript", "(", "'yii2-yiithings-install-cmd'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "runScripts", "(", "$", "scripts", ")", ")", "{", "return", "1", ";", "}", "}", "return", "0", ";", "}" ]
Run installation.
[ "Run", "installation", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/extensions/yii2-deploy/commands/DeployController.php#L38-L52
238,255
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.open
public function open($sessionPath, $sessionName){ //si la sesión no está abierta tengo que abrir conexión a base de datos if(!$this->opened){ $this->connection= new DataBaseAR(FALSE); $this->connection->connect($this->dataBase); $this->opened= TRUE; return TRUE; } else{ return TRUE; } }
php
public function open($sessionPath, $sessionName){ //si la sesión no está abierta tengo que abrir conexión a base de datos if(!$this->opened){ $this->connection= new DataBaseAR(FALSE); $this->connection->connect($this->dataBase); $this->opened= TRUE; return TRUE; } else{ return TRUE; } }
[ "public", "function", "open", "(", "$", "sessionPath", ",", "$", "sessionName", ")", "{", "//si la sesión no está abierta tengo que abrir conexión a base de datos", "if", "(", "!", "$", "this", "->", "opened", ")", "{", "$", "this", "->", "connection", "=", "new", "DataBaseAR", "(", "FALSE", ")", ";", "$", "this", "->", "connection", "->", "connect", "(", "$", "this", "->", "dataBase", ")", ";", "$", "this", "->", "opened", "=", "TRUE", ";", "return", "TRUE", ";", "}", "else", "{", "return", "TRUE", ";", "}", "}" ]
Abre la conexion a la base de datos si no esta abierta @param string $sessionPath @param string $sessionName @return boolean
[ "Abre", "la", "conexion", "a", "la", "base", "de", "datos", "si", "no", "esta", "abierta" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L44-L55
238,256
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.read
public function read($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('SELECT session_data FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); $sql->execute(); $result= $sql->fetch(\PDO::FETCH_ASSOC); if($result != NULL){ return $result['session_data']; } return ''; } else{ return ''; } }
php
public function read($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('SELECT session_data FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); $sql->execute(); $result= $sql->fetch(\PDO::FETCH_ASSOC); if($result != NULL){ return $result['session_data']; } return ''; } else{ return ''; } }
[ "public", "function", "read", "(", "$", "sessionId", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'SELECT session_data FROM sessions WHERE session_id = :id'", ")", ";", "$", "sql", "->", "bindValue", "(", "'id'", ",", "$", "sessionId", ")", ";", "$", "sql", "->", "execute", "(", ")", ";", "$", "result", "=", "$", "sql", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "if", "(", "$", "result", "!=", "NULL", ")", "{", "return", "$", "result", "[", "'session_data'", "]", ";", "}", "return", "''", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Lee los datos de la session de la base de datos Si no hay nada retorna "" @param string $sessionId @return string
[ "Lee", "los", "datos", "de", "la", "session", "de", "la", "base", "de", "datos", "Si", "no", "hay", "nada", "retorna" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L71-L86
238,257
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.write
public function write($sessionId, $sessionData){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)'); $sql->bindValue('id', $sessionId); $sql->bindValue('data', $sessionData); $fecha= new \DateTime(); $fecha->add(new \DateInterval($this->expirationTime)); $sql->bindValue('expiration', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function write($sessionId, $sessionData){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)'); $sql->bindValue('id', $sessionId); $sql->bindValue('data', $sessionData); $fecha= new \DateTime(); $fecha->add(new \DateInterval($this->expirationTime)); $sql->bindValue('expiration', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "sessionData", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)'", ")", ";", "$", "sql", "->", "bindValue", "(", "'id'", ",", "$", "sessionId", ")", ";", "$", "sql", "->", "bindValue", "(", "'data'", ",", "$", "sessionData", ")", ";", "$", "fecha", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "fecha", "->", "add", "(", "new", "\\", "DateInterval", "(", "$", "this", "->", "expirationTime", ")", ")", ";", "$", "sql", "->", "bindValue", "(", "'expiration'", ",", "$", "fecha", "->", "format", "(", "'Y-m-d H:i:s'", ")", ")", ";", "return", "$", "sql", "->", "execute", "(", ")", "===", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Escribe los datos de la session en la base de datos @param string $sessionId @param string $sessionData @return boolean
[ "Escribe", "los", "datos", "de", "la", "session", "en", "la", "base", "de", "datos" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L93-L107
238,258
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.destroy
public function destroy($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function destroy($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "destroy", "(", "$", "sessionId", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'DELETE FROM sessions WHERE session_id = :id'", ")", ";", "$", "sql", "->", "bindValue", "(", "'id'", ",", "$", "sessionId", ")", ";", "return", "$", "sql", "->", "execute", "(", ")", "===", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Destruye los datos e la session de la base de datos @param string $sessionId @return boolean
[ "Destruye", "los", "datos", "e", "la", "session", "de", "la", "base", "de", "datos" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L113-L123
238,259
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.gc
public function gc($lifetime){ //si la sesión está abierta y tengo lock if($this->opened){ $fecha= new \DateTime(); $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_expiration < :fecha'); $sql->bindValue('fecha', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function gc($lifetime){ //si la sesión está abierta y tengo lock if($this->opened){ $fecha= new \DateTime(); $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_expiration < :fecha'); $sql->bindValue('fecha', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "gc", "(", "$", "lifetime", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "fecha", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'DELETE FROM sessions WHERE session_expiration < :fecha'", ")", ";", "$", "sql", "->", "bindValue", "(", "'fecha'", ",", "$", "fecha", "->", "format", "(", "'Y-m-d H:i:s'", ")", ")", ";", "return", "$", "sql", "->", "execute", "(", ")", "===", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Elimina las session en la que su tiempo de expiration sea menor que el tiempo actual @param int $lifetime @return boolean
[ "Elimina", "las", "session", "en", "la", "que", "su", "tiempo", "de", "expiration", "sea", "menor", "que", "el", "tiempo", "actual" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L129-L140
238,260
solo-framework/solo-logger
src/Logger.php
Logger.init
public static function init($settings = null) { if (!is_null($settings)) self::$settings = array_replace_recursive(self::$settings, $settings); }
php
public static function init($settings = null) { if (!is_null($settings)) self::$settings = array_replace_recursive(self::$settings, $settings); }
[ "public", "static", "function", "init", "(", "$", "settings", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "settings", ")", ")", "self", "::", "$", "settings", "=", "array_replace_recursive", "(", "self", "::", "$", "settings", ",", "$", "settings", ")", ";", "}" ]
Init the logger @param mixed $settings @return void
[ "Init", "the", "logger" ]
2f0a9f789479c4e9ab6ee9fe5817f256eb18db70
https://github.com/solo-framework/solo-logger/blob/2f0a9f789479c4e9ab6ee9fe5817f256eb18db70/src/Logger.php#L117-L121
238,261
angelk/bbCodeBundle
src/Potaka/BbcodeBundle/BbCode/TextToHtml.php
TextToHtml.getHtml
public function getHtml(string $text) : string { $textAsHtml = htmlspecialchars($text, ENT_QUOTES); $textWithNewLines = nl2br($textAsHtml); $tokenized = $this->tokenizer->tokenize($textWithNewLines); $html = $this->bbCode->format($tokenized); return $html; }
php
public function getHtml(string $text) : string { $textAsHtml = htmlspecialchars($text, ENT_QUOTES); $textWithNewLines = nl2br($textAsHtml); $tokenized = $this->tokenizer->tokenize($textWithNewLines); $html = $this->bbCode->format($tokenized); return $html; }
[ "public", "function", "getHtml", "(", "string", "$", "text", ")", ":", "string", "{", "$", "textAsHtml", "=", "htmlspecialchars", "(", "$", "text", ",", "ENT_QUOTES", ")", ";", "$", "textWithNewLines", "=", "nl2br", "(", "$", "textAsHtml", ")", ";", "$", "tokenized", "=", "$", "this", "->", "tokenizer", "->", "tokenize", "(", "$", "textWithNewLines", ")", ";", "$", "html", "=", "$", "this", "->", "bbCode", "->", "format", "(", "$", "tokenized", ")", ";", "return", "$", "html", ";", "}" ]
Transform string to html escaped string with applied bb-code. @param string $text @return string
[ "Transform", "string", "to", "html", "escaped", "string", "with", "applied", "bb", "-", "code", "." ]
bd5512d2bcddb1bd841469a66ff9af60b3f85f34
https://github.com/angelk/bbCodeBundle/blob/bd5512d2bcddb1bd841469a66ff9af60b3f85f34/src/Potaka/BbcodeBundle/BbCode/TextToHtml.php#L37-L46
238,262
OWeb/OWeb-Framework
OWeb/defaults/controllers/demo/jquery/ui/Tabs.php
Tabs.doRefresh
public function doRefresh(){ //Validating elements. Should be already done but let's say on the safe side $this->form->validateElements(); //If valid apply values to the accordion if($this->form->isValid()){ foreach($this->form->getElements() as $element){ $this->tabs->addParams($element->getName(), $element->getVal()); } } }
php
public function doRefresh(){ //Validating elements. Should be already done but let's say on the safe side $this->form->validateElements(); //If valid apply values to the accordion if($this->form->isValid()){ foreach($this->form->getElements() as $element){ $this->tabs->addParams($element->getName(), $element->getVal()); } } }
[ "public", "function", "doRefresh", "(", ")", "{", "//Validating elements. Should be already done but let's say on the safe side", "$", "this", "->", "form", "->", "validateElements", "(", ")", ";", "//If valid apply values to the accordion", "if", "(", "$", "this", "->", "form", "->", "isValid", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "form", "->", "getElements", "(", ")", "as", "$", "element", ")", "{", "$", "this", "->", "tabs", "->", "addParams", "(", "$", "element", "->", "getName", "(", ")", ",", "$", "element", "->", "getVal", "(", ")", ")", ";", "}", "}", "}" ]
If form returned an action
[ "If", "form", "returned", "an", "action" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/demo/jquery/ui/Tabs.php#L56-L66
238,263
mtils/ems-signal
src/Signal/NamedEvent/BusHolderTrait.php
BusHolderTrait.getEventBus
public function getEventBus() { if (!$this->eventBus) { if (isset(static::$staticEventBus)) { return static::$staticEventBus; } $this->eventBus = new Bus; } return $this->eventBus; }
php
public function getEventBus() { if (!$this->eventBus) { if (isset(static::$staticEventBus)) { return static::$staticEventBus; } $this->eventBus = new Bus; } return $this->eventBus; }
[ "public", "function", "getEventBus", "(", ")", "{", "if", "(", "!", "$", "this", "->", "eventBus", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "staticEventBus", ")", ")", "{", "return", "static", "::", "$", "staticEventBus", ";", "}", "$", "this", "->", "eventBus", "=", "new", "Bus", ";", "}", "return", "$", "this", "->", "eventBus", ";", "}" ]
Return the eventBus @return \Signal\Contracts\NamedEvent\Bus
[ "Return", "the", "eventBus" ]
3246eea699dce1a6d6f758bcfc89b20320f6becc
https://github.com/mtils/ems-signal/blob/3246eea699dce1a6d6f758bcfc89b20320f6becc/src/Signal/NamedEvent/BusHolderTrait.php#L20-L29
238,264
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.createDataProvider
protected function createDataProvider() : ActiveDataProvider { $query = $this->buildQuery(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => $this->defaultOrder ] ]); if (!$this->load($this->requestData())) { return $dataProvider; } if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $this->buildFilter($query); return $dataProvider; }
php
protected function createDataProvider() : ActiveDataProvider { $query = $this->buildQuery(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => $this->defaultOrder ] ]); if (!$this->load($this->requestData())) { return $dataProvider; } if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $this->buildFilter($query); return $dataProvider; }
[ "protected", "function", "createDataProvider", "(", ")", ":", "ActiveDataProvider", "{", "$", "query", "=", "$", "this", "->", "buildQuery", "(", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", "'sort'", "=>", "[", "'defaultOrder'", "=>", "$", "this", "->", "defaultOrder", "]", "]", ")", ";", "if", "(", "!", "$", "this", "->", "load", "(", "$", "this", "->", "requestData", "(", ")", ")", ")", "{", "return", "$", "dataProvider", ";", "}", "if", "(", "!", "$", "this", "->", "validate", "(", ")", ")", "{", "$", "query", "->", "where", "(", "'0=1'", ")", ";", "return", "$", "dataProvider", ";", "}", "$", "this", "->", "buildFilter", "(", "$", "query", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Create ActiveDataProvider. @return \yii\data\ActiveDataProvider
[ "Create", "ActiveDataProvider", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L164-L185
238,265
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.requestData
protected function requestData() : array { switch ($this->method) { case 'post': return Yii::$app->request->post(); case 'get': return Yii::$app->request->getQueryParams(); default: throw new InvalidConfigException('Request method is not defined'); } }
php
protected function requestData() : array { switch ($this->method) { case 'post': return Yii::$app->request->post(); case 'get': return Yii::$app->request->getQueryParams(); default: throw new InvalidConfigException('Request method is not defined'); } }
[ "protected", "function", "requestData", "(", ")", ":", "array", "{", "switch", "(", "$", "this", "->", "method", ")", "{", "case", "'post'", ":", "return", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ";", "case", "'get'", ":", "return", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ";", "default", ":", "throw", "new", "InvalidConfigException", "(", "'Request method is not defined'", ")", ";", "}", "}" ]
Get request data params. @return array @throws \yii\base\InvalidConfigException
[ "Get", "request", "data", "params", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L211-L221
238,266
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.filterTimestamp
protected function filterTimestamp(&$query, $attr = 'updated_at') { if (!is_null($this->{$attr}) && strpos($this->{$attr}, ' - ') !== false ) { list($start_date, $end_date) = explode(' - ', $this->{$attr}); $query->andFilterWhere(['>=', $attr, (int)strtotime($start_date)]); $query->andFilterWhere(['<=', $attr, (int)strtotime($end_date) + 24 * 3600]); } }
php
protected function filterTimestamp(&$query, $attr = 'updated_at') { if (!is_null($this->{$attr}) && strpos($this->{$attr}, ' - ') !== false ) { list($start_date, $end_date) = explode(' - ', $this->{$attr}); $query->andFilterWhere(['>=', $attr, (int)strtotime($start_date)]); $query->andFilterWhere(['<=', $attr, (int)strtotime($end_date) + 24 * 3600]); } }
[ "protected", "function", "filterTimestamp", "(", "&", "$", "query", ",", "$", "attr", "=", "'updated_at'", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "{", "$", "attr", "}", ")", "&&", "strpos", "(", "$", "this", "->", "{", "$", "attr", "}", ",", "' - '", ")", "!==", "false", ")", "{", "list", "(", "$", "start_date", ",", "$", "end_date", ")", "=", "explode", "(", "' - '", ",", "$", "this", "->", "{", "$", "attr", "}", ")", ";", "$", "query", "->", "andFilterWhere", "(", "[", "'>='", ",", "$", "attr", ",", "(", "int", ")", "strtotime", "(", "$", "start_date", ")", "]", ")", ";", "$", "query", "->", "andFilterWhere", "(", "[", "'<='", ",", "$", "attr", ",", "(", "int", ")", "strtotime", "(", "$", "end_date", ")", "+", "24", "*", "3600", "]", ")", ";", "}", "}" ]
Add filter on timestamp. @param string $attr
[ "Add", "filter", "on", "timestamp", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L227-L234
238,267
timostamm/pathinfo
src/Path.php
Path.isIn
public function isIn($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd); $self = $self->abs($cwd); } if (strpos($self->__toString(), $dir->__toString()) === 0) { return true; } return false; }
php
public function isIn($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd); $self = $self->abs($cwd); } if (strpos($self->__toString(), $dir->__toString()) === 0) { return true; } return false; }
[ "public", "function", "isIn", "(", "$", "directory", ",", "$", "cwd", "=", "null", ")", "{", "$", "dir", "=", "Path", "::", "info", "(", "$", "directory", ")", ";", "if", "(", "$", "dir", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Directory is empty.'", ")", ";", "}", "$", "dir", "=", "$", "dir", "->", "normalize", "(", ")", "->", "assumeDirectory", "(", ")", ";", "$", "self", "=", "$", "this", "->", "normalize", "(", ")", ";", "if", "(", "!", "$", "dir", "->", "isAbsolute", "(", ")", "&&", "is_null", "(", "$", "cwd", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Directory \"%s\" is not absolute, you have to provide a working directory.'", ",", "$", "directory", ")", ")", ";", "}", "if", "(", "!", "$", "self", "->", "isAbsolute", "(", ")", "&&", "is_null", "(", "$", "cwd", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Path \"%s\" is not absolute, you have to provide a working directory.'", ",", "$", "this", ")", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "cwd", ")", ")", "{", "$", "cwd", "=", "Path", "::", "info", "(", "$", "cwd", ")", "->", "normalize", "(", ")", "->", "assumeDirectory", "(", ")", ";", "if", "(", "!", "$", "cwd", "->", "isAbsolute", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Working directory \"%s\" must be absolute.'", ",", "$", "cwd", ")", ")", ";", "}", "if", "(", "$", "cwd", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Working directory is empty.'", ")", ";", "}", "$", "dir", "=", "$", "dir", "->", "abs", "(", "$", "cwd", ")", ";", "$", "self", "=", "$", "self", "->", "abs", "(", "$", "cwd", ")", ";", "}", "if", "(", "strpos", "(", "$", "self", "->", "__toString", "(", ")", ",", "$", "dir", "->", "__toString", "(", ")", ")", "===", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tests whether the path is within the given directory. @param string|Path $directory @param string|Path|NULL $cwd @throws \InvalidArgumentException @return boolean
[ "Tests", "whether", "the", "path", "is", "within", "the", "given", "directory", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L44-L75
238,268
timostamm/pathinfo
src/Path.php
Path.relativeTo
public function relativeTo($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize()->dir(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd)->normalize(); $self = $self->abs($cwd)->normalize(); } $i = 0; while ($i < $dir->partCount && $i < $self->partCount && $dir->parts[$i] === $self->parts[$i]) { $i ++; } $remainder = new Path(''); $remainder->setParts(array_slice($self->parts, $i)); $outsideDepth = $dir->partCount - $i - 1; if ($outsideDepth > 0) { $traversal = array_fill(0, $outsideDepth, '..'); $remainder->setParts(array_merge($traversal, $remainder->parts)); } $result = $remainder->resolve($this->filename()); return $result->isEmpty() ? new Path('./') : $result; }
php
public function relativeTo($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize()->dir(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd)->normalize(); $self = $self->abs($cwd)->normalize(); } $i = 0; while ($i < $dir->partCount && $i < $self->partCount && $dir->parts[$i] === $self->parts[$i]) { $i ++; } $remainder = new Path(''); $remainder->setParts(array_slice($self->parts, $i)); $outsideDepth = $dir->partCount - $i - 1; if ($outsideDepth > 0) { $traversal = array_fill(0, $outsideDepth, '..'); $remainder->setParts(array_merge($traversal, $remainder->parts)); } $result = $remainder->resolve($this->filename()); return $result->isEmpty() ? new Path('./') : $result; }
[ "public", "function", "relativeTo", "(", "$", "directory", ",", "$", "cwd", "=", "null", ")", "{", "$", "dir", "=", "Path", "::", "info", "(", "$", "directory", ")", ";", "if", "(", "$", "dir", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Directory is empty.'", ")", ";", "}", "$", "dir", "=", "$", "dir", "->", "normalize", "(", ")", "->", "assumeDirectory", "(", ")", ";", "$", "self", "=", "$", "this", "->", "normalize", "(", ")", "->", "dir", "(", ")", ";", "if", "(", "!", "$", "dir", "->", "isAbsolute", "(", ")", "&&", "is_null", "(", "$", "cwd", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Directory \"%s\" is not absolute, you have to provide a working directory.'", ",", "$", "directory", ")", ")", ";", "}", "if", "(", "!", "$", "self", "->", "isAbsolute", "(", ")", "&&", "is_null", "(", "$", "cwd", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Path \"%s\" is not absolute, you have to provide a working directory.'", ",", "$", "this", ")", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "cwd", ")", ")", "{", "$", "cwd", "=", "Path", "::", "info", "(", "$", "cwd", ")", "->", "normalize", "(", ")", "->", "assumeDirectory", "(", ")", ";", "if", "(", "!", "$", "cwd", "->", "isAbsolute", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Working directory \"%s\" must be absolute.'", ",", "$", "cwd", ")", ")", ";", "}", "if", "(", "$", "cwd", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Working directory is empty.'", ")", ";", "}", "$", "dir", "=", "$", "dir", "->", "abs", "(", "$", "cwd", ")", "->", "normalize", "(", ")", ";", "$", "self", "=", "$", "self", "->", "abs", "(", "$", "cwd", ")", "->", "normalize", "(", ")", ";", "}", "$", "i", "=", "0", ";", "while", "(", "$", "i", "<", "$", "dir", "->", "partCount", "&&", "$", "i", "<", "$", "self", "->", "partCount", "&&", "$", "dir", "->", "parts", "[", "$", "i", "]", "===", "$", "self", "->", "parts", "[", "$", "i", "]", ")", "{", "$", "i", "++", ";", "}", "$", "remainder", "=", "new", "Path", "(", "''", ")", ";", "$", "remainder", "->", "setParts", "(", "array_slice", "(", "$", "self", "->", "parts", ",", "$", "i", ")", ")", ";", "$", "outsideDepth", "=", "$", "dir", "->", "partCount", "-", "$", "i", "-", "1", ";", "if", "(", "$", "outsideDepth", ">", "0", ")", "{", "$", "traversal", "=", "array_fill", "(", "0", ",", "$", "outsideDepth", ",", "'..'", ")", ";", "$", "remainder", "->", "setParts", "(", "array_merge", "(", "$", "traversal", ",", "$", "remainder", "->", "parts", ")", ")", ";", "}", "$", "result", "=", "$", "remainder", "->", "resolve", "(", "$", "this", "->", "filename", "(", ")", ")", ";", "return", "$", "result", "->", "isEmpty", "(", ")", "?", "new", "Path", "(", "'./'", ")", ":", "$", "result", ";", "}" ]
Gets the relative path to the given directory. Example: new Path('/var/wwwroot/js/script.js')->relativeTo('/var/wwwroot/') => js/script.js If you provide a working directory, you can use relative paths. new Path('js/script.js')->relativeTo('.', '/var/wwwroot/') => js/script.js If the current path is a directory, it must end with a slash. @param string|Path $directory @param string|Path|NULL $cwd @throws \InvalidArgumentException @return static a new Path object
[ "Gets", "the", "relative", "path", "to", "the", "given", "directory", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L94-L134
238,269
timostamm/pathinfo
src/Path.php
Path.set
public function set($path) { if (! is_string($path)) { throw new \InvalidArgumentException(); } if ($path === '') { $this->setParts([]); } else { $this->setParts(explode('/', $path)); } return $this; }
php
public function set($path) { if (! is_string($path)) { throw new \InvalidArgumentException(); } if ($path === '') { $this->setParts([]); } else { $this->setParts(explode('/', $path)); } return $this; }
[ "public", "function", "set", "(", "$", "path", ")", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", ")", ";", "}", "if", "(", "$", "path", "===", "''", ")", "{", "$", "this", "->", "setParts", "(", "[", "]", ")", ";", "}", "else", "{", "$", "this", "->", "setParts", "(", "explode", "(", "'/'", ",", "$", "path", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the path. @param string $path @throws \InvalidArgumentException @return self
[ "Set", "the", "path", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L202-L213
238,270
timostamm/pathinfo
src/Path.php
Path.isEmpty
public function isEmpty() { if ($this->partCount === 0) { return true; } if ($this->partCount === 1) { return $this->firstPart === ''; } if ($this->partCount === 3 && $this->isStreamWrapped()) { return true; } return false; }
php
public function isEmpty() { if ($this->partCount === 0) { return true; } if ($this->partCount === 1) { return $this->firstPart === ''; } if ($this->partCount === 3 && $this->isStreamWrapped()) { return true; } return false; }
[ "public", "function", "isEmpty", "(", ")", "{", "if", "(", "$", "this", "->", "partCount", "===", "0", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "partCount", "===", "1", ")", "{", "return", "$", "this", "->", "firstPart", "===", "''", ";", "}", "if", "(", "$", "this", "->", "partCount", "===", "3", "&&", "$", "this", "->", "isStreamWrapped", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is the this path empty? @return boolean
[ "Is", "the", "this", "path", "empty?" ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L230-L242
238,271
timostamm/pathinfo
src/Path.php
Path.isStreamWrapped
public function isStreamWrapped() { $maybeStreamWrapped = $this->partCount > 1 && $this->firstPart !== '' && $this->parts[1] === '' && ':' === substr($this->firstPart, -1); if (! $maybeStreamWrapped) { return false; } $name = substr($this->firstPart, 0, -1); return in_array($name, stream_get_wrappers()); }
php
public function isStreamWrapped() { $maybeStreamWrapped = $this->partCount > 1 && $this->firstPart !== '' && $this->parts[1] === '' && ':' === substr($this->firstPart, -1); if (! $maybeStreamWrapped) { return false; } $name = substr($this->firstPart, 0, -1); return in_array($name, stream_get_wrappers()); }
[ "public", "function", "isStreamWrapped", "(", ")", "{", "$", "maybeStreamWrapped", "=", "$", "this", "->", "partCount", ">", "1", "&&", "$", "this", "->", "firstPart", "!==", "''", "&&", "$", "this", "->", "parts", "[", "1", "]", "===", "''", "&&", "':'", "===", "substr", "(", "$", "this", "->", "firstPart", ",", "-", "1", ")", ";", "if", "(", "!", "$", "maybeStreamWrapped", ")", "{", "return", "false", ";", "}", "$", "name", "=", "substr", "(", "$", "this", "->", "firstPart", ",", "0", ",", "-", "1", ")", ";", "return", "in_array", "(", "$", "name", ",", "stream_get_wrappers", "(", ")", ")", ";", "}" ]
Is this a stream-wrapped path? @see http://php.net/manual/de/class.streamwrapper.php @return boolean
[ "Is", "this", "a", "stream", "-", "wrapped", "path?" ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L263-L271
238,272
timostamm/pathinfo
src/Path.php
Path.equals
public function equals($path) { $p = Path::info($path); return $p->normalize()->get() === $this->normalize()->get(); }
php
public function equals($path) { $p = Path::info($path); return $p->normalize()->get() === $this->normalize()->get(); }
[ "public", "function", "equals", "(", "$", "path", ")", "{", "$", "p", "=", "Path", "::", "info", "(", "$", "path", ")", ";", "return", "$", "p", "->", "normalize", "(", ")", "->", "get", "(", ")", "===", "$", "this", "->", "normalize", "(", ")", "->", "get", "(", ")", ";", "}" ]
Returns true if both parts are equal after normalization. @param string|Path $path @return boolean
[ "Returns", "true", "if", "both", "parts", "are", "equal", "after", "normalization", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L279-L283
238,273
timostamm/pathinfo
src/Path.php
Path.dir
public function dir() { $dir = clone $this; if ($this->lastPart === '') { // already dir } else if ($this->lastPart === '..' || $this->lastPart === '.') { $dir->parts[] = ''; } else { array_pop($dir->parts); $dir->parts[] = ''; } $dir->setParts($dir->parts); return $dir; }
php
public function dir() { $dir = clone $this; if ($this->lastPart === '') { // already dir } else if ($this->lastPart === '..' || $this->lastPart === '.') { $dir->parts[] = ''; } else { array_pop($dir->parts); $dir->parts[] = ''; } $dir->setParts($dir->parts); return $dir; }
[ "public", "function", "dir", "(", ")", "{", "$", "dir", "=", "clone", "$", "this", ";", "if", "(", "$", "this", "->", "lastPart", "===", "''", ")", "{", "// already dir", "}", "else", "if", "(", "$", "this", "->", "lastPart", "===", "'..'", "||", "$", "this", "->", "lastPart", "===", "'.'", ")", "{", "$", "dir", "->", "parts", "[", "]", "=", "''", ";", "}", "else", "{", "array_pop", "(", "$", "dir", "->", "parts", ")", ";", "$", "dir", "->", "parts", "[", "]", "=", "''", ";", "}", "$", "dir", "->", "setParts", "(", "$", "dir", "->", "parts", ")", ";", "return", "$", "dir", ";", "}" ]
Returns a new path object that points to the dirname part. @return static a new Path object
[ "Returns", "a", "new", "path", "object", "that", "points", "to", "the", "dirname", "part", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L290-L303
238,274
timostamm/pathinfo
src/Path.php
Path.resolve
public function resolve($path) { if ($path instanceof Path) { $add = clone $path; } else if (is_string($path)) { $add = new Path($path); } else { throw new \InvalidArgumentException(); } $base = clone $this; if ($base->partCount === 0) { return $add; } if ($add->isAbsolute()) { return $add; } if ($base->lastPart === '') { array_pop($base->parts); } if ($add->firstPart === '') { array_shift($add->parts); } foreach ($add->parts as $part) { $base->parts[] = $part; } if ($add->partCount === 0) { $base->parts[] = ''; } $base->setParts($base->parts); return $base; }
php
public function resolve($path) { if ($path instanceof Path) { $add = clone $path; } else if (is_string($path)) { $add = new Path($path); } else { throw new \InvalidArgumentException(); } $base = clone $this; if ($base->partCount === 0) { return $add; } if ($add->isAbsolute()) { return $add; } if ($base->lastPart === '') { array_pop($base->parts); } if ($add->firstPart === '') { array_shift($add->parts); } foreach ($add->parts as $part) { $base->parts[] = $part; } if ($add->partCount === 0) { $base->parts[] = ''; } $base->setParts($base->parts); return $base; }
[ "public", "function", "resolve", "(", "$", "path", ")", "{", "if", "(", "$", "path", "instanceof", "Path", ")", "{", "$", "add", "=", "clone", "$", "path", ";", "}", "else", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "add", "=", "new", "Path", "(", "$", "path", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", ")", ";", "}", "$", "base", "=", "clone", "$", "this", ";", "if", "(", "$", "base", "->", "partCount", "===", "0", ")", "{", "return", "$", "add", ";", "}", "if", "(", "$", "add", "->", "isAbsolute", "(", ")", ")", "{", "return", "$", "add", ";", "}", "if", "(", "$", "base", "->", "lastPart", "===", "''", ")", "{", "array_pop", "(", "$", "base", "->", "parts", ")", ";", "}", "if", "(", "$", "add", "->", "firstPart", "===", "''", ")", "{", "array_shift", "(", "$", "add", "->", "parts", ")", ";", "}", "foreach", "(", "$", "add", "->", "parts", "as", "$", "part", ")", "{", "$", "base", "->", "parts", "[", "]", "=", "$", "part", ";", "}", "if", "(", "$", "add", "->", "partCount", "===", "0", ")", "{", "$", "base", "->", "parts", "[", "]", "=", "''", ";", "}", "$", "base", "->", "setParts", "(", "$", "base", "->", "parts", ")", ";", "return", "$", "base", ";", "}" ]
Adds a path to the current path and returns the new path object. Example: Resolving 'foo/bar' from the path '/dir' produces '/dir/foo/bar'. Noteworthy special cases: - If the path to resolve is absolute, this absolute path is returned and our current base is dropped. - If the path to resolve is empty, a slash is added to the current path if not already present. - We do not know if our path is a directory or not. Resolving 'dir' from '/file' results in '/file/dir'. @param string|Path $path @return static a new Path object
[ "Adds", "a", "path", "to", "the", "current", "path", "and", "returns", "the", "new", "path", "object", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L381-L413
238,275
firelit/firelit-framework
src/Router.php
Router.triggerError
public function triggerError($errorCode, $errorMessage = '') { $callError = $errorCode; if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) { if (isset($this->error[0]) && is_callable($this->error[0])) { $callError = 0; } else { // Nothing set to handle this error! return; } } // Error response function exists $this->match = true; //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage)); $this->error[$callError]($errorCode, $errorMessage); // Or use call_user_func_array ? exit($errorCode); }
php
public function triggerError($errorCode, $errorMessage = '') { $callError = $errorCode; if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) { if (isset($this->error[0]) && is_callable($this->error[0])) { $callError = 0; } else { // Nothing set to handle this error! return; } } // Error response function exists $this->match = true; //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage)); $this->error[$callError]($errorCode, $errorMessage); // Or use call_user_func_array ? exit($errorCode); }
[ "public", "function", "triggerError", "(", "$", "errorCode", ",", "$", "errorMessage", "=", "''", ")", "{", "$", "callError", "=", "$", "errorCode", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "error", "[", "$", "errorCode", "]", ")", "||", "!", "is_callable", "(", "$", "this", "->", "error", "[", "$", "errorCode", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "error", "[", "0", "]", ")", "&&", "is_callable", "(", "$", "this", "->", "error", "[", "0", "]", ")", ")", "{", "$", "callError", "=", "0", ";", "}", "else", "{", "// Nothing set to handle this error!", "return", ";", "}", "}", "// Error response function exists", "$", "this", "->", "match", "=", "true", ";", "//call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage));", "$", "this", "->", "error", "[", "$", "callError", "]", "(", "$", "errorCode", ",", "$", "errorMessage", ")", ";", "// Or use call_user_func_array ?", "exit", "(", "$", "errorCode", ")", ";", "}" ]
Trigger an error route based on the error code and exit script with that error code @param int $errorCode @param string $errorMessage @return void
[ "Trigger", "an", "error", "route", "based", "on", "the", "error", "code", "and", "exit", "script", "with", "that", "error", "code" ]
308639d40391dd82b45038e35d5e3589d2666886
https://github.com/firelit/firelit-framework/blob/308639d40391dd82b45038e35d5e3589d2666886/src/Router.php#L217-L238
238,276
0x20h/phloppy
src/Client/Producer.php
Producer.addJob
public function addJob($queue, Job $job, $maxlen = 0, $async = false) { $command = [ 'ADDJOB', $queue, $job->getBody(), $this->getReplicationTimeout(), 'REPLICATE', $this->getReplicationFactor(), 'DELAY', $job->getDelay(), 'RETRY', $job->getRetry(), 'TTL', $job->getTtL(), ]; if ($maxlen) { $command[] = 'MAXLEN'; $command[] = (int) $maxlen; } if ($async) { $command[] = 'ASYNC'; } $id = $this->send($command); $job->setId($id); $job->setQueue($queue); return $job; }
php
public function addJob($queue, Job $job, $maxlen = 0, $async = false) { $command = [ 'ADDJOB', $queue, $job->getBody(), $this->getReplicationTimeout(), 'REPLICATE', $this->getReplicationFactor(), 'DELAY', $job->getDelay(), 'RETRY', $job->getRetry(), 'TTL', $job->getTtL(), ]; if ($maxlen) { $command[] = 'MAXLEN'; $command[] = (int) $maxlen; } if ($async) { $command[] = 'ASYNC'; } $id = $this->send($command); $job->setId($id); $job->setQueue($queue); return $job; }
[ "public", "function", "addJob", "(", "$", "queue", ",", "Job", "$", "job", ",", "$", "maxlen", "=", "0", ",", "$", "async", "=", "false", ")", "{", "$", "command", "=", "[", "'ADDJOB'", ",", "$", "queue", ",", "$", "job", "->", "getBody", "(", ")", ",", "$", "this", "->", "getReplicationTimeout", "(", ")", ",", "'REPLICATE'", ",", "$", "this", "->", "getReplicationFactor", "(", ")", ",", "'DELAY'", ",", "$", "job", "->", "getDelay", "(", ")", ",", "'RETRY'", ",", "$", "job", "->", "getRetry", "(", ")", ",", "'TTL'", ",", "$", "job", "->", "getTtL", "(", ")", ",", "]", ";", "if", "(", "$", "maxlen", ")", "{", "$", "command", "[", "]", "=", "'MAXLEN'", ";", "$", "command", "[", "]", "=", "(", "int", ")", "$", "maxlen", ";", "}", "if", "(", "$", "async", ")", "{", "$", "command", "[", "]", "=", "'ASYNC'", ";", "}", "$", "id", "=", "$", "this", "->", "send", "(", "$", "command", ")", ";", "$", "job", "->", "setId", "(", "$", "id", ")", ";", "$", "job", "->", "setQueue", "(", "$", "queue", ")", ";", "return", "$", "job", ";", "}" ]
Enqueue the given job. @param string $queue @param Job $job @param int $maxlen specifies that if there are already count messages queued for the specified queue name, the message is refused and an error reported to the client. @oaram bool $async asks the server to let the command return ASAP and replicate the job to other nodes in the background. The job gets queued ASAP, while normally the job is put into the queue only when the client gets a positive reply. @return Job The updated job (e.g. ID set).
[ "Enqueue", "the", "given", "job", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Client/Producer.php#L39-L65
238,277
GrupaZero/core
src/Gzero/Core/Http/Controllers/Api/FileController.php
FileController.show
public function show($id) { $file = $this->repository->getById($id); if (!$file) { return $this->errorNotFound(); } $this->authorize('read', $file); return new FileResource($file); }
php
public function show($id) { $file = $this->repository->getById($id); if (!$file) { return $this->errorNotFound(); } $this->authorize('read', $file); return new FileResource($file); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "file", "=", "$", "this", "->", "repository", "->", "getById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "file", ")", "{", "return", "$", "this", "->", "errorNotFound", "(", ")", ";", "}", "$", "this", "->", "authorize", "(", "'read'", ",", "$", "file", ")", ";", "return", "new", "FileResource", "(", "$", "file", ")", ";", "}" ]
Display a specified file. @SWG\Get( path="/files/{id}", tags={"files"}, summary="Returns a specific file by id", description="Returns a specific file by id", produces={"application/json"}, security={{"AdminAccess": {}}}, @SWG\Parameter( name="id", in="path", description="Id of file that needs to be returned.", required=true, type="integer" ), @SWG\Response( response=200, description="Successful operation", @SWG\Schema(type="object", ref="#/definitions/File"), ), @SWG\Response(response=404, description="File not found") ) @param int $id content Id @return FileResource
[ "Display", "a", "specified", "file", "." ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/FileController.php#L204-L214
238,278
HeroicTeam/m
Html/Table.php
Table.setHeading
public function setHeading($column) { $columns = is_array($column) ? $column : func_get_args(); $this->_head = array_values($columns); return $this; }
php
public function setHeading($column) { $columns = is_array($column) ? $column : func_get_args(); $this->_head = array_values($columns); return $this; }
[ "public", "function", "setHeading", "(", "$", "column", ")", "{", "$", "columns", "=", "is_array", "(", "$", "column", ")", "?", "$", "column", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "_head", "=", "array_values", "(", "$", "columns", ")", ";", "return", "$", "this", ";", "}" ]
Set the columns for the table heading. @param string|array $column @return \m\Html\Table
[ "Set", "the", "columns", "for", "the", "table", "heading", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L30-L37
238,279
HeroicTeam/m
Html/Table.php
Table.setRow
public function setRow($column) { $columns = is_array($column) ? $column : func_get_args(); // If this is a sequential array if (array_keys($columns) === range(0, count($columns) - 1)) { $assocArray = array(); for($i=0;$i<count($this->_head);$i++) { $assocArray[$this->_head[$i]] = isset($columns[$i]) ? $columns[$i] : ''; } $columns = $assocArray; } $this->_rows[] = $columns; return $this; }
php
public function setRow($column) { $columns = is_array($column) ? $column : func_get_args(); // If this is a sequential array if (array_keys($columns) === range(0, count($columns) - 1)) { $assocArray = array(); for($i=0;$i<count($this->_head);$i++) { $assocArray[$this->_head[$i]] = isset($columns[$i]) ? $columns[$i] : ''; } $columns = $assocArray; } $this->_rows[] = $columns; return $this; }
[ "public", "function", "setRow", "(", "$", "column", ")", "{", "$", "columns", "=", "is_array", "(", "$", "column", ")", "?", "$", "column", ":", "func_get_args", "(", ")", ";", "// If this is a sequential array", "if", "(", "array_keys", "(", "$", "columns", ")", "===", "range", "(", "0", ",", "count", "(", "$", "columns", ")", "-", "1", ")", ")", "{", "$", "assocArray", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "_head", ")", ";", "$", "i", "++", ")", "{", "$", "assocArray", "[", "$", "this", "->", "_head", "[", "$", "i", "]", "]", "=", "isset", "(", "$", "columns", "[", "$", "i", "]", ")", "?", "$", "columns", "[", "$", "i", "]", ":", "''", ";", "}", "$", "columns", "=", "$", "assocArray", ";", "}", "$", "this", "->", "_rows", "[", "]", "=", "$", "columns", ";", "return", "$", "this", ";", "}" ]
Sets the colums for a table row. @param string|array $column @return \m\Html\Table
[ "Sets", "the", "colums", "for", "a", "table", "row", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L55-L75
238,280
HeroicTeam/m
Html/Table.php
Table.setRows
public function setRows(array $rows) { if (isset($rows['_head'])) { $this->setHeading($rows['_head']); unset($rows['_head']); } if (!empty($rows)) { foreach($rows as $row) { $this->setRow($row); } } return $this; }
php
public function setRows(array $rows) { if (isset($rows['_head'])) { $this->setHeading($rows['_head']); unset($rows['_head']); } if (!empty($rows)) { foreach($rows as $row) { $this->setRow($row); } } return $this; }
[ "public", "function", "setRows", "(", "array", "$", "rows", ")", "{", "if", "(", "isset", "(", "$", "rows", "[", "'_head'", "]", ")", ")", "{", "$", "this", "->", "setHeading", "(", "$", "rows", "[", "'_head'", "]", ")", ";", "unset", "(", "$", "rows", "[", "'_head'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "rows", ")", ")", "{", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "this", "->", "setRow", "(", "$", "row", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set several rows at once. You can also set the heading by providing an array item with the key of "_head". @param array $rows @return \m\Html\Table
[ "Set", "several", "rows", "at", "once", ".", "You", "can", "also", "set", "the", "heading", "by", "providing", "an", "array", "item", "with", "the", "key", "of", "_head", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L96-L110
238,281
HeroicTeam/m
Html/Table.php
Table.render
public function render() { // Render the table container $output = "<table {$this->renderAttributes()} >\n\t<tbody>\n"; // Render the heading $output .= "\t\t<th>\n"; foreach ($this->_head as $heading) { $output .= "\t\t\t<td>{$heading}</td>\n"; } $output .= "\t\t</th>\n"; // Render the rows foreach($this->_rows as $row) { $output .= "\t\t<tr>\n"; foreach($this->_head as $columnName) { $column = $row[$columnName]; switch(gettype($column)) { case 'array': $column = print_r($column, true); break; case 'object': $column = (method_exists($column, 'render')) ? $column->render() : 'Object'; break; case 'boolean': $column = $column ? 'True' : 'False'; break; case 'unknown type': case 'resource': case 'NULL': $column = 'NULL'; default: break; } $output .= "\t\t\t<td>{$column}</td>\n"; } $output .= "\t\t</tr>\n"; } $output .= "\t</tbody>\n</table>"; return $output; }
php
public function render() { // Render the table container $output = "<table {$this->renderAttributes()} >\n\t<tbody>\n"; // Render the heading $output .= "\t\t<th>\n"; foreach ($this->_head as $heading) { $output .= "\t\t\t<td>{$heading}</td>\n"; } $output .= "\t\t</th>\n"; // Render the rows foreach($this->_rows as $row) { $output .= "\t\t<tr>\n"; foreach($this->_head as $columnName) { $column = $row[$columnName]; switch(gettype($column)) { case 'array': $column = print_r($column, true); break; case 'object': $column = (method_exists($column, 'render')) ? $column->render() : 'Object'; break; case 'boolean': $column = $column ? 'True' : 'False'; break; case 'unknown type': case 'resource': case 'NULL': $column = 'NULL'; default: break; } $output .= "\t\t\t<td>{$column}</td>\n"; } $output .= "\t\t</tr>\n"; } $output .= "\t</tbody>\n</table>"; return $output; }
[ "public", "function", "render", "(", ")", "{", "// Render the table container", "$", "output", "=", "\"<table {$this->renderAttributes()} >\\n\\t<tbody>\\n\"", ";", "// Render the heading", "$", "output", ".=", "\"\\t\\t<th>\\n\"", ";", "foreach", "(", "$", "this", "->", "_head", "as", "$", "heading", ")", "{", "$", "output", ".=", "\"\\t\\t\\t<td>{$heading}</td>\\n\"", ";", "}", "$", "output", ".=", "\"\\t\\t</th>\\n\"", ";", "// Render the rows", "foreach", "(", "$", "this", "->", "_rows", "as", "$", "row", ")", "{", "$", "output", ".=", "\"\\t\\t<tr>\\n\"", ";", "foreach", "(", "$", "this", "->", "_head", "as", "$", "columnName", ")", "{", "$", "column", "=", "$", "row", "[", "$", "columnName", "]", ";", "switch", "(", "gettype", "(", "$", "column", ")", ")", "{", "case", "'array'", ":", "$", "column", "=", "print_r", "(", "$", "column", ",", "true", ")", ";", "break", ";", "case", "'object'", ":", "$", "column", "=", "(", "method_exists", "(", "$", "column", ",", "'render'", ")", ")", "?", "$", "column", "->", "render", "(", ")", ":", "'Object'", ";", "break", ";", "case", "'boolean'", ":", "$", "column", "=", "$", "column", "?", "'True'", ":", "'False'", ";", "break", ";", "case", "'unknown type'", ":", "case", "'resource'", ":", "case", "'NULL'", ":", "$", "column", "=", "'NULL'", ";", "default", ":", "break", ";", "}", "$", "output", ".=", "\"\\t\\t\\t<td>{$column}</td>\\n\"", ";", "}", "$", "output", ".=", "\"\\t\\t</tr>\\n\"", ";", "}", "$", "output", ".=", "\"\\t</tbody>\\n</table>\"", ";", "return", "$", "output", ";", "}" ]
Renders the table and returns it as a string. @return string
[ "Renders", "the", "table", "and", "returns", "it", "as", "a", "string", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L162-L224
238,282
WellCommerce/Form
Elements/AbstractNode.php
AbstractNode.getElementType
protected function getElementType() { $class = $this->getElementClass($this); $parts = explode('\\', $class); $type = end($parts); $replace = '$1_$2'; return ctype_lower($type) ? $type : strtolower(preg_replace('/(.)([A-Z])/', $replace, $type)); }
php
protected function getElementType() { $class = $this->getElementClass($this); $parts = explode('\\', $class); $type = end($parts); $replace = '$1_$2'; return ctype_lower($type) ? $type : strtolower(preg_replace('/(.)([A-Z])/', $replace, $type)); }
[ "protected", "function", "getElementType", "(", ")", "{", "$", "class", "=", "$", "this", "->", "getElementClass", "(", "$", "this", ")", ";", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "class", ")", ";", "$", "type", "=", "end", "(", "$", "parts", ")", ";", "$", "replace", "=", "'$1_$2'", ";", "return", "ctype_lower", "(", "$", "type", ")", "?", "$", "type", ":", "strtolower", "(", "preg_replace", "(", "'/(.)([A-Z])/'", ",", "$", "replace", ",", "$", "type", ")", ")", ";", "}" ]
Returns friendly element type used for example in Twig macros @return mixed|string
[ "Returns", "friendly", "element", "type", "used", "for", "example", "in", "Twig", "macros" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/AbstractNode.php#L183-L191
238,283
WellCommerce/Form
Elements/AbstractNode.php
AbstractNode.getJavascriptNodeName
protected function getJavascriptNodeName(ElementInterface $element) { $class = $this->getElementClass($element); $parts = explode('\\', $class); return 'GForm' . end($parts); }
php
protected function getJavascriptNodeName(ElementInterface $element) { $class = $this->getElementClass($element); $parts = explode('\\', $class); return 'GForm' . end($parts); }
[ "protected", "function", "getJavascriptNodeName", "(", "ElementInterface", "$", "element", ")", "{", "$", "class", "=", "$", "this", "->", "getElementClass", "(", "$", "element", ")", ";", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "class", ")", ";", "return", "'GForm'", ".", "end", "(", "$", "parts", ")", ";", "}" ]
Returns element javascript-friendly name @param ElementInterface $element @return string
[ "Returns", "element", "javascript", "-", "friendly", "name" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/AbstractNode.php#L223-L229
238,284
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.define
public static function define($section, \Closure $closure) { $config = call_user_func($closure, self::getInstance()); if (! is_array($config)) { throw new \Exception("You should return an array in the Configuration::define closure!"); } self::getInstance()->add($section, $config); }
php
public static function define($section, \Closure $closure) { $config = call_user_func($closure, self::getInstance()); if (! is_array($config)) { throw new \Exception("You should return an array in the Configuration::define closure!"); } self::getInstance()->add($section, $config); }
[ "public", "static", "function", "define", "(", "$", "section", ",", "\\", "Closure", "$", "closure", ")", "{", "$", "config", "=", "call_user_func", "(", "$", "closure", ",", "self", "::", "getInstance", "(", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"You should return an array in the Configuration::define closure!\"", ")", ";", "}", "self", "::", "getInstance", "(", ")", "->", "add", "(", "$", "section", ",", "$", "config", ")", ";", "}" ]
Define multiple configuration keys and values in a closure. @param string $section Section to define. @param \Closure $closure Function (inline) that will return the values. @throws \Exception
[ "Define", "multiple", "configuration", "keys", "and", "values", "in", "a", "closure", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L57-L65
238,285
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.getSection
public function getSection($section, $default = -1) { // Return if section is defined. if (isset($this->config[$section])) { return $this->config[$section]; } if ($default !== -1) { return $default; } // Find the default value (in default configuration definitions). $defaultClass = new \ReflectionClass(DefaultConfiguration::class); return $defaultClass->getStaticPropertyValue($section, null); }
php
public function getSection($section, $default = -1) { // Return if section is defined. if (isset($this->config[$section])) { return $this->config[$section]; } if ($default !== -1) { return $default; } // Find the default value (in default configuration definitions). $defaultClass = new \ReflectionClass(DefaultConfiguration::class); return $defaultClass->getStaticPropertyValue($section, null); }
[ "public", "function", "getSection", "(", "$", "section", ",", "$", "default", "=", "-", "1", ")", "{", "// Return if section is defined.", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", ")", "{", "return", "$", "this", "->", "config", "[", "$", "section", "]", ";", "}", "if", "(", "$", "default", "!==", "-", "1", ")", "{", "return", "$", "default", ";", "}", "// Find the default value (in default configuration definitions).", "$", "defaultClass", "=", "new", "\\", "ReflectionClass", "(", "DefaultConfiguration", "::", "class", ")", ";", "return", "$", "defaultClass", "->", "getStaticPropertyValue", "(", "$", "section", ",", "null", ")", ";", "}" ]
Get the whole set of the configuration section. @param string $section section name. @param mixed $default default value when undefined. Leave undefined to use the build-in defined defaults for the section. @return mixed @codeCoverageIgnore ignore due to a coverage bug.
[ "Get", "the", "whole", "set", "of", "the", "configuration", "section", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L133-L147
238,286
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.add
public function add($section, $config = array()) { if (! isset($this->config[$section])) { $this->config[$section] = array(); } $this->config[$section] = array_merge($this->config[$section], $config); }
php
public function add($section, $config = array()) { if (! isset($this->config[$section])) { $this->config[$section] = array(); } $this->config[$section] = array_merge($this->config[$section], $config); }
[ "public", "function", "add", "(", "$", "section", ",", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", ")", "{", "$", "this", "->", "config", "[", "$", "section", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "config", "[", "$", "section", "]", "=", "array_merge", "(", "$", "this", "->", "config", "[", "$", "section", "]", ",", "$", "config", ")", ";", "}" ]
Add section data to the configuration. @param string $section @param array $config
[ "Add", "section", "data", "to", "the", "configuration", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L155-L162
238,287
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.doGetSection
private function doGetSection($section) { return isset($this->config[$section]) ? $this->config[$section] : null; }
php
private function doGetSection($section) { return isset($this->config[$section]) ? $this->config[$section] : null; }
[ "private", "function", "doGetSection", "(", "$", "section", ")", "{", "return", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", "?", "$", "this", "->", "config", "[", "$", "section", "]", ":", "null", ";", "}" ]
Get section configuration data. @deprecated Since 1.2.0. Will be removed in 2.0.0. @param string $section @return array|null @codeCoverageIgnore
[ "Get", "section", "configuration", "data", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L184-L187
238,288
mvccore/ext-router-extended
src/MvcCore/Ext/Routers/Extendeds/Preparing.php
Preparing.prepare
protected function prepare () { $request = & $this->request; // store original path value for later use $request->SetOriginalPath($request->GetPath(TRUE)); // switching media site version and targeting localized version // will be only by GET method, other methods are not very useful // to localize or target for media site version. It adds only another // not much useful route records to route processing: $this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET; // look into request params if there is any switching // parameter for session strict mode $this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET` // Set up session object to look inside for something from previous requests. // This command starts the session if not started yet. $this->setUpSession(); // Try to recognize administration request by `admin` param in query string // and by any authenticated user. The boolean flag `$this->adminRequest` // is used only to not process strict session mode redirections and to serve // requested documents directly, so there is not necessary to check if user // has any privileges or not, because this is only router. if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) { $authClass = static::$baseAuthClass; if (class_exists($authClass)) { $user = $authClass::GetInstance()->GetUser(); if ($user !== NULL) $this->adminRequest = TRUE; } } }
php
protected function prepare () { $request = & $this->request; // store original path value for later use $request->SetOriginalPath($request->GetPath(TRUE)); // switching media site version and targeting localized version // will be only by GET method, other methods are not very useful // to localize or target for media site version. It adds only another // not much useful route records to route processing: $this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET; // look into request params if there is any switching // parameter for session strict mode $this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET` // Set up session object to look inside for something from previous requests. // This command starts the session if not started yet. $this->setUpSession(); // Try to recognize administration request by `admin` param in query string // and by any authenticated user. The boolean flag `$this->adminRequest` // is used only to not process strict session mode redirections and to serve // requested documents directly, so there is not necessary to check if user // has any privileges or not, because this is only router. if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) { $authClass = static::$baseAuthClass; if (class_exists($authClass)) { $user = $authClass::GetInstance()->GetUser(); if ($user !== NULL) $this->adminRequest = TRUE; } } }
[ "protected", "function", "prepare", "(", ")", "{", "$", "request", "=", "&", "$", "this", "->", "request", ";", "// store original path value for later use", "$", "request", "->", "SetOriginalPath", "(", "$", "request", "->", "GetPath", "(", "TRUE", ")", ")", ";", "// switching media site version and targeting localized version ", "// will be only by GET method, other methods are not very useful ", "// to localize or target for media site version. It adds only another", "// not much useful route records to route processing:", "$", "this", "->", "isGet", "=", "$", "request", "->", "GetMethod", "(", ")", "==", "\\", "MvcCore", "\\", "IRequest", "::", "METHOD_GET", ";", "// look into request params if there is any switching ", "// parameter for session strict mode", "$", "this", "->", "requestGlobalGet", "=", "array_merge", "(", "[", "]", ",", "$", "request", "->", "GetGlobalCollection", "(", "'get'", ")", ")", ";", "// clone `$_GET`", "// Set up session object to look inside for something from previous requests. ", "// This command starts the session if not started yet.", "$", "this", "->", "setUpSession", "(", ")", ";", "// Try to recognize administration request by `admin` param in query string", "// and by any authenticated user. The boolean flag `$this->adminRequest`", "// is used only to not process strict session mode redirections and to serve", "// requested documents directly, so there is not necessary to check if user", "// has any privileges or not, because this is only router.", "if", "(", "isset", "(", "$", "this", "->", "requestGlobalGet", "[", "static", "::", "$", "adminRequestQueryParamName", "]", ")", ")", "{", "$", "authClass", "=", "static", "::", "$", "baseAuthClass", ";", "if", "(", "class_exists", "(", "$", "authClass", ")", ")", "{", "$", "user", "=", "$", "authClass", "::", "GetInstance", "(", ")", "->", "GetUser", "(", ")", ";", "if", "(", "$", "user", "!==", "NULL", ")", "$", "this", "->", "adminRequest", "=", "TRUE", ";", "}", "}", "}" ]
Prepare extended router media site version or localization processing. @return void
[ "Prepare", "extended", "router", "media", "site", "version", "or", "localization", "processing", "." ]
39f95c1242509edae3b973db70364d7cdc61f2f5
https://github.com/mvccore/ext-router-extended/blob/39f95c1242509edae3b973db70364d7cdc61f2f5/src/MvcCore/Ext/Routers/Extendeds/Preparing.php#L31-L64
238,289
mvccore/ext-router-extended
src/MvcCore/Ext/Routers/Extendeds/Preparing.php
Preparing.setUpSession
protected function setUpSession () { if ($this->session === NULL) { $sessionClass = $this->application->GetSessionClass(); $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; $this->session = $sessionClass::GetNamespace($selfClass); $this->session->SetExpirationSeconds($this->sessionExpirationSeconds); } }
php
protected function setUpSession () { if ($this->session === NULL) { $sessionClass = $this->application->GetSessionClass(); $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; $this->session = $sessionClass::GetNamespace($selfClass); $this->session->SetExpirationSeconds($this->sessionExpirationSeconds); } }
[ "protected", "function", "setUpSession", "(", ")", "{", "if", "(", "$", "this", "->", "session", "===", "NULL", ")", "{", "$", "sessionClass", "=", "$", "this", "->", "application", "->", "GetSessionClass", "(", ")", ";", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "$", "this", "->", "session", "=", "$", "sessionClass", "::", "GetNamespace", "(", "$", "selfClass", ")", ";", "$", "this", "->", "session", "->", "SetExpirationSeconds", "(", "$", "this", "->", "sessionExpirationSeconds", ")", ";", "}", "}" ]
If session namespace by this class is not initialized, initialize session namespace under this class name and move expiration to configured value. @return void
[ "If", "session", "namespace", "by", "this", "class", "is", "not", "initialized", "initialize", "session", "namespace", "under", "this", "class", "name", "and", "move", "expiration", "to", "configured", "value", "." ]
39f95c1242509edae3b973db70364d7cdc61f2f5
https://github.com/mvccore/ext-router-extended/blob/39f95c1242509edae3b973db70364d7cdc61f2f5/src/MvcCore/Ext/Routers/Extendeds/Preparing.php#L72-L79
238,290
Innmind/neo4j-onm
src/RepositoryFactory.php
RepositoryFactory.register
private function register( Entity $meta, Repository $repository ): self { $this->repositories = $this->repositories->put( $meta, $repository ); return $this; }
php
private function register( Entity $meta, Repository $repository ): self { $this->repositories = $this->repositories->put( $meta, $repository ); return $this; }
[ "private", "function", "register", "(", "Entity", "$", "meta", ",", "Repository", "$", "repository", ")", ":", "self", "{", "$", "this", "->", "repositories", "=", "$", "this", "->", "repositories", "->", "put", "(", "$", "meta", ",", "$", "repository", ")", ";", "return", "$", "this", ";", "}" ]
Register a new repository instance To be used in case the repository can't be instanciated automatically
[ "Register", "a", "new", "repository", "instance" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/RepositoryFactory.php#L74-L84
238,291
popy-dev/popy-calendar
src/Parser/SymbolParser/Chain.php
Chain.addParser
public function addParser(SymbolParserInterface $parser) { if ($parser instanceof self) { // Reducing recursivity $this->addParsers($parser->parsers); } else { $this->parsers[] = $parser; } return $this; }
php
public function addParser(SymbolParserInterface $parser) { if ($parser instanceof self) { // Reducing recursivity $this->addParsers($parser->parsers); } else { $this->parsers[] = $parser; } return $this; }
[ "public", "function", "addParser", "(", "SymbolParserInterface", "$", "parser", ")", "{", "if", "(", "$", "parser", "instanceof", "self", ")", "{", "// Reducing recursivity", "$", "this", "->", "addParsers", "(", "$", "parser", "->", "parsers", ")", ";", "}", "else", "{", "$", "this", "->", "parsers", "[", "]", "=", "$", "parser", ";", "}", "return", "$", "this", ";", "}" ]
Adds a Parser to the chain. @param SymbolParserInterface $parser
[ "Adds", "a", "Parser", "to", "the", "chain", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/SymbolParser/Chain.php#L40-L50
238,292
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session.set
public static function set($var, $value) { // var_dump($var." ".$value); Session::init(true); if (!Session::check_checksum()) return false; $_SESSION[$var] = $value; $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return $value; }
php
public static function set($var, $value) { // var_dump($var." ".$value); Session::init(true); if (!Session::check_checksum()) return false; $_SESSION[$var] = $value; $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return $value; }
[ "public", "static", "function", "set", "(", "$", "var", ",", "$", "value", ")", "{", "// \tvar_dump($var.\" \".$value);", "Session", "::", "init", "(", "true", ")", ";", "if", "(", "!", "Session", "::", "check_checksum", "(", ")", ")", "return", "false", ";", "$", "_SESSION", "[", "$", "var", "]", "=", "$", "value", ";", "$", "_SESSION", "[", "__SESSION_checksum_var", "]", "=", "Session", "::", "make_checksum", "(", ")", ";", "return", "$", "value", ";", "}" ]
Nastavi session premennu @param string $var @param string $value
[ "Nastavi", "session", "premennu" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L191-L198
238,293
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session._unset
public static function _unset($var) { Session::init(true); if (!Session::check_checksum()) return false; unset($_SESSION[$var]); $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return true; }
php
public static function _unset($var) { Session::init(true); if (!Session::check_checksum()) return false; unset($_SESSION[$var]); $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return true; }
[ "public", "static", "function", "_unset", "(", "$", "var", ")", "{", "Session", "::", "init", "(", "true", ")", ";", "if", "(", "!", "Session", "::", "check_checksum", "(", ")", ")", "return", "false", ";", "unset", "(", "$", "_SESSION", "[", "$", "var", "]", ")", ";", "$", "_SESSION", "[", "__SESSION_checksum_var", "]", "=", "Session", "::", "make_checksum", "(", ")", ";", "return", "true", ";", "}" ]
Odstrani session premennu @param unknown_type $var @return unknown
[ "Odstrani", "session", "premennu" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L205-L211
238,294
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session.make_checksum
private static function make_checksum() { $ret = ""; $_SESSION[__SESSION_time_var] = \AsyncWeb\Date\Time::get(); if (isset($_SESSION) && is_array($_SESSION)) foreach ($_SESSION as $s => $v) { if ($s != __SESSION_checksum_var) { $ret = md5($ret . $s); } } Session::$checksum = $ret; return $ret; }
php
private static function make_checksum() { $ret = ""; $_SESSION[__SESSION_time_var] = \AsyncWeb\Date\Time::get(); if (isset($_SESSION) && is_array($_SESSION)) foreach ($_SESSION as $s => $v) { if ($s != __SESSION_checksum_var) { $ret = md5($ret . $s); } } Session::$checksum = $ret; return $ret; }
[ "private", "static", "function", "make_checksum", "(", ")", "{", "$", "ret", "=", "\"\"", ";", "$", "_SESSION", "[", "__SESSION_time_var", "]", "=", "\\", "AsyncWeb", "\\", "Date", "\\", "Time", "::", "get", "(", ")", ";", "if", "(", "isset", "(", "$", "_SESSION", ")", "&&", "is_array", "(", "$", "_SESSION", ")", ")", "foreach", "(", "$", "_SESSION", "as", "$", "s", "=>", "$", "v", ")", "{", "if", "(", "$", "s", "!=", "__SESSION_checksum_var", ")", "{", "$", "ret", "=", "md5", "(", "$", "ret", ".", "$", "s", ")", ";", "}", "}", "Session", "::", "$", "checksum", "=", "$", "ret", ";", "return", "$", "ret", ";", "}" ]
Vytvori md5 session checksum @return string32 session checksum
[ "Vytvori", "md5", "session", "checksum" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L251-L261
238,295
mszewcz/php-light-framework
src/Validator/Specific/Isbn.php
Isbn.validateIsbn10
private function validateIsbn10(): bool { $value = \str_replace(['-', ' '], '', $this->value); if (!\preg_match($this->patterns['isbn10-basic'], $value)) { $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; } $sum = 0; for ($i = 0; $i < 9; $i++) { $sum += (10 - $i) * $value{$i}; } $checksum = 11 - ($sum % 11); if ($checksum == 11) { $checksum = '0'; } elseif ($checksum == 10) { $checksum = 'X'; } $isValid = \substr($value, -1) == $checksum ? true : false; if (!$isValid) { $this->setError(self::VALIDATOR_ERROR_ISBN_INVALID_NUMBER); } return $isValid; }
php
private function validateIsbn10(): bool { $value = \str_replace(['-', ' '], '', $this->value); if (!\preg_match($this->patterns['isbn10-basic'], $value)) { $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; } $sum = 0; for ($i = 0; $i < 9; $i++) { $sum += (10 - $i) * $value{$i}; } $checksum = 11 - ($sum % 11); if ($checksum == 11) { $checksum = '0'; } elseif ($checksum == 10) { $checksum = 'X'; } $isValid = \substr($value, -1) == $checksum ? true : false; if (!$isValid) { $this->setError(self::VALIDATOR_ERROR_ISBN_INVALID_NUMBER); } return $isValid; }
[ "private", "function", "validateIsbn10", "(", ")", ":", "bool", "{", "$", "value", "=", "\\", "str_replace", "(", "[", "'-'", ",", "' '", "]", ",", "''", ",", "$", "this", "->", "value", ")", ";", "if", "(", "!", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn10-basic'", "]", ",", "$", "value", ")", ")", "{", "$", "this", "->", "setError", "(", "self", "::", "VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT", ")", ";", "return", "false", ";", "}", "$", "sum", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "9", ";", "$", "i", "++", ")", "{", "$", "sum", "+=", "(", "10", "-", "$", "i", ")", "*", "$", "value", "{", "$", "i", "}", ";", "}", "$", "checksum", "=", "11", "-", "(", "$", "sum", "%", "11", ")", ";", "if", "(", "$", "checksum", "==", "11", ")", "{", "$", "checksum", "=", "'0'", ";", "}", "elseif", "(", "$", "checksum", "==", "10", ")", "{", "$", "checksum", "=", "'X'", ";", "}", "$", "isValid", "=", "\\", "substr", "(", "$", "value", ",", "-", "1", ")", "==", "$", "checksum", "?", "true", ":", "false", ";", "if", "(", "!", "$", "isValid", ")", "{", "$", "this", "->", "setError", "(", "self", "::", "VALIDATOR_ERROR_ISBN_INVALID_NUMBER", ")", ";", "}", "return", "$", "isValid", ";", "}" ]
Validates ISBN-10 number @return bool
[ "Validates", "ISBN", "-", "10", "number" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Isbn.php#L49-L73
238,296
mszewcz/php-light-framework
src/Validator/Specific/Isbn.php
Isbn.validateAuto
private function validateAuto(): bool { if (\preg_match($this->patterns['isbn13-basic'], $this->value)) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn13-separated'], $this->value) && \strlen($this->value) == 17) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn10-basic'], $this->value)) { return $this->validateIsbn10(); } if (\preg_match($this->patterns['isbn10-separated'], $this->value) && \strlen($this->value) == 13) { return $this->validateIsbn10(); } $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; }
php
private function validateAuto(): bool { if (\preg_match($this->patterns['isbn13-basic'], $this->value)) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn13-separated'], $this->value) && \strlen($this->value) == 17) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn10-basic'], $this->value)) { return $this->validateIsbn10(); } if (\preg_match($this->patterns['isbn10-separated'], $this->value) && \strlen($this->value) == 13) { return $this->validateIsbn10(); } $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; }
[ "private", "function", "validateAuto", "(", ")", ":", "bool", "{", "if", "(", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn13-basic'", "]", ",", "$", "this", "->", "value", ")", ")", "{", "return", "$", "this", "->", "validateIsbn13", "(", ")", ";", "}", "if", "(", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn13-separated'", "]", ",", "$", "this", "->", "value", ")", "&&", "\\", "strlen", "(", "$", "this", "->", "value", ")", "==", "17", ")", "{", "return", "$", "this", "->", "validateIsbn13", "(", ")", ";", "}", "if", "(", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn10-basic'", "]", ",", "$", "this", "->", "value", ")", ")", "{", "return", "$", "this", "->", "validateIsbn10", "(", ")", ";", "}", "if", "(", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn10-separated'", "]", ",", "$", "this", "->", "value", ")", "&&", "\\", "strlen", "(", "$", "this", "->", "value", ")", "==", "13", ")", "{", "return", "$", "this", "->", "validateIsbn10", "(", ")", ";", "}", "$", "this", "->", "setError", "(", "self", "::", "VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT", ")", ";", "return", "false", ";", "}" ]
Validates ISBN number with auto format detection @return bool
[ "Validates", "ISBN", "number", "with", "auto", "format", "detection" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Isbn.php#L106-L123
238,297
jaeger-app/exceptions
src/Exception.php
Exception.logException
public function logException(\Exception $e) { $error = $e->getMessage() . $e->getTraceAsString(); return $this->logEmergency($error); }
php
public function logException(\Exception $e) { $error = $e->getMessage() . $e->getTraceAsString(); return $this->logEmergency($error); }
[ "public", "function", "logException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "$", "e", "->", "getMessage", "(", ")", ".", "$", "e", "->", "getTraceAsString", "(", ")", ";", "return", "$", "this", "->", "logEmergency", "(", "$", "error", ")", ";", "}" ]
Logs an exeption @param \Exception $e @return bool
[ "Logs", "an", "exeption" ]
38ae3f1db547a311ccb306bb2c1ffc43d33890bf
https://github.com/jaeger-app/exceptions/blob/38ae3f1db547a311ccb306bb2c1ffc43d33890bf/src/Exception.php#L33-L37
238,298
marando/phpSOFA
src/Marando/IAU/iauUtcut1.php
iauUtcut1.Utcut1
public static function Utcut1($utc1, $utc2, $dut1, &$ut11, &$ut12) { $iy; $im; $id; $js; $jw; $w; $dat; $dta; $tai1; $tai2; /* Look up TAI-UTC. */ if (IAU::Jd2cal($utc1, $utc2, $iy, $im, $id, $w)) return -1; $js = IAU::Dat($iy, $im, $id, 0.0, $dat); if ($js < 0) return -1; /* Form UT1-TAI. */ $dta = $dut1 - $dat; /* UTC to TAI to UT1. */ $jw = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($jw < 0) { return -1; } else if ($jw > 0) { $js = $jw; } if (IAU::Taiut1($tai1, $tai2, $dta, $ut11, $ut12)) return -1; /* Status. */ return $js; }
php
public static function Utcut1($utc1, $utc2, $dut1, &$ut11, &$ut12) { $iy; $im; $id; $js; $jw; $w; $dat; $dta; $tai1; $tai2; /* Look up TAI-UTC. */ if (IAU::Jd2cal($utc1, $utc2, $iy, $im, $id, $w)) return -1; $js = IAU::Dat($iy, $im, $id, 0.0, $dat); if ($js < 0) return -1; /* Form UT1-TAI. */ $dta = $dut1 - $dat; /* UTC to TAI to UT1. */ $jw = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($jw < 0) { return -1; } else if ($jw > 0) { $js = $jw; } if (IAU::Taiut1($tai1, $tai2, $dta, $ut11, $ut12)) return -1; /* Status. */ return $js; }
[ "public", "static", "function", "Utcut1", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "dut1", ",", "&", "$", "ut11", ",", "&", "$", "ut12", ")", "{", "$", "iy", ";", "$", "im", ";", "$", "id", ";", "$", "js", ";", "$", "jw", ";", "$", "w", ";", "$", "dat", ";", "$", "dta", ";", "$", "tai1", ";", "$", "tai2", ";", "/* Look up TAI-UTC. */", "if", "(", "IAU", "::", "Jd2cal", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "$", "w", ")", ")", "return", "-", "1", ";", "$", "js", "=", "IAU", "::", "Dat", "(", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "0.0", ",", "$", "dat", ")", ";", "if", "(", "$", "js", "<", "0", ")", "return", "-", "1", ";", "/* Form UT1-TAI. */", "$", "dta", "=", "$", "dut1", "-", "$", "dat", ";", "/* UTC to TAI to UT1. */", "$", "jw", "=", "IAU", "::", "Utctai", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "tai1", ",", "$", "tai2", ")", ";", "if", "(", "$", "jw", "<", "0", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "$", "jw", ">", "0", ")", "{", "$", "js", "=", "$", "jw", ";", "}", "if", "(", "IAU", "::", "Taiut1", "(", "$", "tai1", ",", "$", "tai2", ",", "$", "dta", ",", "$", "ut11", ",", "$", "ut12", ")", ")", "return", "-", "1", ";", "/* Status. */", "return", "$", "js", ";", "}" ]
- - - - - - - - - - i a u U t c u t 1 - - - - - - - - - - Time scale transformation: Coordinated Universal Time, UTC, to Universal Time, UT1. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical. Given: utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4) dut1 double Delta UT1 = UT1-UTC in seconds (Note 5) Returned: ut11,ut12 double UT1 as a 2-part Julian Date (Note 6) Returned (function value): int status: +1 = dubious year (Note 3) 0 = OK -1 = unacceptable date Notes: 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any convenient way between the two arguments, for example where utc1 is the Julian Day Number and utc2 is the fraction of a day. 2) JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds. 3) The warning status "dubious year" flags UTCs that predate the introduction of the time scale or that are too far in the future to be trusted. See iauDat for further details. 4) The function iauDtf2d converts from calendar date and time of day into 2-part Julian Date, and in the case of UTC implements the leap-second-ambiguity convention described above. 5) Delta UT1 can be obtained from tabulations provided by the International Earth Rotation and Reference Systems Service. It is the caller's responsibility to supply a dut1 argument containing the UT1-UTC value that matches the given UTC. 6) The returned ut11,ut12 are such that their sum is the UT1 Julian Date. References: McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed), University Science Books (1992) Called: iauJd2cal JD to Gregorian calendar iauDat delta(AT) = TAI-UTC iauUtctai UTC to TAI iauTaiut1 TAI to UT1 This revision: 2013 August 12 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "U", "t", "c", "u", "t", "1", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUtcut1.php#L79-L114
238,299
tadcka/Tree
Validator/NodeValidator.php
NodeValidator.validateByOnlyOne
public function validateByOnlyOne($nodeType, TreeInterface $tree) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ($config->isOnlyOne()) { return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree)); } return true; }
php
public function validateByOnlyOne($nodeType, TreeInterface $tree) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ($config->isOnlyOne()) { return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree)); } return true; }
[ "public", "function", "validateByOnlyOne", "(", "$", "nodeType", ",", "TreeInterface", "$", "tree", ")", "{", "if", "(", "!", "$", "nodeType", ")", "{", "return", "true", ";", "}", "$", "config", "=", "$", "this", "->", "getNodeTypeConfig", "(", "$", "nodeType", ")", ";", "if", "(", "null", "===", "$", "config", ")", "{", "return", "false", ";", "}", "if", "(", "$", "config", "->", "isOnlyOne", "(", ")", ")", "{", "return", "!", "in_array", "(", "$", "nodeType", ",", "$", "this", "->", "nodeManager", "->", "findExistingNodeTypes", "(", "$", "tree", ")", ")", ";", "}", "return", "true", ";", "}" ]
Validate by only one. @param string $nodeType @param TreeInterface $tree @return bool
[ "Validate", "by", "only", "one", "." ]
b45038283225508b09a05f99651ecd5127a08f20
https://github.com/tadcka/Tree/blob/b45038283225508b09a05f99651ecd5127a08f20/Validator/NodeValidator.php#L58-L74