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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
229,100 | lekoala/silverstripe-form-extras | code/controller/AjaxUploadController.php | AjaxUploadController.findTemporaryUploads | public static function findTemporaryUploads($content)
{
$links = self::findExternalLinks($content);
if (empty($links)) {
return $links;
}
$files = [];
foreach ($links as $link) {
$strpos = strpos($link, '/' . self::TEMPORARY_FOLDER . '/');
if ($strpos === false) {
continue;
}
$path = substr($link, $strpos);
$file = File::find(ASSETS_DIR . $path);
if ($file) {
$files[] = $file;
}
}
return $files;
} | php | public static function findTemporaryUploads($content)
{
$links = self::findExternalLinks($content);
if (empty($links)) {
return $links;
}
$files = [];
foreach ($links as $link) {
$strpos = strpos($link, '/' . self::TEMPORARY_FOLDER . '/');
if ($strpos === false) {
continue;
}
$path = substr($link, $strpos);
$file = File::find(ASSETS_DIR . $path);
if ($file) {
$files[] = $file;
}
}
return $files;
} | [
"public",
"static",
"function",
"findTemporaryUploads",
"(",
"$",
"content",
")",
"{",
"$",
"links",
"=",
"self",
"::",
"findExternalLinks",
"(",
"$",
"content",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"links",
")",
")",
"{",
"return",
"$",
"links",
";... | Finds temporary file and image in a given html content
@param string $content Your html content
@return array An array of files | [
"Finds",
"temporary",
"file",
"and",
"image",
"in",
"a",
"given",
"html",
"content"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/controller/AjaxUploadController.php#L183-L209 |
229,101 | lekoala/silverstripe-form-extras | code/controller/AjaxUploadController.php | AjaxUploadController.deleteUnusedFiles | public static function deleteUnusedFiles($originalContent, $content)
{
$originalFiles = self::findExternalLinks($originalContent);
$deleted = [];
if (empty($originalFiles)) {
return $deleted;
}
$currentFiles = self::findExternalLinks($content);
$diff = array_diff($originalFiles, $currentFiles);
if (empty($diff)) {
return $deleted;
}
foreach ($diff as $path) {
// Skip absolute path
if (strpos($path, 'http') === 0) {
continue;
}
$file = File::find(ASSETS_DIR . $path);
if ($file) {
$deleted[] = $path;
$file->delete();
}
}
return $deleted;
} | php | public static function deleteUnusedFiles($originalContent, $content)
{
$originalFiles = self::findExternalLinks($originalContent);
$deleted = [];
if (empty($originalFiles)) {
return $deleted;
}
$currentFiles = self::findExternalLinks($content);
$diff = array_diff($originalFiles, $currentFiles);
if (empty($diff)) {
return $deleted;
}
foreach ($diff as $path) {
// Skip absolute path
if (strpos($path, 'http') === 0) {
continue;
}
$file = File::find(ASSETS_DIR . $path);
if ($file) {
$deleted[] = $path;
$file->delete();
}
}
return $deleted;
} | [
"public",
"static",
"function",
"deleteUnusedFiles",
"(",
"$",
"originalContent",
",",
"$",
"content",
")",
"{",
"$",
"originalFiles",
"=",
"self",
"::",
"findExternalLinks",
"(",
"$",
"originalContent",
")",
";",
"$",
"deleted",
"=",
"[",
"]",
";",
"if",
... | Diff original and new content to find and delete removed files
@param string $originalContent
@param string $content
@return array An array of deleted files | [
"Diff",
"original",
"and",
"new",
"content",
"to",
"find",
"and",
"delete",
"removed",
"files"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/controller/AjaxUploadController.php#L218-L249 |
229,102 | lekoala/silverstripe-form-extras | code/controller/AjaxUploadController.php | AjaxUploadController.moveTemporaryUploads | public static function moveTemporaryUploads($content, $destFolder, &$tmpFiles)
{
$replace = [];
$folder = Folder::find_or_make($destFolder);
/* @var $file File */
foreach ($tmpFiles as $file) {
// Keep a copy of the old url to remplace with a new one in the html content
$oldURL = $file->getURL();
$name = pathinfo($file->Name, PATHINFO_FILENAME);
$ext = pathinfo($file->Name, PATHINFO_EXTENSION);
$file->Name = $name . '_' . time() . '.' . $ext;
$file->ParentID = $folder->ID;
$file->write();
$replace[$oldURL] = $file->getURL();
}
$content = str_replace(array_keys($replace), array_values($replace), $content);
return $content;
} | php | public static function moveTemporaryUploads($content, $destFolder, &$tmpFiles)
{
$replace = [];
$folder = Folder::find_or_make($destFolder);
/* @var $file File */
foreach ($tmpFiles as $file) {
// Keep a copy of the old url to remplace with a new one in the html content
$oldURL = $file->getURL();
$name = pathinfo($file->Name, PATHINFO_FILENAME);
$ext = pathinfo($file->Name, PATHINFO_EXTENSION);
$file->Name = $name . '_' . time() . '.' . $ext;
$file->ParentID = $folder->ID;
$file->write();
$replace[$oldURL] = $file->getURL();
}
$content = str_replace(array_keys($replace), array_values($replace), $content);
return $content;
} | [
"public",
"static",
"function",
"moveTemporaryUploads",
"(",
"$",
"content",
",",
"$",
"destFolder",
",",
"&",
"$",
"tmpFiles",
")",
"{",
"$",
"replace",
"=",
"[",
"]",
";",
"$",
"folder",
"=",
"Folder",
"::",
"find_or_make",
"(",
"$",
"destFolder",
")",... | Move temporary files into a valid folder
@param string $content
@param string $destFolder
@param array $tmpFiles
@return string Updated html content with new urls | [
"Move",
"temporary",
"files",
"into",
"a",
"valid",
"folder"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/controller/AjaxUploadController.php#L259-L284 |
229,103 | slickframework/slick | src/Slick/Di/Definition/ObjectDefinition/MethodInjection.php | MethodInjection.getParameter | public function getParameter($index) {
$parameter = null;
if ($this->hasParameter($index)) {
$parameter = $this->_parameters[$index];
}
return $parameter;
} | php | public function getParameter($index) {
$parameter = null;
if ($this->hasParameter($index)) {
$parameter = $this->_parameters[$index];
}
return $parameter;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"index",
")",
"{",
"$",
"parameter",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasParameter",
"(",
"$",
"index",
")",
")",
"{",
"$",
"parameter",
"=",
"$",
"this",
"->",
"_parameters",
"[",
"$",
... | Returns the value at the provided position index
@param int $index
@return null|mixed | [
"Returns",
"the",
"value",
"at",
"the",
"provided",
"position",
"index"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Definition/ObjectDefinition/MethodInjection.php#L96-L102 |
229,104 | inc2734/wp-breadcrumbs | src/Controller/Front_Page.php | Front_Page.get_home_label | protected function get_home_label() {
$page_on_front = get_option( 'page_on_front' );
$home_label = __( 'Home', 'inc2734-wp-breadcrumbs' );
if ( $page_on_front ) {
$home_label = get_the_title( $page_on_front );
}
return $home_label;
} | php | protected function get_home_label() {
$page_on_front = get_option( 'page_on_front' );
$home_label = __( 'Home', 'inc2734-wp-breadcrumbs' );
if ( $page_on_front ) {
$home_label = get_the_title( $page_on_front );
}
return $home_label;
} | [
"protected",
"function",
"get_home_label",
"(",
")",
"{",
"$",
"page_on_front",
"=",
"get_option",
"(",
"'page_on_front'",
")",
";",
"$",
"home_label",
"=",
"__",
"(",
"'Home'",
",",
"'inc2734-wp-breadcrumbs'",
")",
";",
"if",
"(",
"$",
"page_on_front",
")",
... | Return front page label
@return string | [
"Return",
"front",
"page",
"label"
] | fb904467f5ab3ec18c17c7420d1cbd98248367d8 | https://github.com/inc2734/wp-breadcrumbs/blob/fb904467f5ab3ec18c17c7420d1cbd98248367d8/src/Controller/Front_Page.php#L37-L44 |
229,105 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.add | public function add($input, $name = null)
{
if (
is_a($input, 'Slick\Form\InputFilter\InputFilterInterface') &&
is_null($name)
) {
throw new InvalidArgumentException(
"You must set a name to add an input filter to the list of " .
"inputs of an input filter."
);
}
if (
!is_a($input, 'Slick\Form\InputFilter\InputFilterInterface') &&
!is_a($input, 'Slick\Form\InputFilter\InputInterface')
) {
throw new InvalidArgumentException(
"You can only add an input or input filter to an input filter."
);
}
$key = $name;
if (is_null($name)) {
$key = $input->name;
}
$this->_inputs[$key] = $input;
return $this;
} | php | public function add($input, $name = null)
{
if (
is_a($input, 'Slick\Form\InputFilter\InputFilterInterface') &&
is_null($name)
) {
throw new InvalidArgumentException(
"You must set a name to add an input filter to the list of " .
"inputs of an input filter."
);
}
if (
!is_a($input, 'Slick\Form\InputFilter\InputFilterInterface') &&
!is_a($input, 'Slick\Form\InputFilter\InputInterface')
) {
throw new InvalidArgumentException(
"You can only add an input or input filter to an input filter."
);
}
$key = $name;
if (is_null($name)) {
$key = $input->name;
}
$this->_inputs[$key] = $input;
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"input",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"input",
",",
"'Slick\\Form\\InputFilter\\InputFilterInterface'",
")",
"&&",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",... | Add an input to the input filter
If name is not set, the input name will be used to as the
name to retrieve it.
@param Input|InputFilter $input
@param string $name (Optional) Name used to retrieve the input
@throws \Slick\Form\Exception\InvalidArgumentException If input is
an InputFilterInterface object and $name is not provided.
@return InputFilterInterface | [
"Add",
"an",
"input",
"to",
"the",
"input",
"filter"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L55-L84 |
229,106 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.get | public function get($name)
{
$input = null;
if ($this->has($name)) {
$input = $this->_inputs[$name];
}
return $input;
} | php | public function get($name)
{
$input = null;
if ($this->has($name)) {
$input = $this->_inputs[$name];
}
return $input;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"input",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"_inputs",
"[",
"$",
"name",
"]",
";",
"}",
... | Retrieves the input stored with the provided name
@param string $name Name under witch input was stored
@return Input|InputFilter | [
"Retrieves",
"the",
"input",
"stored",
"with",
"the",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L93-L100 |
229,107 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.remove | public function remove($name)
{
$removed = false;
if ($this->has($name)) {
unset($this->_inputs[$name]);
$removed = true;
}
return $removed;
} | php | public function remove($name)
{
$removed = false;
if ($this->has($name)) {
unset($this->_inputs[$name]);
$removed = true;
}
return $removed;
} | [
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"$",
"removed",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_inputs",
"[",
"$",
"name",
"]",
")",
";",
... | Removes the input that was stored with the provided name
@param string $name Name under witch input was stored
@return boolean True if an input with given name existed and was removed | [
"Removes",
"the",
"input",
"that",
"was",
"stored",
"with",
"the",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L121-L129 |
229,108 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.setData | public function setData($data)
{
foreach ($data as $name => $value) {
if ($this->has($name)) {
$this->get($name)->setValue($value);
}
}
return $this;
} | php | public function setData($data)
{
foreach ($data as $name => $value) {
if ($this->has($name)) {
$this->get($name)->setValue($value);
}
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"$... | Populate data on current input list
@param array $data An associative array with input names and
corespondent values
@return InputFilterInterface | [
"Populate",
"data",
"on",
"current",
"input",
"list"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L139-L147 |
229,109 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.isValid | public function isValid()
{
$valid = true;
$messages = array();
/** @var Input $input */
foreach ($this->_inputs as $input) {
if (!$input->isValid()) {
$valid = false;
$messages[$input->name] = $input->getMessages();
}
}
$this->_messages = $messages;
return $valid;
} | php | public function isValid()
{
$valid = true;
$messages = array();
/** @var Input $input */
foreach ($this->_inputs as $input) {
if (!$input->isValid()) {
$valid = false;
$messages[$input->name] = $input->getMessages();
}
}
$this->_messages = $messages;
return $valid;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"valid",
"=",
"true",
";",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"/** @var Input $input */",
"foreach",
"(",
"$",
"this",
"->",
"_inputs",
"as",
"$",
"input",
")",
"{",
"if",
"(",
"!",
"$",... | Check if all data set is valid
@return boolean | [
"Check",
"if",
"all",
"data",
"set",
"is",
"valid"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L154-L168 |
229,110 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.getValue | public function getValue($name)
{
$value = null;
if ($this->has($name)) {
$value = call_user_func_array(
[$this->_inputs[$name], 'getValue'],
[$name]
);
}
return $value;
} | php | public function getValue($name)
{
$value = null;
if ($this->has($name)) {
$value = call_user_func_array(
[$this->_inputs[$name], 'getValue'],
[$name]
);
}
return $value;
} | [
"public",
"function",
"getValue",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"value",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"_inputs",
... | Get filtered value of the input with provided name
@param string $name Name under witch input was stored
@return mixed | [
"Get",
"filtered",
"value",
"of",
"the",
"input",
"with",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L177-L187 |
229,111 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.getValues | public function getValues()
{
$values = array();
/** @var Input $input */
foreach ($this->_inputs as $name => $input) {
if (strlen($name) > 0) {
$values[$name] = call_user_func_array(
[$input, 'getValue'],
[$name]
);
}
}
return $values;
} | php | public function getValues()
{
$values = array();
/** @var Input $input */
foreach ($this->_inputs as $name => $input) {
if (strlen($name) > 0) {
$values[$name] = call_user_func_array(
[$input, 'getValue'],
[$name]
);
}
}
return $values;
} | [
"public",
"function",
"getValues",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"/** @var Input $input */",
"foreach",
"(",
"$",
"this",
"->",
"_inputs",
"as",
"$",
"name",
"=>",
"$",
"input",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"n... | Returns all input values filtered
@return array An associative array with input names as keys and
filtered values as values | [
"Returns",
"all",
"input",
"values",
"filtered"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L195-L208 |
229,112 | slickframework/slick | src/Slick/Form/InputFilter/InputFilter.php | InputFilter.getRawValues | public function getRawValues()
{
$values = array();
foreach ($this->_inputs as $name => $input) {
/** @var Input $input */
$values[$name] = call_user_func_array(
[$input, 'getRawValue'],
[$name]
);
}
return $values;
} | php | public function getRawValues()
{
$values = array();
foreach ($this->_inputs as $name => $input) {
/** @var Input $input */
$values[$name] = call_user_func_array(
[$input, 'getRawValue'],
[$name]
);
}
return $values;
} | [
"public",
"function",
"getRawValues",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_inputs",
"as",
"$",
"name",
"=>",
"$",
"input",
")",
"{",
"/** @var Input $input */",
"$",
"values",
"[",
"$",
"name",... | Get all the values from data set without filtering
@return array An associative array with input names as keys and
corespondent raw values | [
"Get",
"all",
"the",
"values",
"from",
"data",
"set",
"without",
"filtering"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/InputFilter.php#L235-L246 |
229,113 | AOEpeople/StackFormation | src/StackFormation/Helper/Pipeline.php | Pipeline.process | public function process($payload)
{
foreach ($this->stages as $stage) {
$payload = call_user_func($stage, $payload);
}
return $payload;
} | php | public function process($payload)
{
foreach ($this->stages as $stage) {
$payload = call_user_func($stage, $payload);
}
return $payload;
} | [
"public",
"function",
"process",
"(",
"$",
"payload",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"stages",
"as",
"$",
"stage",
")",
"{",
"$",
"payload",
"=",
"call_user_func",
"(",
"$",
"stage",
",",
"$",
"payload",
")",
";",
"}",
"return",
"$",
... | Process the payload.
@param $payload
@return mixed | [
"Process",
"the",
"payload",
"."
] | 5332dbbe54653e50d610cbaf75fb865c68aa2f1e | https://github.com/AOEpeople/StackFormation/blob/5332dbbe54653e50d610cbaf75fb865c68aa2f1e/src/StackFormation/Helper/Pipeline.php#L33-L39 |
229,114 | slickframework/slick | src/Slick/FileSystem/Folder.php | Folder.getNodes | public function getNodes()
{
if (is_null($this->_nodes)) {
$this->_nodes = new FileSystemList(
$this->details->getRealPath()
);
}
return $this->_nodes;
} | php | public function getNodes()
{
if (is_null($this->_nodes)) {
$this->_nodes = new FileSystemList(
$this->details->getRealPath()
);
}
return $this->_nodes;
} | [
"public",
"function",
"getNodes",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_nodes",
")",
")",
"{",
"$",
"this",
"->",
"_nodes",
"=",
"new",
"FileSystemList",
"(",
"$",
"this",
"->",
"details",
"->",
"getRealPath",
"(",
")",
")",
... | Returns an interator for this folder nodes
@return \Slick\FileSystem\FileSystemList A list of folder objects | [
"Returns",
"an",
"interator",
"for",
"this",
"folder",
"nodes"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/Folder.php#L65-L73 |
229,115 | slickframework/slick | src/Slick/FileSystem/Folder.php | Folder.addFile | public function addFile($name, $mode = 'c+')
{
$path = $this->details->getRealPath();
return new File($path .'/'. ltrim($name, '/'), $mode);
} | php | public function addFile($name, $mode = 'c+')
{
$path = $this->details->getRealPath();
return new File($path .'/'. ltrim($name, '/'), $mode);
} | [
"public",
"function",
"addFile",
"(",
"$",
"name",
",",
"$",
"mode",
"=",
"'c+'",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"details",
"->",
"getRealPath",
"(",
")",
";",
"return",
"new",
"File",
"(",
"$",
"path",
".",
"'/'",
".",
"ltrim",
"... | Adds a file to current folder
@param string $name The file name to add
@param string $mode The file opening mode
@return \Slick\FileSystem\File The added file object. | [
"Adds",
"a",
"file",
"to",
"current",
"folder"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/Folder.php#L83-L87 |
229,116 | slickframework/slick | src/Slick/FileSystem/Folder.php | Folder.addFolder | public function addFolder($name)
{
$path = $this->details->getRealPath();
return new Folder(
array(
'name' => $path .'/'. ltrim($name, '/')
)
);
} | php | public function addFolder($name)
{
$path = $this->details->getRealPath();
return new Folder(
array(
'name' => $path .'/'. ltrim($name, '/')
)
);
} | [
"public",
"function",
"addFolder",
"(",
"$",
"name",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"details",
"->",
"getRealPath",
"(",
")",
";",
"return",
"new",
"Folder",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"path",
".",
"'/'",
".",
"ltrim",
... | Adds a folder to current folder
@param string $name The folder name to add
@return \Slick\FileSystem\Folder The added folder object. | [
"Adds",
"a",
"folder",
"to",
"current",
"folder"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/Folder.php#L96-L104 |
229,117 | slickframework/slick | src/Slick/FileSystem/Folder.php | Folder.hasFile | public function hasFile($name)
{
foreach ($this->nodes as $node) {
if ($node->details->getFilename() == $name
&& !$node->details->isDir()
) {
return true;
}
}
return false;
} | php | public function hasFile($name)
{
foreach ($this->nodes as $node) {
if ($node->details->getFilename() == $name
&& !$node->details->isDir()
) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFile",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"details",
"->",
"getFilename",
"(",
")",
"==",
"$",
"name",
"&&",
"!",
"$",
"node... | Searches for file existence in current folder.
@param string $name The file name to check
@return boolean True if file exists in current folder. | [
"Searches",
"for",
"file",
"existence",
"in",
"current",
"folder",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/Folder.php#L113-L123 |
229,118 | slickframework/slick | src/Slick/Orm/Entity/Manager.php | Manager.get | public function get($entity)
{
$name = is_object($entity) ? get_class($entity) : $entity;
if (!isset($this->_entities[$name])) {
$this->_entities[$name] = new Descriptor(['entity' => $entity]);
}
return $this->_entities[$name];
} | php | public function get($entity)
{
$name = is_object($entity) ? get_class($entity) : $entity;
if (!isset($this->_entities[$name])) {
$this->_entities[$name] = new Descriptor(['entity' => $entity]);
}
return $this->_entities[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"entity",
")",
"{",
"$",
"name",
"=",
"is_object",
"(",
"$",
"entity",
")",
"?",
"get_class",
"(",
"$",
"entity",
")",
":",
"$",
"entity",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_entities",
"... | Returns the descriptor for the provided entity object
@param Entity|string $entity
@return Descriptor | [
"Returns",
"the",
"descriptor",
"for",
"the",
"provided",
"entity",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Manager.php#L85-L92 |
229,119 | slickframework/slick | src/Slick/Mvc/Command/Utils/ControllerData.php | ControllerData.setControllerName | public function setControllerName($modelName)
{
$name = end(explode('/', $modelName));
$this->_controllerName = ucfirst(Text::plural(lcfirst($name)));
return $this;
} | php | public function setControllerName($modelName)
{
$name = end(explode('/', $modelName));
$this->_controllerName = ucfirst(Text::plural(lcfirst($name)));
return $this;
} | [
"public",
"function",
"setControllerName",
"(",
"$",
"modelName",
")",
"{",
"$",
"name",
"=",
"end",
"(",
"explode",
"(",
"'/'",
",",
"$",
"modelName",
")",
")",
";",
"$",
"this",
"->",
"_controllerName",
"=",
"ucfirst",
"(",
"Text",
"::",
"plural",
"(... | Sets controller name
@param string $modelName
@return ControllerData | [
"Sets",
"controller",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Command/Utils/ControllerData.php#L91-L96 |
229,120 | slickframework/slick | src/Slick/Mvc/Command/Utils/ControllerData.php | ControllerData.getModelPlural | public function getModelPlural()
{
if (is_null($this->_modelPlural)) {
$name = $this->getModelSimpleName();
$names = Text::camelCaseToSeparator($name, '#');
$names = explode('#', $names);
$last = ucfirst(Text::plural(strtolower(array_pop($names))));
$names[] = $last;
$this->_modelPlural = lcfirst(implode('', $names));
}
return $this->_modelPlural;
} | php | public function getModelPlural()
{
if (is_null($this->_modelPlural)) {
$name = $this->getModelSimpleName();
$names = Text::camelCaseToSeparator($name, '#');
$names = explode('#', $names);
$last = ucfirst(Text::plural(strtolower(array_pop($names))));
$names[] = $last;
$this->_modelPlural = lcfirst(implode('', $names));
}
return $this->_modelPlural;
} | [
"public",
"function",
"getModelPlural",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_modelPlural",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getModelSimpleName",
"(",
")",
";",
"$",
"names",
"=",
"Text",
"::",
"camelCaseToS... | Returns lowercase model name in plural form
@return string | [
"Returns",
"lowercase",
"model",
"name",
"in",
"plural",
"form"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Command/Utils/ControllerData.php#L137-L148 |
229,121 | slickframework/slick | src/Slick/Mvc/Command/Utils/ControllerData.php | ControllerData.getForm | public function getForm()
{
if (is_null($this->_form)) {
$this->_form = new Form("scaffold", $this->getDescriptor());
}
return $this->_form;
} | php | public function getForm()
{
if (is_null($this->_form)) {
$this->_form = new Form("scaffold", $this->getDescriptor());
}
return $this->_form;
} | [
"public",
"function",
"getForm",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_form",
")",
")",
"{",
"$",
"this",
"->",
"_form",
"=",
"new",
"Form",
"(",
"\"scaffold\"",
",",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
")",
";",
... | Returns the default form for current controller
@return int|Form|string | [
"Returns",
"the",
"default",
"form",
"for",
"current",
"controller"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Command/Utils/ControllerData.php#L193-L199 |
229,122 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/UpdateSqlTemplate.php | UpdateSqlTemplate._getFieldsAndPlaceholders | protected function _getFieldsAndPlaceholders()
{
$fields = $this->_sql->getFields();
$parts = [];
foreach ($fields as $field) {
$parts[] = "{$field} = :{$field}";
}
return implode(', ', $parts);
} | php | protected function _getFieldsAndPlaceholders()
{
$fields = $this->_sql->getFields();
$parts = [];
foreach ($fields as $field) {
$parts[] = "{$field} = :{$field}";
}
return implode(', ', $parts);
} | [
"protected",
"function",
"_getFieldsAndPlaceholders",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getFields",
"(",
")",
";",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
... | Creates the fields and its placeholders
@return string | [
"Creates",
"the",
"fields",
"and",
"its",
"placeholders"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/UpdateSqlTemplate.php#L53-L61 |
229,123 | laravelcity/laravel-categories | src/Lib/Slugger.php | Slugger.storeSlug | function storeSlug($slug,$title){
if($slug!='')
$slug= $this->str_slug($slug);
else
$slug= $this->str_slug($title);
return $this->checkSlugInCategories($slug);
} | php | function storeSlug($slug,$title){
if($slug!='')
$slug= $this->str_slug($slug);
else
$slug= $this->str_slug($title);
return $this->checkSlugInCategories($slug);
} | [
"function",
"storeSlug",
"(",
"$",
"slug",
",",
"$",
"title",
")",
"{",
"if",
"(",
"$",
"slug",
"!=",
"''",
")",
"$",
"slug",
"=",
"$",
"this",
"->",
"str_slug",
"(",
"$",
"slug",
")",
";",
"else",
"$",
"slug",
"=",
"$",
"this",
"->",
"str_slug... | build slug for new category
@param Categories $category
@param string $title
@param string $slug
@return string | [
"build",
"slug",
"for",
"new",
"category"
] | b5c1baf8cbb51377fef090fc9ddaa0946bf42a68 | https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Slugger.php#L124-L131 |
229,124 | laravelcity/laravel-categories | src/Lib/Slugger.php | Slugger.updateSlug | function updateSlug($category,$slug,$title){
if($slug!='')
$slug= $this->str_slug($slug);
else
$slug= $this->str_slug($title);
if($category->slug==$slug)
return $slug;
else
return $this->checkSlugInCategories($slug);
} | php | function updateSlug($category,$slug,$title){
if($slug!='')
$slug= $this->str_slug($slug);
else
$slug= $this->str_slug($title);
if($category->slug==$slug)
return $slug;
else
return $this->checkSlugInCategories($slug);
} | [
"function",
"updateSlug",
"(",
"$",
"category",
",",
"$",
"slug",
",",
"$",
"title",
")",
"{",
"if",
"(",
"$",
"slug",
"!=",
"''",
")",
"$",
"slug",
"=",
"$",
"this",
"->",
"str_slug",
"(",
"$",
"slug",
")",
";",
"else",
"$",
"slug",
"=",
"$",
... | build slug for update category
@param Categories $category
@param string $title
@param string $slug
@return string | [
"build",
"slug",
"for",
"update",
"category"
] | b5c1baf8cbb51377fef090fc9ddaa0946bf42a68 | https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Slugger.php#L139-L149 |
229,125 | laravelcity/laravel-categories | src/Lib/Slugger.php | Slugger.checkSlugInCategories | function checkSlugInCategories($slug){
$repet=true;
$counter=1;
$newSlug=$slug;
while ($repet)
{
if(Categories::where('slug',$newSlug)->where('model_type',$this->type)->first())
{
$newSlug=$slug.'-'.$counter;
$counter++;
}
else
$repet=false;
}
return $newSlug;
} | php | function checkSlugInCategories($slug){
$repet=true;
$counter=1;
$newSlug=$slug;
while ($repet)
{
if(Categories::where('slug',$newSlug)->where('model_type',$this->type)->first())
{
$newSlug=$slug.'-'.$counter;
$counter++;
}
else
$repet=false;
}
return $newSlug;
} | [
"function",
"checkSlugInCategories",
"(",
"$",
"slug",
")",
"{",
"$",
"repet",
"=",
"true",
";",
"$",
"counter",
"=",
"1",
";",
"$",
"newSlug",
"=",
"$",
"slug",
";",
"while",
"(",
"$",
"repet",
")",
"{",
"if",
"(",
"Categories",
"::",
"where",
"("... | search slug in database and build new slug when already exist slug
@param string $slug
@return string | [
"search",
"slug",
"in",
"database",
"and",
"build",
"new",
"slug",
"when",
"already",
"exist",
"slug"
] | b5c1baf8cbb51377fef090fc9ddaa0946bf42a68 | https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Slugger.php#L156-L173 |
229,126 | slickframework/slick | src/Slick/Mvc/Router.php | Router.filter | public function filter()
{
$requestUrl = $this->application->request->getQuery('url', '/');
$requestMethod = $this->application->request->getMethod();
$event = new Route([
'router' => $this,
'application' => $this->application,
'request' => $this->application->request
]);
$this->_application->getEventManager()
->trigger(Route::BEFORE_ROUTE, $this, $event);
$options = $this->getService()->match($requestUrl, $requestMethod);
if ($options == false) {
throw new RouterException(
"No route was found for the given request URL."
);
}
// Route match, add the extension
$cfg = $this->application->getContainer()->get('configuration');
$routerInfo = new RouteInfo($options);
$routerInfo->setConfiguration($cfg)
->setTarget($options['target']);
$extension = $this->application->getRequest()
->getQuery('extension');
if (strlen($extension) < 1) {
$extension = $cfg->get('router.extension', 'html');
}
$routerInfo->extension = $extension;
$event->routeInfo = $routerInfo;
$this->_application->getEventManager()
->trigger(Route::AFTER_ROUTE, $this, $event);
return $event->routeInfo;
} | php | public function filter()
{
$requestUrl = $this->application->request->getQuery('url', '/');
$requestMethod = $this->application->request->getMethod();
$event = new Route([
'router' => $this,
'application' => $this->application,
'request' => $this->application->request
]);
$this->_application->getEventManager()
->trigger(Route::BEFORE_ROUTE, $this, $event);
$options = $this->getService()->match($requestUrl, $requestMethod);
if ($options == false) {
throw new RouterException(
"No route was found for the given request URL."
);
}
// Route match, add the extension
$cfg = $this->application->getContainer()->get('configuration');
$routerInfo = new RouteInfo($options);
$routerInfo->setConfiguration($cfg)
->setTarget($options['target']);
$extension = $this->application->getRequest()
->getQuery('extension');
if (strlen($extension) < 1) {
$extension = $cfg->get('router.extension', 'html');
}
$routerInfo->extension = $extension;
$event->routeInfo = $routerInfo;
$this->_application->getEventManager()
->trigger(Route::AFTER_ROUTE, $this, $event);
return $event->routeInfo;
} | [
"public",
"function",
"filter",
"(",
")",
"{",
"$",
"requestUrl",
"=",
"$",
"this",
"->",
"application",
"->",
"request",
"->",
"getQuery",
"(",
"'url'",
",",
"'/'",
")",
";",
"$",
"requestMethod",
"=",
"$",
"this",
"->",
"application",
"->",
"request",
... | Filter out route information
@throws Exception\RouterException If no match was found in the router
@return RouteInfo | [
"Filter",
"out",
"route",
"information"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Router.php#L116-L153 |
229,127 | slickframework/slick | src/Slick/Orm/Relation/AbstractRelation.php | AbstractRelation.getForeignKey | public function getForeignKey()
{
if (is_null($this->_foreignKey)) {
$this->setForeignKey($this->_guessForeignKey());
}
return $this->_foreignKey;
} | php | public function getForeignKey()
{
if (is_null($this->_foreignKey)) {
$this->setForeignKey($this->_guessForeignKey());
}
return $this->_foreignKey;
} | [
"public",
"function",
"getForeignKey",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_foreignKey",
")",
")",
"{",
"$",
"this",
"->",
"setForeignKey",
"(",
"$",
"this",
"->",
"_guessForeignKey",
"(",
")",
")",
";",
"}",
"return",
"$",
... | Returns the foreign key field name for this relation
@return string | [
"Returns",
"the",
"foreign",
"key",
"field",
"name",
"for",
"this",
"relation"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/AbstractRelation.php#L158-L164 |
229,128 | slickframework/slick | src/Slick/Orm/Relation/AbstractRelation.php | AbstractRelation.getContainer | public function getContainer()
{
if (is_null($this->_container)) {
$container = ContainerBuilder::buildContainer([
'sharedEventManager' => Definition::object(
'Zend\EventManager\SharedEventManager'
)
]);
$this->setContainer($container);
}
return $this->_container;
} | php | public function getContainer()
{
if (is_null($this->_container)) {
$container = ContainerBuilder::buildContainer([
'sharedEventManager' => Definition::object(
'Zend\EventManager\SharedEventManager'
)
]);
$this->setContainer($container);
}
return $this->_container;
} | [
"public",
"function",
"getContainer",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_container",
")",
")",
"{",
"$",
"container",
"=",
"ContainerBuilder",
"::",
"buildContainer",
"(",
"[",
"'sharedEventManager'",
"=>",
"Definition",
"::",
"ob... | Returns the dependency container
@return Container | [
"Returns",
"the",
"dependency",
"container"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/AbstractRelation.php#L224-L235 |
229,129 | slickframework/slick | src/Slick/Database/Sql.php | Sql.select | public function select($tableName, $fields = ['*'])
{
$sql = new Select($tableName, $fields);
$sql->setAdapter($this->_adapter);
return $sql;
} | php | public function select($tableName, $fields = ['*'])
{
$sql = new Select($tableName, $fields);
$sql->setAdapter($this->_adapter);
return $sql;
} | [
"public",
"function",
"select",
"(",
"$",
"tableName",
",",
"$",
"fields",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"sql",
"=",
"new",
"Select",
"(",
"$",
"tableName",
",",
"$",
"fields",
")",
";",
"$",
"sql",
"->",
"setAdapter",
"(",
"$",
"this",
"-... | Creates a Select statement object
@param string $tableName
@param array|string $fields
@return Select | [
"Creates",
"a",
"Select",
"statement",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql.php#L65-L70 |
229,130 | slickframework/slick | src/Slick/Database/Sql.php | Sql.delete | public function delete($tableName)
{
$sql = new Delete($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | php | public function delete($tableName)
{
$sql = new Delete($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | [
"public",
"function",
"delete",
"(",
"$",
"tableName",
")",
"{",
"$",
"sql",
"=",
"new",
"Delete",
"(",
"$",
"tableName",
")",
";",
"$",
"sql",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"_adapter",
")",
";",
"return",
"$",
"sql",
";",
"}"
] | Creates a Delete statement object
@param string $tableName
@return Delete | [
"Creates",
"a",
"Delete",
"statement",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql.php#L79-L84 |
229,131 | slickframework/slick | src/Slick/Database/Sql.php | Sql.insert | public function insert($tableName)
{
$sql = new Insert($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | php | public function insert($tableName)
{
$sql = new Insert($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | [
"public",
"function",
"insert",
"(",
"$",
"tableName",
")",
"{",
"$",
"sql",
"=",
"new",
"Insert",
"(",
"$",
"tableName",
")",
";",
"$",
"sql",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"_adapter",
")",
";",
"return",
"$",
"sql",
";",
"}"
] | Creates an Insert statement object
@param string $tableName
@return Insert | [
"Creates",
"an",
"Insert",
"statement",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql.php#L93-L98 |
229,132 | slickframework/slick | src/Slick/Database/Sql.php | Sql.update | public function update($tableName)
{
$sql = new Update($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | php | public function update($tableName)
{
$sql = new Update($tableName);
$sql->setAdapter($this->_adapter);
return $sql;
} | [
"public",
"function",
"update",
"(",
"$",
"tableName",
")",
"{",
"$",
"sql",
"=",
"new",
"Update",
"(",
"$",
"tableName",
")",
";",
"$",
"sql",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"_adapter",
")",
";",
"return",
"$",
"sql",
";",
"}"
] | Creates an Update statement object
@param string $tableName
@return Update | [
"Creates",
"an",
"Update",
"statement",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql.php#L107-L112 |
229,133 | mbilbille/jpnforphp | src/JpnForPhp/Transliterator/System/Romaji.php | Romaji.preTransliterate | protected function preTransliterate($str)
{
$str = $this->escapeLatinCharacters($str);
$str = mb_convert_kana($str, 'c', 'UTF-8');
return $str;
} | php | protected function preTransliterate($str)
{
$str = $this->escapeLatinCharacters($str);
$str = mb_convert_kana($str, 'c', 'UTF-8');
return $str;
} | [
"protected",
"function",
"preTransliterate",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"$",
"this",
"->",
"escapeLatinCharacters",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"mb_convert_kana",
"(",
"$",
"str",
",",
"'c'",
",",
"'UTF-8'",
")",
";",
... | Prepare given string for transliteration
@param string $str String to be transliterated.
@return string A string ready for transliteration. | [
"Prepare",
"given",
"string",
"for",
"transliteration"
] | 5623468503cc2941f4656b0ee1a58b939d263453 | https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Transliterator/System/Romaji.php#L34-L40 |
229,134 | jacobstr/matura | lib/Core/Builder.php | Builder.suite | public static function suite($name, $fn)
{
$suite = new Suite(new InvocationContext(), $fn, $name);
$suite->build();
return $suite;
} | php | public static function suite($name, $fn)
{
$suite = new Suite(new InvocationContext(), $fn, $name);
$suite->build();
return $suite;
} | [
"public",
"static",
"function",
"suite",
"(",
"$",
"name",
",",
"$",
"fn",
")",
"{",
"$",
"suite",
"=",
"new",
"Suite",
"(",
"new",
"InvocationContext",
"(",
")",
",",
"$",
"fn",
",",
"$",
"name",
")",
";",
"$",
"suite",
"->",
"build",
"(",
")",
... | Begins a new test suite. The test suite instantiates a new invocation
context. | [
"Begins",
"a",
"new",
"test",
"suite",
".",
"The",
"test",
"suite",
"instantiates",
"a",
"new",
"invocation",
"context",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/Builder.php#L74-L79 |
229,135 | jacobstr/matura | lib/Core/Builder.php | Builder.it | public static function it($name, $fn)
{
$active_block = InvocationContext::getAndAssertActiveBlock('Matura\Blocks\Describe');
$test_method = new TestMethod($active_block, $fn, $name);
$test_method->addToParent();
return $test_method;
} | php | public static function it($name, $fn)
{
$active_block = InvocationContext::getAndAssertActiveBlock('Matura\Blocks\Describe');
$test_method = new TestMethod($active_block, $fn, $name);
$test_method->addToParent();
return $test_method;
} | [
"public",
"static",
"function",
"it",
"(",
"$",
"name",
",",
"$",
"fn",
")",
"{",
"$",
"active_block",
"=",
"InvocationContext",
"::",
"getAndAssertActiveBlock",
"(",
"'Matura\\Blocks\\Describe'",
")",
";",
"$",
"test_method",
"=",
"new",
"TestMethod",
"(",
"$... | Begins a new test case within the active block. | [
"Begins",
"a",
"new",
"test",
"case",
"within",
"the",
"active",
"block",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/Builder.php#L84-L90 |
229,136 | jacobstr/matura | lib/Core/Builder.php | Builder.before | public static function before($fn)
{
$test_method = new BeforeHook(InvocationContext::getActive(), $fn);
$test_method->addToParent();
return $test_method;
} | php | public static function before($fn)
{
$test_method = new BeforeHook(InvocationContext::getActive(), $fn);
$test_method->addToParent();
return $test_method;
} | [
"public",
"static",
"function",
"before",
"(",
"$",
"fn",
")",
"{",
"$",
"test_method",
"=",
"new",
"BeforeHook",
"(",
"InvocationContext",
"::",
"getActive",
"(",
")",
",",
"$",
"fn",
")",
";",
"$",
"test_method",
"->",
"addToParent",
"(",
")",
";",
"... | Adds a before callback to the active block. The active block should be
a describe block. | [
"Adds",
"a",
"before",
"callback",
"to",
"the",
"active",
"block",
".",
"The",
"active",
"block",
"should",
"be",
"a",
"describe",
"block",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/Builder.php#L96-L101 |
229,137 | jacobstr/matura | lib/Core/Builder.php | Builder.before_all | public static function before_all($fn)
{
$test_method = new BeforeAllHook(InvocationContext::getActive(), $fn);
$test_method->addToParent();
return $test_method;
} | php | public static function before_all($fn)
{
$test_method = new BeforeAllHook(InvocationContext::getActive(), $fn);
$test_method->addToParent();
return $test_method;
} | [
"public",
"static",
"function",
"before_all",
"(",
"$",
"fn",
")",
"{",
"$",
"test_method",
"=",
"new",
"BeforeAllHook",
"(",
"InvocationContext",
"::",
"getActive",
"(",
")",
",",
"$",
"fn",
")",
";",
"$",
"test_method",
"->",
"addToParent",
"(",
")",
"... | Adds a before_all callback to the active block. The active block should
generally be a describe block. | [
"Adds",
"a",
"before_all",
"callback",
"to",
"the",
"active",
"block",
".",
"The",
"active",
"block",
"should",
"generally",
"be",
"a",
"describe",
"block",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/Builder.php#L107-L112 |
229,138 | jacobstr/matura | lib/Core/Builder.php | Builder.getNameAndSkipFlag | protected static function getNameAndSkipFlag($name)
{
if ($name[0] == 'x') {
return array(substr($name, 1), true);
} else {
return array(self::$method_map[$name], false);
}
} | php | protected static function getNameAndSkipFlag($name)
{
if ($name[0] == 'x') {
return array(substr($name, 1), true);
} else {
return array(self::$method_map[$name], false);
}
} | [
"protected",
"static",
"function",
"getNameAndSkipFlag",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"[",
"0",
"]",
"==",
"'x'",
")",
"{",
"return",
"array",
"(",
"substr",
"(",
"$",
"name",
",",
"1",
")",
",",
"true",
")",
";",
"}",
"els... | Used to detect skipped versions of methods.
@example
>>$this->getNameAndSkipFlag('xit');
array('it', true);
>>$this->getNameAndSkipFlag('before_all');
array('before_all', false);
@return a 2-tuple of a method name and skip flag. | [
"Used",
"to",
"detect",
"skipped",
"versions",
"of",
"methods",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/Builder.php#L161-L168 |
229,139 | ricardopedias/artisan-obfuscator | src/appmod/Services/BaseObfuscator.php | BaseObfuscator.prepareAutoloaderFile | private function prepareAutoloaderFile()
{
$plain_name = pathinfo($this->getPlainPath(), PATHINFO_BASENAME);
$obfuscated_name = pathinfo($this->getObfuscatedPath(), PATHINFO_BASENAME);
$autoloader = $this->getPlainPath() . DIRECTORY_SEPARATOR . 'autoloader.php';
$contents = file_get_contents($autoloader);
$contents = str_replace($obfuscated_name, $plain_name, $contents);
return (file_put_contents($autoloader, $contents) !== false);
} | php | private function prepareAutoloaderFile()
{
$plain_name = pathinfo($this->getPlainPath(), PATHINFO_BASENAME);
$obfuscated_name = pathinfo($this->getObfuscatedPath(), PATHINFO_BASENAME);
$autoloader = $this->getPlainPath() . DIRECTORY_SEPARATOR . 'autoloader.php';
$contents = file_get_contents($autoloader);
$contents = str_replace($obfuscated_name, $plain_name, $contents);
return (file_put_contents($autoloader, $contents) !== false);
} | [
"private",
"function",
"prepareAutoloaderFile",
"(",
")",
"{",
"$",
"plain_name",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"getPlainPath",
"(",
")",
",",
"PATHINFO_BASENAME",
")",
";",
"$",
"obfuscated_name",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"getObfu... | Prepara os caminhos de carregamento para os arquivos do autoloader
@return bool | [
"Prepara",
"os",
"caminhos",
"de",
"carregamento",
"para",
"os",
"arquivos",
"do",
"autoloader"
] | 971ee99c906861883b61452547fafe953411852b | https://github.com/ricardopedias/artisan-obfuscator/blob/971ee99c906861883b61452547fafe953411852b/src/appmod/Services/BaseObfuscator.php#L188-L197 |
229,140 | ricardopedias/artisan-obfuscator | src/appmod/Services/BaseObfuscator.php | BaseObfuscator.makeBackup | protected function makeBackup()
{
$path_plain = $this->getPlainPath();
$path_obfuscated = $this->getObfuscatedPath();
$path_backup = $this->getBackupPath();
// Renomeia o diretório com os arquivos originais
// para um novo diretório de backup
if (is_dir($path_backup) == true) {
$this->getObfuscator()->addRuntimeMessage('A previous backup already exists!');
return false;
} elseif(rename($path_plain, $path_backup) === false) {
$this->getObfuscator()->addErrorMessage('Could not back up. Operation canceled!');
return false;
}
// Renomeia o diretório com os arquivos ofuscados
// para ser o novo diretório em execução
if(rename($path_obfuscated, $path_plain) === false) {
$this->getObfuscator()->addErrorMessage('Obfuscated directory could not become the main directory!');
return false;
}
// Renomeia os includes do autoloader
if ($this->prepareAutoloaderFile() == false) {
$this->getObfuscator()->addErrorMessage('Unable to prepare autoloader file!');
return false;
}
return true;
} | php | protected function makeBackup()
{
$path_plain = $this->getPlainPath();
$path_obfuscated = $this->getObfuscatedPath();
$path_backup = $this->getBackupPath();
// Renomeia o diretório com os arquivos originais
// para um novo diretório de backup
if (is_dir($path_backup) == true) {
$this->getObfuscator()->addRuntimeMessage('A previous backup already exists!');
return false;
} elseif(rename($path_plain, $path_backup) === false) {
$this->getObfuscator()->addErrorMessage('Could not back up. Operation canceled!');
return false;
}
// Renomeia o diretório com os arquivos ofuscados
// para ser o novo diretório em execução
if(rename($path_obfuscated, $path_plain) === false) {
$this->getObfuscator()->addErrorMessage('Obfuscated directory could not become the main directory!');
return false;
}
// Renomeia os includes do autoloader
if ($this->prepareAutoloaderFile() == false) {
$this->getObfuscator()->addErrorMessage('Unable to prepare autoloader file!');
return false;
}
return true;
} | [
"protected",
"function",
"makeBackup",
"(",
")",
"{",
"$",
"path_plain",
"=",
"$",
"this",
"->",
"getPlainPath",
"(",
")",
";",
"$",
"path_obfuscated",
"=",
"$",
"this",
"->",
"getObfuscatedPath",
"(",
")",
";",
"$",
"path_backup",
"=",
"$",
"this",
"->"... | Efetua o backup dos arquivos originais
e adiciona os ofuscados no lugar
@return bool | [
"Efetua",
"o",
"backup",
"dos",
"arquivos",
"originais",
"e",
"adiciona",
"os",
"ofuscados",
"no",
"lugar"
] | 971ee99c906861883b61452547fafe953411852b | https://github.com/ricardopedias/artisan-obfuscator/blob/971ee99c906861883b61452547fafe953411852b/src/appmod/Services/BaseObfuscator.php#L205-L236 |
229,141 | ricardopedias/artisan-obfuscator | src/appmod/Services/BaseObfuscator.php | BaseObfuscator.setupComposer | protected function setupComposer()
{
$composer_file = $this->getComposerJsonFile();
$contents = json_decode(file_get_contents($composer_file), true);
if (!isset($contents['autoload']['files'])) {
// Cria a seção files
$contents['autoload']['files'] = [];
}
$autoloader_file = $this->getAutoloaderFile();
if (array_search($autoloader_file, $contents['autoload']['files']) === false) {
// Adiciona o arquivo com prioridade
$contents['autoload']['files'] = array_merge(
[$autoloader_file],
$contents['autoload']['files']
);
}
$json_contents = str_replace("\\/", "/", json_encode($contents, JSON_PRETTY_PRINT));
if (file_put_contents($composer_file, $json_contents) === false) {
$this->getObfuscator()->addErrorMessage("Could not update composer.json file");
return false;
}
$this->getObfuscator()->addErrorMessage("O arquivo composer.json foi configurado com sucesso.");
return true;
} | php | protected function setupComposer()
{
$composer_file = $this->getComposerJsonFile();
$contents = json_decode(file_get_contents($composer_file), true);
if (!isset($contents['autoload']['files'])) {
// Cria a seção files
$contents['autoload']['files'] = [];
}
$autoloader_file = $this->getAutoloaderFile();
if (array_search($autoloader_file, $contents['autoload']['files']) === false) {
// Adiciona o arquivo com prioridade
$contents['autoload']['files'] = array_merge(
[$autoloader_file],
$contents['autoload']['files']
);
}
$json_contents = str_replace("\\/", "/", json_encode($contents, JSON_PRETTY_PRINT));
if (file_put_contents($composer_file, $json_contents) === false) {
$this->getObfuscator()->addErrorMessage("Could not update composer.json file");
return false;
}
$this->getObfuscator()->addErrorMessage("O arquivo composer.json foi configurado com sucesso.");
return true;
} | [
"protected",
"function",
"setupComposer",
"(",
")",
"{",
"$",
"composer_file",
"=",
"$",
"this",
"->",
"getComposerJsonFile",
"(",
")",
";",
"$",
"contents",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"composer_file",
")",
",",
"true",
")",
";",... | Configura o composer para usar os arquivos ofuscados
no lugar dos originais.
@return bool | [
"Configura",
"o",
"composer",
"para",
"usar",
"os",
"arquivos",
"ofuscados",
"no",
"lugar",
"dos",
"originais",
"."
] | 971ee99c906861883b61452547fafe953411852b | https://github.com/ricardopedias/artisan-obfuscator/blob/971ee99c906861883b61452547fafe953411852b/src/appmod/Services/BaseObfuscator.php#L244-L271 |
229,142 | PrestaShop/decimal | src/Operation/Comparison.php | Comparison.compare | public function compare(DecimalNumber $a, DecimalNumber $b)
{
if (function_exists('bccomp')) {
return $this->compareUsingBcMath($a, $b);
}
return $this->compareWithoutBcMath($a, $b);
} | php | public function compare(DecimalNumber $a, DecimalNumber $b)
{
if (function_exists('bccomp')) {
return $this->compareUsingBcMath($a, $b);
}
return $this->compareWithoutBcMath($a, $b);
} | [
"public",
"function",
"compare",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'bccomp'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"compareUsingBcMath",
"(",
"$",
"a",
",",
"$",
"b",
")... | Compares two decimal numbers.
@param DecimalNumber $a
@param DecimalNumber $b
@return int Returns 1 if $a > $b, -1 if $a < $b, and 0 if they are equal. | [
"Compares",
"two",
"decimal",
"numbers",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Comparison.php#L27-L34 |
229,143 | PrestaShop/decimal | src/Operation/Comparison.php | Comparison.compareUsingBcMath | public function compareUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
return bccomp((string) $a, (string) $b, max($a->getExponent(), $b->getExponent()));
} | php | public function compareUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
return bccomp((string) $a, (string) $b, max($a->getExponent(), $b->getExponent()));
} | [
"public",
"function",
"compareUsingBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"return",
"bccomp",
"(",
"(",
"string",
")",
"$",
"a",
",",
"(",
"string",
")",
"$",
"b",
",",
"max",
"(",
"$",
"a",
"->",
"getExpon... | Compares two decimal numbers using BC Math
@param DecimalNumber $a
@param DecimalNumber $b
@return int Returns 1 if $a > $b, -1 if $a < $b, and 0 if they are equal. | [
"Compares",
"two",
"decimal",
"numbers",
"using",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Comparison.php#L44-L47 |
229,144 | PrestaShop/decimal | src/Operation/Comparison.php | Comparison.compareWithoutBcMath | public function compareWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
$signCompare = $this->compareSigns($a->getSign(), $b->getSign());
if ($signCompare !== 0) {
return $signCompare;
}
// signs are equal, compare regardless of sign
$result = $this->positiveCompare($a, $b);
// inverse the result if the signs are negative
if ($a->isNegative()) {
return -$result;
}
return $result;
} | php | public function compareWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
$signCompare = $this->compareSigns($a->getSign(), $b->getSign());
if ($signCompare !== 0) {
return $signCompare;
}
// signs are equal, compare regardless of sign
$result = $this->positiveCompare($a, $b);
// inverse the result if the signs are negative
if ($a->isNegative()) {
return -$result;
}
return $result;
} | [
"public",
"function",
"compareWithoutBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"$",
"signCompare",
"=",
"$",
"this",
"->",
"compareSigns",
"(",
"$",
"a",
"->",
"getSign",
"(",
")",
",",
"$",
"b",
"->",
"getSign",
... | Compares two decimal numbers without using BC Math
@param DecimalNumber $a
@param DecimalNumber $b
@return int Returns 1 if $a > $b, -1 if $a < $b, and 0 if they are equal. | [
"Compares",
"two",
"decimal",
"numbers",
"without",
"using",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Comparison.php#L57-L73 |
229,145 | PrestaShop/decimal | src/Operation/Comparison.php | Comparison.positiveCompare | private function positiveCompare(DecimalNumber $a, DecimalNumber $b)
{
// compare integer length
$intLengthCompare = $this->compareNumeric(
strlen($a->getIntegerPart()),
strlen($b->getIntegerPart())
);
if ($intLengthCompare !== 0) {
return $intLengthCompare;
}
// integer parts are equal in length, compare integer part
$intPartCompare = $this->compareBinary($a->getIntegerPart(), $b->getIntegerPart());
if ($intPartCompare !== 0) {
return $intPartCompare;
}
// integer parts are equal, compare fractional part
return $this->compareBinary($a->getFractionalPart(), $b->getFractionalPart());
} | php | private function positiveCompare(DecimalNumber $a, DecimalNumber $b)
{
// compare integer length
$intLengthCompare = $this->compareNumeric(
strlen($a->getIntegerPart()),
strlen($b->getIntegerPart())
);
if ($intLengthCompare !== 0) {
return $intLengthCompare;
}
// integer parts are equal in length, compare integer part
$intPartCompare = $this->compareBinary($a->getIntegerPart(), $b->getIntegerPart());
if ($intPartCompare !== 0) {
return $intPartCompare;
}
// integer parts are equal, compare fractional part
return $this->compareBinary($a->getFractionalPart(), $b->getFractionalPart());
} | [
"private",
"function",
"positiveCompare",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"// compare integer length",
"$",
"intLengthCompare",
"=",
"$",
"this",
"->",
"compareNumeric",
"(",
"strlen",
"(",
"$",
"a",
"->",
"getIntegerPar... | Compares two decimal numbers as positive regardless of sign.
@param DecimalNumber $a
@param DecimalNumber $b
@return int Returns 1 if $a > $b, -1 if $a < $b, and 0 if they are equal. | [
"Compares",
"two",
"decimal",
"numbers",
"as",
"positive",
"regardless",
"of",
"sign",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Comparison.php#L83-L102 |
229,146 | slickframework/slick | src/Slick/Database/Schema.php | Schema.addTable | public function addTable(TableInterface $table)
{
$table->setSchema($this);
$this->_tables[$table->getName()] = $table;
return $this;
} | php | public function addTable(TableInterface $table)
{
$table->setSchema($this);
$this->_tables[$table->getName()] = $table;
return $this;
} | [
"public",
"function",
"addTable",
"(",
"TableInterface",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"setSchema",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"_tables",
"[",
"$",
"table",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"table",
";",
"... | Adds a table to this schema
@param TableInterface $table
@return SchemaInterface | [
"Adds",
"a",
"table",
"to",
"this",
"schema"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema.php#L115-L120 |
229,147 | slickframework/slick | src/Slick/Database/Schema.php | Schema.getCreateStatement | public function getCreateStatement()
{
$sql = [];
foreach ($this->tables as $table) {
/** @var Table $table*/
$createTable = new CreateTable($table->getName());
$createTable->setAdapter($this->getAdapter());
$createTable->setColumns($table->getColumns());
$createTable->setConstraints($table->getConstraints());
$sql[] = $createTable->getQueryString();
}
return implode(';', $sql);
} | php | public function getCreateStatement()
{
$sql = [];
foreach ($this->tables as $table) {
/** @var Table $table*/
$createTable = new CreateTable($table->getName());
$createTable->setAdapter($this->getAdapter());
$createTable->setColumns($table->getColumns());
$createTable->setConstraints($table->getConstraints());
$sql[] = $createTable->getQueryString();
}
return implode(';', $sql);
} | [
"public",
"function",
"getCreateStatement",
"(",
")",
"{",
"$",
"sql",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"tables",
"as",
"$",
"table",
")",
"{",
"/** @var Table $table*/",
"$",
"createTable",
"=",
"new",
"CreateTable",
"(",
"$",
"tab... | Returns the SQL create statement form this schema
@return string | [
"Returns",
"the",
"SQL",
"create",
"statement",
"form",
"this",
"schema"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema.php#L137-L150 |
229,148 | slickframework/slick | src/Slick/FileSystem/File.php | File.getFolder | public function getFolder()
{
if (is_null($this->_folder)) {
$this->_folder = new Folder(
array(
'name' => $this->details->getPath()
)
);
}
return $this->_folder;
} | php | public function getFolder()
{
if (is_null($this->_folder)) {
$this->_folder = new Folder(
array(
'name' => $this->details->getPath()
)
);
}
return $this->_folder;
} | [
"public",
"function",
"getFolder",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_folder",
")",
")",
"{",
"$",
"this",
"->",
"_folder",
"=",
"new",
"Folder",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"details",
"->",
"ge... | Retrurs this file folder.
@return \Slick\FileSystem\Folder The folder object for this file. | [
"Retrurs",
"this",
"file",
"folder",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/File.php#L86-L96 |
229,149 | slickframework/slick | src/Slick/FileSystem/File.php | File.write | public function write($content, $mode = self::MODE_REPLACE)
{
$fileContent = $this->read();
switch ($mode) {
case self::MODE_PREPEND:
$fileContent = $content . PHP_EOL . $fileContent;
break;
case self::MODE_APPEND:
$fileContent .= PHP_EOL . $content;
break;
case self::MODE_REPLACE:
default:
$fileContent = $content;
}
$result = file_put_contents(
$this->details->getRealPath(),
$fileContent
);
return $result !== false;
} | php | public function write($content, $mode = self::MODE_REPLACE)
{
$fileContent = $this->read();
switch ($mode) {
case self::MODE_PREPEND:
$fileContent = $content . PHP_EOL . $fileContent;
break;
case self::MODE_APPEND:
$fileContent .= PHP_EOL . $content;
break;
case self::MODE_REPLACE:
default:
$fileContent = $content;
}
$result = file_put_contents(
$this->details->getRealPath(),
$fileContent
);
return $result !== false;
} | [
"public",
"function",
"write",
"(",
"$",
"content",
",",
"$",
"mode",
"=",
"self",
"::",
"MODE_REPLACE",
")",
"{",
"$",
"fileContent",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"self",
"::",
"MODE_... | Write content to this file
@param string $content The content to write
@param integer $mode [description]
@return boolean True if content was added to file. | [
"Write",
"content",
"to",
"this",
"file"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/File.php#L106-L129 |
229,150 | mimaen/simplesamlphp-module-attributes | lib/Auth/Process/TargetedID.php | sspmod_hubandspoke_Auth_Process_TargetedID.toNameId | private static function toNameId($value, $source, $destination) {
$nameId = array(
'Format' => SAML2_Const::NAMEID_PERSISTENT,
'Value' => $value,
);
if (!empty($source)) {
$nameId['NameQualifier'] = $source;
}
if (!empty($destination)) {
$nameId['SPNameQualifier'] = $destination;
}
$doc = SAML2_DOMDocumentFactory::create();
$root = $doc->createElement('root');
$doc->appendChild($root);
SAML2_Utils::addNameId($root, $nameId);
return $doc->saveXML($root->firstChild);
} | php | private static function toNameId($value, $source, $destination) {
$nameId = array(
'Format' => SAML2_Const::NAMEID_PERSISTENT,
'Value' => $value,
);
if (!empty($source)) {
$nameId['NameQualifier'] = $source;
}
if (!empty($destination)) {
$nameId['SPNameQualifier'] = $destination;
}
$doc = SAML2_DOMDocumentFactory::create();
$root = $doc->createElement('root');
$doc->appendChild($root);
SAML2_Utils::addNameId($root, $nameId);
return $doc->saveXML($root->firstChild);
} | [
"private",
"static",
"function",
"toNameId",
"(",
"$",
"value",
",",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"$",
"nameId",
"=",
"array",
"(",
"'Format'",
"=>",
"SAML2_Const",
"::",
"NAMEID_PERSISTENT",
",",
"'Value'",
"=>",
"$",
"value",
",",
... | Convert the targeted ID to a SAML 2.0 name identifier element
@param string $value The value of the attribute.
@param string $source Identifier of the IdP.
@param string $destination Identifier of the SP.
@return string The XML representing the element | [
"Convert",
"the",
"targeted",
"ID",
"to",
"a",
"SAML",
"2",
".",
"0",
"name",
"identifier",
"element"
] | acc54b085ce88051d59ef1fc2e6b5154f8a2998b | https://github.com/mimaen/simplesamlphp-module-attributes/blob/acc54b085ce88051d59ef1fc2e6b5154f8a2998b/lib/Auth/Process/TargetedID.php#L228-L248 |
229,151 | slickframework/slick | src/Slick/Database/Sql/Dialect/Sqlite/AlterTableSqlTemplate.php | AlterTableSqlTemplate._parseColumns | protected function _parseColumns()
{
$parts = [];
foreach ($this->_sql->getColumns() as $column) {
$parts[] = $this->_parseColumn($column);
}
$tableName = $this->_sql->getTable();
return implode(
"; ALTER TABLE {$tableName} ADD COLUMN ",
$parts
);
} | php | protected function _parseColumns()
{
$parts = [];
foreach ($this->_sql->getColumns() as $column) {
$parts[] = $this->_parseColumn($column);
}
$tableName = $this->_sql->getTable();
return implode(
"; ALTER TABLE {$tableName} ADD COLUMN ",
$parts
);
} | [
"protected",
"function",
"_parseColumns",
"(",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_sql",
"->",
"getColumns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"this",
"->",
"_p... | Parse column list for SQL create statement
@return string | [
"Parse",
"column",
"list",
"for",
"SQL",
"create",
"statement"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Sqlite/AlterTableSqlTemplate.php#L69-L80 |
229,152 | slickframework/slick | src/Slick/Database/Sql/Dialect/Sqlite/AlterTableSqlTemplate.php | AlterTableSqlTemplate._checkUnsupportedFeatures | private function _checkUnsupportedFeatures()
{
$addCons = $this->_sql->getConstraints();
$droppedCons = $this->_sql->getDroppedConstraints();
$droppedColumns = $this->_sql->getDroppedColumns();
$changedColumns = $this->_sql->getChangedColumns();
return empty($addCons) && empty($changedColumns)
&& empty($droppedColumns) && empty($droppedCons);
} | php | private function _checkUnsupportedFeatures()
{
$addCons = $this->_sql->getConstraints();
$droppedCons = $this->_sql->getDroppedConstraints();
$droppedColumns = $this->_sql->getDroppedColumns();
$changedColumns = $this->_sql->getChangedColumns();
return empty($addCons) && empty($changedColumns)
&& empty($droppedColumns) && empty($droppedCons);
} | [
"private",
"function",
"_checkUnsupportedFeatures",
"(",
")",
"{",
"$",
"addCons",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getConstraints",
"(",
")",
";",
"$",
"droppedCons",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getDroppedConstraints",
"(",
")",
";",
"$",... | Check alter table support
@see http://sqlite.org/lang_altertable.html | [
"Check",
"alter",
"table",
"support"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Sqlite/AlterTableSqlTemplate.php#L87-L96 |
229,153 | Danzabar/phalcon-cli | src/Tasks/Helpers/Question.php | Question.choice | public function choice($question, $choices = array(), $allowedMultiple = false)
{
$this->output->writeln($question);
$this->output->writeln(join(',', $choices));
$answer = $this->input->getInput();
$valid = $this->validateChoices($answer, $choices, $allowedMultiple);
if ($valid !== false) {
return $valid;
}
$this->output->writeln($this->wrongChoiceErrorMessage);
return false;
} | php | public function choice($question, $choices = array(), $allowedMultiple = false)
{
$this->output->writeln($question);
$this->output->writeln(join(',', $choices));
$answer = $this->input->getInput();
$valid = $this->validateChoices($answer, $choices, $allowedMultiple);
if ($valid !== false) {
return $valid;
}
$this->output->writeln($this->wrongChoiceErrorMessage);
return false;
} | [
"public",
"function",
"choice",
"(",
"$",
"question",
",",
"$",
"choices",
"=",
"array",
"(",
")",
",",
"$",
"allowedMultiple",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"question",
")",
";",
"$",
"this",
"->",
... | The choice question, pick a single choice.
@return String | [
"The",
"choice",
"question",
"pick",
"a",
"single",
"choice",
"."
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Question.php#L50-L67 |
229,154 | Danzabar/phalcon-cli | src/Tasks/Helpers/Question.php | Question.validateChoices | public function validateChoices($answer, $choices, $allowedMultiple = false)
{
if ($allowedMultiple) {
return $this->validateMultipleChoice($answer, $choices);
} else {
return $this->validateSingleChoice($answer, $choices);
}
} | php | public function validateChoices($answer, $choices, $allowedMultiple = false)
{
if ($allowedMultiple) {
return $this->validateMultipleChoice($answer, $choices);
} else {
return $this->validateSingleChoice($answer, $choices);
}
} | [
"public",
"function",
"validateChoices",
"(",
"$",
"answer",
",",
"$",
"choices",
",",
"$",
"allowedMultiple",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"allowedMultiple",
")",
"{",
"return",
"$",
"this",
"->",
"validateMultipleChoice",
"(",
"$",
"answer",
"... | Checks that the answer is present in the list of choices
@return Boolean | [
"Checks",
"that",
"the",
"answer",
"is",
"present",
"in",
"the",
"list",
"of",
"choices"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Question.php#L84-L91 |
229,155 | Danzabar/phalcon-cli | src/Tasks/Helpers/Question.php | Question.validateMultipleChoice | public function validateMultipleChoice($answer, $choice)
{
$answers = explode(',', $answer);
foreach ($answers as $ans) {
if (!in_array(trim($ans), $choice)) {
return false;
}
$formatedAnswers[] = trim($ans);
}
return $formatedAnswers;
} | php | public function validateMultipleChoice($answer, $choice)
{
$answers = explode(',', $answer);
foreach ($answers as $ans) {
if (!in_array(trim($ans), $choice)) {
return false;
}
$formatedAnswers[] = trim($ans);
}
return $formatedAnswers;
} | [
"public",
"function",
"validateMultipleChoice",
"(",
"$",
"answer",
",",
"$",
"choice",
")",
"{",
"$",
"answers",
"=",
"explode",
"(",
"','",
",",
"$",
"answer",
")",
";",
"foreach",
"(",
"$",
"answers",
"as",
"$",
"ans",
")",
"{",
"if",
"(",
"!",
... | Validates multiple answers
@return Boolean|String | [
"Validates",
"multiple",
"answers"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Question.php#L112-L125 |
229,156 | Danzabar/phalcon-cli | src/Application.php | Application.setUpDispatcherDefaults | public function setUpDispatcherDefaults()
{
// Set the defaults for the dispatcher
$this->dispatcher->setDefaultTask('Danzabar\CLI\Tasks\Utility\Help');
$this->dispatcher->setDefaultAction('main');
// Set no suffixes
$this->dispatcher->setTaskSuffix('');
$this->dispatcher->setActionSuffix('');
} | php | public function setUpDispatcherDefaults()
{
// Set the defaults for the dispatcher
$this->dispatcher->setDefaultTask('Danzabar\CLI\Tasks\Utility\Help');
$this->dispatcher->setDefaultAction('main');
// Set no suffixes
$this->dispatcher->setTaskSuffix('');
$this->dispatcher->setActionSuffix('');
} | [
"public",
"function",
"setUpDispatcherDefaults",
"(",
")",
"{",
"// Set the defaults for the dispatcher",
"$",
"this",
"->",
"dispatcher",
"->",
"setDefaultTask",
"(",
"'Danzabar\\CLI\\Tasks\\Utility\\Help'",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"setDefaultAct... | Sets up the default settings for the dispatcher
@return void | [
"Sets",
"up",
"the",
"default",
"settings",
"for",
"the",
"dispatcher"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Application.php#L121-L130 |
229,157 | Danzabar/phalcon-cli | src/Application.php | Application.registerDefaultHelpers | public function registerDefaultHelpers()
{
$this->helpers->registerHelper('question', 'Danzabar\CLI\Tasks\Helpers\Question');
$this->helpers->registerHelper('confirm', 'Danzabar\CLI\Tasks\Helpers\Confirmation');
$this->helpers->registerHelper('table', 'Danzabar\CLI\Tasks\Helpers\Table');
} | php | public function registerDefaultHelpers()
{
$this->helpers->registerHelper('question', 'Danzabar\CLI\Tasks\Helpers\Question');
$this->helpers->registerHelper('confirm', 'Danzabar\CLI\Tasks\Helpers\Confirmation');
$this->helpers->registerHelper('table', 'Danzabar\CLI\Tasks\Helpers\Table');
} | [
"public",
"function",
"registerDefaultHelpers",
"(",
")",
"{",
"$",
"this",
"->",
"helpers",
"->",
"registerHelper",
"(",
"'question'",
",",
"'Danzabar\\CLI\\Tasks\\Helpers\\Question'",
")",
";",
"$",
"this",
"->",
"helpers",
"->",
"registerHelper",
"(",
"'confirm'"... | Registers the question, confirmation and table helpers
@return void | [
"Registers",
"the",
"question",
"confirmation",
"and",
"table",
"helpers"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Application.php#L137-L142 |
229,158 | Danzabar/phalcon-cli | src/Application.php | Application.start | public function start($args = array())
{
$arg = $this->formatArgs($args);
/**
* Arguments and Options
*
*/
if (!empty($arg)) {
$this->prepper
->load($arg['task'])
->loadParams($arg['params'])
->prep($arg['action']);
$this->dispatcher->setTaskName($arg['task']);
$this->dispatcher->setActionName($arg['action']);
$this->dispatcher->setParams($arg['params']);
}
$this->di->setShared('library', $this->library);
$this->dispatcher->setDI($this->di);
return $this->dispatcher->dispatch();
} | php | public function start($args = array())
{
$arg = $this->formatArgs($args);
/**
* Arguments and Options
*
*/
if (!empty($arg)) {
$this->prepper
->load($arg['task'])
->loadParams($arg['params'])
->prep($arg['action']);
$this->dispatcher->setTaskName($arg['task']);
$this->dispatcher->setActionName($arg['action']);
$this->dispatcher->setParams($arg['params']);
}
$this->di->setShared('library', $this->library);
$this->dispatcher->setDI($this->di);
return $this->dispatcher->dispatch();
} | [
"public",
"function",
"start",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arg",
"=",
"$",
"this",
"->",
"formatArgs",
"(",
"$",
"args",
")",
";",
"/**\n * Arguments and Options\n *\n */",
"if",
"(",
"!",
"empty",
"(",
... | Start the app
@return Output | [
"Start",
"the",
"app"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Application.php#L149-L172 |
229,159 | Danzabar/phalcon-cli | src/Application.php | Application.add | public function add($command)
{
$tasks = $this->prepper
->load(get_class($command))
->describe();
$this->library->add(['task' => $tasks, 'class' => $command]);
return $this;
} | php | public function add($command)
{
$tasks = $this->prepper
->load(get_class($command))
->describe();
$this->library->add(['task' => $tasks, 'class' => $command]);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"command",
")",
"{",
"$",
"tasks",
"=",
"$",
"this",
"->",
"prepper",
"->",
"load",
"(",
"get_class",
"(",
"$",
"command",
")",
")",
"->",
"describe",
"(",
")",
";",
"$",
"this",
"->",
"library",
"->",
"add",
... | Adds a command to the library
@return Application | [
"Adds",
"a",
"command",
"to",
"the",
"library"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Application.php#L179-L188 |
229,160 | Danzabar/phalcon-cli | src/Application.php | Application.formatArgs | public function formatArgs($args)
{
// The first argument is always the file
unset($args[0]);
if (isset($args[1])) {
$command = explode(':', $args[1]);
unset($args[1]);
} else {
// No Command Specified.
return array();
}
try {
$action = (isset($command[1]) ? $command[1] : 'main');
$cmd = $this->library->find($command[0].':'.$action);
$task = get_class($cmd);
return array(
'task' => $task,
'action' => $action,
'params' => $args
);
} catch (\Exception $e) {
// No Command FOUND
return array();
}
} | php | public function formatArgs($args)
{
// The first argument is always the file
unset($args[0]);
if (isset($args[1])) {
$command = explode(':', $args[1]);
unset($args[1]);
} else {
// No Command Specified.
return array();
}
try {
$action = (isset($command[1]) ? $command[1] : 'main');
$cmd = $this->library->find($command[0].':'.$action);
$task = get_class($cmd);
return array(
'task' => $task,
'action' => $action,
'params' => $args
);
} catch (\Exception $e) {
// No Command FOUND
return array();
}
} | [
"public",
"function",
"formatArgs",
"(",
"$",
"args",
")",
"{",
"// The first argument is always the file",
"unset",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"1",
"]",
")",
")",
"{",
"$",
"command",
"=",
"... | Format the arguments into a useable state
@return Array | [
"Format",
"the",
"arguments",
"into",
"a",
"useable",
"state"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Application.php#L205-L235 |
229,161 | PrestaShop/decimal | src/Operation/Multiplication.php | Multiplication.compute | public function compute(DecimalNumber $a, DecimalNumber $b)
{
if (function_exists('bcmul')) {
return $this->computeUsingBcMath($a, $b);
}
return $this->computeWithoutBcMath($a, $b);
} | php | public function compute(DecimalNumber $a, DecimalNumber $b)
{
if (function_exists('bcmul')) {
return $this->computeUsingBcMath($a, $b);
}
return $this->computeWithoutBcMath($a, $b);
} | [
"public",
"function",
"compute",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'bcmul'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"computeUsingBcMath",
"(",
"$",
"a",
",",
"$",
"b",
")"... | Performs the multiplication
@param DecimalNumber $a Left operand
@param DecimalNumber $b Right operand
@return DecimalNumber Result of the multiplication | [
"Performs",
"the",
"multiplication"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Multiplication.php#L26-L33 |
229,162 | PrestaShop/decimal | src/Operation/Multiplication.php | Multiplication.computeUsingBcMath | public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
$precision1 = $a->getPrecision();
$precision2 = $b->getPrecision();
return new DecimalNumber((string) bcmul($a, $b, $precision1 + $precision2));
} | php | public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
$precision1 = $a->getPrecision();
$precision2 = $b->getPrecision();
return new DecimalNumber((string) bcmul($a, $b, $precision1 + $precision2));
} | [
"public",
"function",
"computeUsingBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"$",
"precision1",
"=",
"$",
"a",
"->",
"getPrecision",
"(",
")",
";",
"$",
"precision2",
"=",
"$",
"b",
"->",
"getPrecision",
"(",
")",... | Performs the multiplication using BC Math
@param DecimalNumber $a Left operand
@param DecimalNumber $b Right operand
@return DecimalNumber Result of the multiplication | [
"Performs",
"the",
"multiplication",
"using",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Multiplication.php#L43-L49 |
229,163 | PrestaShop/decimal | src/Operation/Multiplication.php | Multiplication.computeWithoutBcMath | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
$aAsString = (string) $a;
$bAsString = (string) $b;
// optimization: if either one is zero, the result is zero
if ('0' === $aAsString || '0' === $bAsString) {
return new DecimalNumber('0');
}
// optimization: if either one is one, the result is the other one
if ('1' === $aAsString) {
return $b;
}
if ('1' === $bAsString) {
return $a;
}
$result = $this->multiplyStrings(
ltrim($a->getCoefficient(), '0'),
ltrim($b->getCoefficient(), '0')
);
$sign = ($a->isNegative() xor $b->isNegative()) ? '-' : '';
// a multiplication has at most as many decimal figures as the sum
// of the number of decimal figures the factors have
$exponent = $a->getExponent() + $b->getExponent();
return new DecimalNumber($sign . $result, $exponent);
} | php | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
$aAsString = (string) $a;
$bAsString = (string) $b;
// optimization: if either one is zero, the result is zero
if ('0' === $aAsString || '0' === $bAsString) {
return new DecimalNumber('0');
}
// optimization: if either one is one, the result is the other one
if ('1' === $aAsString) {
return $b;
}
if ('1' === $bAsString) {
return $a;
}
$result = $this->multiplyStrings(
ltrim($a->getCoefficient(), '0'),
ltrim($b->getCoefficient(), '0')
);
$sign = ($a->isNegative() xor $b->isNegative()) ? '-' : '';
// a multiplication has at most as many decimal figures as the sum
// of the number of decimal figures the factors have
$exponent = $a->getExponent() + $b->getExponent();
return new DecimalNumber($sign . $result, $exponent);
} | [
"public",
"function",
"computeWithoutBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"$",
"aAsString",
"=",
"(",
"string",
")",
"$",
"a",
";",
"$",
"bAsString",
"=",
"(",
"string",
")",
"$",
"b",
";",
"// optimization: ... | Performs the multiplication without BC Math
@param DecimalNumber $a Left operand
@param DecimalNumber $b Right operand
@return DecimalNumber Result of the multiplication | [
"Performs",
"the",
"multiplication",
"without",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Multiplication.php#L59-L89 |
229,164 | PrestaShop/decimal | src/Operation/Multiplication.php | Multiplication.multiplyStrings | private function multiplyStrings($topNumber, $bottomNumber)
{
$topNumberLength = strlen($topNumber);
$bottomNumberLength = strlen($bottomNumber);
if ($topNumberLength < $bottomNumberLength) {
// multiplication is commutative, and this algorithm
// performs better if the bottom number is shorter.
return $this->multiplyStrings($bottomNumber, $topNumber);
}
$stepNumber = 0;
$result = new DecimalNumber('0');
for ($i = $bottomNumberLength - 1; $i >= 0; $i--) {
$carryOver = 0;
$partialResult = '';
// optimization: we don't need to bother multiplying by zero
if ($bottomNumber[$i] === '0') {
$stepNumber++;
continue;
}
if ($bottomNumber[$i] === '1') {
// multiplying by one is the same as copying the top number
$partialResult = strrev($topNumber);
} else {
// digit-by-digit multiplication using carry-over
for ($j = $topNumberLength - 1; $j >= 0; $j--) {
$multiplicationResult = ($bottomNumber[$i] * $topNumber[$j]) + $carryOver;
$carryOver = floor($multiplicationResult / 10);
$partialResult .= $multiplicationResult % 10;
}
if ($carryOver > 0) {
$partialResult .= $carryOver;
}
}
// pad the partial result with as many zeros as performed steps
$padding = str_pad('', $stepNumber, '0');
$partialResult = $padding . $partialResult;
// add to the result
$result = $result->plus(
new DecimalNumber(strrev($partialResult))
);
$stepNumber++;
}
return (string) $result;
} | php | private function multiplyStrings($topNumber, $bottomNumber)
{
$topNumberLength = strlen($topNumber);
$bottomNumberLength = strlen($bottomNumber);
if ($topNumberLength < $bottomNumberLength) {
// multiplication is commutative, and this algorithm
// performs better if the bottom number is shorter.
return $this->multiplyStrings($bottomNumber, $topNumber);
}
$stepNumber = 0;
$result = new DecimalNumber('0');
for ($i = $bottomNumberLength - 1; $i >= 0; $i--) {
$carryOver = 0;
$partialResult = '';
// optimization: we don't need to bother multiplying by zero
if ($bottomNumber[$i] === '0') {
$stepNumber++;
continue;
}
if ($bottomNumber[$i] === '1') {
// multiplying by one is the same as copying the top number
$partialResult = strrev($topNumber);
} else {
// digit-by-digit multiplication using carry-over
for ($j = $topNumberLength - 1; $j >= 0; $j--) {
$multiplicationResult = ($bottomNumber[$i] * $topNumber[$j]) + $carryOver;
$carryOver = floor($multiplicationResult / 10);
$partialResult .= $multiplicationResult % 10;
}
if ($carryOver > 0) {
$partialResult .= $carryOver;
}
}
// pad the partial result with as many zeros as performed steps
$padding = str_pad('', $stepNumber, '0');
$partialResult = $padding . $partialResult;
// add to the result
$result = $result->plus(
new DecimalNumber(strrev($partialResult))
);
$stepNumber++;
}
return (string) $result;
} | [
"private",
"function",
"multiplyStrings",
"(",
"$",
"topNumber",
",",
"$",
"bottomNumber",
")",
"{",
"$",
"topNumberLength",
"=",
"strlen",
"(",
"$",
"topNumber",
")",
";",
"$",
"bottomNumberLength",
"=",
"strlen",
"(",
"$",
"bottomNumber",
")",
";",
"if",
... | Multiplies two integer numbers as strings.
This method implements a naive "long multiplication" algorithm.
@param string $topNumber
@param string $bottomNumber
@return string | [
"Multiplies",
"two",
"integer",
"numbers",
"as",
"strings",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Multiplication.php#L101-L154 |
229,165 | slickframework/slick | src/Slick/Form/Fieldset.php | Fieldset.getMessages | public function getMessages()
{
$messages = [];
/** @var Element $element */
foreach ($this->_elements as $element) {
$messages[$element->getName()] = $element->getMessages();
}
return $messages;
} | php | public function getMessages()
{
$messages = [];
/** @var Element $element */
foreach ($this->_elements as $element) {
$messages[$element->getName()] = $element->getMessages();
}
return $messages;
} | [
"public",
"function",
"getMessages",
"(",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"/** @var Element $element */",
"foreach",
"(",
"$",
"this",
"->",
"_elements",
"as",
"$",
"element",
")",
"{",
"$",
"messages",
"[",
"$",
"element",
"->",
"getName",
... | Returns current error messages
@return array | [
"Returns",
"current",
"error",
"messages"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Fieldset.php#L29-L37 |
229,166 | slickframework/slick | src/Slick/Mvc/Model.php | Model.getDescriptor | public function getDescriptor()
{
$entityDescriptor = EntityManager::getInstance()->get($this);
return Manager::getInstance()->get($entityDescriptor);
} | php | public function getDescriptor()
{
$entityDescriptor = EntityManager::getInstance()->get($this);
return Manager::getInstance()->get($entityDescriptor);
} | [
"public",
"function",
"getDescriptor",
"(",
")",
"{",
"$",
"entityDescriptor",
"=",
"EntityManager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
")",
";",
"return",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"entit... | Returns the model descriptor for this model class
@return Model\Descriptor | [
"Returns",
"the",
"model",
"descriptor",
"for",
"this",
"model",
"class"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model.php#L65-L69 |
229,167 | slickframework/slick | src/Slick/Mvc/Model.php | Model.getList | public static function getList()
{
/** @var Model $model */
$model = new static();
$fields = [
trim($model->getPrimaryKey(), '_'),
trim($model->getDisplayField(), '_')
];
$rows = Sql::createSql($model->getAdapter())
->select($model->getTableName(), $fields)
->limit(null)
->all();
$list = [];
list($id, $value) = $fields;
if (!empty($rows)) {
foreach ($rows as $row) {
$list[$row[$id]] = $row[$value];
}
}
return $list;
} | php | public static function getList()
{
/** @var Model $model */
$model = new static();
$fields = [
trim($model->getPrimaryKey(), '_'),
trim($model->getDisplayField(), '_')
];
$rows = Sql::createSql($model->getAdapter())
->select($model->getTableName(), $fields)
->limit(null)
->all();
$list = [];
list($id, $value) = $fields;
if (!empty($rows)) {
foreach ($rows as $row) {
$list[$row[$id]] = $row[$value];
}
}
return $list;
} | [
"public",
"static",
"function",
"getList",
"(",
")",
"{",
"/** @var Model $model */",
"$",
"model",
"=",
"new",
"static",
"(",
")",
";",
"$",
"fields",
"=",
"[",
"trim",
"(",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
",",
"'_'",
")",
",",
"trim",
... | Retrieves an array with primary keys and display fields
This is used mainly for selected options
@return array | [
"Retrieves",
"an",
"array",
"with",
"primary",
"keys",
"and",
"display",
"fields"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model.php#L89-L109 |
229,168 | slickframework/slick | src/Slick/Mvc/Libs/Session/FlashMessageMethods.php | FlashMessageMethods.getFlashMessages | public function getFlashMessages()
{
if (is_null($this->_flashMessages)) {
$this->_flashMessages = FlashMessages::getInstance();
}
return $this->_flashMessages;
} | php | public function getFlashMessages()
{
if (is_null($this->_flashMessages)) {
$this->_flashMessages = FlashMessages::getInstance();
}
return $this->_flashMessages;
} | [
"public",
"function",
"getFlashMessages",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_flashMessages",
")",
")",
"{",
"$",
"this",
"->",
"_flashMessages",
"=",
"FlashMessages",
"::",
"getInstance",
"(",
")",
";",
"}",
"return",
"$",
"th... | Returns the flash messages object
@return FlashMessages | [
"Returns",
"the",
"flash",
"messages",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Libs/Session/FlashMessageMethods.php#L97-L103 |
229,169 | slickframework/slick | src/Slick/Cache/Driver/Memcached.php | Memcached.connect | public function connect()
{
$this->_service = new SplMemcached();
$this->_service->addServer($this->_host, $this->_port);
$stats = $this->_service->getStats();
if (isset($stats[$this->_host.":".$this->_port])) {
$this->_connected = true;
} else {
throw new ServiceException(
"Unable to connect to Memcached service"
);
}
return $this;
} | php | public function connect()
{
$this->_service = new SplMemcached();
$this->_service->addServer($this->_host, $this->_port);
$stats = $this->_service->getStats();
if (isset($stats[$this->_host.":".$this->_port])) {
$this->_connected = true;
} else {
throw new ServiceException(
"Unable to connect to Memcached service"
);
}
return $this;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"this",
"->",
"_service",
"=",
"new",
"SplMemcached",
"(",
")",
";",
"$",
"this",
"->",
"_service",
"->",
"addServer",
"(",
"$",
"this",
"->",
"_host",
",",
"$",
"this",
"->",
"_port",
")",
";",
... | Connects to Memcached service.
@throws ServiceException If any error occurs during
Memcache initialization
@return Memcached A self instance for chaining method calls. | [
"Connects",
"to",
"Memcached",
"service",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/Memcached.php#L83-L97 |
229,170 | slickframework/slick | src/Slick/Cache/Driver/Memcached.php | Memcached.disconnect | public function disconnect()
{
if ($this->_isValidService()) {
$this->getService()->quit();
$this->_service = null;
$this->_connected = false;
}
return $this;
} | php | public function disconnect()
{
if ($this->_isValidService()) {
$this->getService()->quit();
$this->_service = null;
$this->_connected = false;
}
return $this;
} | [
"public",
"function",
"disconnect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isValidService",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getService",
"(",
")",
"->",
"quit",
"(",
")",
";",
"$",
"this",
"->",
"_service",
"=",
"null",
";",
"$",
... | Disconnects the Memcached service.
@return SplMemcached A self instance for chaining
method calls. | [
"Disconnects",
"the",
"Memcached",
"service",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/Memcached.php#L115-L124 |
229,171 | slickframework/slick | src/Slick/Cache/Driver/Memcached.php | Memcached._isValidService | protected function _isValidService()
{
$isEmpty = empty($this->_service);
$isInstance = $this->_service instanceof SplMemcached;
if ($this->_connected && $isInstance && !$isEmpty) {
return true;
}
return false;
} | php | protected function _isValidService()
{
$isEmpty = empty($this->_service);
$isInstance = $this->_service instanceof SplMemcached;
if ($this->_connected && $isInstance && !$isEmpty) {
return true;
}
return false;
} | [
"protected",
"function",
"_isValidService",
"(",
")",
"{",
"$",
"isEmpty",
"=",
"empty",
"(",
"$",
"this",
"->",
"_service",
")",
";",
"$",
"isInstance",
"=",
"$",
"this",
"->",
"_service",
"instanceof",
"SplMemcached",
";",
"if",
"(",
"$",
"this",
"->",... | Checks if service is a valid instance and its connected.
@return boolean True if service is connected and valid, false otherwise. | [
"Checks",
"if",
"service",
"is",
"a",
"valid",
"instance",
"and",
"its",
"connected",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/Memcached.php#L248-L258 |
229,172 | slickframework/slick | src/Slick/Common/Inspector/AnnotationsList.php | AnnotationsList.offsetSet | public function offsetSet($offset, $value)
{
if ($value instanceof AnnotationInterface) {
$offset = $value->getName();
parent::offsetSet($offset, $value);
} else {
throw new Exception\InvalidArgumentException(
"Only annotation objects can be added to an AnnotationsList."
);
}
} | php | public function offsetSet($offset, $value)
{
if ($value instanceof AnnotationInterface) {
$offset = $value->getName();
parent::offsetSet($offset, $value);
} else {
throw new Exception\InvalidArgumentException(
"Only annotation objects can be added to an AnnotationsList."
);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"AnnotationInterface",
")",
"{",
"$",
"offset",
"=",
"$",
"value",
"->",
"getName",
"(",
")",
";",
"parent",
"::",
"offsetSet",
"... | Sets the value at the specified index to value
Overrides to throw an exception if the value provided is not an
instance of annotation interface
@param mixed $offset
@param mixed $value
@throws \Slick\Common\Exception\InvalidArgumentException if the value
provided is not an instance of annotation interface | [
"Sets",
"the",
"value",
"at",
"the",
"specified",
"index",
"to",
"value"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/AnnotationsList.php#L50-L60 |
229,173 | slickframework/slick | src/Slick/Common/Inspector/AnnotationsList.php | AnnotationsList.hasAnnotation | public function hasAnnotation($name)
{
$name = str_replace('@', '', $name);
foreach ($this as $annotation) {
/** @var AnnotationInterface $annotation */
if ($annotation->getName() == $name) {
return true;
}
}
return false;
} | php | public function hasAnnotation($name)
{
$name = str_replace('@', '', $name);
foreach ($this as $annotation) {
/** @var AnnotationInterface $annotation */
if ($annotation->getName() == $name) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasAnnotation",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'@'",
",",
"''",
",",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"annotation",
")",
"{",
"/** @var AnnotationInterface $annotation... | Checks if current list contains an annotation with the provided name
@param string $name
@return boolean True if current list contains an annotation with the
provided name, False otherwise | [
"Checks",
"if",
"current",
"list",
"contains",
"an",
"annotation",
"with",
"the",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/AnnotationsList.php#L70-L80 |
229,174 | slickframework/slick | src/Slick/Common/Inspector/AnnotationsList.php | AnnotationsList.getAnnotation | public function getAnnotation($name)
{
if (!$this->hasAnnotation($name)) {
throw new Exception\InvalidArgumentException(
"Annotation {$name} is not found in this list."
);
}
$name = str_replace('@', '', $name);
return $this[$name];
} | php | public function getAnnotation($name)
{
if (!$this->hasAnnotation($name)) {
throw new Exception\InvalidArgumentException(
"Annotation {$name} is not found in this list."
);
}
$name = str_replace('@', '', $name);
return $this[$name];
} | [
"public",
"function",
"getAnnotation",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAnnotation",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"Annotation {$name} is not found in this... | Returns the annotation with the provided name
@param string $name
@return AnnotationInterface
@throws \Slick\Common\Exception\InvalidArgumentException | [
"Returns",
"the",
"annotation",
"with",
"the",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/AnnotationsList.php#L90-L100 |
229,175 | lekoala/silverstripe-form-extras | code/FormExtraJquery.php | FormExtraJquery.isAdminBackend | public static function isAdminBackend()
{
/* @var $controller Controller */
$controller = Controller::curr();
if (
$controller instanceof LeftAndMain ||
$controller instanceof DevelopmentAdmin ||
$controller instanceof DatabaseAdmin ||
(class_exists('DevBuildController') && $controller instanceof DevBuildController)
) {
return true;
}
return false;
} | php | public static function isAdminBackend()
{
/* @var $controller Controller */
$controller = Controller::curr();
if (
$controller instanceof LeftAndMain ||
$controller instanceof DevelopmentAdmin ||
$controller instanceof DatabaseAdmin ||
(class_exists('DevBuildController') && $controller instanceof DevBuildController)
) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"isAdminBackend",
"(",
")",
"{",
"/* @var $controller Controller */",
"$",
"controller",
"=",
"Controller",
"::",
"curr",
"(",
")",
";",
"if",
"(",
"$",
"controller",
"instanceof",
"LeftAndMain",
"||",
"$",
"controller",
"instanceof... | Helper to detect if we are in admin or development admin
@return boolean | [
"Helper",
"to",
"detect",
"if",
"we",
"are",
"in",
"admin",
"or",
"development",
"admin"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraJquery.php#L48-L62 |
229,176 | lekoala/silverstripe-form-extras | code/FormExtraJquery.php | FormExtraJquery.include_jquery_ui | public static function include_jquery_ui()
{
if (self::$disabled || in_array('jquery_ui', self::$included)) {
return;
}
// Avoid conflicts with jquery ui version of the cms
if (self::isAdminBackend()) {
self::$included[] = 'jquery_ui';
return;
}
switch (self::config()->jquery_ui_version) {
case self::JQUERY_UI_FRAMEWORK:
$path = THIRDPARTY_DIR . '/jquery-ui/jquery-ui';
break;
case self::JQUERY_UI_V1:
$path = FORM_EXTRAS_PATH . '/javascript/jquery-ui/jquery-ui';
break;
default:
$path = THIRDPARTY_DIR . '/jquery-ui/jquery-ui';
break;
}
if (Director::isDev()) {
Requirements::javascript($path . '.js');
Requirements::block($path . '.min.js');
} else {
Requirements::javascript($path . '.min.js');
Requirements::block($path . '.js');
}
if (self::config()->jquery_ui_theme != self::JQUERY_UI_THEME_DEFAULT) {
Requirements::block(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
Requirements::block(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.min.css');
$theme = self::config()->jquery_ui_theme;
// in case the less styles are used, developer should include it himself
if ($theme != self::JQUERY_UI_THEME_NONE) {
Requirements::css($theme);
}
} else {
if (Director::isDev()) {
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
} else {
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.min.css');
}
}
self::$included[] = 'jquery_ui';
} | php | public static function include_jquery_ui()
{
if (self::$disabled || in_array('jquery_ui', self::$included)) {
return;
}
// Avoid conflicts with jquery ui version of the cms
if (self::isAdminBackend()) {
self::$included[] = 'jquery_ui';
return;
}
switch (self::config()->jquery_ui_version) {
case self::JQUERY_UI_FRAMEWORK:
$path = THIRDPARTY_DIR . '/jquery-ui/jquery-ui';
break;
case self::JQUERY_UI_V1:
$path = FORM_EXTRAS_PATH . '/javascript/jquery-ui/jquery-ui';
break;
default:
$path = THIRDPARTY_DIR . '/jquery-ui/jquery-ui';
break;
}
if (Director::isDev()) {
Requirements::javascript($path . '.js');
Requirements::block($path . '.min.js');
} else {
Requirements::javascript($path . '.min.js');
Requirements::block($path . '.js');
}
if (self::config()->jquery_ui_theme != self::JQUERY_UI_THEME_DEFAULT) {
Requirements::block(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
Requirements::block(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.min.css');
$theme = self::config()->jquery_ui_theme;
// in case the less styles are used, developer should include it himself
if ($theme != self::JQUERY_UI_THEME_NONE) {
Requirements::css($theme);
}
} else {
if (Director::isDev()) {
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
} else {
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.min.css');
}
}
self::$included[] = 'jquery_ui';
} | [
"public",
"static",
"function",
"include_jquery_ui",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"disabled",
"||",
"in_array",
"(",
"'jquery_ui'",
",",
"self",
"::",
"$",
"included",
")",
")",
"{",
"return",
";",
"}",
"// Avoid conflicts with jquery ui versio... | Include jquery ui and theme | [
"Include",
"jquery",
"ui",
"and",
"theme"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraJquery.php#L156-L201 |
229,177 | lekoala/silverstripe-form-extras | code/FormExtraJquery.php | FormExtraJquery.include_entwine | public static function include_entwine()
{
if (self::$disabled || in_array('entwine', self::$included)) {
return;
}
switch (self::config()->jquery_ui) {
case self::JQUERY_FRAMEWORK:
Requirements::javascript('framework/javascript/thirdparty/jquery-entwine/jquery.entwine-dist.js');
Requirements::block(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.js');
Requirements::block(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.min.js');
break;
default:
Requirements::block('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
if (Director::isDev()) {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.js');
} else {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.min.js');
}
break;
}
self::$included[] = 'entwine';
} | php | public static function include_entwine()
{
if (self::$disabled || in_array('entwine', self::$included)) {
return;
}
switch (self::config()->jquery_ui) {
case self::JQUERY_FRAMEWORK:
Requirements::javascript('framework/javascript/thirdparty/jquery-entwine/jquery.entwine-dist.js');
Requirements::block(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.js');
Requirements::block(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.min.js');
break;
default:
Requirements::block('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
if (Director::isDev()) {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.js');
} else {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/entwine/jquery.entwine-dist.min.js');
}
break;
}
self::$included[] = 'entwine';
} | [
"public",
"static",
"function",
"include_entwine",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"disabled",
"||",
"in_array",
"(",
"'entwine'",
",",
"self",
"::",
"$",
"included",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"self",
"::",
"config"... | Include jquery entwine | [
"Include",
"jquery",
"entwine"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraJquery.php#L206-L227 |
229,178 | slickframework/slick | src/Slick/Mvc/View.php | View.render | public function render()
{
$this->engine->parse($this->file);
$output = $this->engine->process($this->data);
return $output;
} | php | public function render()
{
$this->engine->parse($this->file);
$output = $this->engine->process($this->data);
return $output;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"engine",
"->",
"parse",
"(",
"$",
"this",
"->",
"file",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"engine",
"->",
"process",
"(",
"$",
"this",
"->",
"data",
")",
";",
"retu... | Renders this view.
@return string The rendered output | [
"Renders",
"this",
"view",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/View.php#L71-L76 |
229,179 | slickframework/slick | src/Slick/Mvc/View.php | View.getEngine | public function getEngine()
{
if (is_null($this->_engine)) {
$template = new Template($this->engineOptions);
$this->_engine = $template->initialize();
}
return $this->_engine;
} | php | public function getEngine()
{
if (is_null($this->_engine)) {
$template = new Template($this->engineOptions);
$this->_engine = $template->initialize();
}
return $this->_engine;
} | [
"public",
"function",
"getEngine",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_engine",
")",
")",
"{",
"$",
"template",
"=",
"new",
"Template",
"(",
"$",
"this",
"->",
"engineOptions",
")",
";",
"$",
"this",
"->",
"_engine",
"=",
... | Returns the template engine for this view
@return EngineInterface | [
"Returns",
"the",
"template",
"engine",
"for",
"this",
"view"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/View.php#L96-L103 |
229,180 | slickframework/slick | src/Slick/Database/Schema/Loader/Standard.php | Standard.getTables | public function getTables()
{
if (is_null($this->_tables)) {
$result = $this->_adapter->query(
$this->_getTablesSql,
[$this->_adapter->getSchemaName()]
);
$names = [];
foreach ($result as $table) {
$names[] = $table['TABLE_NAME'];
}
$this->_tables = $names;
}
return $this->_tables;
} | php | public function getTables()
{
if (is_null($this->_tables)) {
$result = $this->_adapter->query(
$this->_getTablesSql,
[$this->_adapter->getSchemaName()]
);
$names = [];
foreach ($result as $table) {
$names[] = $table['TABLE_NAME'];
}
$this->_tables = $names;
}
return $this->_tables;
} | [
"public",
"function",
"getTables",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_tables",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_adapter",
"->",
"query",
"(",
"$",
"this",
"->",
"_getTablesSql",
",",
"[",
"$",
"thi... | Returns a list of table names
@return string[] | [
"Returns",
"a",
"list",
"of",
"table",
"names"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Standard.php#L225-L241 |
229,181 | slickframework/slick | src/Slick/Database/Schema/Loader/Standard.php | Standard.getSchema | public function getSchema()
{
$schema = new Schema(['adapter' => $this->_adapter]);
$tables = $this->getTables();
foreach ($tables as $tableName) {
$schema->addTable($this->getTable($tableName));
}
return $schema;
} | php | public function getSchema()
{
$schema = new Schema(['adapter' => $this->_adapter]);
$tables = $this->getTables();
foreach ($tables as $tableName) {
$schema->addTable($this->getTable($tableName));
}
return $schema;
} | [
"public",
"function",
"getSchema",
"(",
")",
"{",
"$",
"schema",
"=",
"new",
"Schema",
"(",
"[",
"'adapter'",
"=>",
"$",
"this",
"->",
"_adapter",
"]",
")",
";",
"$",
"tables",
"=",
"$",
"this",
"->",
"getTables",
"(",
")",
";",
"foreach",
"(",
"$"... | Returns the schema for the given interface
@return SchemaInterface | [
"Returns",
"the",
"schema",
"for",
"the",
"given",
"interface"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Standard.php#L274-L283 |
229,182 | slickframework/slick | src/Slick/Database/Schema/Loader/Standard.php | Standard._getColumns | protected function _getColumns($tableName)
{
$params = [
':schemaName' => $this->_adapter->getSchemaName(),
':tableName' => $tableName
];
return $this->_adapter->query($this->_getColumnsSql, $params);
} | php | protected function _getColumns($tableName)
{
$params = [
':schemaName' => $this->_adapter->getSchemaName(),
':tableName' => $tableName
];
return $this->_adapter->query($this->_getColumnsSql, $params);
} | [
"protected",
"function",
"_getColumns",
"(",
"$",
"tableName",
")",
"{",
"$",
"params",
"=",
"[",
"':schemaName'",
"=>",
"$",
"this",
"->",
"_adapter",
"->",
"getSchemaName",
"(",
")",
",",
"':tableName'",
"=>",
"$",
"tableName",
"]",
";",
"return",
"$",
... | Retrieve the column metadata from a given table
@param string $tableName
@return \Slick\Database\RecordList | [
"Retrieve",
"the",
"column",
"metadata",
"from",
"a",
"given",
"table"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Standard.php#L291-L299 |
229,183 | slickframework/slick | src/Slick/Database/Schema/Loader/Standard.php | Standard._getColumnClass | protected function _getColumnClass($typeName)
{
$class = $this->_defaultColumn;
foreach ($this->_typeExpressions as $className => $exp) {
if (preg_match("/{$exp}/i", $typeName)) {
$class = $className;
break;
}
}
return $class;
} | php | protected function _getColumnClass($typeName)
{
$class = $this->_defaultColumn;
foreach ($this->_typeExpressions as $className => $exp) {
if (preg_match("/{$exp}/i", $typeName)) {
$class = $className;
break;
}
}
return $class;
} | [
"protected",
"function",
"_getColumnClass",
"(",
"$",
"typeName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"_defaultColumn",
";",
"foreach",
"(",
"$",
"this",
"->",
"_typeExpressions",
"as",
"$",
"className",
"=>",
"$",
"exp",
")",
"{",
"if",
"(",... | Returns the column class name for a given column type
@param string $typeName
@return string | [
"Returns",
"the",
"column",
"class",
"name",
"for",
"a",
"given",
"column",
"type"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Standard.php#L308-L318 |
229,184 | slickframework/slick | src/Slick/Database/Schema/Loader/Standard.php | Standard._getConstraintClass | protected function _getConstraintClass($type)
{
$class = null;
foreach ($this->_constraintExpressions as $className => $exp) {
if (preg_match("/{$exp}/i", $type)) {
$class = $className;
break;
}
}
return $class;
} | php | protected function _getConstraintClass($type)
{
$class = null;
foreach ($this->_constraintExpressions as $className => $exp) {
if (preg_match("/{$exp}/i", $type)) {
$class = $className;
break;
}
}
return $class;
} | [
"protected",
"function",
"_getConstraintClass",
"(",
"$",
"type",
")",
"{",
"$",
"class",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_constraintExpressions",
"as",
"$",
"className",
"=>",
"$",
"exp",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"... | Retrieves the constraint class name for provided constraint type
@param string $type
@return null|string | [
"Retrieves",
"the",
"constraint",
"class",
"name",
"for",
"provided",
"constraint",
"type"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Standard.php#L394-L404 |
229,185 | mjacobus/php-query-builder | lib/PO/QueryBuilder/Clauses/FromClause.php | FromClause.addJoin | private function addJoin($type, $join, $on = null)
{
$join = "$type JOIN $join";
if ($on !== null) {
$join .= " ON $on";
}
$this->addParam($join);
return $this;
} | php | private function addJoin($type, $join, $on = null)
{
$join = "$type JOIN $join";
if ($on !== null) {
$join .= " ON $on";
}
$this->addParam($join);
return $this;
} | [
"private",
"function",
"addJoin",
"(",
"$",
"type",
",",
"$",
"join",
",",
"$",
"on",
"=",
"null",
")",
"{",
"$",
"join",
"=",
"\"$type JOIN $join\"",
";",
"if",
"(",
"$",
"on",
"!==",
"null",
")",
"{",
"$",
"join",
".=",
"\" ON $on\"",
";",
"}",
... | Joins a table
@param string $type the type of join (INNER, LEFT)
@param string $join the table to join
@param string $on the condtition to join
@return PO\QueryBuilder\Clauses\FromClause | [
"Joins",
"a",
"table"
] | eb7a90ae3bc433659306807535b39f12ce4dfd9f | https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder/Clauses/FromClause.php#L56-L67 |
229,186 | pixers/PixersDoctrineProfilerBundle | DataCollector/QueryCollector.php | QueryCollector.selectQuerySource | protected function selectQuerySource(&$query)
{
foreach ($query['trace'] as $i => &$trace) {
$isSource = true;
foreach ($this->getNamespacesCutoff() as $namespace) {
$namespace = trim($namespace, '/\\').'\\';
if (isset($trace['class']) && strpos($trace['class'], $namespace) !== false) {
$isSource = false;
}
}
if ($isSource) {
$query['trace'][$i - 1]['query_source'] = true;
break;
}
}
} | php | protected function selectQuerySource(&$query)
{
foreach ($query['trace'] as $i => &$trace) {
$isSource = true;
foreach ($this->getNamespacesCutoff() as $namespace) {
$namespace = trim($namespace, '/\\').'\\';
if (isset($trace['class']) && strpos($trace['class'], $namespace) !== false) {
$isSource = false;
}
}
if ($isSource) {
$query['trace'][$i - 1]['query_source'] = true;
break;
}
}
} | [
"protected",
"function",
"selectQuerySource",
"(",
"&",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"query",
"[",
"'trace'",
"]",
"as",
"$",
"i",
"=>",
"&",
"$",
"trace",
")",
"{",
"$",
"isSource",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"-... | Marks selected trace item as query source based on invoking class namespace
@param array $query | [
"Marks",
"selected",
"trace",
"item",
"as",
"query",
"source",
"based",
"on",
"invoking",
"class",
"namespace"
] | 31038fab5f78b301ba369313c5485000505450e3 | https://github.com/pixers/PixersDoctrineProfilerBundle/blob/31038fab5f78b301ba369313c5485000505450e3/DataCollector/QueryCollector.php#L80-L95 |
229,187 | pixers/PixersDoctrineProfilerBundle | DataCollector/QueryCollector.php | QueryCollector.getDuplicatedCount | public function getDuplicatedCount()
{
$count = 0;
foreach ($this->getQueries() as $query) {
if ($query['count'] > 1) {
$count += $query['count'] - 1;
}
}
return $count;
} | php | public function getDuplicatedCount()
{
$count = 0;
foreach ($this->getQueries() as $query) {
if ($query['count'] > 1) {
$count += $query['count'] - 1;
}
}
return $count;
} | [
"public",
"function",
"getDuplicatedCount",
"(",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueries",
"(",
")",
"as",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"[",
"'count'",
"]",
">",
"1",
")",
"{",
"$"... | Returns duplicated queries count.
@return int | [
"Returns",
"duplicated",
"queries",
"count",
"."
] | 31038fab5f78b301ba369313c5485000505450e3 | https://github.com/pixers/PixersDoctrineProfilerBundle/blob/31038fab5f78b301ba369313c5485000505450e3/DataCollector/QueryCollector.php#L112-L122 |
229,188 | pixers/PixersDoctrineProfilerBundle | DataCollector/QueryCollector.php | QueryCollector.getCallGraph | public function getCallGraph()
{
$node = $root = new Node(array());
foreach ($this->getQueries() as $query) {
foreach (array_reverse($query['trace']) as $trace) {
$node = $node->push($trace);
}
$node->addValue($query);
$node = $root;
}
return $root;
} | php | public function getCallGraph()
{
$node = $root = new Node(array());
foreach ($this->getQueries() as $query) {
foreach (array_reverse($query['trace']) as $trace) {
$node = $node->push($trace);
}
$node->addValue($query);
$node = $root;
}
return $root;
} | [
"public",
"function",
"getCallGraph",
"(",
")",
"{",
"$",
"node",
"=",
"$",
"root",
"=",
"new",
"Node",
"(",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueries",
"(",
")",
"as",
"$",
"query",
")",
"{",
"foreach",
"(",
"ar... | Returns queries stacktrace tree root node
@return Node | [
"Returns",
"queries",
"stacktrace",
"tree",
"root",
"node"
] | 31038fab5f78b301ba369313c5485000505450e3 | https://github.com/pixers/PixersDoctrineProfilerBundle/blob/31038fab5f78b301ba369313c5485000505450e3/DataCollector/QueryCollector.php#L173-L185 |
229,189 | jameshalsall/licenser | src/Licenser.php | Licenser.process | public function process($path, $replaceExisting = false, $dryRun = false)
{
$iterator = $this->getFiles($path);
foreach ($iterator as $file) {
$this->processFile($file, $replaceExisting, $dryRun);
}
} | php | public function process($path, $replaceExisting = false, $dryRun = false)
{
$iterator = $this->getFiles($path);
foreach ($iterator as $file) {
$this->processFile($file, $replaceExisting, $dryRun);
}
} | [
"public",
"function",
"process",
"(",
"$",
"path",
",",
"$",
"replaceExisting",
"=",
"false",
",",
"$",
"dryRun",
"=",
"false",
")",
"{",
"$",
"iterator",
"=",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"iterator"... | Processes a path and adds licenses
@param string $path The path to the files/directory
@param bool $replaceExisting True to replace existing license headers
@param bool $dryRun True to report modified files and to not make any modifications | [
"Processes",
"a",
"path",
"and",
"adds",
"licenses"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L118-L125 |
229,190 | jameshalsall/licenser | src/Licenser.php | Licenser.check | public function check($path)
{
foreach ($this->getFiles($path) as $file) {
$this->checkFile($file);
}
} | php | public function check($path)
{
foreach ($this->getFiles($path) as $file) {
$this->checkFile($file);
}
} | [
"public",
"function",
"check",
"(",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"path",
")",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"checkFile",
"(",
"$",
"file",
")",
";",
"}",
"}"
] | Checks a single file path
@param string $path The path to the files/directory | [
"Checks",
"a",
"single",
"file",
"path"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L132-L137 |
229,191 | jameshalsall/licenser | src/Licenser.php | Licenser.processFile | private function processFile(SplFileInfo $file, $replaceExisting, $dryRun)
{
if ($file->isDir()) {
return;
}
$tokens = token_get_all($file->getContents());
$licenseTokenIndex = $this->getLicenseTokenIndex($tokens);
if (null !== $licenseTokenIndex && true === $replaceExisting) {
$this->removeExistingLicense($file, $tokens, $licenseTokenIndex, $dryRun);
}
if (null === $licenseTokenIndex || true === $replaceExisting) {
$this->log(sprintf('<fg=green>[+]</> Adding license header for <options=bold>%s</>', $file->getRealPath()));
if (true === $dryRun) {
return;
}
$license = $this->getLicenseAsComment();
$content = preg_replace('/<\?php/', '<?php' . PHP_EOL . PHP_EOL . $license, $file->getContents(), 1);
file_put_contents($file->getRealPath(), $content);
} else {
$this->log(sprintf('<fg=cyan>[S]</> Skipping <options=bold>%s</>', $file->getRealPath()));
}
} | php | private function processFile(SplFileInfo $file, $replaceExisting, $dryRun)
{
if ($file->isDir()) {
return;
}
$tokens = token_get_all($file->getContents());
$licenseTokenIndex = $this->getLicenseTokenIndex($tokens);
if (null !== $licenseTokenIndex && true === $replaceExisting) {
$this->removeExistingLicense($file, $tokens, $licenseTokenIndex, $dryRun);
}
if (null === $licenseTokenIndex || true === $replaceExisting) {
$this->log(sprintf('<fg=green>[+]</> Adding license header for <options=bold>%s</>', $file->getRealPath()));
if (true === $dryRun) {
return;
}
$license = $this->getLicenseAsComment();
$content = preg_replace('/<\?php/', '<?php' . PHP_EOL . PHP_EOL . $license, $file->getContents(), 1);
file_put_contents($file->getRealPath(), $content);
} else {
$this->log(sprintf('<fg=cyan>[S]</> Skipping <options=bold>%s</>', $file->getRealPath()));
}
} | [
"private",
"function",
"processFile",
"(",
"SplFileInfo",
"$",
"file",
",",
"$",
"replaceExisting",
",",
"$",
"dryRun",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"token_get_all",
"(",
... | Processes a single file
@param SplFileInfo $file The path to the file
@param bool $replaceExisting True to replace existing license header
@param bool $dryRun True to report a modified file and to not make modifications | [
"Processes",
"a",
"single",
"file"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L146-L173 |
229,192 | jameshalsall/licenser | src/Licenser.php | Licenser.removeExistingLicense | private function removeExistingLicense(SplFileInfo $file, array $tokens, $licenseIndex, $dryRun)
{
$this->log(sprintf('<fg=red>[-]</> Removing license header for <options=bold>%s</>', $file->getRealPath()));
if (true === $dryRun) {
return;
}
$content = $file->getContents();
$removals = array();
// ignore index 0 (this should always be <?php tag) and find all whitespace tokens before license
for ($index = 1; $index <= $licenseIndex; $index++) {
$token = $tokens[$index];
if ($token[0] !== T_WHITESPACE && $token[0] !== T_COMMENT) {
continue;
}
$startLineNumber = $token[2];
$removalLength = strlen($token[1]);
// find start line in content
$currentLineNumber = 1;
$removalStart = 0;
while ($currentLineNumber < $startLineNumber) {
$removalStart = strpos($content, PHP_EOL, $removalStart) + strlen(PHP_EOL);
$currentLineNumber++;
}
$removals[] = new TokenRemoval($removalStart, $removalLength);
}
$removalOffset = 0;
/** @var $removal TokenRemoval */
foreach ($removals as $removal) {
$content = substr($content, 0, $removal->getStart() - $removalOffset) . substr($content, $removal->getEnd());
$removalOffset += $removal->getLength();
}
file_put_contents($file->getRealPath(), $content);
} | php | private function removeExistingLicense(SplFileInfo $file, array $tokens, $licenseIndex, $dryRun)
{
$this->log(sprintf('<fg=red>[-]</> Removing license header for <options=bold>%s</>', $file->getRealPath()));
if (true === $dryRun) {
return;
}
$content = $file->getContents();
$removals = array();
// ignore index 0 (this should always be <?php tag) and find all whitespace tokens before license
for ($index = 1; $index <= $licenseIndex; $index++) {
$token = $tokens[$index];
if ($token[0] !== T_WHITESPACE && $token[0] !== T_COMMENT) {
continue;
}
$startLineNumber = $token[2];
$removalLength = strlen($token[1]);
// find start line in content
$currentLineNumber = 1;
$removalStart = 0;
while ($currentLineNumber < $startLineNumber) {
$removalStart = strpos($content, PHP_EOL, $removalStart) + strlen(PHP_EOL);
$currentLineNumber++;
}
$removals[] = new TokenRemoval($removalStart, $removalLength);
}
$removalOffset = 0;
/** @var $removal TokenRemoval */
foreach ($removals as $removal) {
$content = substr($content, 0, $removal->getStart() - $removalOffset) . substr($content, $removal->getEnd());
$removalOffset += $removal->getLength();
}
file_put_contents($file->getRealPath(), $content);
} | [
"private",
"function",
"removeExistingLicense",
"(",
"SplFileInfo",
"$",
"file",
",",
"array",
"$",
"tokens",
",",
"$",
"licenseIndex",
",",
"$",
"dryRun",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'<fg=red>[-]</> Removing license header for <optio... | Removes an existing license header from a file
@param SplFileInfo $file The file to remove the license header from
@param array $tokens File token information
@param integer $licenseIndex License token index
@param bool $dryRun True to report a modified file and not to make modifications | [
"Removes",
"an",
"existing",
"license",
"header",
"from",
"a",
"file"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L183-L228 |
229,193 | jameshalsall/licenser | src/Licenser.php | Licenser.checkFile | private function checkFile(SplFileInfo $file)
{
$tokens = token_get_all($file->getContents());
$licenseTokenIndex = $this->getLicenseTokenIndex($tokens);
if ($licenseTokenIndex === null) {
$this->log(sprintf('Missing license header in "%s"', $file->getRealPath()));
} elseif ($tokens[$licenseTokenIndex][1] != $this->getLicenseAsComment()) {
$this->log(sprintf('Different license header in "%s"', $file->getRealPath()));
}
} | php | private function checkFile(SplFileInfo $file)
{
$tokens = token_get_all($file->getContents());
$licenseTokenIndex = $this->getLicenseTokenIndex($tokens);
if ($licenseTokenIndex === null) {
$this->log(sprintf('Missing license header in "%s"', $file->getRealPath()));
} elseif ($tokens[$licenseTokenIndex][1] != $this->getLicenseAsComment()) {
$this->log(sprintf('Different license header in "%s"', $file->getRealPath()));
}
} | [
"private",
"function",
"checkFile",
"(",
"SplFileInfo",
"$",
"file",
")",
"{",
"$",
"tokens",
"=",
"token_get_all",
"(",
"$",
"file",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"licenseTokenIndex",
"=",
"$",
"this",
"->",
"getLicenseTokenIndex",
"(",
"$... | Checks the header of a single file
@param SplFileInfo $file The file to check | [
"Checks",
"the",
"header",
"of",
"a",
"single",
"file"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L249-L259 |
229,194 | jameshalsall/licenser | src/Licenser.php | Licenser.getLicenseTokenIndex | private function getLicenseTokenIndex(array $tokens)
{
$licenseTokenIndex = null;
foreach ($tokens as $index => $token) {
if ($token[0] === T_COMMENT) {
$licenseTokenIndex = $index;
}
// if we reach the class declaration then it does not have a license
if ($token[0] === T_CLASS) {
break;
}
}
return $licenseTokenIndex;
} | php | private function getLicenseTokenIndex(array $tokens)
{
$licenseTokenIndex = null;
foreach ($tokens as $index => $token) {
if ($token[0] === T_COMMENT) {
$licenseTokenIndex = $index;
}
// if we reach the class declaration then it does not have a license
if ($token[0] === T_CLASS) {
break;
}
}
return $licenseTokenIndex;
} | [
"private",
"function",
"getLicenseTokenIndex",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"licenseTokenIndex",
"=",
"null",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"index",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
... | Returns the index of the first token that is a comment
@param array $tokens An array of the tokens in the file
@return int|null The index of the token or null when no comment is found before the class declaration | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"token",
"that",
"is",
"a",
"comment"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L284-L300 |
229,195 | jameshalsall/licenser | src/Licenser.php | Licenser.getLicenseAsComment | private function getLicenseAsComment()
{
$license = explode(PHP_EOL, $this->licenseHeader);
// if there are a bunch of new lines at the end of the license file
// then we want to remove these
while (end($license) === '') {
array_pop($license);
}
reset($license);
$license = array_map(function ($licenseLine) {
return rtrim(' * ' . $licenseLine);
}, $license);
$license = implode(PHP_EOL, $license);
$license = '/*' . PHP_EOL . $license . PHP_EOL . ' */';
return $license;
} | php | private function getLicenseAsComment()
{
$license = explode(PHP_EOL, $this->licenseHeader);
// if there are a bunch of new lines at the end of the license file
// then we want to remove these
while (end($license) === '') {
array_pop($license);
}
reset($license);
$license = array_map(function ($licenseLine) {
return rtrim(' * ' . $licenseLine);
}, $license);
$license = implode(PHP_EOL, $license);
$license = '/*' . PHP_EOL . $license . PHP_EOL . ' */';
return $license;
} | [
"private",
"function",
"getLicenseAsComment",
"(",
")",
"{",
"$",
"license",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"this",
"->",
"licenseHeader",
")",
";",
"// if there are a bunch of new lines at the end of the license file",
"// then we want to remove these",
"while",... | Returns the license formatted as a comment
@return string | [
"Returns",
"the",
"license",
"formatted",
"as",
"a",
"comment"
] | 41fce6a66bf42e0045bd479397f788c83f7d78af | https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Licenser.php#L307-L326 |
229,196 | lekoala/silverstripe-form-extras | code/fields/TimeDropdownField.php | TimeDropdownField.parseTime | protected function parseTime($value, $format, $locale = null, $exactMatch = false)
{
// Check if the date is in the correct format
if (!Zend_Date::isDate($value, $format)) {
return null;
}
// Parse the value
$valueObject = new Zend_Date($value, $format, $locale);
// For exact matches, ensure the value preserves formatting after conversion
if ($exactMatch && ($value !== $valueObject->get($format))) {
return null;
} else {
return $valueObject;
}
} | php | protected function parseTime($value, $format, $locale = null, $exactMatch = false)
{
// Check if the date is in the correct format
if (!Zend_Date::isDate($value, $format)) {
return null;
}
// Parse the value
$valueObject = new Zend_Date($value, $format, $locale);
// For exact matches, ensure the value preserves formatting after conversion
if ($exactMatch && ($value !== $valueObject->get($format))) {
return null;
} else {
return $valueObject;
}
} | [
"protected",
"function",
"parseTime",
"(",
"$",
"value",
",",
"$",
"format",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"exactMatch",
"=",
"false",
")",
"{",
"// Check if the date is in the correct format",
"if",
"(",
"!",
"Zend_Date",
"::",
"isDate",
"(",
"... | Parses a time into a Zend_Date object
@param string $value Raw value
@param string $format Format string to check against
@param string $locale Optional locale to parse against
@param boolean $exactMatch Flag indicating that the date must be in this
exact format, and is unchanged after being parsed and written out
@return Zend_Date Returns the Zend_Date, or null if not in the specified format | [
"Parses",
"a",
"time",
"into",
"a",
"Zend_Date",
"object"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TimeDropdownField.php#L102-L118 |
229,197 | lekoala/silverstripe-form-extras | code/fields/TimeDropdownField.php | TimeDropdownField.setValue | public function setValue($val)
{
// Fuzzy matching through strtotime() to support a wider range of times,
// e.g. 11am. This means that validate() might not fire.
// Note: Time formats are assumed to be less ambiguous than dates across locales.
if ($this->getConfig('use_strtotime') && !empty($val)) {
if ($parsedTimestamp = strtotime($val)) {
$parsedObj = new Zend_Date($parsedTimestamp, Zend_Date::TIMESTAMP);
$val = $parsedObj->get($this->getConfig('timeformat'));
unset($parsedObj);
}
}
if (empty($val)) {
$this->value = null;
$this->valueObj = null;
}
// load ISO time from database (usually through Form->loadDataForm())
// Requires exact format to prevent false positives from locale specific times
else if ($this->valueObj = $this->parseTime($val, $this->getConfig('datavalueformat'), null, true)) {
$this->value = $this->valueObj->get($this->getConfig('timeformat'));
}
// Set in current locale (as string)
else if ($this->valueObj = $this->parseTime($val, $this->getConfig('timeformat'), $this->locale)) {
$this->value = $this->valueObj->get($this->getConfig('timeformat'));
}
// Fallback: Set incorrect value so validate() can pick it up
elseif (is_string($val)) {
$this->value = $val;
$this->valueObj = null;
} else {
$this->value = null;
$this->valueObj = null;
}
return $this;
} | php | public function setValue($val)
{
// Fuzzy matching through strtotime() to support a wider range of times,
// e.g. 11am. This means that validate() might not fire.
// Note: Time formats are assumed to be less ambiguous than dates across locales.
if ($this->getConfig('use_strtotime') && !empty($val)) {
if ($parsedTimestamp = strtotime($val)) {
$parsedObj = new Zend_Date($parsedTimestamp, Zend_Date::TIMESTAMP);
$val = $parsedObj->get($this->getConfig('timeformat'));
unset($parsedObj);
}
}
if (empty($val)) {
$this->value = null;
$this->valueObj = null;
}
// load ISO time from database (usually through Form->loadDataForm())
// Requires exact format to prevent false positives from locale specific times
else if ($this->valueObj = $this->parseTime($val, $this->getConfig('datavalueformat'), null, true)) {
$this->value = $this->valueObj->get($this->getConfig('timeformat'));
}
// Set in current locale (as string)
else if ($this->valueObj = $this->parseTime($val, $this->getConfig('timeformat'), $this->locale)) {
$this->value = $this->valueObj->get($this->getConfig('timeformat'));
}
// Fallback: Set incorrect value so validate() can pick it up
elseif (is_string($val)) {
$this->value = $val;
$this->valueObj = null;
} else {
$this->value = null;
$this->valueObj = null;
}
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"val",
")",
"{",
"// Fuzzy matching through strtotime() to support a wider range of times,",
"// e.g. 11am. This means that validate() might not fire.",
"// Note: Time formats are assumed to be less ambiguous than dates across locales.",
"if",
"(",... | Sets the internal value to ISO date format.
@param String|Array $val | [
"Sets",
"the",
"internal",
"value",
"to",
"ISO",
"date",
"format",
"."
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TimeDropdownField.php#L125-L162 |
229,198 | PrestaShop/decimal | src/Operation/Addition.php | Addition.computeUsingBcMath | public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
$precision1 = $a->getPrecision();
$precision2 = $b->getPrecision();
return new DecimalNumber((string) bcadd($a, $b, max($precision1, $precision2)));
} | php | public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
{
$precision1 = $a->getPrecision();
$precision2 = $b->getPrecision();
return new DecimalNumber((string) bcadd($a, $b, max($precision1, $precision2)));
} | [
"public",
"function",
"computeUsingBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"$",
"precision1",
"=",
"$",
"a",
"->",
"getPrecision",
"(",
")",
";",
"$",
"precision2",
"=",
"$",
"b",
"->",
"getPrecision",
"(",
")",... | Performs the addition using BC Math
@param DecimalNumber $a Base number
@param DecimalNumber $b Addend
@return DecimalNumber Result of the addition | [
"Performs",
"the",
"addition",
"using",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Addition.php#L59-L64 |
229,199 | PrestaShop/decimal | src/Operation/Addition.php | Addition.computeWithoutBcMath | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
if ($a->isNegative()) {
if ($b->isNegative()) {
// if both numbers are negative,
// we can just add them as positive numbers and then invert the sign
// f(x, y) = -(|x| + |y|)
// eg. f(-1, -2) = -(|-1| + |-2|) = -3
// eg. f(-2, -1) = -(|-2| + |-1|) = -3
return $this
->computeWithoutBcMath($a->toPositive(), $b->toPositive())
->invert();
}
// if the number is negative and the addend positive,
// perform an inverse subtraction by inverting the terms
// f(x, y) = y - |x|
// eg. f(-2, 1) = 1 - |-2| = -1
// eg. f(-1, 2) = 2 - |-1| = 1
// eg. f(-1, 1) = 1 - |-1| = 0
return $b->minus(
$a->toPositive()
);
}
if ($b->isNegative()) {
// if the number is positive and the addend is negative
// perform subtraction instead: 2 - 1
// f(x, y) = x - |y|
// f(2, -1) = 2 - |-1| = 1
// f(1, -2) = 1 - |-2| = -1
// f(1, -1) = 1 - |-1| = 0
return $a->minus(
$b->toPositive()
);
}
// optimization: 0 + x = x
if ('0' === (string) $a) {
return $b;
}
// optimization: x + 0 = x
if ('0' === (string) $b) {
return $a;
}
// pad coefficients with leading/trailing zeroes
list($coeff1, $coeff2) = $this->normalizeCoefficients($a, $b);
// compute the coefficient sum
$sum = $this->addStrings($coeff1, $coeff2);
// both signs are equal, so we can use either
$sign = $a->getSign();
// keep the bigger exponent
$exponent = max($a->getExponent(), $b->getExponent());
return new DecimalNumber($sign . $sum, $exponent);
} | php | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
if ($a->isNegative()) {
if ($b->isNegative()) {
// if both numbers are negative,
// we can just add them as positive numbers and then invert the sign
// f(x, y) = -(|x| + |y|)
// eg. f(-1, -2) = -(|-1| + |-2|) = -3
// eg. f(-2, -1) = -(|-2| + |-1|) = -3
return $this
->computeWithoutBcMath($a->toPositive(), $b->toPositive())
->invert();
}
// if the number is negative and the addend positive,
// perform an inverse subtraction by inverting the terms
// f(x, y) = y - |x|
// eg. f(-2, 1) = 1 - |-2| = -1
// eg. f(-1, 2) = 2 - |-1| = 1
// eg. f(-1, 1) = 1 - |-1| = 0
return $b->minus(
$a->toPositive()
);
}
if ($b->isNegative()) {
// if the number is positive and the addend is negative
// perform subtraction instead: 2 - 1
// f(x, y) = x - |y|
// f(2, -1) = 2 - |-1| = 1
// f(1, -2) = 1 - |-2| = -1
// f(1, -1) = 1 - |-1| = 0
return $a->minus(
$b->toPositive()
);
}
// optimization: 0 + x = x
if ('0' === (string) $a) {
return $b;
}
// optimization: x + 0 = x
if ('0' === (string) $b) {
return $a;
}
// pad coefficients with leading/trailing zeroes
list($coeff1, $coeff2) = $this->normalizeCoefficients($a, $b);
// compute the coefficient sum
$sum = $this->addStrings($coeff1, $coeff2);
// both signs are equal, so we can use either
$sign = $a->getSign();
// keep the bigger exponent
$exponent = max($a->getExponent(), $b->getExponent());
return new DecimalNumber($sign . $sum, $exponent);
} | [
"public",
"function",
"computeWithoutBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"isNegative",
"(",
")",
")",
"{",
"if",
"(",
"$",
"b",
"->",
"isNegative",
"(",
")",
")",
"{",
"// if b... | Performs the addition without BC Math
@param DecimalNumber $a Base number
@param DecimalNumber $b Addend
@return DecimalNumber Result of the addition | [
"Performs",
"the",
"addition",
"without",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Addition.php#L74-L133 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.