id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
233,500
jumilla/php-source-generator
sources/FileGenerator.php
FileGenerator.read
protected function read($stub_path) { $content = $this->stubbox->read($stub_path); if ($content === false) { throw new InvalidArgumentException("File '$stub_path' is not found."); } return $content; }
php
protected function read($stub_path) { $content = $this->stubbox->read($stub_path); if ($content === false) { throw new InvalidArgumentException("File '$stub_path' is not found."); } return $content; }
[ "protected", "function", "read", "(", "$", "stub_path", ")", "{", "$", "content", "=", "$", "this", "->", "stubbox", "->", "read", "(", "$", "stub_path", ")", ";", "if", "(", "$", "content", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"File '$stub_path' is not found.\"", ")", ";", "}", "return", "$", "content", ";", "}" ]
Read stub file @param string $content @param array $arguments @return mixed
[ "Read", "stub", "file" ]
7982dc2dc91504d2119fc09b949c28dcc7c3b9d9
https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L345-L354
233,501
civicrm/civicrm-setup
src/Setup/Template.php
Template.getContent
public function getContent($infile) { $contents = $this->smarty->fetch($infile); if ($this->filetype === 'php') { $this->beautifier->setInputString($contents); $this->beautifier->process(); $contents = $this->beautifier->get(); // The beautifier isn't as beautiful as one would hope. Here's some extra string fudging. $replacements = [ ') ,' => '),', "\n }\n}\n" => "\n }\n\n}\n", '=> true,' => '=> TRUE,', '=> false,' => '=> FALSE,', ]; $contents = str_replace(array_keys($replacements), array_values($replacements), $contents); $contents = preg_replace('#(\s*)\\/\\*\\*#', "\n\$1/**", $contents); // Convert old array syntax to new square brackets $contents = CRM_Core_CodeGen_Util_ArraySyntaxConverter::convert($contents); } return $contents; }
php
public function getContent($infile) { $contents = $this->smarty->fetch($infile); if ($this->filetype === 'php') { $this->beautifier->setInputString($contents); $this->beautifier->process(); $contents = $this->beautifier->get(); // The beautifier isn't as beautiful as one would hope. Here's some extra string fudging. $replacements = [ ') ,' => '),', "\n }\n}\n" => "\n }\n\n}\n", '=> true,' => '=> TRUE,', '=> false,' => '=> FALSE,', ]; $contents = str_replace(array_keys($replacements), array_values($replacements), $contents); $contents = preg_replace('#(\s*)\\/\\*\\*#', "\n\$1/**", $contents); // Convert old array syntax to new square brackets $contents = CRM_Core_CodeGen_Util_ArraySyntaxConverter::convert($contents); } return $contents; }
[ "public", "function", "getContent", "(", "$", "infile", ")", "{", "$", "contents", "=", "$", "this", "->", "smarty", "->", "fetch", "(", "$", "infile", ")", ";", "if", "(", "$", "this", "->", "filetype", "===", "'php'", ")", "{", "$", "this", "->", "beautifier", "->", "setInputString", "(", "$", "contents", ")", ";", "$", "this", "->", "beautifier", "->", "process", "(", ")", ";", "$", "contents", "=", "$", "this", "->", "beautifier", "->", "get", "(", ")", ";", "// The beautifier isn't as beautiful as one would hope. Here's some extra string fudging.", "$", "replacements", "=", "[", "') ,'", "=>", "'),'", ",", "\"\\n }\\n}\\n\"", "=>", "\"\\n }\\n\\n}\\n\"", ",", "'=> true,'", "=>", "'=> TRUE,'", ",", "'=> false,'", "=>", "'=> FALSE,'", ",", "]", ";", "$", "contents", "=", "str_replace", "(", "array_keys", "(", "$", "replacements", ")", ",", "array_values", "(", "$", "replacements", ")", ",", "$", "contents", ")", ";", "$", "contents", "=", "preg_replace", "(", "'#(\\s*)\\\\/\\\\*\\\\*#'", ",", "\"\\n\\$1/**\"", ",", "$", "contents", ")", ";", "// Convert old array syntax to new square brackets", "$", "contents", "=", "CRM_Core_CodeGen_Util_ArraySyntaxConverter", "::", "convert", "(", "$", "contents", ")", ";", "}", "return", "$", "contents", ";", "}" ]
Run template generator. @param string $infile Filename of the template, without a path. @return string
[ "Run", "template", "generator", "." ]
556b312faf78781c85c4fc4ae6c1c3b658da9e09
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/Template.php#L41-L62
233,502
CampaignChain/core
Entity/Milestone.php
Milestone.getJavascriptTimestamp
public function getJavascriptTimestamp() { $date = new \DateTime($this->startDate->format('Y-m-d H:i:s')); $javascriptTimestamp = $date->getTimestamp()*1000; return $javascriptTimestamp; }
php
public function getJavascriptTimestamp() { $date = new \DateTime($this->startDate->format('Y-m-d H:i:s')); $javascriptTimestamp = $date->getTimestamp()*1000; return $javascriptTimestamp; }
[ "public", "function", "getJavascriptTimestamp", "(", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", "$", "this", "->", "startDate", "->", "format", "(", "'Y-m-d H:i:s'", ")", ")", ";", "$", "javascriptTimestamp", "=", "$", "date", "->", "getTimestamp", "(", ")", "*", "1000", ";", "return", "$", "javascriptTimestamp", ";", "}" ]
Get time in JavaScript timestamp format @return \DateTime
[ "Get", "time", "in", "JavaScript", "timestamp", "format" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/Milestone.php#L69-L74
233,503
jumilla/php-source-generator
sources/Php/ConfigGenerator.php
ConfigGenerator.generate
public function generate(array $config, $namespace = null) { $this->writeLine('<?php'.PHP_EOL); if ($namespace) { $this->writeLine("namespace $namespace;".PHP_EOL); } $this->indent = 0; $this->writeLine('return ['); $this->generateArray($config); $this->writeLine('];'); return $this->text; }
php
public function generate(array $config, $namespace = null) { $this->writeLine('<?php'.PHP_EOL); if ($namespace) { $this->writeLine("namespace $namespace;".PHP_EOL); } $this->indent = 0; $this->writeLine('return ['); $this->generateArray($config); $this->writeLine('];'); return $this->text; }
[ "public", "function", "generate", "(", "array", "$", "config", ",", "$", "namespace", "=", "null", ")", "{", "$", "this", "->", "writeLine", "(", "'<?php'", ".", "PHP_EOL", ")", ";", "if", "(", "$", "namespace", ")", "{", "$", "this", "->", "writeLine", "(", "\"namespace $namespace;\"", ".", "PHP_EOL", ")", ";", "}", "$", "this", "->", "indent", "=", "0", ";", "$", "this", "->", "writeLine", "(", "'return ['", ")", ";", "$", "this", "->", "generateArray", "(", "$", "config", ")", ";", "$", "this", "->", "writeLine", "(", "'];'", ")", ";", "return", "$", "this", "->", "text", ";", "}" ]
Generate php source text. @param array $config @param string $namespace @return string
[ "Generate", "php", "source", "text", "." ]
7982dc2dc91504d2119fc09b949c28dcc7c3b9d9
https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/Php/ConfigGenerator.php#L40-L57
233,504
jumilla/php-source-generator
sources/Php/ConfigGenerator.php
ConfigGenerator.generateArray
private function generateArray(array $config) { ++$this->indent; foreach ($config as $key => $value) { if (is_null($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, 'null')); } else { $this->writeLine(sprintf('%s,', 'null')); } } elseif (is_bool($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, $value ? 'true' : 'false')); } else { $this->writeLine(sprintf('%s,', $value ? 'true' : 'false')); } } elseif (is_string($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => '%s',", $key, $value)); } else { $this->writeLine(sprintf("'%s',", $value)); } } elseif (is_array($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => [", $key)); } else { $this->writeLine('['); } $this->generateArray($value); $this->writeLine('],'); } elseif ($value instanceof ClassName) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, (string) $value)); } else { $this->writeLine(sprintf('%s,', (string) $value)); } } else { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, $value)); } else { $this->writeLine($value.','); } } } --$this->indent; }
php
private function generateArray(array $config) { ++$this->indent; foreach ($config as $key => $value) { if (is_null($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, 'null')); } else { $this->writeLine(sprintf('%s,', 'null')); } } elseif (is_bool($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, $value ? 'true' : 'false')); } else { $this->writeLine(sprintf('%s,', $value ? 'true' : 'false')); } } elseif (is_string($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => '%s',", $key, $value)); } else { $this->writeLine(sprintf("'%s',", $value)); } } elseif (is_array($value)) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => [", $key)); } else { $this->writeLine('['); } $this->generateArray($value); $this->writeLine('],'); } elseif ($value instanceof ClassName) { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, (string) $value)); } else { $this->writeLine(sprintf('%s,', (string) $value)); } } else { if (is_string($key)) { $this->writeLine(sprintf("'%s' => %s,", $key, $value)); } else { $this->writeLine($value.','); } } } --$this->indent; }
[ "private", "function", "generateArray", "(", "array", "$", "config", ")", "{", "++", "$", "this", "->", "indent", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => %s,\"", ",", "$", "key", ",", "'null'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "'%s,'", ",", "'null'", ")", ")", ";", "}", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => %s,\"", ",", "$", "key", ",", "$", "value", "?", "'true'", ":", "'false'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "'%s,'", ",", "$", "value", "?", "'true'", ":", "'false'", ")", ")", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => '%s',\"", ",", "$", "key", ",", "$", "value", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s',\"", ",", "$", "value", ")", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => [\"", ",", "$", "key", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "'['", ")", ";", "}", "$", "this", "->", "generateArray", "(", "$", "value", ")", ";", "$", "this", "->", "writeLine", "(", "'],'", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "ClassName", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => %s,\"", ",", "$", "key", ",", "(", "string", ")", "$", "value", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "'%s,'", ",", "(", "string", ")", "$", "value", ")", ")", ";", "}", "}", "else", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "writeLine", "(", "sprintf", "(", "\"'%s' => %s,\"", ",", "$", "key", ",", "$", "value", ")", ")", ";", "}", "else", "{", "$", "this", "->", "writeLine", "(", "$", "value", ".", "','", ")", ";", "}", "}", "}", "--", "$", "this", "->", "indent", ";", "}" ]
Generate php array elements @param array $config
[ "Generate", "php", "array", "elements" ]
7982dc2dc91504d2119fc09b949c28dcc7c3b9d9
https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/Php/ConfigGenerator.php#L64-L113
233,505
jumilla/php-source-generator
sources/Php/ConfigGenerator.php
ConfigGenerator.writeLine
private function writeLine($line) { $this->text .= str_repeat(' ', $this->indent * 4); $this->text .= $line; $this->text .= PHP_EOL; }
php
private function writeLine($line) { $this->text .= str_repeat(' ', $this->indent * 4); $this->text .= $line; $this->text .= PHP_EOL; }
[ "private", "function", "writeLine", "(", "$", "line", ")", "{", "$", "this", "->", "text", ".=", "str_repeat", "(", "' '", ",", "$", "this", "->", "indent", "*", "4", ")", ";", "$", "this", "->", "text", ".=", "$", "line", ";", "$", "this", "->", "text", ".=", "PHP_EOL", ";", "}" ]
Write a source line. @param string $line
[ "Write", "a", "source", "line", "." ]
7982dc2dc91504d2119fc09b949c28dcc7c3b9d9
https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/Php/ConfigGenerator.php#L120-L125
233,506
kgilden/php-digidoc
src/Signature.php
Signature.createFromSoap
public static function createFromSoap(SignatureInfo $info) { $signature = new static(); $signature->id = $info->Id; $signature->seal(); return $signature; }
php
public static function createFromSoap(SignatureInfo $info) { $signature = new static(); $signature->id = $info->Id; $signature->seal(); return $signature; }
[ "public", "static", "function", "createFromSoap", "(", "SignatureInfo", "$", "info", ")", "{", "$", "signature", "=", "new", "static", "(", ")", ";", "$", "signature", "->", "id", "=", "$", "info", "->", "Id", ";", "$", "signature", "->", "seal", "(", ")", ";", "return", "$", "signature", ";", "}" ]
Creates a new Signature object from its Soap counterpart. @internal @param SignatureInfo $info @return Signature
[ "Creates", "a", "new", "Signature", "object", "from", "its", "Soap", "counterpart", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Signature.php#L74-L81
233,507
ionux/phactor
src/ASN1.php
ASN1.pemInitialDataCheck
private function pemInitialDataCheck($keypair) { if (true === empty($keypair) || false === is_array($keypair) || strlen($keypair[0]) < 62 || strlen($keypair[1]) < 126) { throw new \Exception('Invalid or corrupt secp256k1 keypair provided. Cannot encode the keys to PEM format. Value checked was "' . var_export($keypair, true) . '".'); } }
php
private function pemInitialDataCheck($keypair) { if (true === empty($keypair) || false === is_array($keypair) || strlen($keypair[0]) < 62 || strlen($keypair[1]) < 126) { throw new \Exception('Invalid or corrupt secp256k1 keypair provided. Cannot encode the keys to PEM format. Value checked was "' . var_export($keypair, true) . '".'); } }
[ "private", "function", "pemInitialDataCheck", "(", "$", "keypair", ")", "{", "if", "(", "true", "===", "empty", "(", "$", "keypair", ")", "||", "false", "===", "is_array", "(", "$", "keypair", ")", "||", "strlen", "(", "$", "keypair", "[", "0", "]", ")", "<", "62", "||", "strlen", "(", "$", "keypair", "[", "1", "]", ")", "<", "126", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid or corrupt secp256k1 keypair provided. Cannot encode the keys to PEM format. Value checked was \"'", ".", "var_export", "(", "$", "keypair", ",", "true", ")", ".", "'\".'", ")", ";", "}", "}" ]
Ensures the data we want to PEM encode is acceptable. @param array $keypair The values to check. @throws \Exception
[ "Ensures", "the", "data", "we", "want", "to", "PEM", "encode", "is", "acceptable", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/ASN1.php#L113-L118
233,508
ionux/phactor
src/ASN1.php
ASN1.pemKeyLenCheck
private function pemKeyLenCheck($values) { if (!is_array($values) || strlen($values[0]) < 62 || strlen($values[1]) < 126) { throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Key lengths too short. Values checked were "' . var_export($values[0], true) . '" and "' . var_export($values[1], true) . '".'); } }
php
private function pemKeyLenCheck($values) { if (!is_array($values) || strlen($values[0]) < 62 || strlen($values[1]) < 126) { throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Key lengths too short. Values checked were "' . var_export($values[0], true) . '" and "' . var_export($values[1], true) . '".'); } }
[ "private", "function", "pemKeyLenCheck", "(", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", "||", "strlen", "(", "$", "values", "[", "0", "]", ")", "<", "62", "||", "strlen", "(", "$", "values", "[", "1", "]", ")", "<", "126", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Key lengths too short. Values checked were \"'", ".", "var_export", "(", "$", "values", "[", "0", "]", ",", "true", ")", ".", "'\" and \"'", ".", "var_export", "(", "$", "values", "[", "1", "]", ",", "true", ")", ".", "'\".'", ")", ";", "}", "}" ]
Ensures the decoded PEM key lengths are acceptable. @param array $values The key values to check. @throws \Exception
[ "Ensures", "the", "decoded", "PEM", "key", "lengths", "are", "acceptable", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/ASN1.php#L139-L144
233,509
ionux/phactor
src/ASN1.php
ASN1.pemDataClean
private function pemDataClean($value) { $value = str_ireplace('-----BEGIN EC PRIVATE KEY-----', '', $value); $value = str_ireplace('-----END EC PRIVATE KEY-----', '', $value); $value = str_ireplace("\r", '', trim($value)); $value = str_ireplace("\n", '', trim($value)); $value = str_ireplace(' ', '', trim($value)); return $value; }
php
private function pemDataClean($value) { $value = str_ireplace('-----BEGIN EC PRIVATE KEY-----', '', $value); $value = str_ireplace('-----END EC PRIVATE KEY-----', '', $value); $value = str_ireplace("\r", '', trim($value)); $value = str_ireplace("\n", '', trim($value)); $value = str_ireplace(' ', '', trim($value)); return $value; }
[ "private", "function", "pemDataClean", "(", "$", "value", ")", "{", "$", "value", "=", "str_ireplace", "(", "'-----BEGIN EC PRIVATE KEY-----'", ",", "''", ",", "$", "value", ")", ";", "$", "value", "=", "str_ireplace", "(", "'-----END EC PRIVATE KEY-----'", ",", "''", ",", "$", "value", ")", ";", "$", "value", "=", "str_ireplace", "(", "\"\\r\"", ",", "''", ",", "trim", "(", "$", "value", ")", ")", ";", "$", "value", "=", "str_ireplace", "(", "\"\\n\"", ",", "''", ",", "trim", "(", "$", "value", ")", ")", ";", "$", "value", "=", "str_ireplace", "(", "' '", ",", "''", ",", "trim", "(", "$", "value", ")", ")", ";", "return", "$", "value", ";", "}" ]
Cleans the PEM data of unwanted data. @param string $value The value to clean. @return string $value The cleaned value.
[ "Cleans", "the", "PEM", "data", "of", "unwanted", "data", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/ASN1.php#L165-L174
233,510
ionux/phactor
src/ASN1.php
ASN1.decodeOID
public function decodeOID($data) { $bin_data = array(); $index = 0; $binary_string = ''; $oid = array(); // first two numbers are: (40*x)+y // all next chars are 7-bit numbers foreach ($data as $key => $value) { $bin_data[$index] = bitConv($value); $binary_string .= $bin_data[$index]; $index++; } $oid[0] = (int)($data[0] / 0x28); $oid[1] = $data[0] % 0x28; $elements = count($bin_data); $temp_number = '00000000'; for ($x = 1; $x < $elements; $x++) { $and_temp = $bin_data[$x] & '01111111'; $temp_number = bitAdd($temp_number, $and_temp); if (substr($bin_data[$x], 0, 1) == '0') { // This is a final value without // a value preceeding it. $oid[$x + 1] = decConv($temp_number); $temp_number = ''; } else { $temp_number = shiftLeft($temp_number, 7); } } $oid_string = ''; foreach ($oid as $key => $value) { $oid_string .= $value . "."; } $oid_string = substr($oid_string, 0, -1); return $oid_string; }
php
public function decodeOID($data) { $bin_data = array(); $index = 0; $binary_string = ''; $oid = array(); // first two numbers are: (40*x)+y // all next chars are 7-bit numbers foreach ($data as $key => $value) { $bin_data[$index] = bitConv($value); $binary_string .= $bin_data[$index]; $index++; } $oid[0] = (int)($data[0] / 0x28); $oid[1] = $data[0] % 0x28; $elements = count($bin_data); $temp_number = '00000000'; for ($x = 1; $x < $elements; $x++) { $and_temp = $bin_data[$x] & '01111111'; $temp_number = bitAdd($temp_number, $and_temp); if (substr($bin_data[$x], 0, 1) == '0') { // This is a final value without // a value preceeding it. $oid[$x + 1] = decConv($temp_number); $temp_number = ''; } else { $temp_number = shiftLeft($temp_number, 7); } } $oid_string = ''; foreach ($oid as $key => $value) { $oid_string .= $value . "."; } $oid_string = substr($oid_string, 0, -1); return $oid_string; }
[ "public", "function", "decodeOID", "(", "$", "data", ")", "{", "$", "bin_data", "=", "array", "(", ")", ";", "$", "index", "=", "0", ";", "$", "binary_string", "=", "''", ";", "$", "oid", "=", "array", "(", ")", ";", "// first two numbers are: (40*x)+y", "// all next chars are 7-bit numbers", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "bin_data", "[", "$", "index", "]", "=", "bitConv", "(", "$", "value", ")", ";", "$", "binary_string", ".=", "$", "bin_data", "[", "$", "index", "]", ";", "$", "index", "++", ";", "}", "$", "oid", "[", "0", "]", "=", "(", "int", ")", "(", "$", "data", "[", "0", "]", "/", "0x28", ")", ";", "$", "oid", "[", "1", "]", "=", "$", "data", "[", "0", "]", "%", "0x28", ";", "$", "elements", "=", "count", "(", "$", "bin_data", ")", ";", "$", "temp_number", "=", "'00000000'", ";", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<", "$", "elements", ";", "$", "x", "++", ")", "{", "$", "and_temp", "=", "$", "bin_data", "[", "$", "x", "]", "&", "'01111111'", ";", "$", "temp_number", "=", "bitAdd", "(", "$", "temp_number", ",", "$", "and_temp", ")", ";", "if", "(", "substr", "(", "$", "bin_data", "[", "$", "x", "]", ",", "0", ",", "1", ")", "==", "'0'", ")", "{", "// This is a final value without", "// a value preceeding it.", "$", "oid", "[", "$", "x", "+", "1", "]", "=", "decConv", "(", "$", "temp_number", ")", ";", "$", "temp_number", "=", "''", ";", "}", "else", "{", "$", "temp_number", "=", "shiftLeft", "(", "$", "temp_number", ",", "7", ")", ";", "}", "}", "$", "oid_string", "=", "''", ";", "foreach", "(", "$", "oid", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "oid_string", ".=", "$", "value", ".", "\".\"", ";", "}", "$", "oid_string", "=", "substr", "(", "$", "oid_string", ",", "0", ",", "-", "1", ")", ";", "return", "$", "oid_string", ";", "}" ]
Decodes an OID hex value obtained from a PEM file or other encoded key file. @param string $data The hex OID string to decode. @return string The decoded OID string.
[ "Decodes", "an", "OID", "hex", "value", "obtained", "from", "a", "PEM", "file", "or", "other", "encoded", "key", "file", "." ]
667064d3930e043fd78abed9a2324aee52466fa5
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/ASN1.php#L183-L228
233,511
prooph/link-process-manager
src/Model/Task.php
Task.updateMetadata
public function updateMetadata(ProcessingMetadata $metadata) { $this->recordThat(TaskMetadataWasUpdated::record($this->id(), $metadata)); }
php
public function updateMetadata(ProcessingMetadata $metadata) { $this->recordThat(TaskMetadataWasUpdated::record($this->id(), $metadata)); }
[ "public", "function", "updateMetadata", "(", "ProcessingMetadata", "$", "metadata", ")", "{", "$", "this", "->", "recordThat", "(", "TaskMetadataWasUpdated", "::", "record", "(", "$", "this", "->", "id", "(", ")", ",", "$", "metadata", ")", ")", ";", "}" ]
Simply override existing metadata with the new one @param ProcessingMetadata $metadata
[ "Simply", "override", "existing", "metadata", "with", "the", "new", "one" ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/Task.php#L81-L84
233,512
malenkiki/aleavatar
src/Malenki/Aleavatar/Primitive/Triangle.php
Triangle.point
public function point($int_x, $int_y) { if (count($this->arr_points) >= 3) { throw new \RuntimeException('Triangle has only three points!'); } return parent::point($int_x, $int_y); }
php
public function point($int_x, $int_y) { if (count($this->arr_points) >= 3) { throw new \RuntimeException('Triangle has only three points!'); } return parent::point($int_x, $int_y); }
[ "public", "function", "point", "(", "$", "int_x", ",", "$", "int_y", ")", "{", "if", "(", "count", "(", "$", "this", "->", "arr_points", ")", ">=", "3", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Triangle has only three points!'", ")", ";", "}", "return", "parent", "::", "point", "(", "$", "int_x", ",", "$", "int_y", ")", ";", "}" ]
Set one point by giving its coordinates. @param integer $int_x @param integer $int_y @throws \RuntimeException If you try to set 4th point. @access public @return void
[ "Set", "one", "point", "by", "giving", "its", "coordinates", "." ]
91affa83f8580c8e6da62c77ce34b1c4451784bf
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Triangle.php#L44-L51
233,513
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/ClassStore.php
ClassStore.getClassByName
public function getClassByName($className) { $classMap = $this->getClassMap($this->splitClassName($className)) . "[\"__class\"]"; $return = null; eval( "if (isset(\$this->indexedClasses$classMap)) {" . " \$return = \$this->indexedClasses$classMap;" . "}" ); return $return; }
php
public function getClassByName($className) { $classMap = $this->getClassMap($this->splitClassName($className)) . "[\"__class\"]"; $return = null; eval( "if (isset(\$this->indexedClasses$classMap)) {" . " \$return = \$this->indexedClasses$classMap;" . "}" ); return $return; }
[ "public", "function", "getClassByName", "(", "$", "className", ")", "{", "$", "classMap", "=", "$", "this", "->", "getClassMap", "(", "$", "this", "->", "splitClassName", "(", "$", "className", ")", ")", ".", "\"[\\\"__class\\\"]\"", ";", "$", "return", "=", "null", ";", "eval", "(", "\"if (isset(\\$this->indexedClasses$classMap)) {\"", ".", "\" \\$return = \\$this->indexedClasses$classMap;\"", ".", "\"}\"", ")", ";", "return", "$", "return", ";", "}" ]
Retrieve a class metadata instance by name from the given array @param string $className @return ClassMetadata|null
[ "Retrieve", "a", "class", "metadata", "instance", "by", "name", "from", "the", "given", "array" ]
414b95f81d36b6530b083b296c5eeb700679ab3b
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/ClassStore.php#L61-L73
233,514
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/ClassStore.php
ClassStore.getParent
public function getParent(ClassMetadata $class) { $className = $class->getName(); if (!class_exists($className) || (!$parent = get_parent_class($className))) { return null; } return $this->getClassByName($parent); }
php
public function getParent(ClassMetadata $class) { $className = $class->getName(); if (!class_exists($className) || (!$parent = get_parent_class($className))) { return null; } return $this->getClassByName($parent); }
[ "public", "function", "getParent", "(", "ClassMetadata", "$", "class", ")", "{", "$", "className", "=", "$", "class", "->", "getName", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", "||", "(", "!", "$", "parent", "=", "get_parent_class", "(", "$", "className", ")", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "getClassByName", "(", "$", "parent", ")", ";", "}" ]
Retrieve a class metadata's parent class metadata @param ClassMetadata $class @return ClassMetadata|null
[ "Retrieve", "a", "class", "metadata", "s", "parent", "class", "metadata" ]
414b95f81d36b6530b083b296c5eeb700679ab3b
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/ClassStore.php#L82-L90
233,515
sulu/SuluAutomationBundle
EventSubscriber/PHPTaskEventSubscriber.php
PHPTaskEventSubscriber.pushRequest
public function pushRequest(TaskEvent $event) { $task = $this->taskRepository->findByTaskId($event->getTask()->getUuid()); if (!$task) { // current task is not managed by this bundle return; } $request = new Request( [], [], ['_task_id' => $event->getTask()->getUuid()], [], [], ['SERVER_NAME' => $task->getHost(), 'HTTPS' => $task->getScheme() === 'http' ? 'off' : 'on'] ); $this->requestStack->push($request); }
php
public function pushRequest(TaskEvent $event) { $task = $this->taskRepository->findByTaskId($event->getTask()->getUuid()); if (!$task) { // current task is not managed by this bundle return; } $request = new Request( [], [], ['_task_id' => $event->getTask()->getUuid()], [], [], ['SERVER_NAME' => $task->getHost(), 'HTTPS' => $task->getScheme() === 'http' ? 'off' : 'on'] ); $this->requestStack->push($request); }
[ "public", "function", "pushRequest", "(", "TaskEvent", "$", "event", ")", "{", "$", "task", "=", "$", "this", "->", "taskRepository", "->", "findByTaskId", "(", "$", "event", "->", "getTask", "(", ")", "->", "getUuid", "(", ")", ")", ";", "if", "(", "!", "$", "task", ")", "{", "// current task is not managed by this bundle", "return", ";", "}", "$", "request", "=", "new", "Request", "(", "[", "]", ",", "[", "]", ",", "[", "'_task_id'", "=>", "$", "event", "->", "getTask", "(", ")", "->", "getUuid", "(", ")", "]", ",", "[", "]", ",", "[", "]", ",", "[", "'SERVER_NAME'", "=>", "$", "task", "->", "getHost", "(", ")", ",", "'HTTPS'", "=>", "$", "task", "->", "getScheme", "(", ")", "===", "'http'", "?", "'off'", ":", "'on'", "]", ")", ";", "$", "this", "->", "requestStack", "->", "push", "(", "$", "request", ")", ";", "}" ]
Create and push new request to requests-stack. @param TaskEvent $event
[ "Create", "and", "push", "new", "request", "to", "requests", "-", "stack", "." ]
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/EventSubscriber/PHPTaskEventSubscriber.php#L53-L72
233,516
sulu/SuluAutomationBundle
EventSubscriber/PHPTaskEventSubscriber.php
PHPTaskEventSubscriber.popRequest
public function popRequest(TaskEvent $event) { $request = $this->requestStack->getCurrentRequest(); if (!$request || $request->attributes->get('_task_id') !== $event->getTask()->getUuid()) { // current request was not created for current task return; } $this->requestStack->pop(); }
php
public function popRequest(TaskEvent $event) { $request = $this->requestStack->getCurrentRequest(); if (!$request || $request->attributes->get('_task_id') !== $event->getTask()->getUuid()) { // current request was not created for current task return; } $this->requestStack->pop(); }
[ "public", "function", "popRequest", "(", "TaskEvent", "$", "event", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "if", "(", "!", "$", "request", "||", "$", "request", "->", "attributes", "->", "get", "(", "'_task_id'", ")", "!==", "$", "event", "->", "getTask", "(", ")", "->", "getUuid", "(", ")", ")", "{", "// current request was not created for current task", "return", ";", "}", "$", "this", "->", "requestStack", "->", "pop", "(", ")", ";", "}" ]
Pop request from request stack. @param TaskEvent $event
[ "Pop", "request", "from", "request", "stack", "." ]
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/EventSubscriber/PHPTaskEventSubscriber.php#L79-L89
233,517
kgilden/php-digidoc
src/Encoder.php
Encoder.decode
public function decode($data) { $decoded = ''; $delimiters = "\n"; $token = strtok($data, $delimiters); while (false !== $token) { $decoded .= base64_decode($token); $token = strtok($delimiters); } return $decoded; }
php
public function decode($data) { $decoded = ''; $delimiters = "\n"; $token = strtok($data, $delimiters); while (false !== $token) { $decoded .= base64_decode($token); $token = strtok($delimiters); } return $decoded; }
[ "public", "function", "decode", "(", "$", "data", ")", "{", "$", "decoded", "=", "''", ";", "$", "delimiters", "=", "\"\\n\"", ";", "$", "token", "=", "strtok", "(", "$", "data", ",", "$", "delimiters", ")", ";", "while", "(", "false", "!==", "$", "token", ")", "{", "$", "decoded", ".=", "base64_decode", "(", "$", "token", ")", ";", "$", "token", "=", "strtok", "(", "$", "delimiters", ")", ";", "}", "return", "$", "decoded", ";", "}" ]
Decodes a piece of data from base64. The encoded data may be either a long string in base64 or delimited by newline characters. @param string $data The encoded data @return string
[ "Decodes", "a", "piece", "of", "data", "from", "base64", ".", "The", "encoded", "data", "may", "be", "either", "a", "long", "string", "in", "base64", "or", "delimited", "by", "newline", "characters", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Encoder.php#L51-L64
233,518
kgilden/php-digidoc
src/Encoder.php
Encoder.getFileContent
private function getFileContent($pathToFile) { $level = error_reporting(0); $content = file_get_contents($pathToFile); error_reporting($level); if (false === $content) { $error = error_get_last(); throw new RuntimeException($error['message']); } return $content; }
php
private function getFileContent($pathToFile) { $level = error_reporting(0); $content = file_get_contents($pathToFile); error_reporting($level); if (false === $content) { $error = error_get_last(); throw new RuntimeException($error['message']); } return $content; }
[ "private", "function", "getFileContent", "(", "$", "pathToFile", ")", "{", "$", "level", "=", "error_reporting", "(", "0", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "pathToFile", ")", ";", "error_reporting", "(", "$", "level", ")", ";", "if", "(", "false", "===", "$", "content", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "throw", "new", "RuntimeException", "(", "$", "error", "[", "'message'", "]", ")", ";", "}", "return", "$", "content", ";", "}" ]
Gets the file content. @todo Refactor this out to some other class @param string $pathToFile @return string
[ "Gets", "the", "file", "content", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Encoder.php#L75-L87
233,519
PhillippOhlandt/materializecss-laravel-pagination
src/Presenters/Pagination/Materialize.php
Materialize.render
public function render() { if (!$this->hasPages()) return ''; return sprintf( '<div><ul class="pagination">%s %s %s</ul></div>', $this->getPreviousButton(), $this->getLinks(), $this->getNextButton() ); }
php
public function render() { if (!$this->hasPages()) return ''; return sprintf( '<div><ul class="pagination">%s %s %s</ul></div>', $this->getPreviousButton(), $this->getLinks(), $this->getNextButton() ); }
[ "public", "function", "render", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasPages", "(", ")", ")", "return", "''", ";", "return", "sprintf", "(", "'<div><ul class=\"pagination\">%s %s %s</ul></div>'", ",", "$", "this", "->", "getPreviousButton", "(", ")", ",", "$", "this", "->", "getLinks", "(", ")", ",", "$", "this", "->", "getNextButton", "(", ")", ")", ";", "}" ]
Convert the URL window into Materialize CSS HTML. @return string
[ "Convert", "the", "URL", "window", "into", "Materialize", "CSS", "HTML", "." ]
a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b
https://github.com/PhillippOhlandt/materializecss-laravel-pagination/blob/a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b/src/Presenters/Pagination/Materialize.php#L17-L28
233,520
PhillippOhlandt/materializecss-laravel-pagination
src/Presenters/Pagination/Materialize.php
Materialize.getDisabledTextWrapper
protected function getDisabledTextWrapper($text) { $hide = ''; if ($text == "&laquo;") { $text = '<i class="material-icons">chevron_left</i>'; $hide = 'hide'; } elseif ($text == "&raquo;") { $text = '<i class="material-icons">chevron_right</i>'; $hide = 'hide'; } return '<li class="disabled ' . $hide . '">' . $text . '</li>'; }
php
protected function getDisabledTextWrapper($text) { $hide = ''; if ($text == "&laquo;") { $text = '<i class="material-icons">chevron_left</i>'; $hide = 'hide'; } elseif ($text == "&raquo;") { $text = '<i class="material-icons">chevron_right</i>'; $hide = 'hide'; } return '<li class="disabled ' . $hide . '">' . $text . '</li>'; }
[ "protected", "function", "getDisabledTextWrapper", "(", "$", "text", ")", "{", "$", "hide", "=", "''", ";", "if", "(", "$", "text", "==", "\"&laquo;\"", ")", "{", "$", "text", "=", "'<i class=\"material-icons\">chevron_left</i>'", ";", "$", "hide", "=", "'hide'", ";", "}", "elseif", "(", "$", "text", "==", "\"&raquo;\"", ")", "{", "$", "text", "=", "'<i class=\"material-icons\">chevron_right</i>'", ";", "$", "hide", "=", "'hide'", ";", "}", "return", "'<li class=\"disabled '", ".", "$", "hide", ".", "'\">'", ".", "$", "text", ".", "'</li>'", ";", "}" ]
Get HTML wrapper for disabled text. Hide disabled arrows. @param string $text @return string
[ "Get", "HTML", "wrapper", "for", "disabled", "text", ".", "Hide", "disabled", "arrows", "." ]
a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b
https://github.com/PhillippOhlandt/materializecss-laravel-pagination/blob/a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b/src/Presenters/Pagination/Materialize.php#L37-L50
233,521
PhillippOhlandt/materializecss-laravel-pagination
src/Presenters/Pagination/Materialize.php
Materialize.getActivePageWrapper
protected function getActivePageWrapper($text) { $color = ''; if ($this->color) { $color = $this->color; } return '<li class="active ' . $color . '"><a>' . $text . '</a></li>'; }
php
protected function getActivePageWrapper($text) { $color = ''; if ($this->color) { $color = $this->color; } return '<li class="active ' . $color . '"><a>' . $text . '</a></li>'; }
[ "protected", "function", "getActivePageWrapper", "(", "$", "text", ")", "{", "$", "color", "=", "''", ";", "if", "(", "$", "this", "->", "color", ")", "{", "$", "color", "=", "$", "this", "->", "color", ";", "}", "return", "'<li class=\"active '", ".", "$", "color", ".", "'\"><a>'", ".", "$", "text", ".", "'</a></li>'", ";", "}" ]
Get HTML wrapper for active text. @param string $text @return string
[ "Get", "HTML", "wrapper", "for", "active", "text", "." ]
a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b
https://github.com/PhillippOhlandt/materializecss-laravel-pagination/blob/a56d0c0f4c1a069f287d13dc1c88d60ab8efac9b/src/Presenters/Pagination/Materialize.php#L58-L67
233,522
kgilden/php-digidoc
src/Ocsp/Response.php
Response.getResponseMapped
private function getResponseMapped() { $parser = new Asn1Parser(); $responseBasicDecoded = $parser->decodeBER(base64_decode($this->response)); return $parser->asn1map($responseBasicDecoded[0], $this->asn1->BasicOCSPResponse); }
php
private function getResponseMapped() { $parser = new Asn1Parser(); $responseBasicDecoded = $parser->decodeBER(base64_decode($this->response)); return $parser->asn1map($responseBasicDecoded[0], $this->asn1->BasicOCSPResponse); }
[ "private", "function", "getResponseMapped", "(", ")", "{", "$", "parser", "=", "new", "Asn1Parser", "(", ")", ";", "$", "responseBasicDecoded", "=", "$", "parser", "->", "decodeBER", "(", "base64_decode", "(", "$", "this", "->", "response", ")", ")", ";", "return", "$", "parser", "->", "asn1map", "(", "$", "responseBasicDecoded", "[", "0", "]", ",", "$", "this", "->", "asn1", "->", "BasicOCSPResponse", ")", ";", "}" ]
Decodes and maps the BasicOCSPResponse part of the response. @return array
[ "Decodes", "and", "maps", "the", "BasicOCSPResponse", "part", "of", "the", "response", "." ]
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Ocsp/Response.php#L169-L175
233,523
sulu/SuluAutomationBundle
Serializer/TaskSerializerSubscriber.php
TaskSerializerSubscriber.onTaskSerialize
public function onTaskSerialize(ObjectEvent $event) { $object = $event->getObject(); if (!$object instanceof TaskInterface) { return; } $handler = $this->handlerFactory->create($object->getHandlerClass()); if ($handler instanceof AutomationTaskHandlerInterface) { $event->getVisitor()->addData('taskName', $handler->getConfiguration()->getTitle()); } $executions = $this->taskExecutionRepository->findByTaskUuid($object->getTaskId()); if (0 < count($executions)) { $event->getVisitor()->addData('status', $executions[0]->getStatus()); } }
php
public function onTaskSerialize(ObjectEvent $event) { $object = $event->getObject(); if (!$object instanceof TaskInterface) { return; } $handler = $this->handlerFactory->create($object->getHandlerClass()); if ($handler instanceof AutomationTaskHandlerInterface) { $event->getVisitor()->addData('taskName', $handler->getConfiguration()->getTitle()); } $executions = $this->taskExecutionRepository->findByTaskUuid($object->getTaskId()); if (0 < count($executions)) { $event->getVisitor()->addData('status', $executions[0]->getStatus()); } }
[ "public", "function", "onTaskSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "object", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "object", "instanceof", "TaskInterface", ")", "{", "return", ";", "}", "$", "handler", "=", "$", "this", "->", "handlerFactory", "->", "create", "(", "$", "object", "->", "getHandlerClass", "(", ")", ")", ";", "if", "(", "$", "handler", "instanceof", "AutomationTaskHandlerInterface", ")", "{", "$", "event", "->", "getVisitor", "(", ")", "->", "addData", "(", "'taskName'", ",", "$", "handler", "->", "getConfiguration", "(", ")", "->", "getTitle", "(", ")", ")", ";", "}", "$", "executions", "=", "$", "this", "->", "taskExecutionRepository", "->", "findByTaskUuid", "(", "$", "object", "->", "getTaskId", "(", ")", ")", ";", "if", "(", "0", "<", "count", "(", "$", "executions", ")", ")", "{", "$", "event", "->", "getVisitor", "(", ")", "->", "addData", "(", "'status'", ",", "$", "executions", "[", "0", "]", "->", "getStatus", "(", ")", ")", ";", "}", "}" ]
Append task-name to task-serialization. @param ObjectEvent $event
[ "Append", "task", "-", "name", "to", "task", "-", "serialization", "." ]
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Serializer/TaskSerializerSubscriber.php#L68-L84
233,524
notthatbad/silverstripe-rest-api
code/authenticators/AuthFactory.php
AuthFactory.generate_token
public static function generate_token($user) { $generator = new \RandomGenerator(); $tokenString = $generator->randomToken(); $e = \PasswordEncryptor::create_for_algorithm('blowfish'); $salt = $e->salt($tokenString); $token = sha1($e->encrypt($tokenString, $salt)) . substr(md5($user->Created.$user->LastEdited.$user->ID), 7); return $token; }
php
public static function generate_token($user) { $generator = new \RandomGenerator(); $tokenString = $generator->randomToken(); $e = \PasswordEncryptor::create_for_algorithm('blowfish'); $salt = $e->salt($tokenString); $token = sha1($e->encrypt($tokenString, $salt)) . substr(md5($user->Created.$user->LastEdited.$user->ID), 7); return $token; }
[ "public", "static", "function", "generate_token", "(", "$", "user", ")", "{", "$", "generator", "=", "new", "\\", "RandomGenerator", "(", ")", ";", "$", "tokenString", "=", "$", "generator", "->", "randomToken", "(", ")", ";", "$", "e", "=", "\\", "PasswordEncryptor", "::", "create_for_algorithm", "(", "'blowfish'", ")", ";", "$", "salt", "=", "$", "e", "->", "salt", "(", "$", "tokenString", ")", ";", "$", "token", "=", "sha1", "(", "$", "e", "->", "encrypt", "(", "$", "tokenString", ",", "$", "salt", ")", ")", ".", "substr", "(", "md5", "(", "$", "user", "->", "Created", ".", "$", "user", "->", "LastEdited", ".", "$", "user", "->", "ID", ")", ",", "7", ")", ";", "return", "$", "token", ";", "}" ]
Generates an encrypted random token. @param \Member $user @throws \PasswordEncryptor_NotFoundException @return string
[ "Generates", "an", "encrypted", "random", "token", "." ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/authenticators/AuthFactory.php#L26-L33
233,525
notthatbad/silverstripe-rest-api
code/authenticators/AuthFactory.php
AuthFactory.get_token
public static function get_token($request) { // try to get the token from request object $tokenStrFromHeader = $request->getHeader('Authorization'); $tokenStrFromVar = $request->requestVar('access_token'); if (!empty($tokenStrFromHeader)) { // string must have format: type token return explode(' ', $tokenStrFromHeader)[1]; } else if(!empty($tokenStrFromVar)) { // try variables return $tokenStrFromVar; } else if(function_exists('getallheaders')) { // get all headers from apache server $headers = getallheaders(); if(isset($headers['Authorization'])) { return explode(' ', $headers['Authorization'])[1]; } } throw new \Exception("Token can't be read or was not specified"); }
php
public static function get_token($request) { // try to get the token from request object $tokenStrFromHeader = $request->getHeader('Authorization'); $tokenStrFromVar = $request->requestVar('access_token'); if (!empty($tokenStrFromHeader)) { // string must have format: type token return explode(' ', $tokenStrFromHeader)[1]; } else if(!empty($tokenStrFromVar)) { // try variables return $tokenStrFromVar; } else if(function_exists('getallheaders')) { // get all headers from apache server $headers = getallheaders(); if(isset($headers['Authorization'])) { return explode(' ', $headers['Authorization'])[1]; } } throw new \Exception("Token can't be read or was not specified"); }
[ "public", "static", "function", "get_token", "(", "$", "request", ")", "{", "// try to get the token from request object", "$", "tokenStrFromHeader", "=", "$", "request", "->", "getHeader", "(", "'Authorization'", ")", ";", "$", "tokenStrFromVar", "=", "$", "request", "->", "requestVar", "(", "'access_token'", ")", ";", "if", "(", "!", "empty", "(", "$", "tokenStrFromHeader", ")", ")", "{", "// string must have format: type token", "return", "explode", "(", "' '", ",", "$", "tokenStrFromHeader", ")", "[", "1", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "tokenStrFromVar", ")", ")", "{", "// try variables", "return", "$", "tokenStrFromVar", ";", "}", "else", "if", "(", "function_exists", "(", "'getallheaders'", ")", ")", "{", "// get all headers from apache server", "$", "headers", "=", "getallheaders", "(", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "'Authorization'", "]", ")", ")", "{", "return", "explode", "(", "' '", ",", "$", "headers", "[", "'Authorization'", "]", ")", "[", "1", "]", ";", "}", "}", "throw", "new", "\\", "Exception", "(", "\"Token can't be read or was not specified\"", ")", ";", "}" ]
Returns the token from the request. Silverstripe doesn't include Authorization header in its requests. We should check it, because we can use the mechanism in the tests. @param \SS_HTTPRequest $request @return String the token @throws \Exception
[ "Returns", "the", "token", "from", "the", "request", "." ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/authenticators/AuthFactory.php#L44-L62
233,526
joomla-framework/twitter-api
src/Places.php
Places.createPlace
public function createPlace($lat, $long, $name, $geoToken, $within, $attribute = null, $callback = null) { // Check the rate limit for remaining hits $this->checkRateLimit('geo', 'place'); $data['lat'] = $lat; $data['long'] = $long; $data['name'] = rawurlencode($name); $data['token'] = $geoToken; $data['contained_within'] = $within; // Check if attribute is specified if ($attribute) { $data['attribute:street_address'] = rawurlencode($attribute); } // Check if callback is specified if ($callback) { $data['callback'] = $callback; } // Set the API path $path = '/geo/place.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
php
public function createPlace($lat, $long, $name, $geoToken, $within, $attribute = null, $callback = null) { // Check the rate limit for remaining hits $this->checkRateLimit('geo', 'place'); $data['lat'] = $lat; $data['long'] = $long; $data['name'] = rawurlencode($name); $data['token'] = $geoToken; $data['contained_within'] = $within; // Check if attribute is specified if ($attribute) { $data['attribute:street_address'] = rawurlencode($attribute); } // Check if callback is specified if ($callback) { $data['callback'] = $callback; } // Set the API path $path = '/geo/place.json'; // Send the request. return $this->sendRequest($path, 'POST', $data); }
[ "public", "function", "createPlace", "(", "$", "lat", ",", "$", "long", ",", "$", "name", ",", "$", "geoToken", ",", "$", "within", ",", "$", "attribute", "=", "null", ",", "$", "callback", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$", "this", "->", "checkRateLimit", "(", "'geo'", ",", "'place'", ")", ";", "$", "data", "[", "'lat'", "]", "=", "$", "lat", ";", "$", "data", "[", "'long'", "]", "=", "$", "long", ";", "$", "data", "[", "'name'", "]", "=", "rawurlencode", "(", "$", "name", ")", ";", "$", "data", "[", "'token'", "]", "=", "$", "geoToken", ";", "$", "data", "[", "'contained_within'", "]", "=", "$", "within", ";", "// Check if attribute is specified", "if", "(", "$", "attribute", ")", "{", "$", "data", "[", "'attribute:street_address'", "]", "=", "rawurlencode", "(", "$", "attribute", ")", ";", "}", "// Check if callback is specified", "if", "(", "$", "callback", ")", "{", "$", "data", "[", "'callback'", "]", "=", "$", "callback", ";", "}", "// Set the API path", "$", "path", "=", "'/geo/place.json'", ";", "// Send the request.", "return", "$", "this", "->", "sendRequest", "(", "$", "path", ",", "'POST'", ",", "$", "data", ")", ";", "}" ]
Method to create a new place object at the given latitude and longitude. @param float $lat The latitude to search around. @param float $long The longitude to search around. @param string $name The name a place is known as. @param string $geoToken The token found in the response from geo/similar_places. @param string $within This is the place_id which you would like to restrict the search results to. @param string $attribute This parameter searches for places which have this given street address. @param string $callback If supplied, the response will use the JSONP format with a callback of the given name. @return array The decoded JSON response @since 1.0
[ "Method", "to", "create", "a", "new", "place", "object", "at", "the", "given", "latitude", "and", "longitude", "." ]
289719bbd67e83c7cfaf515b94b1d5497b1f0525
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Places.php#L261-L289
233,527
CampaignChain/core
Module/Kernel.php
Kernel.registerConfigs
protected function registerConfigs() { $hasNewConfigs = false; $yamlConfig = new YamlConfig('', $this->configFiles['config']); $parameters = $yamlConfig->read(); $configs = $this->kernelConfig->getConfigs(); if (!count($configs)) { return; } foreach ($configs as $config) { // Check if the config is already being imported. if (VariableUtil::recursiveArraySearch($config, $parameters['imports']) === false) { $hasNewConfigs = true; // Add the config to the imports $parameters['imports'][]['resource'] = $config; } } if (!$hasNewConfigs) { return; } $yamlConfig = new YamlConfig('', $this->configFiles['config']); $yamlConfig->write($parameters); $yamlConfig->clean(); }
php
protected function registerConfigs() { $hasNewConfigs = false; $yamlConfig = new YamlConfig('', $this->configFiles['config']); $parameters = $yamlConfig->read(); $configs = $this->kernelConfig->getConfigs(); if (!count($configs)) { return; } foreach ($configs as $config) { // Check if the config is already being imported. if (VariableUtil::recursiveArraySearch($config, $parameters['imports']) === false) { $hasNewConfigs = true; // Add the config to the imports $parameters['imports'][]['resource'] = $config; } } if (!$hasNewConfigs) { return; } $yamlConfig = new YamlConfig('', $this->configFiles['config']); $yamlConfig->write($parameters); $yamlConfig->clean(); }
[ "protected", "function", "registerConfigs", "(", ")", "{", "$", "hasNewConfigs", "=", "false", ";", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'config'", "]", ")", ";", "$", "parameters", "=", "$", "yamlConfig", "->", "read", "(", ")", ";", "$", "configs", "=", "$", "this", "->", "kernelConfig", "->", "getConfigs", "(", ")", ";", "if", "(", "!", "count", "(", "$", "configs", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "configs", "as", "$", "config", ")", "{", "// Check if the config is already being imported.", "if", "(", "VariableUtil", "::", "recursiveArraySearch", "(", "$", "config", ",", "$", "parameters", "[", "'imports'", "]", ")", "===", "false", ")", "{", "$", "hasNewConfigs", "=", "true", ";", "// Add the config to the imports", "$", "parameters", "[", "'imports'", "]", "[", "]", "[", "'resource'", "]", "=", "$", "config", ";", "}", "}", "if", "(", "!", "$", "hasNewConfigs", ")", "{", "return", ";", "}", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'config'", "]", ")", ";", "$", "yamlConfig", "->", "write", "(", "$", "parameters", ")", ";", "$", "yamlConfig", "->", "clean", "(", ")", ";", "}" ]
Register bundle's config.yml files
[ "Register", "bundle", "s", "config", ".", "yml", "files" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Kernel.php#L193-L223
233,528
CampaignChain/core
Module/Kernel.php
Kernel.registerSecurity
protected function registerSecurity() { /* * Re-create the security.yml file to avoid duplicates in merged array * that occur upon multiple parsing. */ $fs = new Filesystem(); if(!$fs->exists($this->configFiles['security'])){ $fs->copy( $this->configFiles['security_dist'], $this->configFiles['security'], true ); } $yamlConfig = new YamlConfig('', $this->configFiles['security_dist']); $appParameters = $yamlConfig->read(); // Read content of all security.yml files and merge the arrays. $securityFiles = $this->kernelConfig->getSecurities(); if (!count($securityFiles)) { return; } foreach ($securityFiles as $securityFile) { $yamlConfig = new YamlConfig('', $securityFile); $bundleParameters = $yamlConfig->read(); $appParameters = VariableUtil::arrayMerge($bundleParameters, $appParameters); } $yamlConfig = new YamlConfig('', $this->configFiles['security']); $yamlConfig->write($appParameters, 5); $yamlConfig->clean(); }
php
protected function registerSecurity() { /* * Re-create the security.yml file to avoid duplicates in merged array * that occur upon multiple parsing. */ $fs = new Filesystem(); if(!$fs->exists($this->configFiles['security'])){ $fs->copy( $this->configFiles['security_dist'], $this->configFiles['security'], true ); } $yamlConfig = new YamlConfig('', $this->configFiles['security_dist']); $appParameters = $yamlConfig->read(); // Read content of all security.yml files and merge the arrays. $securityFiles = $this->kernelConfig->getSecurities(); if (!count($securityFiles)) { return; } foreach ($securityFiles as $securityFile) { $yamlConfig = new YamlConfig('', $securityFile); $bundleParameters = $yamlConfig->read(); $appParameters = VariableUtil::arrayMerge($bundleParameters, $appParameters); } $yamlConfig = new YamlConfig('', $this->configFiles['security']); $yamlConfig->write($appParameters, 5); $yamlConfig->clean(); }
[ "protected", "function", "registerSecurity", "(", ")", "{", "/*\n * Re-create the security.yml file to avoid duplicates in merged array\n * that occur upon multiple parsing.\n */", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "this", "->", "configFiles", "[", "'security'", "]", ")", ")", "{", "$", "fs", "->", "copy", "(", "$", "this", "->", "configFiles", "[", "'security_dist'", "]", ",", "$", "this", "->", "configFiles", "[", "'security'", "]", ",", "true", ")", ";", "}", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'security_dist'", "]", ")", ";", "$", "appParameters", "=", "$", "yamlConfig", "->", "read", "(", ")", ";", "// Read content of all security.yml files and merge the arrays.", "$", "securityFiles", "=", "$", "this", "->", "kernelConfig", "->", "getSecurities", "(", ")", ";", "if", "(", "!", "count", "(", "$", "securityFiles", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "securityFiles", "as", "$", "securityFile", ")", "{", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "securityFile", ")", ";", "$", "bundleParameters", "=", "$", "yamlConfig", "->", "read", "(", ")", ";", "$", "appParameters", "=", "VariableUtil", "::", "arrayMerge", "(", "$", "bundleParameters", ",", "$", "appParameters", ")", ";", "}", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'security'", "]", ")", ";", "$", "yamlConfig", "->", "write", "(", "$", "appParameters", ",", "5", ")", ";", "$", "yamlConfig", "->", "clean", "(", ")", ";", "}" ]
Register bundle's security.yml files
[ "Register", "bundle", "s", "security", ".", "yml", "files" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Kernel.php#L228-L261
233,529
CampaignChain/core
Module/Kernel.php
Kernel.registerRoutings
protected function registerRoutings() { $yamlConfig = new YamlConfig('', $this->configFiles['routing']); $parameters = $yamlConfig->read(); $hasNewRoutings = false; $routings = $this->kernelConfig->getRoutings(); if (!count($routings)) { return false; } foreach ($routings as $routing) { // Check if the routing is already defined. if (isset($parameters[$routing['name']])) { continue; } $hasNewRoutings = true; // Add the config to the imports $parameters[$routing['name']] = array( 'resource' => $routing['resource'], 'prefix' => $routing['prefix'], ); } if (!$hasNewRoutings) { return; } $yamlConfig = new YamlConfig('', $this->configFiles['routing']); $yamlConfig->write($parameters); $yamlConfig->clean(); }
php
protected function registerRoutings() { $yamlConfig = new YamlConfig('', $this->configFiles['routing']); $parameters = $yamlConfig->read(); $hasNewRoutings = false; $routings = $this->kernelConfig->getRoutings(); if (!count($routings)) { return false; } foreach ($routings as $routing) { // Check if the routing is already defined. if (isset($parameters[$routing['name']])) { continue; } $hasNewRoutings = true; // Add the config to the imports $parameters[$routing['name']] = array( 'resource' => $routing['resource'], 'prefix' => $routing['prefix'], ); } if (!$hasNewRoutings) { return; } $yamlConfig = new YamlConfig('', $this->configFiles['routing']); $yamlConfig->write($parameters); $yamlConfig->clean(); }
[ "protected", "function", "registerRoutings", "(", ")", "{", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'routing'", "]", ")", ";", "$", "parameters", "=", "$", "yamlConfig", "->", "read", "(", ")", ";", "$", "hasNewRoutings", "=", "false", ";", "$", "routings", "=", "$", "this", "->", "kernelConfig", "->", "getRoutings", "(", ")", ";", "if", "(", "!", "count", "(", "$", "routings", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "routings", "as", "$", "routing", ")", "{", "// Check if the routing is already defined.", "if", "(", "isset", "(", "$", "parameters", "[", "$", "routing", "[", "'name'", "]", "]", ")", ")", "{", "continue", ";", "}", "$", "hasNewRoutings", "=", "true", ";", "// Add the config to the imports", "$", "parameters", "[", "$", "routing", "[", "'name'", "]", "]", "=", "array", "(", "'resource'", "=>", "$", "routing", "[", "'resource'", "]", ",", "'prefix'", "=>", "$", "routing", "[", "'prefix'", "]", ",", ")", ";", "}", "if", "(", "!", "$", "hasNewRoutings", ")", "{", "return", ";", "}", "$", "yamlConfig", "=", "new", "YamlConfig", "(", "''", ",", "$", "this", "->", "configFiles", "[", "'routing'", "]", ")", ";", "$", "yamlConfig", "->", "write", "(", "$", "parameters", ")", ";", "$", "yamlConfig", "->", "clean", "(", ")", ";", "}" ]
Register bundle's routing.yml files
[ "Register", "bundle", "s", "routing", ".", "yml", "files" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Kernel.php#L266-L301
233,530
vinterskogen/laravel-uploaded-image
src/AdvancedUploadedImage.php
AdvancedUploadedImage.createFromBase
public static function createFromBase($uploadedImage) { $interventionImage = $uploadedImage->getInterventionImage(); $driver = $interventionImage->getDriver(); $core = $interventionImage->getCore(); $image = new self($uploadedImage, $driver, $core); $image->mime = $interventionImage->mime(); $image->setFileInfoFromPath($uploadedImage->getRealPath()); return $image; }
php
public static function createFromBase($uploadedImage) { $interventionImage = $uploadedImage->getInterventionImage(); $driver = $interventionImage->getDriver(); $core = $interventionImage->getCore(); $image = new self($uploadedImage, $driver, $core); $image->mime = $interventionImage->mime(); $image->setFileInfoFromPath($uploadedImage->getRealPath()); return $image; }
[ "public", "static", "function", "createFromBase", "(", "$", "uploadedImage", ")", "{", "$", "interventionImage", "=", "$", "uploadedImage", "->", "getInterventionImage", "(", ")", ";", "$", "driver", "=", "$", "interventionImage", "->", "getDriver", "(", ")", ";", "$", "core", "=", "$", "interventionImage", "->", "getCore", "(", ")", ";", "$", "image", "=", "new", "self", "(", "$", "uploadedImage", ",", "$", "driver", ",", "$", "core", ")", ";", "$", "image", "->", "mime", "=", "$", "interventionImage", "->", "mime", "(", ")", ";", "$", "image", "->", "setFileInfoFromPath", "(", "$", "uploadedImage", "->", "getRealPath", "(", ")", ")", ";", "return", "$", "image", ";", "}" ]
Create advanced uploaded image with given uploaded image instance. @param \Vinterskogen\UploadedImage\UploadedImage $uploadedImage @return \Vinterskogen\UploadedImage\AdvancedUploadedImage
[ "Create", "advanced", "uploaded", "image", "with", "given", "uploaded", "image", "instance", "." ]
1b2c06ce3386622ac9360cc7895c5e5db0211797
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/AdvancedUploadedImage.php#L167-L180
233,531
malenkiki/aleavatar
src/Malenki/Aleavatar/Unit.php
Unit.generate
public function generate($rank1, $rank2) { $str_method_name = 'row' . $rank1; if (method_exists($this,$str_method_name)) { $this->$str_method_name($rank2); } else { throw new \RuntimeException('Not implemented yet!'); } return $this; }
php
public function generate($rank1, $rank2) { $str_method_name = 'row' . $rank1; if (method_exists($this,$str_method_name)) { $this->$str_method_name($rank2); } else { throw new \RuntimeException('Not implemented yet!'); } return $this; }
[ "public", "function", "generate", "(", "$", "rank1", ",", "$", "rank2", ")", "{", "$", "str_method_name", "=", "'row'", ".", "$", "rank1", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "str_method_name", ")", ")", "{", "$", "this", "->", "$", "str_method_name", "(", "$", "rank2", ")", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "'Not implemented yet!'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Generates unit part by giving row index and column index to choose the shapes to populate with. Parameters are both integers from 0 to 15 inclusive. @uses Unit::row0 Various shapes DONE @uses Unit::row1 Square shapes DONE @uses Unit::row2 Triangle shapes DONE @uses Unit::row3 Rectangle shapes DONE @uses Unit::row4 Circle shapes DONE @uses Unit::row5 Polygon shapes DONE @uses Unit::row6 Triangle shapes part 2 DONE @uses Unit::row7 Circle shapes part 2 DONE @uses Unit::row8 Diamond shapes 1 DONE @uses Unit::row9 Polygon shapes part 2 DONE @uses Unit::row10 Triangle shapes part 3 DONE @uses Unit::row11 Polygon shapes part 3 DONE @uses Unit::row12 Polygon shapes part 4 DONE @uses Unit::row13 Mixed shapes part 1 @uses Unit::row14 Mixed shapes part 2 @uses Unit::row15 Mixed shapes part 3 @param integer $rank1 @param inteer $rank2 @access public @return Unit
[ "Generates", "unit", "part", "by", "giving", "row", "index", "and", "column", "index", "to", "choose", "the", "shapes", "to", "populate", "with", "." ]
91affa83f8580c8e6da62c77ce34b1c4451784bf
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Unit.php#L2931-L2941
233,532
opus-online/yii2-payment
lib/services/ServicesAbstract.php
ServicesAbstract.loadAdapters
public function loadAdapters() { $this->paymentAdapters = array(); foreach ($this->paymentHandler->getAdapters() as $adapterName => $paymentAdapter) { $interfaceClass = sprintf( '%s\%s\AdapterInterface', __NAMESPACE__, ucwords($this->getServiceCode()) ); if ($paymentAdapter instanceof $interfaceClass) { $this->paymentAdapters[$adapterName] = $paymentAdapter; } } }
php
public function loadAdapters() { $this->paymentAdapters = array(); foreach ($this->paymentHandler->getAdapters() as $adapterName => $paymentAdapter) { $interfaceClass = sprintf( '%s\%s\AdapterInterface', __NAMESPACE__, ucwords($this->getServiceCode()) ); if ($paymentAdapter instanceof $interfaceClass) { $this->paymentAdapters[$adapterName] = $paymentAdapter; } } }
[ "public", "function", "loadAdapters", "(", ")", "{", "$", "this", "->", "paymentAdapters", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "paymentHandler", "->", "getAdapters", "(", ")", "as", "$", "adapterName", "=>", "$", "paymentAdapter", ")", "{", "$", "interfaceClass", "=", "sprintf", "(", "'%s\\%s\\AdapterInterface'", ",", "__NAMESPACE__", ",", "ucwords", "(", "$", "this", "->", "getServiceCode", "(", ")", ")", ")", ";", "if", "(", "$", "paymentAdapter", "instanceof", "$", "interfaceClass", ")", "{", "$", "this", "->", "paymentAdapters", "[", "$", "adapterName", "]", "=", "$", "paymentAdapter", ";", "}", "}", "}" ]
Load supported adapters for this service
[ "Load", "supported", "adapters", "for", "this", "service" ]
df48093f7ef1368a0992460bc66f12f0f090044c
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/ServicesAbstract.php#L48-L61
233,533
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.validateParentID
public function validateParentID($attribute) { if ($this->{$attribute} !== NULL) { $comment = self::find()->where(['id' => $this->{$attribute}, 'entity' => $this->entity, 'entityId' => $this->entityId])->active()->exists(); if ($comment === FALSE) { $this->addError('content', Yii::t('app', 'Oops, something went wrong. Please try again later.')); } } }
php
public function validateParentID($attribute) { if ($this->{$attribute} !== NULL) { $comment = self::find()->where(['id' => $this->{$attribute}, 'entity' => $this->entity, 'entityId' => $this->entityId])->active()->exists(); if ($comment === FALSE) { $this->addError('content', Yii::t('app', 'Oops, something went wrong. Please try again later.')); } } }
[ "public", "function", "validateParentID", "(", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "{", "$", "attribute", "}", "!==", "NULL", ")", "{", "$", "comment", "=", "self", "::", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "this", "->", "{", "$", "attribute", "}", ",", "'entity'", "=>", "$", "this", "->", "entity", ",", "'entityId'", "=>", "$", "this", "->", "entityId", "]", ")", "->", "active", "(", ")", "->", "exists", "(", ")", ";", "if", "(", "$", "comment", "===", "FALSE", ")", "{", "$", "this", "->", "addError", "(", "'content'", ",", "Yii", "::", "t", "(", "'app'", ",", "'Oops, something went wrong. Please try again later.'", ")", ")", ";", "}", "}", "}" ]
Validate parentId attribute @param $attribute
[ "Validate", "parentId", "attribute" ]
e06409ea52b12dc14d0594030088fd7d2c2e160a
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L102-L112
233,534
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.behaviors
public function behaviors() { return [ 'blameable' => [ 'class' => BlameableBehavior::className(), 'createdByAttribute' => 'createdBy', 'updatedByAttribute' => 'updatedBy', ], 'timestamp' => [ 'class' => TimestampBehavior::className(), 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updatedAt'] ] ], 'purify' => [ 'class' => PurifyBehavior::className(), 'attributes' => ['content'] ] ]; }
php
public function behaviors() { return [ 'blameable' => [ 'class' => BlameableBehavior::className(), 'createdByAttribute' => 'createdBy', 'updatedByAttribute' => 'updatedBy', ], 'timestamp' => [ 'class' => TimestampBehavior::className(), 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updatedAt'] ] ], 'purify' => [ 'class' => PurifyBehavior::className(), 'attributes' => ['content'] ] ]; }
[ "public", "function", "behaviors", "(", ")", "{", "return", "[", "'blameable'", "=>", "[", "'class'", "=>", "BlameableBehavior", "::", "className", "(", ")", ",", "'createdByAttribute'", "=>", "'createdBy'", ",", "'updatedByAttribute'", "=>", "'updatedBy'", ",", "]", ",", "'timestamp'", "=>", "[", "'class'", "=>", "TimestampBehavior", "::", "className", "(", ")", ",", "'attributes'", "=>", "[", "ActiveRecord", "::", "EVENT_BEFORE_INSERT", "=>", "[", "'createdAt'", "]", ",", "ActiveRecord", "::", "EVENT_BEFORE_UPDATE", "=>", "[", "'updatedAt'", "]", "]", "]", ",", "'purify'", "=>", "[", "'class'", "=>", "PurifyBehavior", "::", "className", "(", ")", ",", "'attributes'", "=>", "[", "'content'", "]", "]", "]", ";", "}" ]
Returns a list of behaviors that this component should behave as. @return array
[ "Returns", "a", "list", "of", "behaviors", "that", "this", "component", "should", "behave", "as", "." ]
e06409ea52b12dc14d0594030088fd7d2c2e160a
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L119-L139
233,535
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.beforeSave
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->parentId > 0) { $parentNodeLevel = (int)self::find()->select('level')->where(['id' => $this->parentId])->scalar(); $this->level = $parentNodeLevel + 1; } return TRUE; } else { return FALSE; } }
php
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->parentId > 0) { $parentNodeLevel = (int)self::find()->select('level')->where(['id' => $this->parentId])->scalar(); $this->level = $parentNodeLevel + 1; } return TRUE; } else { return FALSE; } }
[ "public", "function", "beforeSave", "(", "$", "insert", ")", "{", "if", "(", "parent", "::", "beforeSave", "(", "$", "insert", ")", ")", "{", "if", "(", "$", "this", "->", "parentId", ">", "0", ")", "{", "$", "parentNodeLevel", "=", "(", "int", ")", "self", "::", "find", "(", ")", "->", "select", "(", "'level'", ")", "->", "where", "(", "[", "'id'", "=>", "$", "this", "->", "parentId", "]", ")", "->", "scalar", "(", ")", ";", "$", "this", "->", "level", "=", "$", "parentNodeLevel", "+", "1", ";", "}", "return", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
This method is called at the beginning of inserting or updating a record. @param bool $insert @return bool
[ "This", "method", "is", "called", "at", "the", "beginning", "of", "inserting", "or", "updating", "a", "record", "." ]
e06409ea52b12dc14d0594030088fd7d2c2e160a
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L174-L190
233,536
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.getContent
public function getContent($deletedCommentText = NULL) { if (is_null($deletedCommentText)) { $deletedCommentText = Yii::t('app', 'Comment was deleted.'); } return $this->isDeleted ? $deletedCommentText : Yii::$app->formatter->asNtext($this->content); }
php
public function getContent($deletedCommentText = NULL) { if (is_null($deletedCommentText)) { $deletedCommentText = Yii::t('app', 'Comment was deleted.'); } return $this->isDeleted ? $deletedCommentText : Yii::$app->formatter->asNtext($this->content); }
[ "public", "function", "getContent", "(", "$", "deletedCommentText", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "deletedCommentText", ")", ")", "{", "$", "deletedCommentText", "=", "Yii", "::", "t", "(", "'app'", ",", "'Comment was deleted.'", ")", ";", "}", "return", "$", "this", "->", "isDeleted", "?", "$", "deletedCommentText", ":", "Yii", "::", "$", "app", "->", "formatter", "->", "asNtext", "(", "$", "this", "->", "content", ")", ";", "}" ]
Get comment content @param string $deletedCommentText @return string
[ "Get", "comment", "content" ]
e06409ea52b12dc14d0594030088fd7d2c2e160a
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L394-L402
233,537
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.getAvatar
public function getAvatar($imgOptions = []) { $imgOptions = ArrayHelper::merge($imgOptions, ['class' => 'img-responsive']); if (is_null($this->createdBy)) { return Html::img("http://gravatar.com/avatar/1/?s=50", $imgOptions); } return Html::img("http://gravatar.com/avatar/{$this->author->id}/?s=50", $imgOptions); }
php
public function getAvatar($imgOptions = []) { $imgOptions = ArrayHelper::merge($imgOptions, ['class' => 'img-responsive']); if (is_null($this->createdBy)) { return Html::img("http://gravatar.com/avatar/1/?s=50", $imgOptions); } return Html::img("http://gravatar.com/avatar/{$this->author->id}/?s=50", $imgOptions); }
[ "public", "function", "getAvatar", "(", "$", "imgOptions", "=", "[", "]", ")", "{", "$", "imgOptions", "=", "ArrayHelper", "::", "merge", "(", "$", "imgOptions", ",", "[", "'class'", "=>", "'img-responsive'", "]", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "createdBy", ")", ")", "{", "return", "Html", "::", "img", "(", "\"http://gravatar.com/avatar/1/?s=50\"", ",", "$", "imgOptions", ")", ";", "}", "return", "Html", "::", "img", "(", "\"http://gravatar.com/avatar/{$this->author->id}/?s=50\"", ",", "$", "imgOptions", ")", ";", "}" ]
Get avatar user @param array $imgOptions @return string
[ "Get", "avatar", "user" ]
e06409ea52b12dc14d0594030088fd7d2c2e160a
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L409-L419
233,538
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.runStart
public function runStart($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } /** * @var \Civi\Setup\Model $model */ $model = $this->setup->getModel(); $tplFile = $this->getResourcePath('template.php'); $tplVars = [ 'ctrl' => $this, 'civicrm_version' => \CRM_Utils_System::version(), 'installURLPath' => $this->urls['res'], 'short_lang_code' => \CRM_Core_I18n_PseudoConstant::shortForLong($GLOBALS['tsLocale']), 'text_direction' => (\CRM_Core_I18n::isLanguageRTL($GLOBALS['tsLocale']) ? 'rtl' : 'ltr'), 'model' => $model, 'reqs' => $this->setup->checkRequirements(), ]; // $body = "<pre>" . htmlentities(print_r(['method' => $method, 'urls' => $this->urls, 'data' => $fields], 1)) . "</pre>"; $body = $this->render($tplFile, $tplVars); return array(array(), $body); }
php
public function runStart($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } /** * @var \Civi\Setup\Model $model */ $model = $this->setup->getModel(); $tplFile = $this->getResourcePath('template.php'); $tplVars = [ 'ctrl' => $this, 'civicrm_version' => \CRM_Utils_System::version(), 'installURLPath' => $this->urls['res'], 'short_lang_code' => \CRM_Core_I18n_PseudoConstant::shortForLong($GLOBALS['tsLocale']), 'text_direction' => (\CRM_Core_I18n::isLanguageRTL($GLOBALS['tsLocale']) ? 'rtl' : 'ltr'), 'model' => $model, 'reqs' => $this->setup->checkRequirements(), ]; // $body = "<pre>" . htmlentities(print_r(['method' => $method, 'urls' => $this->urls, 'data' => $fields], 1)) . "</pre>"; $body = $this->render($tplFile, $tplVars); return array(array(), $body); }
[ "public", "function", "runStart", "(", "$", "method", ",", "$", "fields", ")", "{", "$", "checkInstalled", "=", "$", "this", "->", "setup", "->", "checkInstalled", "(", ")", ";", "if", "(", "$", "checkInstalled", "->", "isDatabaseInstalled", "(", ")", "||", "$", "checkInstalled", "->", "isSettingInstalled", "(", ")", ")", "{", "return", "$", "this", "->", "createError", "(", "\"CiviCRM is already installed\"", ")", ";", "}", "/**\n * @var \\Civi\\Setup\\Model $model\n */", "$", "model", "=", "$", "this", "->", "setup", "->", "getModel", "(", ")", ";", "$", "tplFile", "=", "$", "this", "->", "getResourcePath", "(", "'template.php'", ")", ";", "$", "tplVars", "=", "[", "'ctrl'", "=>", "$", "this", ",", "'civicrm_version'", "=>", "\\", "CRM_Utils_System", "::", "version", "(", ")", ",", "'installURLPath'", "=>", "$", "this", "->", "urls", "[", "'res'", "]", ",", "'short_lang_code'", "=>", "\\", "CRM_Core_I18n_PseudoConstant", "::", "shortForLong", "(", "$", "GLOBALS", "[", "'tsLocale'", "]", ")", ",", "'text_direction'", "=>", "(", "\\", "CRM_Core_I18n", "::", "isLanguageRTL", "(", "$", "GLOBALS", "[", "'tsLocale'", "]", ")", "?", "'rtl'", ":", "'ltr'", ")", ",", "'model'", "=>", "$", "model", ",", "'reqs'", "=>", "$", "this", "->", "setup", "->", "checkRequirements", "(", ")", ",", "]", ";", "// $body = \"<pre>\" . htmlentities(print_r(['method' => $method, 'urls' => $this->urls, 'data' => $fields], 1)) . \"</pre>\";", "$", "body", "=", "$", "this", "->", "render", "(", "$", "tplFile", ",", "$", "tplVars", ")", ";", "return", "array", "(", "array", "(", ")", ",", "$", "body", ")", ";", "}" ]
Run the main installer page. @param string $method Ex: 'GET' or 'POST'. @param array $fields List of any HTTP GET/POST fields. @return array The HTTP headers and response text. [0 => array $headers, 1 => string $body].
[ "Run", "the", "main", "installer", "page", "." ]
556b312faf78781c85c4fc4ae6c1c3b658da9e09
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L81-L107
233,539
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.runInstall
public function runInstall($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } $reqs = $this->setup->checkRequirements(); if (count($reqs->getErrors())) { return $this->runStart($method, $fields); } $this->setup->installFiles(); $this->setup->installDatabase(); $m = $this->setup->getModel(); $tplFile = $this->getResourcePath('finished.' . $m->cms . '.php'); if (file_exists($tplFile)) { $tplVars = array(); return array(array(), $this->render($tplFile, $tplVars)); } else { return $this->createError("Installation succeeded. However, the final page ($tplFile) was not available."); } }
php
public function runInstall($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } $reqs = $this->setup->checkRequirements(); if (count($reqs->getErrors())) { return $this->runStart($method, $fields); } $this->setup->installFiles(); $this->setup->installDatabase(); $m = $this->setup->getModel(); $tplFile = $this->getResourcePath('finished.' . $m->cms . '.php'); if (file_exists($tplFile)) { $tplVars = array(); return array(array(), $this->render($tplFile, $tplVars)); } else { return $this->createError("Installation succeeded. However, the final page ($tplFile) was not available."); } }
[ "public", "function", "runInstall", "(", "$", "method", ",", "$", "fields", ")", "{", "$", "checkInstalled", "=", "$", "this", "->", "setup", "->", "checkInstalled", "(", ")", ";", "if", "(", "$", "checkInstalled", "->", "isDatabaseInstalled", "(", ")", "||", "$", "checkInstalled", "->", "isSettingInstalled", "(", ")", ")", "{", "return", "$", "this", "->", "createError", "(", "\"CiviCRM is already installed\"", ")", ";", "}", "$", "reqs", "=", "$", "this", "->", "setup", "->", "checkRequirements", "(", ")", ";", "if", "(", "count", "(", "$", "reqs", "->", "getErrors", "(", ")", ")", ")", "{", "return", "$", "this", "->", "runStart", "(", "$", "method", ",", "$", "fields", ")", ";", "}", "$", "this", "->", "setup", "->", "installFiles", "(", ")", ";", "$", "this", "->", "setup", "->", "installDatabase", "(", ")", ";", "$", "m", "=", "$", "this", "->", "setup", "->", "getModel", "(", ")", ";", "$", "tplFile", "=", "$", "this", "->", "getResourcePath", "(", "'finished.'", ".", "$", "m", "->", "cms", ".", "'.php'", ")", ";", "if", "(", "file_exists", "(", "$", "tplFile", ")", ")", "{", "$", "tplVars", "=", "array", "(", ")", ";", "return", "array", "(", "array", "(", ")", ",", "$", "this", "->", "render", "(", "$", "tplFile", ",", "$", "tplVars", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "createError", "(", "\"Installation succeeded. However, the final page ($tplFile) was not available.\"", ")", ";", "}", "}" ]
Perform the installation action. @param string $method Ex: 'GET' or 'POST'. @param array $fields List of any HTTP GET/POST fields. @return array The HTTP headers and response text. [0 => array $headers, 1 => string $body].
[ "Perform", "the", "installation", "action", "." ]
556b312faf78781c85c4fc4ae6c1c3b658da9e09
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L120-L143
233,540
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.parseAction
protected function parseAction($fields, $default) { if (empty($fields[self::PREFIX]['action'])) { return $default; } else { if (is_array($fields[self::PREFIX]['action'])) { foreach ($fields[self::PREFIX]['action'] as $name => $label) { return $name; } } elseif (is_string($fields[self::PREFIX]['action'])) { return $fields[self::PREFIX]['action']; } } return NULL; }
php
protected function parseAction($fields, $default) { if (empty($fields[self::PREFIX]['action'])) { return $default; } else { if (is_array($fields[self::PREFIX]['action'])) { foreach ($fields[self::PREFIX]['action'] as $name => $label) { return $name; } } elseif (is_string($fields[self::PREFIX]['action'])) { return $fields[self::PREFIX]['action']; } } return NULL; }
[ "protected", "function", "parseAction", "(", "$", "fields", ",", "$", "default", ")", "{", "if", "(", "empty", "(", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "if", "(", "is_array", "(", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", ")", ")", "{", "foreach", "(", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", "as", "$", "name", "=>", "$", "label", ")", "{", "return", "$", "name", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", ")", ")", "{", "return", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", ";", "}", "}", "return", "NULL", ";", "}" ]
Given an HTML submission, determine the name. @param array $fields HTTP inputs -- e.g. with a form element like this: `<input type="submit" name="civisetup[action][Foo]" value="Do the foo">` @return string The name of the action. Ex: 'Foo'.
[ "Given", "an", "HTML", "submission", "determine", "the", "name", "." ]
556b312faf78781c85c4fc4ae6c1c3b658da9e09
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L232-L247
233,541
CampaignChain/core
Wizard/InstallWizard.php
InstallWizard.getSortedSteps
private function getSortedSteps() { $sortedSteps = array(); ksort($this->steps); foreach ($this->steps as $steps) { $sortedSteps = array_merge($sortedSteps, $steps); } return $sortedSteps; }
php
private function getSortedSteps() { $sortedSteps = array(); ksort($this->steps); foreach ($this->steps as $steps) { $sortedSteps = array_merge($sortedSteps, $steps); } return $sortedSteps; }
[ "private", "function", "getSortedSteps", "(", ")", "{", "$", "sortedSteps", "=", "array", "(", ")", ";", "ksort", "(", "$", "this", "->", "steps", ")", ";", "foreach", "(", "$", "this", "->", "steps", "as", "$", "steps", ")", "{", "$", "sortedSteps", "=", "array_merge", "(", "$", "sortedSteps", ",", "$", "steps", ")", ";", "}", "return", "$", "sortedSteps", ";", "}" ]
Sort routers by priority. The lowest number is the highest priority @return StepInterface[]
[ "Sort", "routers", "by", "priority", ".", "The", "lowest", "number", "is", "the", "highest", "priority" ]
82526548a223ed49fcd65ed7c23638544499775f
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Wizard/InstallWizard.php#L71-L81
233,542
notthatbad/silverstripe-rest-api
code/serializers/SerializerFactory.php
SerializerFactory.create
public static function create($mimeType='application/json') { $availableSerializers = \ClassInfo::implementorsOf('Ntb\RestAPI\IRestSerializer'); foreach($availableSerializers as $serializer) { /** @var IRestSerializer $instance */ $instance = new $serializer(); if($instance->active() && $instance->contentType() === $mimeType) { return $instance; } } throw new RestUserException("Requested Accept '$mimeType' not supported", 404); }
php
public static function create($mimeType='application/json') { $availableSerializers = \ClassInfo::implementorsOf('Ntb\RestAPI\IRestSerializer'); foreach($availableSerializers as $serializer) { /** @var IRestSerializer $instance */ $instance = new $serializer(); if($instance->active() && $instance->contentType() === $mimeType) { return $instance; } } throw new RestUserException("Requested Accept '$mimeType' not supported", 404); }
[ "public", "static", "function", "create", "(", "$", "mimeType", "=", "'application/json'", ")", "{", "$", "availableSerializers", "=", "\\", "ClassInfo", "::", "implementorsOf", "(", "'Ntb\\RestAPI\\IRestSerializer'", ")", ";", "foreach", "(", "$", "availableSerializers", "as", "$", "serializer", ")", "{", "/** @var IRestSerializer $instance */", "$", "instance", "=", "new", "$", "serializer", "(", ")", ";", "if", "(", "$", "instance", "->", "active", "(", ")", "&&", "$", "instance", "->", "contentType", "(", ")", "===", "$", "mimeType", ")", "{", "return", "$", "instance", ";", "}", "}", "throw", "new", "RestUserException", "(", "\"Requested Accept '$mimeType' not supported\"", ",", "404", ")", ";", "}" ]
Returns a new instance of a serializer depending on the given type. @param string $mimeType the serializer type; Default: application/json @return IRestSerializer an instance of a serializer @throws RestUserException
[ "Returns", "a", "new", "instance", "of", "a", "serializer", "depending", "on", "the", "given", "type", "." ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/SerializerFactory.php#L24-L34
233,543
notthatbad/silverstripe-rest-api
code/serializers/SerializerFactory.php
SerializerFactory.create_from_request
public static function create_from_request($request) { if($type = $request->getVar('accept')) { try { if(array_key_exists($type, self::$lookup)) { return self::create(self::$lookup[$type]); } } catch(\Exception $e) {} } $types = $request->getAcceptMimetypes(); foreach($types as $type) { try { return self::create($type); } catch(RestUserException $e) {} } return self::create(); }
php
public static function create_from_request($request) { if($type = $request->getVar('accept')) { try { if(array_key_exists($type, self::$lookup)) { return self::create(self::$lookup[$type]); } } catch(\Exception $e) {} } $types = $request->getAcceptMimetypes(); foreach($types as $type) { try { return self::create($type); } catch(RestUserException $e) {} } return self::create(); }
[ "public", "static", "function", "create_from_request", "(", "$", "request", ")", "{", "if", "(", "$", "type", "=", "$", "request", "->", "getVar", "(", "'accept'", ")", ")", "{", "try", "{", "if", "(", "array_key_exists", "(", "$", "type", ",", "self", "::", "$", "lookup", ")", ")", "{", "return", "self", "::", "create", "(", "self", "::", "$", "lookup", "[", "$", "type", "]", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "}", "$", "types", "=", "$", "request", "->", "getAcceptMimetypes", "(", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "try", "{", "return", "self", "::", "create", "(", "$", "type", ")", ";", "}", "catch", "(", "RestUserException", "$", "e", ")", "{", "}", "}", "return", "self", "::", "create", "(", ")", ";", "}" ]
Determines the correct serializer from an incoming request. @param \SS_HTTPRequest $request the request object @return IRestSerializer a new instance of a serializer which fits the request best @throws RestUserException
[ "Determines", "the", "correct", "serializer", "from", "an", "incoming", "request", "." ]
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/SerializerFactory.php#L43-L58
233,544
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessStartedByMessage
public function logProcessStartedByMessage(ProcessId $processId, $startMessageName) { $data = [ 'start_message' => $startMessageName, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessStartedByMessage(ProcessId $processId, $startMessageName) { $data = [ 'start_message' => $startMessageName, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessStartedByMessage", "(", "ProcessId", "$", "processId", ",", "$", "startMessageName", ")", "{", "$", "data", "=", "[", "'start_message'", "=>", "$", "startMessageName", ",", "]", ";", "$", "entry", "=", "$", "this", "->", "loadProcessEntryIfExists", "(", "$", "processId", ")", ";", "if", "(", "is_null", "(", "$", "entry", ")", ")", "{", "$", "data", "[", "'status'", "]", "=", "self", "::", "STATUS_RUNNING", ";", "$", "this", "->", "insertNewEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "updateEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "}" ]
Create or update entry for process with the start message name. If a new process needs to be created set status to "running". @param string $startMessageName @param ProcessId $processId @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "the", "start", "message", "name", ".", "If", "a", "new", "process", "needs", "to", "be", "created", "set", "status", "to", "running", "." ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L57-L72
233,545
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessStartedAt
public function logProcessStartedAt(ProcessId $processId, \DateTimeImmutable $startedAt) { $data = [ 'started_at' => $startedAt->format(\DateTime::ISO8601), ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessStartedAt(ProcessId $processId, \DateTimeImmutable $startedAt) { $data = [ 'started_at' => $startedAt->format(\DateTime::ISO8601), ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessStartedAt", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "startedAt", ")", "{", "$", "data", "=", "[", "'started_at'", "=>", "$", "startedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ",", "]", ";", "$", "entry", "=", "$", "this", "->", "loadProcessEntryIfExists", "(", "$", "processId", ")", ";", "if", "(", "is_null", "(", "$", "entry", ")", ")", "{", "$", "data", "[", "'status'", "]", "=", "self", "::", "STATUS_RUNNING", ";", "$", "this", "->", "insertNewEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "updateEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "}" ]
Create or update entry for process with the started at information. If a new process needs to be created set status to "running". @param ProcessId $processId @param \DateTimeImmutable $startedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "the", "started", "at", "information", ".", "If", "a", "new", "process", "needs", "to", "be", "created", "set", "status", "to", "running", "." ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L82-L97
233,546
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessSucceed
public function logProcessSucceed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_SUCCEED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessSucceed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_SUCCEED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessSucceed", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "finishedAt", ")", "{", "$", "data", "=", "[", "'finished_at'", "=>", "$", "finishedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ",", "'status'", "=>", "self", "::", "STATUS_SUCCEED", ",", "]", ";", "$", "entry", "=", "$", "this", "->", "loadProcessEntryIfExists", "(", "$", "processId", ")", ";", "if", "(", "is_null", "(", "$", "entry", ")", ")", "{", "$", "this", "->", "insertNewEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "updateEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "}" ]
Create or update entry for process with finished at information. Set status to "succeed". @param ProcessId $processId @param \DateTimeImmutable $finishedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "finished", "at", "information", ".", "Set", "status", "to", "succeed", "." ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L107-L121
233,547
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessFailed
public function logProcessFailed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_FAILED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessFailed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_FAILED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessFailed", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "finishedAt", ")", "{", "$", "data", "=", "[", "'finished_at'", "=>", "$", "finishedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ",", "'status'", "=>", "self", "::", "STATUS_FAILED", ",", "]", ";", "$", "entry", "=", "$", "this", "->", "loadProcessEntryIfExists", "(", "$", "processId", ")", ";", "if", "(", "is_null", "(", "$", "entry", ")", ")", "{", "$", "this", "->", "insertNewEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "updateEntry", "(", "$", "processId", ",", "$", "data", ")", ";", "}", "}" ]
Create or update entry for process with finished at information. Set status to "failed". @param ProcessId $processId @param \DateTimeImmutable $finishedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "finished", "at", "information", ".", "Set", "status", "to", "failed", "." ]
3d6c8bdc72e855786227747bf06bcf8221f7860a
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L131-L145
233,548
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.encode
public function encode($format, $quality = null) { $this->toggleModified(); $this->getInterventionImage()->encode($format, $quality); return $this; }
php
public function encode($format, $quality = null) { $this->toggleModified(); $this->getInterventionImage()->encode($format, $quality); return $this; }
[ "public", "function", "encode", "(", "$", "format", ",", "$", "quality", "=", "null", ")", "{", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", "encode", "(", "$", "format", ",", "$", "quality", ")", ";", "return", "$", "this", ";", "}" ]
Encode uploaded image to given format and quality. @param mixed $format @param int|null $quality @return $this
[ "Encode", "uploaded", "image", "to", "given", "format", "and", "quality", "." ]
1b2c06ce3386622ac9360cc7895c5e5db0211797
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L119-L126
233,549
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.scale
public function scale($percentage) { $this->validatePercentageValue($percentage); $this->toggleModified(); $percentage = floatval($percentage); $width = $this->width() / 100 * $percentage; $height = $this->height() / 100 * $percentage; $this->getInterventionImage()->resize($width, $height); return $this; }
php
public function scale($percentage) { $this->validatePercentageValue($percentage); $this->toggleModified(); $percentage = floatval($percentage); $width = $this->width() / 100 * $percentage; $height = $this->height() / 100 * $percentage; $this->getInterventionImage()->resize($width, $height); return $this; }
[ "public", "function", "scale", "(", "$", "percentage", ")", "{", "$", "this", "->", "validatePercentageValue", "(", "$", "percentage", ")", ";", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "percentage", "=", "floatval", "(", "$", "percentage", ")", ";", "$", "width", "=", "$", "this", "->", "width", "(", ")", "/", "100", "*", "$", "percentage", ";", "$", "height", "=", "$", "this", "->", "height", "(", ")", "/", "100", "*", "$", "percentage", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", "resize", "(", "$", "width", ",", "$", "height", ")", ";", "return", "$", "this", ";", "}" ]
Scale the uploaded image size using given percentage. @param int|float $percentage @return $this
[ "Scale", "the", "uploaded", "image", "size", "using", "given", "percentage", "." ]
1b2c06ce3386622ac9360cc7895c5e5db0211797
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L134-L147
233,550
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getDBInstance
public function getDBInstance() { if ($this->database === null) { $this->database = new MySQLDBImpl($this->config); } return $this->database; }
php
public function getDBInstance() { if ($this->database === null) { $this->database = new MySQLDBImpl($this->config); } return $this->database; }
[ "public", "function", "getDBInstance", "(", ")", "{", "if", "(", "$", "this", "->", "database", "===", "null", ")", "{", "$", "this", "->", "database", "=", "new", "MySQLDBImpl", "(", "$", "this", "->", "config", ")", ";", "}", "return", "$", "this", "->", "database", ";", "}" ]
This will return a DB. The same from time to time @return DB
[ "This", "will", "return", "a", "DB", ".", "The", "same", "from", "time", "to", "time" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L81-L88
233,551
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getAJAXServerInstance
public function getAJAXServerInstance() { if ($this->ajaxServer === null) { $this->ajaxServer = new ServerImpl($this); } return $this->ajaxServer; }
php
public function getAJAXServerInstance() { if ($this->ajaxServer === null) { $this->ajaxServer = new ServerImpl($this); } return $this->ajaxServer; }
[ "public", "function", "getAJAXServerInstance", "(", ")", "{", "if", "(", "$", "this", "->", "ajaxServer", "===", "null", ")", "{", "$", "this", "->", "ajaxServer", "=", "new", "ServerImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "ajaxServer", ";", "}" ]
This will return an ajax register, and reuse it from time to time @return ServerImpl
[ "This", "will", "return", "an", "ajax", "register", "and", "reuse", "it", "from", "time", "to", "time" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L95-L101
233,552
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getPageOrderInstance
public function getPageOrderInstance() { if ($this->pageOrder === null) { $this->pageOrder = new PageOrderImpl($this); } return $this->pageOrder; }
php
public function getPageOrderInstance() { if ($this->pageOrder === null) { $this->pageOrder = new PageOrderImpl($this); } return $this->pageOrder; }
[ "public", "function", "getPageOrderInstance", "(", ")", "{", "if", "(", "$", "this", "->", "pageOrder", "===", "null", ")", "{", "$", "this", "->", "pageOrder", "=", "new", "PageOrderImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "pageOrder", ";", "}" ]
This will return an instance of PageOrder, and reuse it. @return PageOrder
[ "This", "will", "return", "an", "instance", "of", "PageOrder", "and", "reuse", "it", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L107-L113
233,553
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getCurrentPageStrategyInstance
public function getCurrentPageStrategyInstance() { if ($this->currentPageStrategy === null) { $this->currentPageStrategy = new CurrentPageStrategyImpl($this); } return $this->currentPageStrategy; }
php
public function getCurrentPageStrategyInstance() { if ($this->currentPageStrategy === null) { $this->currentPageStrategy = new CurrentPageStrategyImpl($this); } return $this->currentPageStrategy; }
[ "public", "function", "getCurrentPageStrategyInstance", "(", ")", "{", "if", "(", "$", "this", "->", "currentPageStrategy", "===", "null", ")", "{", "$", "this", "->", "currentPageStrategy", "=", "new", "CurrentPageStrategyImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "currentPageStrategy", ";", "}" ]
This will return an instance of CurrentPageStrategy, and reuse it. @return CurrentPageStrategy
[ "This", "will", "return", "an", "instance", "of", "CurrentPageStrategy", "and", "reuse", "it", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L119-L125
233,554
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getUserLibraryInstance
public function getUserLibraryInstance() { if ($this->userLibrary === null) { $this->userLibrary = new UserLibraryImpl($this); } return $this->userLibrary; }
php
public function getUserLibraryInstance() { if ($this->userLibrary === null) { $this->userLibrary = new UserLibraryImpl($this); } return $this->userLibrary; }
[ "public", "function", "getUserLibraryInstance", "(", ")", "{", "if", "(", "$", "this", "->", "userLibrary", "===", "null", ")", "{", "$", "this", "->", "userLibrary", "=", "new", "UserLibraryImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "userLibrary", ";", "}" ]
Will create and reuse an instance of UserLibrary @return UserLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "UserLibrary" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L141-L147
233,555
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getDefaultPageLibraryInstance
public function getDefaultPageLibraryInstance() { if ($this->defaultPageLibrary === null) { $this->defaultPageLibrary = new DefaultPageLibraryImpl($this); } return $this->defaultPageLibrary; }
php
public function getDefaultPageLibraryInstance() { if ($this->defaultPageLibrary === null) { $this->defaultPageLibrary = new DefaultPageLibraryImpl($this); } return $this->defaultPageLibrary; }
[ "public", "function", "getDefaultPageLibraryInstance", "(", ")", "{", "if", "(", "$", "this", "->", "defaultPageLibrary", "===", "null", ")", "{", "$", "this", "->", "defaultPageLibrary", "=", "new", "DefaultPageLibraryImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "defaultPageLibrary", ";", "}" ]
Will create and reuse an instance of DefaultPageLibrary @return DefaultPageLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "DefaultPageLibrary" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L154-L161
233,556
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getCacheControlInstance
public function getCacheControlInstance() { if ($this->cacheControl == null) { $this->cacheControl = new CacheControlImpl($this->getSiteInstance(), $this->getCurrentPageStrategyInstance()); } return $this->cacheControl; }
php
public function getCacheControlInstance() { if ($this->cacheControl == null) { $this->cacheControl = new CacheControlImpl($this->getSiteInstance(), $this->getCurrentPageStrategyInstance()); } return $this->cacheControl; }
[ "public", "function", "getCacheControlInstance", "(", ")", "{", "if", "(", "$", "this", "->", "cacheControl", "==", "null", ")", "{", "$", "this", "->", "cacheControl", "=", "new", "CacheControlImpl", "(", "$", "this", "->", "getSiteInstance", "(", ")", ",", "$", "this", "->", "getCurrentPageStrategyInstance", "(", ")", ")", ";", "}", "return", "$", "this", "->", "cacheControl", ";", "}" ]
Will create and reuse an instance of CacheControl @return CacheControl
[ "Will", "create", "and", "reuse", "an", "instance", "of", "CacheControl" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L168-L174
233,557
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getUpdaterInstance
public function getUpdaterInstance() { if ($this->updater == null) { $this->updater = new GitUpdaterImpl($this, $this->getConfigInstance()->getRootPath()); } return $this->updater; }
php
public function getUpdaterInstance() { if ($this->updater == null) { $this->updater = new GitUpdaterImpl($this, $this->getConfigInstance()->getRootPath()); } return $this->updater; }
[ "public", "function", "getUpdaterInstance", "(", ")", "{", "if", "(", "$", "this", "->", "updater", "==", "null", ")", "{", "$", "this", "->", "updater", "=", "new", "GitUpdaterImpl", "(", "$", "this", ",", "$", "this", "->", "getConfigInstance", "(", ")", "->", "getRootPath", "(", ")", ")", ";", "}", "return", "$", "this", "->", "updater", ";", "}" ]
Will create and reuse an instance of Updater @return mixed
[ "Will", "create", "and", "reuse", "an", "instance", "of", "Updater" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L180-L186
233,558
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getSiteInstance
public function getSiteInstance() { return $this->site == null ? $this->site = new SiteImpl($this) : $this->site; }
php
public function getSiteInstance() { return $this->site == null ? $this->site = new SiteImpl($this) : $this->site; }
[ "public", "function", "getSiteInstance", "(", ")", "{", "return", "$", "this", "->", "site", "==", "null", "?", "$", "this", "->", "site", "=", "new", "SiteImpl", "(", "$", "this", ")", ":", "$", "this", "->", "site", ";", "}" ]
Will create and reuse an instance of Variables. These should reflect the site scoped variables. @return Site
[ "Will", "create", "and", "reuse", "an", "instance", "of", "Variables", ".", "These", "should", "reflect", "the", "site", "scoped", "variables", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L193-L196
233,559
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getFileLibraryInstance
public function getFileLibraryInstance() { return $this->fileLibrary == null ? $this->fileLibrary = new FileLibraryImpl($this, new FolderImpl($this->getConfigInstance()->getRootPath() . "/files/")) : $this->fileLibrary; }
php
public function getFileLibraryInstance() { return $this->fileLibrary == null ? $this->fileLibrary = new FileLibraryImpl($this, new FolderImpl($this->getConfigInstance()->getRootPath() . "/files/")) : $this->fileLibrary; }
[ "public", "function", "getFileLibraryInstance", "(", ")", "{", "return", "$", "this", "->", "fileLibrary", "==", "null", "?", "$", "this", "->", "fileLibrary", "=", "new", "FileLibraryImpl", "(", "$", "this", ",", "new", "FolderImpl", "(", "$", "this", "->", "getConfigInstance", "(", ")", "->", "getRootPath", "(", ")", ".", "\"/files/\"", ")", ")", ":", "$", "this", "->", "fileLibrary", ";", "}" ]
Will create and reuse an instance of FileLibrary. @return FileLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "FileLibrary", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L202-L205
233,560
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getTypeHandlerLibraryInstance
public function getTypeHandlerLibraryInstance() { return $this->typeHandlerLib == null ? $this->typeHandlerLib = new TypeHandlerLibraryImpl($this) : $this->typeHandlerLib; }
php
public function getTypeHandlerLibraryInstance() { return $this->typeHandlerLib == null ? $this->typeHandlerLib = new TypeHandlerLibraryImpl($this) : $this->typeHandlerLib; }
[ "public", "function", "getTypeHandlerLibraryInstance", "(", ")", "{", "return", "$", "this", "->", "typeHandlerLib", "==", "null", "?", "$", "this", "->", "typeHandlerLib", "=", "new", "TypeHandlerLibraryImpl", "(", "$", "this", ")", ":", "$", "this", "->", "typeHandlerLib", ";", "}" ]
Will create and reuse instance of TypeHandlerLibrary. @return TypeHandlerLibrary
[ "Will", "create", "and", "reuse", "instance", "of", "TypeHandlerLibrary", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L361-L364
233,561
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.load_language
function load_language($file_name) { if ($file_name == $this->loaded_language) { // this file is already loaded! return; } //Prepare some stuff before actually loading the language file $this->loaded_language = $file_name; $this->parse_cache_built = false; $this->enable_highlighting(); $language_data = array(); //Load the language file require $file_name; // Perhaps some checking might be added here later to check that // $language data is a valid thing but maybe not $this->language_data = $language_data; // Set strict mode if should be set $this->strict_mode = $this->language_data['STRICT_MODE_APPLIES']; // Set permissions for all lexics to true // so they'll be highlighted by default foreach (array_keys($this->language_data['KEYWORDS']) as $key) { if (!empty($this->language_data['KEYWORDS'][$key])) { $this->lexic_permissions['KEYWORDS'][$key] = true; } else { $this->lexic_permissions['KEYWORDS'][$key] = false; } } foreach (array_keys($this->language_data['COMMENT_SINGLE']) as $key) { $this->lexic_permissions['COMMENTS'][$key] = true; } foreach (array_keys($this->language_data['REGEXPS']) as $key) { $this->lexic_permissions['REGEXPS'][$key] = true; } // for BenBE and future code reviews: // we can use empty here since we only check for existance and emptiness of an array // if it is not an array at all but rather false or null this will work as intended as well // even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice if (!empty($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'])) { foreach ($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'] as $flag => $value) { // it's either true or false and maybe is true as well $perm = $value !== GESHI_NEVER; if ($flag == 'ALL') { $this->enable_highlighting($perm); continue; } if (!isset($this->lexic_permissions[$flag])) { // unknown lexic permission continue; } if (is_array($this->lexic_permissions[$flag])) { foreach ($this->lexic_permissions[$flag] as $key => $val) { $this->lexic_permissions[$flag][$key] = $perm; } } else { $this->lexic_permissions[$flag] = $perm; } } unset($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS']); } //Fix: Problem where hardescapes weren't handled if no ESCAPE_CHAR was given //You need to set one for HARDESCAPES only in this case. if(!isset($this->language_data['HARDCHAR'])) { $this->language_data['HARDCHAR'] = $this->language_data['ESCAPE_CHAR']; } //NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults $style_filename = substr($file_name, 0, -4) . '.style.php'; if (is_readable($style_filename)) { //Clear any style_data that could have been set before ... if (isset($style_data)) { unset($style_data); } //Read the Style Information from the style file include $style_filename; //Apply the new styles to our current language styles if (isset($style_data) && is_array($style_data)) { $this->language_data['STYLES'] = $this->merge_arrays($this->language_data['STYLES'], $style_data); } } }
php
function load_language($file_name) { if ($file_name == $this->loaded_language) { // this file is already loaded! return; } //Prepare some stuff before actually loading the language file $this->loaded_language = $file_name; $this->parse_cache_built = false; $this->enable_highlighting(); $language_data = array(); //Load the language file require $file_name; // Perhaps some checking might be added here later to check that // $language data is a valid thing but maybe not $this->language_data = $language_data; // Set strict mode if should be set $this->strict_mode = $this->language_data['STRICT_MODE_APPLIES']; // Set permissions for all lexics to true // so they'll be highlighted by default foreach (array_keys($this->language_data['KEYWORDS']) as $key) { if (!empty($this->language_data['KEYWORDS'][$key])) { $this->lexic_permissions['KEYWORDS'][$key] = true; } else { $this->lexic_permissions['KEYWORDS'][$key] = false; } } foreach (array_keys($this->language_data['COMMENT_SINGLE']) as $key) { $this->lexic_permissions['COMMENTS'][$key] = true; } foreach (array_keys($this->language_data['REGEXPS']) as $key) { $this->lexic_permissions['REGEXPS'][$key] = true; } // for BenBE and future code reviews: // we can use empty here since we only check for existance and emptiness of an array // if it is not an array at all but rather false or null this will work as intended as well // even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice if (!empty($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'])) { foreach ($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'] as $flag => $value) { // it's either true or false and maybe is true as well $perm = $value !== GESHI_NEVER; if ($flag == 'ALL') { $this->enable_highlighting($perm); continue; } if (!isset($this->lexic_permissions[$flag])) { // unknown lexic permission continue; } if (is_array($this->lexic_permissions[$flag])) { foreach ($this->lexic_permissions[$flag] as $key => $val) { $this->lexic_permissions[$flag][$key] = $perm; } } else { $this->lexic_permissions[$flag] = $perm; } } unset($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS']); } //Fix: Problem where hardescapes weren't handled if no ESCAPE_CHAR was given //You need to set one for HARDESCAPES only in this case. if(!isset($this->language_data['HARDCHAR'])) { $this->language_data['HARDCHAR'] = $this->language_data['ESCAPE_CHAR']; } //NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults $style_filename = substr($file_name, 0, -4) . '.style.php'; if (is_readable($style_filename)) { //Clear any style_data that could have been set before ... if (isset($style_data)) { unset($style_data); } //Read the Style Information from the style file include $style_filename; //Apply the new styles to our current language styles if (isset($style_data) && is_array($style_data)) { $this->language_data['STYLES'] = $this->merge_arrays($this->language_data['STYLES'], $style_data); } } }
[ "function", "load_language", "(", "$", "file_name", ")", "{", "if", "(", "$", "file_name", "==", "$", "this", "->", "loaded_language", ")", "{", "// this file is already loaded!", "return", ";", "}", "//Prepare some stuff before actually loading the language file", "$", "this", "->", "loaded_language", "=", "$", "file_name", ";", "$", "this", "->", "parse_cache_built", "=", "false", ";", "$", "this", "->", "enable_highlighting", "(", ")", ";", "$", "language_data", "=", "array", "(", ")", ";", "//Load the language file", "require", "$", "file_name", ";", "// Perhaps some checking might be added here later to check that", "// $language data is a valid thing but maybe not", "$", "this", "->", "language_data", "=", "$", "language_data", ";", "// Set strict mode if should be set", "$", "this", "->", "strict_mode", "=", "$", "this", "->", "language_data", "[", "'STRICT_MODE_APPLIES'", "]", ";", "// Set permissions for all lexics to true", "// so they'll be highlighted by default", "foreach", "(", "array_keys", "(", "$", "this", "->", "language_data", "[", "'KEYWORDS'", "]", ")", "as", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "language_data", "[", "'KEYWORDS'", "]", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "lexic_permissions", "[", "'KEYWORDS'", "]", "[", "$", "key", "]", "=", "true", ";", "}", "else", "{", "$", "this", "->", "lexic_permissions", "[", "'KEYWORDS'", "]", "[", "$", "key", "]", "=", "false", ";", "}", "}", "foreach", "(", "array_keys", "(", "$", "this", "->", "language_data", "[", "'COMMENT_SINGLE'", "]", ")", "as", "$", "key", ")", "{", "$", "this", "->", "lexic_permissions", "[", "'COMMENTS'", "]", "[", "$", "key", "]", "=", "true", ";", "}", "foreach", "(", "array_keys", "(", "$", "this", "->", "language_data", "[", "'REGEXPS'", "]", ")", "as", "$", "key", ")", "{", "$", "this", "->", "lexic_permissions", "[", "'REGEXPS'", "]", "[", "$", "key", "]", "=", "true", ";", "}", "// for BenBE and future code reviews:", "// we can use empty here since we only check for existance and emptiness of an array", "// if it is not an array at all but rather false or null this will work as intended as well", "// even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice", "if", "(", "!", "empty", "(", "$", "this", "->", "language_data", "[", "'PARSER_CONTROL'", "]", "[", "'ENABLE_FLAGS'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "language_data", "[", "'PARSER_CONTROL'", "]", "[", "'ENABLE_FLAGS'", "]", "as", "$", "flag", "=>", "$", "value", ")", "{", "// it's either true or false and maybe is true as well", "$", "perm", "=", "$", "value", "!==", "GESHI_NEVER", ";", "if", "(", "$", "flag", "==", "'ALL'", ")", "{", "$", "this", "->", "enable_highlighting", "(", "$", "perm", ")", ";", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "lexic_permissions", "[", "$", "flag", "]", ")", ")", "{", "// unknown lexic permission", "continue", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "lexic_permissions", "[", "$", "flag", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "lexic_permissions", "[", "$", "flag", "]", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "lexic_permissions", "[", "$", "flag", "]", "[", "$", "key", "]", "=", "$", "perm", ";", "}", "}", "else", "{", "$", "this", "->", "lexic_permissions", "[", "$", "flag", "]", "=", "$", "perm", ";", "}", "}", "unset", "(", "$", "this", "->", "language_data", "[", "'PARSER_CONTROL'", "]", "[", "'ENABLE_FLAGS'", "]", ")", ";", "}", "//Fix: Problem where hardescapes weren't handled if no ESCAPE_CHAR was given", "//You need to set one for HARDESCAPES only in this case.", "if", "(", "!", "isset", "(", "$", "this", "->", "language_data", "[", "'HARDCHAR'", "]", ")", ")", "{", "$", "this", "->", "language_data", "[", "'HARDCHAR'", "]", "=", "$", "this", "->", "language_data", "[", "'ESCAPE_CHAR'", "]", ";", "}", "//NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults", "$", "style_filename", "=", "substr", "(", "$", "file_name", ",", "0", ",", "-", "4", ")", ".", "'.style.php'", ";", "if", "(", "is_readable", "(", "$", "style_filename", ")", ")", "{", "//Clear any style_data that could have been set before ...", "if", "(", "isset", "(", "$", "style_data", ")", ")", "{", "unset", "(", "$", "style_data", ")", ";", "}", "//Read the Style Information from the style file", "include", "$", "style_filename", ";", "//Apply the new styles to our current language styles", "if", "(", "isset", "(", "$", "style_data", ")", "&&", "is_array", "(", "$", "style_data", ")", ")", "{", "$", "this", "->", "language_data", "[", "'STYLES'", "]", "=", "$", "this", "->", "merge_arrays", "(", "$", "this", "->", "language_data", "[", "'STYLES'", "]", ",", "$", "style_data", ")", ";", "}", "}", "}" ]
Gets language information and stores it for later use @param string The filename of the language file you want to load @since 1.0.0 @access private @todo Needs to load keys for lexic permissions for keywords, regexps etc
[ "Gets", "language", "information", "and", "stores", "it", "for", "later", "use" ]
ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L3761-L3850
233,562
MW-Peachy/Peachy
Plugins/Xml.php
Xml.input
public static function input( $name, $size = false, $value = false, $attribs = array() ) { $attributes = array( 'name' => $name ); if( $size ) { $attributes['size'] = $size; } if( $value !== false ) { // maybe 0 $attributes['value'] = $value; } return self::element( 'input', $attributes + $attribs ); }
php
public static function input( $name, $size = false, $value = false, $attribs = array() ) { $attributes = array( 'name' => $name ); if( $size ) { $attributes['size'] = $size; } if( $value !== false ) { // maybe 0 $attributes['value'] = $value; } return self::element( 'input', $attributes + $attribs ); }
[ "public", "static", "function", "input", "(", "$", "name", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array", "(", "'name'", "=>", "$", "name", ")", ";", "if", "(", "$", "size", ")", "{", "$", "attributes", "[", "'size'", "]", "=", "$", "size", ";", "}", "if", "(", "$", "value", "!==", "false", ")", "{", "// maybe 0", "$", "attributes", "[", "'value'", "]", "=", "$", "value", ";", "}", "return", "self", "::", "element", "(", "'input'", ",", "$", "attributes", "+", "$", "attribs", ")", ";", "}" ]
Convenience function to build an HTML text input field @param string $name value of the name attribute @param bool|int $size value of the size attribute @param mixed $value mixed value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "text", "input", "field" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L176-L188
233,563
MW-Peachy/Peachy
Plugins/Xml.php
Xml.password
public static function password( $name, $size = false, $value = false, $attribs = array() ) { return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) ); }
php
public static function password( $name, $size = false, $value = false, $attribs = array() ) { return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) ); }
[ "public", "static", "function", "password", "(", "$", "name", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "input", "(", "$", "name", ",", "$", "size", ",", "$", "value", ",", "array_merge", "(", "$", "attribs", ",", "array", "(", "'type'", "=>", "'password'", ")", ")", ")", ";", "}" ]
Convenience function to build an HTML password input field @param string $name value of the name attribute @param bool|int $size value of the size attribute @param $value mixed value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "password", "input", "field" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L198-L200
233,564
MW-Peachy/Peachy
Plugins/Xml.php
Xml.check
public static function check( $name, $checked = false, $attribs = array() ) { return self::element( 'input', array_merge( array( 'name' => $name, 'type' => 'checkbox', 'value' => 1 ), self::attrib( 'checked', $checked ), $attribs ) ); }
php
public static function check( $name, $checked = false, $attribs = array() ) { return self::element( 'input', array_merge( array( 'name' => $name, 'type' => 'checkbox', 'value' => 1 ), self::attrib( 'checked', $checked ), $attribs ) ); }
[ "public", "static", "function", "check", "(", "$", "name", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'input'", ",", "array_merge", "(", "array", "(", "'name'", "=>", "$", "name", ",", "'type'", "=>", "'checkbox'", ",", "'value'", "=>", "1", ")", ",", "self", "::", "attrib", "(", "'checked'", ",", "$", "checked", ")", ",", "$", "attribs", ")", ")", ";", "}" ]
Convenience function to build an HTML checkbox @param string $name value of the name attribute @param bool $checked Whether the checkbox is checked or not @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "checkbox" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L221-L233
233,565
MW-Peachy/Peachy
Plugins/Xml.php
Xml.radio
public static function radio( $name, $value, $checked = false, $attribs = array() ) { return self::element( 'input', array( 'name' => $name, 'type' => 'radio', 'value' => $value ) + self::attrib( 'checked', $checked ) + $attribs ); }
php
public static function radio( $name, $value, $checked = false, $attribs = array() ) { return self::element( 'input', array( 'name' => $name, 'type' => 'radio', 'value' => $value ) + self::attrib( 'checked', $checked ) + $attribs ); }
[ "public", "static", "function", "radio", "(", "$", "name", ",", "$", "value", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'input'", ",", "array", "(", "'name'", "=>", "$", "name", ",", "'type'", "=>", "'radio'", ",", "'value'", "=>", "$", "value", ")", "+", "self", "::", "attrib", "(", "'checked'", ",", "$", "checked", ")", "+", "$", "attribs", ")", ";", "}" ]
Convenience function to build an HTML radio button @param string $name value of the name attribute @param string $value value of the value attribute @param bool $checked Whether the checkbox is checked or not @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "radio", "button" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L243-L251
233,566
MW-Peachy/Peachy
Plugins/Xml.php
Xml.label
public static function label( $label, $id, $attribs = array() ) { $a = array( 'for' => $id ); // FIXME avoid copy pasting below: if( isset( $attribs['class'] ) ) { $a['class'] = $attribs['class']; } if( isset( $attribs['title'] ) ) { $a['title'] = $attribs['title']; } return self::element( 'label', $a, $label ); }
php
public static function label( $label, $id, $attribs = array() ) { $a = array( 'for' => $id ); // FIXME avoid copy pasting below: if( isset( $attribs['class'] ) ) { $a['class'] = $attribs['class']; } if( isset( $attribs['title'] ) ) { $a['title'] = $attribs['title']; } return self::element( 'label', $a, $label ); }
[ "public", "static", "function", "label", "(", "$", "label", ",", "$", "id", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "a", "=", "array", "(", "'for'", "=>", "$", "id", ")", ";", "// FIXME avoid copy pasting below:", "if", "(", "isset", "(", "$", "attribs", "[", "'class'", "]", ")", ")", "{", "$", "a", "[", "'class'", "]", "=", "$", "attribs", "[", "'class'", "]", ";", "}", "if", "(", "isset", "(", "$", "attribs", "[", "'title'", "]", ")", ")", "{", "$", "a", "[", "'title'", "]", "=", "$", "attribs", "[", "'title'", "]", ";", "}", "return", "self", "::", "element", "(", "'label'", ",", "$", "a", ",", "$", "label", ")", ";", "}" ]
Convenience function to build an HTML form label @param string $label text of the label @param $id @param array $attribs an attribute array. This will usually be the same array as is passed to the corresponding input element, so this function will cherry-pick appropriate attributes to apply to the label as well; only class and title are applied. @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "form", "label" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L263-L275
233,567
MW-Peachy/Peachy
Plugins/Xml.php
Xml.inputLabel
public static function inputLabel( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); return $label . '&#160;' . $input; }
php
public static function inputLabel( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); return $label . '&#160;' . $input; }
[ "public", "static", "function", "inputLabel", "(", "$", "label", ",", "$", "name", ",", "$", "id", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "list", "(", "$", "label", ",", "$", "input", ")", "=", "self", "::", "inputLabelSep", "(", "$", "label", ",", "$", "name", ",", "$", "id", ",", "$", "size", ",", "$", "value", ",", "$", "attribs", ")", ";", "return", "$", "label", ".", "'&#160;'", ".", "$", "input", ";", "}" ]
Convenience function to build an HTML text input field with a label @param string $label text of the label @param string $name value of the name attribute @param string $id id of the input @param int|Bool $size value of the size attribute @param string|Bool $value value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "text", "input", "field", "with", "a", "label" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L287-L290
233,568
MW-Peachy/Peachy
Plugins/Xml.php
Xml.checkLabel
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) { return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
php
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) { return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
[ "public", "static", "function", "checkLabel", "(", "$", "label", ",", "$", "name", ",", "$", "id", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "check", "(", "$", "name", ",", "$", "checked", ",", "array", "(", "'id'", "=>", "$", "id", ")", "+", "$", "attribs", ")", ".", "'&#160;'", ".", "self", "::", "label", "(", "$", "label", ",", "$", "id", ",", "$", "attribs", ")", ";", "}" ]
Convenience function to build an HTML checkbox with a label @param $label @param $name @param $id @param $checked bool @param $attribs array @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "checkbox", "with", "a", "label" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L322-L326
233,569
MW-Peachy/Peachy
Plugins/Xml.php
Xml.radioLabel
public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
php
public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
[ "public", "static", "function", "radioLabel", "(", "$", "label", ",", "$", "name", ",", "$", "value", ",", "$", "id", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "radio", "(", "$", "name", ",", "$", "value", ",", "$", "checked", ",", "array", "(", "'id'", "=>", "$", "id", ")", "+", "$", "attribs", ")", ".", "'&#160;'", ".", "self", "::", "label", "(", "$", "label", ",", "$", "id", ",", "$", "attribs", ")", ";", "}" ]
Convenience function to build an HTML radio button with a label @param $label @param $name @param $value @param $id @param $checked bool @param $attribs array @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "radio", "button", "with", "a", "label" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L340-L344
233,570
MW-Peachy/Peachy
Plugins/Xml.php
Xml.option
public static function option( $text, $value = null, $selected = false, $attribs = array() ) { if( !is_null( $value ) ) { $attribs['value'] = $value; } if( $selected ) { $attribs['selected'] = 'selected'; } return self::element( 'option', $attribs, $text ); }
php
public static function option( $text, $value = null, $selected = false, $attribs = array() ) { if( !is_null( $value ) ) { $attribs['value'] = $value; } if( $selected ) { $attribs['selected'] = 'selected'; } return self::element( 'option', $attribs, $text ); }
[ "public", "static", "function", "option", "(", "$", "text", ",", "$", "value", "=", "null", ",", "$", "selected", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "attribs", "[", "'value'", "]", "=", "$", "value", ";", "}", "if", "(", "$", "selected", ")", "{", "$", "attribs", "[", "'selected'", "]", "=", "'selected'", ";", "}", "return", "self", "::", "element", "(", "'option'", ",", "$", "attribs", ",", "$", "text", ")", ";", "}" ]
Convenience function to build an HTML drop-down list item. @param string $text text for this item. Will be HTML escaped @param string $value form submission value; if empty, use text @param $selected boolean: if true, will be the default selected item @param array $attribs optional additional HTML attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "drop", "-", "down", "list", "item", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L364-L373
233,571
MW-Peachy/Peachy
Plugins/Xml.php
Xml.listDropDown
public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { $optgroup = false; $options = self::option( $other, 'other', $selected === 'other' ); foreach( explode( "\n", $list ) as $option ){ $value = trim( $option ); if( $value == '' ) { continue; } elseif( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) { // A new group is starting ... $value = trim( substr( $value, 1 ) ); if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::openElement( 'optgroup', array( 'label' => $value ) ); $optgroup = true; } elseif( substr( $value, 0, 2 ) == '**' ) { // groupmember $value = trim( substr( $value, 2 ) ); $options .= self::option( $value, $value, $selected === $value ); } else { // groupless reason list if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::option( $value, $value, $selected === $value ); $optgroup = false; } } if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $attribs = array(); if( $name ) { $attribs['id'] = $name; $attribs['name'] = $name; } if( $class ) { $attribs['class'] = $class; } if( $tabindex ) { $attribs['tabindex'] = $tabindex; } return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" . self::closeElement( 'select' ); }
php
public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { $optgroup = false; $options = self::option( $other, 'other', $selected === 'other' ); foreach( explode( "\n", $list ) as $option ){ $value = trim( $option ); if( $value == '' ) { continue; } elseif( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) { // A new group is starting ... $value = trim( substr( $value, 1 ) ); if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::openElement( 'optgroup', array( 'label' => $value ) ); $optgroup = true; } elseif( substr( $value, 0, 2 ) == '**' ) { // groupmember $value = trim( substr( $value, 2 ) ); $options .= self::option( $value, $value, $selected === $value ); } else { // groupless reason list if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::option( $value, $value, $selected === $value ); $optgroup = false; } } if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $attribs = array(); if( $name ) { $attribs['id'] = $name; $attribs['name'] = $name; } if( $class ) { $attribs['class'] = $class; } if( $tabindex ) { $attribs['tabindex'] = $tabindex; } return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" . self::closeElement( 'select' ); }
[ "public", "static", "function", "listDropDown", "(", "$", "name", "=", "''", ",", "$", "list", "=", "''", ",", "$", "other", "=", "''", ",", "$", "selected", "=", "''", ",", "$", "class", "=", "''", ",", "$", "tabindex", "=", "null", ")", "{", "$", "optgroup", "=", "false", ";", "$", "options", "=", "self", "::", "option", "(", "$", "other", ",", "'other'", ",", "$", "selected", "===", "'other'", ")", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "list", ")", "as", "$", "option", ")", "{", "$", "value", "=", "trim", "(", "$", "option", ")", ";", "if", "(", "$", "value", "==", "''", ")", "{", "continue", ";", "}", "elseif", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'*'", "&&", "substr", "(", "$", "value", ",", "1", ",", "1", ")", "!=", "'*'", ")", "{", "// A new group is starting ...", "$", "value", "=", "trim", "(", "substr", "(", "$", "value", ",", "1", ")", ")", ";", "if", "(", "$", "optgroup", ")", "{", "$", "options", ".=", "self", "::", "closeElement", "(", "'optgroup'", ")", ";", "}", "$", "options", ".=", "self", "::", "openElement", "(", "'optgroup'", ",", "array", "(", "'label'", "=>", "$", "value", ")", ")", ";", "$", "optgroup", "=", "true", ";", "}", "elseif", "(", "substr", "(", "$", "value", ",", "0", ",", "2", ")", "==", "'**'", ")", "{", "// groupmember", "$", "value", "=", "trim", "(", "substr", "(", "$", "value", ",", "2", ")", ")", ";", "$", "options", ".=", "self", "::", "option", "(", "$", "value", ",", "$", "value", ",", "$", "selected", "===", "$", "value", ")", ";", "}", "else", "{", "// groupless reason list", "if", "(", "$", "optgroup", ")", "{", "$", "options", ".=", "self", "::", "closeElement", "(", "'optgroup'", ")", ";", "}", "$", "options", ".=", "self", "::", "option", "(", "$", "value", ",", "$", "value", ",", "$", "selected", "===", "$", "value", ")", ";", "$", "optgroup", "=", "false", ";", "}", "}", "if", "(", "$", "optgroup", ")", "{", "$", "options", ".=", "self", "::", "closeElement", "(", "'optgroup'", ")", ";", "}", "$", "attribs", "=", "array", "(", ")", ";", "if", "(", "$", "name", ")", "{", "$", "attribs", "[", "'id'", "]", "=", "$", "name", ";", "$", "attribs", "[", "'name'", "]", "=", "$", "name", ";", "}", "if", "(", "$", "class", ")", "{", "$", "attribs", "[", "'class'", "]", "=", "$", "class", ";", "}", "if", "(", "$", "tabindex", ")", "{", "$", "attribs", "[", "'tabindex'", "]", "=", "$", "tabindex", ";", "}", "return", "self", "::", "openElement", "(", "'select'", ",", "$", "attribs", ")", ".", "\"\\n\"", ".", "$", "options", ".", "\"\\n\"", ".", "self", "::", "closeElement", "(", "'select'", ")", ";", "}" ]
Build a drop-down box from a textual list. @param $name Mixed: Name and id for the drop-down @param $list Mixed: Correctly formatted text (newline delimited) to be used to generate the options @param $other Mixed: Text for the "Other reasons" option @param $selected Mixed: Option which should be pre-selected @param $class Mixed: CSS classes for the drop-down @param $tabindex Mixed: Value of the tabindex attribute @return string
[ "Build", "a", "drop", "-", "down", "box", "from", "a", "textual", "list", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L386-L441
233,572
MW-Peachy/Peachy
Plugins/Xml.php
Xml.fieldset
public static function fieldset( $legend = false, $content = false, $attribs = array() ) { $s = self::openElement( 'fieldset', $attribs ) . "\n"; if( $legend ) { $s .= self::element( 'legend', null, $legend ) . "\n"; } if( $content !== false ) { $s .= $content . "\n"; $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; }
php
public static function fieldset( $legend = false, $content = false, $attribs = array() ) { $s = self::openElement( 'fieldset', $attribs ) . "\n"; if( $legend ) { $s .= self::element( 'legend', null, $legend ) . "\n"; } if( $content !== false ) { $s .= $content . "\n"; $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; }
[ "public", "static", "function", "fieldset", "(", "$", "legend", "=", "false", ",", "$", "content", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'fieldset'", ",", "$", "attribs", ")", ".", "\"\\n\"", ";", "if", "(", "$", "legend", ")", "{", "$", "s", ".=", "self", "::", "element", "(", "'legend'", ",", "null", ",", "$", "legend", ")", ".", "\"\\n\"", ";", "}", "if", "(", "$", "content", "!==", "false", ")", "{", "$", "s", ".=", "$", "content", ".", "\"\\n\"", ";", "$", "s", ".=", "self", "::", "closeElement", "(", "'fieldset'", ")", ".", "\"\\n\"", ";", "}", "return", "$", "s", ";", "}" ]
Shortcut for creating fieldsets. @param string|bool $legend Legend of the fieldset. If evaluates to false, legend is not added. @param string|bool $content Pre-escaped content for the fieldset. If false, only open fieldset is returned. @param array $attribs Any attributes to fieldset-element. @return string
[ "Shortcut", "for", "creating", "fieldsets", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L452-L465
233,573
MW-Peachy/Peachy
Plugins/Xml.php
Xml.textarea
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) { return self::element( 'textarea', array( 'name' => $name, 'id' => $name, 'cols' => $cols, 'rows' => $rows ) + $attribs, $content, false ); }
php
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) { return self::element( 'textarea', array( 'name' => $name, 'id' => $name, 'cols' => $cols, 'rows' => $rows ) + $attribs, $content, false ); }
[ "public", "static", "function", "textarea", "(", "$", "name", ",", "$", "content", ",", "$", "cols", "=", "40", ",", "$", "rows", "=", "5", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'textarea'", ",", "array", "(", "'name'", "=>", "$", "name", ",", "'id'", "=>", "$", "name", ",", "'cols'", "=>", "$", "cols", ",", "'rows'", "=>", "$", "rows", ")", "+", "$", "attribs", ",", "$", "content", ",", "false", ")", ";", "}" ]
Shortcut for creating textareas. @param string $name The 'name' for the textarea @param string $content Content for the textarea @param int $cols The number of columns for the textarea @param int $rows The number of rows for the textarea @param array $attribs Any other attributes for the textarea @return string
[ "Shortcut", "for", "creating", "textareas", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L478-L489
233,574
MW-Peachy/Peachy
Plugins/Xml.php
Xml.isWellFormed
public static function isWellFormed( $text ) { $parser = xml_parser_create( "UTF-8" ); # case folding violates XML standard, turn it off xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); if( !xml_parse( $parser, $text, true ) ) { //$err = xml_error_string( xml_get_error_code( $parser ) ); //$position = xml_get_current_byte_index( $parser ); //$fragment = $this->extractFragment( $html, $position ); //$this->mXmlError = "$err at byte $position:\n$fragment"; xml_parser_free( $parser ); return false; } xml_parser_free( $parser ); return true; }
php
public static function isWellFormed( $text ) { $parser = xml_parser_create( "UTF-8" ); # case folding violates XML standard, turn it off xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); if( !xml_parse( $parser, $text, true ) ) { //$err = xml_error_string( xml_get_error_code( $parser ) ); //$position = xml_get_current_byte_index( $parser ); //$fragment = $this->extractFragment( $html, $position ); //$this->mXmlError = "$err at byte $position:\n$fragment"; xml_parser_free( $parser ); return false; } xml_parser_free( $parser ); return true; }
[ "public", "static", "function", "isWellFormed", "(", "$", "text", ")", "{", "$", "parser", "=", "xml_parser_create", "(", "\"UTF-8\"", ")", ";", "# case folding violates XML standard, turn it off", "xml_parser_set_option", "(", "$", "parser", ",", "XML_OPTION_CASE_FOLDING", ",", "false", ")", ";", "if", "(", "!", "xml_parse", "(", "$", "parser", ",", "$", "text", ",", "true", ")", ")", "{", "//$err = xml_error_string( xml_get_error_code( $parser ) );", "//$position = xml_get_current_byte_index( $parser );", "//$fragment = $this->extractFragment( $html, $position );", "//$this->mXmlError = \"$err at byte $position:\\n$fragment\";", "xml_parser_free", "(", "$", "parser", ")", ";", "return", "false", ";", "}", "xml_parser_free", "(", "$", "parser", ")", ";", "return", "true", ";", "}" ]
Check if a string is well-formed XML. Must include the surrounding tag. @param string $text string to test. @return bool @todo Error position reporting return
[ "Check", "if", "a", "string", "is", "well", "-", "formed", "XML", ".", "Must", "include", "the", "surrounding", "tag", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L605-L623
233,575
MW-Peachy/Peachy
Plugins/Xml.php
Xml.buildTable
public static function buildTable( $rows, $attribs = array(), $headers = null ) { $s = self::openElement( 'table', $attribs ); if( is_array( $headers ) ) { $s .= self::openElement( 'thead', $attribs ); foreach( $headers as $id => $header ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'th', $attribs, $header ); } $s .= self::closeElement( 'thead' ); } foreach( $rows as $id => $row ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::buildTableRow( $attribs, $row ); } $s .= self::closeElement( 'table' ); return $s; }
php
public static function buildTable( $rows, $attribs = array(), $headers = null ) { $s = self::openElement( 'table', $attribs ); if( is_array( $headers ) ) { $s .= self::openElement( 'thead', $attribs ); foreach( $headers as $id => $header ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'th', $attribs, $header ); } $s .= self::closeElement( 'thead' ); } foreach( $rows as $id => $row ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::buildTableRow( $attribs, $row ); } $s .= self::closeElement( 'table' ); return $s; }
[ "public", "static", "function", "buildTable", "(", "$", "rows", ",", "$", "attribs", "=", "array", "(", ")", ",", "$", "headers", "=", "null", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'table'", ",", "$", "attribs", ")", ";", "if", "(", "is_array", "(", "$", "headers", ")", ")", "{", "$", "s", ".=", "self", "::", "openElement", "(", "'thead'", ",", "$", "attribs", ")", ";", "foreach", "(", "$", "headers", "as", "$", "id", "=>", "$", "header", ")", "{", "$", "attribs", "=", "array", "(", ")", ";", "if", "(", "is_string", "(", "$", "id", ")", ")", "{", "$", "attribs", "[", "'id'", "]", "=", "$", "id", ";", "}", "$", "s", ".=", "self", "::", "element", "(", "'th'", ",", "$", "attribs", ",", "$", "header", ")", ";", "}", "$", "s", ".=", "self", "::", "closeElement", "(", "'thead'", ")", ";", "}", "foreach", "(", "$", "rows", "as", "$", "id", "=>", "$", "row", ")", "{", "$", "attribs", "=", "array", "(", ")", ";", "if", "(", "is_string", "(", "$", "id", ")", ")", "{", "$", "attribs", "[", "'id'", "]", "=", "$", "id", ";", "}", "$", "s", ".=", "self", "::", "buildTableRow", "(", "$", "attribs", ",", "$", "row", ")", ";", "}", "$", "s", ".=", "self", "::", "closeElement", "(", "'table'", ")", ";", "return", "$", "s", ";", "}" ]
Build a table of data @param array $rows An array of arrays of strings, each to be a row in a table @param array $attribs An array of attributes to apply to the table tag [optional] @param array $headers An array of strings to use as table headers [optional] @return string
[ "Build", "a", "table", "of", "data" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L928-L959
233,576
MW-Peachy/Peachy
Plugins/Xml.php
Xml.buildTableRow
public static function buildTableRow( $attribs, $cells ) { $s = self::openElement( 'tr', $attribs ); foreach( $cells as $id => $cell ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'td', $attribs, $cell ); } $s .= self::closeElement( 'tr' ); return $s; }
php
public static function buildTableRow( $attribs, $cells ) { $s = self::openElement( 'tr', $attribs ); foreach( $cells as $id => $cell ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'td', $attribs, $cell ); } $s .= self::closeElement( 'tr' ); return $s; }
[ "public", "static", "function", "buildTableRow", "(", "$", "attribs", ",", "$", "cells", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'tr'", ",", "$", "attribs", ")", ";", "foreach", "(", "$", "cells", "as", "$", "id", "=>", "$", "cell", ")", "{", "$", "attribs", "=", "array", "(", ")", ";", "if", "(", "is_string", "(", "$", "id", ")", ")", "{", "$", "attribs", "[", "'id'", "]", "=", "$", "id", ";", "}", "$", "s", ".=", "self", "::", "element", "(", "'td'", ",", "$", "attribs", ",", "$", "cell", ")", ";", "}", "$", "s", ".=", "self", "::", "closeElement", "(", "'tr'", ")", ";", "return", "$", "s", ";", "}" ]
Build a row for a table @param array $attribs An array of attributes to apply to the tr tag @param array $cells An array of strings to put in <td> @return string
[ "Build", "a", "row", "for", "a", "table" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L967-L983
233,577
scherersoftware/cake-notifications
src/Transport/EmailTransport.php
EmailTransport.processQueueObject
public static function processQueueObject(Base $job) { $notification = new EmailNotification(); if ($job->data('beforeSendCallback') !== []) { foreach ($job->data('beforeSendCallback') as $callback) { $notification->addBeforeSendCallback($callback['class'], $callback['args']); } } if ($job->data('afterSendCallback') !== []) { foreach ($job->data('afterSendCallback') as $callback) { $notification->addAfterSendCallback($callback['class'], $callback['args']); } } if ($job->data('locale') !== '') { $notification->locale($job->data('locale')); } $notification->unserialize($job->data('email')); return self::sendNotification($notification); }
php
public static function processQueueObject(Base $job) { $notification = new EmailNotification(); if ($job->data('beforeSendCallback') !== []) { foreach ($job->data('beforeSendCallback') as $callback) { $notification->addBeforeSendCallback($callback['class'], $callback['args']); } } if ($job->data('afterSendCallback') !== []) { foreach ($job->data('afterSendCallback') as $callback) { $notification->addAfterSendCallback($callback['class'], $callback['args']); } } if ($job->data('locale') !== '') { $notification->locale($job->data('locale')); } $notification->unserialize($job->data('email')); return self::sendNotification($notification); }
[ "public", "static", "function", "processQueueObject", "(", "Base", "$", "job", ")", "{", "$", "notification", "=", "new", "EmailNotification", "(", ")", ";", "if", "(", "$", "job", "->", "data", "(", "'beforeSendCallback'", ")", "!==", "[", "]", ")", "{", "foreach", "(", "$", "job", "->", "data", "(", "'beforeSendCallback'", ")", "as", "$", "callback", ")", "{", "$", "notification", "->", "addBeforeSendCallback", "(", "$", "callback", "[", "'class'", "]", ",", "$", "callback", "[", "'args'", "]", ")", ";", "}", "}", "if", "(", "$", "job", "->", "data", "(", "'afterSendCallback'", ")", "!==", "[", "]", ")", "{", "foreach", "(", "$", "job", "->", "data", "(", "'afterSendCallback'", ")", "as", "$", "callback", ")", "{", "$", "notification", "->", "addAfterSendCallback", "(", "$", "callback", "[", "'class'", "]", ",", "$", "callback", "[", "'args'", "]", ")", ";", "}", "}", "if", "(", "$", "job", "->", "data", "(", "'locale'", ")", "!==", "''", ")", "{", "$", "notification", "->", "locale", "(", "$", "job", "->", "data", "(", "'locale'", ")", ")", ";", "}", "$", "notification", "->", "unserialize", "(", "$", "job", "->", "data", "(", "'email'", ")", ")", ";", "return", "self", "::", "sendNotification", "(", "$", "notification", ")", ";", "}" ]
Process the job coming from the queue @param Base $job Queuesadilla base job @return void
[ "Process", "the", "job", "coming", "from", "the", "queue" ]
916fa8d60dbe94c0b146339eed147b1a1f2a1902
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Transport/EmailTransport.php#L47-L67
233,578
goalio/GoalioMailService
src/GoalioMailService/Mail/Service/Message.php
Message.createTextMessage
public function createTextMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $content); }
php
public function createTextMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $content); }
[ "public", "function", "createTextMessage", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "nameOrModel", ",", "$", "values", "=", "array", "(", ")", ")", "{", "$", "renderer", "=", "$", "this", "->", "getRenderer", "(", ")", ";", "$", "content", "=", "$", "renderer", "->", "render", "(", "$", "nameOrModel", ",", "$", "values", ")", ";", "return", "$", "this", "->", "getDefaultMessage", "(", "$", "from", ",", "'utf-8'", ",", "$", "to", ",", "$", "subject", ",", "$", "content", ")", ";", "}" ]
Return a text message ready to be sent @param array|string $from A string containing the sender e-mail address, or if array with keys email and name @param array|string $to An array containing the recipients of the mail @param string $subject Subject of the mail @param string|\Zend\View\Model\ModelInterface $nameOrModel Either the template to use, or a ViewModel @param null|array $values Values to use when the template is rendered @return Message
[ "Return", "a", "text", "message", "ready", "to", "be", "sent" ]
49f69fb5e29885b70712660b1ac5bb934164bbbb
https://github.com/goalio/GoalioMailService/blob/49f69fb5e29885b70712660b1ac5bb934164bbbb/src/GoalioMailService/Mail/Service/Message.php#L96-L101
233,579
wardrobecms/core-archived
src/Wardrobe/Core/Models/Post.php
Post.getParsedContentAttribute
public function getParsedContentAttribute() { if (Config::get('core::wardrobe.cache')) { $content = $this->attributes['content']; return Cache::rememberForever('post-'.$this->attributes['id'], function() use ($content) { return md($content); }); } return md($this->attributes['content']); }
php
public function getParsedContentAttribute() { if (Config::get('core::wardrobe.cache')) { $content = $this->attributes['content']; return Cache::rememberForever('post-'.$this->attributes['id'], function() use ($content) { return md($content); }); } return md($this->attributes['content']); }
[ "public", "function", "getParsedContentAttribute", "(", ")", "{", "if", "(", "Config", "::", "get", "(", "'core::wardrobe.cache'", ")", ")", "{", "$", "content", "=", "$", "this", "->", "attributes", "[", "'content'", "]", ";", "return", "Cache", "::", "rememberForever", "(", "'post-'", ".", "$", "this", "->", "attributes", "[", "'id'", "]", ",", "function", "(", ")", "use", "(", "$", "content", ")", "{", "return", "md", "(", "$", "content", ")", ";", "}", ")", ";", "}", "return", "md", "(", "$", "this", "->", "attributes", "[", "'content'", "]", ")", ";", "}" ]
Get the content parsed into html @return string
[ "Get", "the", "content", "parsed", "into", "html" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Models/Post.php#L47-L60
233,580
wardrobecms/core-archived
src/Wardrobe/Core/Models/Post.php
Post.getParsedIntroAttribute
public function getParsedIntroAttribute() { $intro = $this->getIntroAttribute(); if (Config::get('core::wardrobe.cache')) { return Cache::rememberForever('post-intro-'.$this->attributes['id'], function() use ($intro) { return md($intro); }); } return md($intro); }
php
public function getParsedIntroAttribute() { $intro = $this->getIntroAttribute(); if (Config::get('core::wardrobe.cache')) { return Cache::rememberForever('post-intro-'.$this->attributes['id'], function() use ($intro) { return md($intro); }); } return md($intro); }
[ "public", "function", "getParsedIntroAttribute", "(", ")", "{", "$", "intro", "=", "$", "this", "->", "getIntroAttribute", "(", ")", ";", "if", "(", "Config", "::", "get", "(", "'core::wardrobe.cache'", ")", ")", "{", "return", "Cache", "::", "rememberForever", "(", "'post-intro-'", ".", "$", "this", "->", "attributes", "[", "'id'", "]", ",", "function", "(", ")", "use", "(", "$", "intro", ")", "{", "return", "md", "(", "$", "intro", ")", ";", "}", ")", ";", "}", "return", "md", "(", "$", "intro", ")", ";", "}" ]
Get the parsed short version of a post @return string
[ "Get", "the", "parsed", "short", "version", "of", "a", "post" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Models/Post.php#L113-L126
233,581
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ClassWithEmbeddedMessageProperty(); case 1: return new ClassWithEmbeddedMessageProperty(func_get_arg(0)); case 2: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new ClassWithEmbeddedMessageProperty(); case 1: return new ClassWithEmbeddedMessageProperty(func_get_arg(0)); case 2: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", ")", ";", "case", "1", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ")", ";", "case", "2", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ")", ";", "case", "3", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ")", ";", "case", "4", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ",", "func_get_arg", "(", "3", ")", ")", ";", "case", "5", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ",", "func_get_arg", "(", "3", ")", ",", "func_get_arg", "(", "4", ")", ")", ";", "case", "6", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ",", "func_get_arg", "(", "3", ")", ",", "func_get_arg", "(", "4", ")", ",", "func_get_arg", "(", "5", ")", ")", ";", "case", "7", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ",", "func_get_arg", "(", "3", ")", ",", "func_get_arg", "(", "4", ")", ",", "func_get_arg", "(", "5", ")", ",", "func_get_arg", "(", "6", ")", ")", ";", "case", "8", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", "func_get_arg", "(", "0", ")", ",", "func_get_arg", "(", "1", ")", ",", "func_get_arg", "(", "2", ")", ",", "func_get_arg", "(", "3", ")", ",", "func_get_arg", "(", "4", ")", ",", "func_get_arg", "(", "5", ")", ",", "func_get_arg", "(", "6", ")", ",", "func_get_arg", "(", "7", ")", ")", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'More than 8 arguments supplied, please be reasonable.'", ")", ";", "}", "}" ]
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty @throws \InvalidArgumentException @return ClassWithEmbeddedMessageProperty
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L67-L91
233,582
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->x)) { hash_update($ctx, 'x'); EmbeddedMeta::hash($object->x, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->x)) { hash_update($ctx, 'x'); EmbeddedMeta::hash($object->x, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrCtx", ")", ";", "}", "else", "{", "$", "ctx", "=", "$", "algoOrCtx", ";", "}", "if", "(", "isset", "(", "$", "object", "->", "x", ")", ")", "{", "hash_update", "(", "$", "ctx", ",", "'x'", ")", ";", "EmbeddedMeta", "::", "hash", "(", "$", "object", "->", "x", ",", "$", "ctx", ")", ";", "}", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "return", "hash_final", "(", "$", "ctx", ",", "$", "raw", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Computes hash of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L122-L140
233,583
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x0a"; $buffer = EmbeddedMeta::toProtobuf($object->x, $filter === null ? null : $filter['x']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x0a"; $buffer = EmbeddedMeta::toProtobuf($object->x, $filter === null ? null : $filter['x']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "x", ")", "&&", "(", "$", "filter", "===", "null", "||", "isset", "(", "$", "filter", "[", "'x'", "]", ")", ")", ")", "{", "$", "output", ".=", "\"\\x0a\"", ";", "$", "buffer", "=", "EmbeddedMeta", "::", "toProtobuf", "(", "$", "object", "->", "x", ",", "$", "filter", "===", "null", "?", "null", ":", "$", "filter", "[", "'x'", "]", ")", ";", "$", "output", ".=", "Binary", "::", "encodeVarint", "(", "strlen", "(", "$", "buffer", ")", ")", ";", "$", "output", ".=", "$", "buffer", ";", "}", "return", "$", "output", ";", "}" ]
Serialized \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty to Protocol Buffers message. @param ClassWithEmbeddedMessageProperty $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty", "to", "Protocol", "Buffers", "message", "." ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L396-L408
233,584
scherersoftware/cake-model-history
src/Model/Entity/HistoryContextTrait.php
HistoryContextTrait.setHistoryContext
public function setHistoryContext(string $type, $dataObject = null, $slug = null): void { if (!in_array($type, array_keys(ModelHistory::getContextTypes()))) { throw new InvalidArgumentException("$type is not allowed as context type. Allowed types are: " . implode(', ', ModelHistory::getContextTypes())); } switch ($type) { case ModelHistory::CONTEXT_TYPE_SHELL: if (!$dataObject instanceof Shell) { throw new InvalidArgumentException('You have to specify a Shell data object for this context type.'); } $context = [ 'OptionParser' => $dataObject->OptionParser, 'interactive' => $dataObject->interactive, 'params' => $dataObject->params, 'command' => $dataObject->command, 'args' => $dataObject->args, 'name' => $dataObject->name, 'plugin' => $dataObject->plugin, 'tasks' => $dataObject->tasks, 'taskNames' => $dataObject->taskNames ]; $contextSlug = null; if ($slug !== null) { $contextSlug = $slug; } break; case ModelHistory::CONTEXT_TYPE_CONTROLLER: if (!$dataObject instanceof Request) { throw new InvalidArgumentException('You have to specify a Request data object for this context type.'); } $context = [ 'params' => $dataObject->params, 'method' => $dataObject->method() ]; if ($slug !== null) { $contextSlug = $slug; } else { $contextSlug = Text::insert(':plugin/:controller/:action', [ 'plugin' => $context['params']['plugin'], 'controller' => $context['params']['controller'], 'action' => $context['params']['action'] ]); } break; case ModelHistory::CONTEXT_TYPE_SLUG: default: $context = []; if ($slug === null) { throw new InvalidArgumentException('You have to specify a slug for this context type.'); } $contextSlug = $slug; break; } $this->_context = Hash::merge([ 'type' => $type, 'namespace' => get_class($this) ], $context); $this->_contextSlug = $contextSlug; $this->_contextType = $type; }
php
public function setHistoryContext(string $type, $dataObject = null, $slug = null): void { if (!in_array($type, array_keys(ModelHistory::getContextTypes()))) { throw new InvalidArgumentException("$type is not allowed as context type. Allowed types are: " . implode(', ', ModelHistory::getContextTypes())); } switch ($type) { case ModelHistory::CONTEXT_TYPE_SHELL: if (!$dataObject instanceof Shell) { throw new InvalidArgumentException('You have to specify a Shell data object for this context type.'); } $context = [ 'OptionParser' => $dataObject->OptionParser, 'interactive' => $dataObject->interactive, 'params' => $dataObject->params, 'command' => $dataObject->command, 'args' => $dataObject->args, 'name' => $dataObject->name, 'plugin' => $dataObject->plugin, 'tasks' => $dataObject->tasks, 'taskNames' => $dataObject->taskNames ]; $contextSlug = null; if ($slug !== null) { $contextSlug = $slug; } break; case ModelHistory::CONTEXT_TYPE_CONTROLLER: if (!$dataObject instanceof Request) { throw new InvalidArgumentException('You have to specify a Request data object for this context type.'); } $context = [ 'params' => $dataObject->params, 'method' => $dataObject->method() ]; if ($slug !== null) { $contextSlug = $slug; } else { $contextSlug = Text::insert(':plugin/:controller/:action', [ 'plugin' => $context['params']['plugin'], 'controller' => $context['params']['controller'], 'action' => $context['params']['action'] ]); } break; case ModelHistory::CONTEXT_TYPE_SLUG: default: $context = []; if ($slug === null) { throw new InvalidArgumentException('You have to specify a slug for this context type.'); } $contextSlug = $slug; break; } $this->_context = Hash::merge([ 'type' => $type, 'namespace' => get_class($this) ], $context); $this->_contextSlug = $contextSlug; $this->_contextType = $type; }
[ "public", "function", "setHistoryContext", "(", "string", "$", "type", ",", "$", "dataObject", "=", "null", ",", "$", "slug", "=", "null", ")", ":", "void", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "array_keys", "(", "ModelHistory", "::", "getContextTypes", "(", ")", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"$type is not allowed as context type. Allowed types are: \"", ".", "implode", "(", "', '", ",", "ModelHistory", "::", "getContextTypes", "(", ")", ")", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "ModelHistory", "::", "CONTEXT_TYPE_SHELL", ":", "if", "(", "!", "$", "dataObject", "instanceof", "Shell", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'You have to specify a Shell data object for this context type.'", ")", ";", "}", "$", "context", "=", "[", "'OptionParser'", "=>", "$", "dataObject", "->", "OptionParser", ",", "'interactive'", "=>", "$", "dataObject", "->", "interactive", ",", "'params'", "=>", "$", "dataObject", "->", "params", ",", "'command'", "=>", "$", "dataObject", "->", "command", ",", "'args'", "=>", "$", "dataObject", "->", "args", ",", "'name'", "=>", "$", "dataObject", "->", "name", ",", "'plugin'", "=>", "$", "dataObject", "->", "plugin", ",", "'tasks'", "=>", "$", "dataObject", "->", "tasks", ",", "'taskNames'", "=>", "$", "dataObject", "->", "taskNames", "]", ";", "$", "contextSlug", "=", "null", ";", "if", "(", "$", "slug", "!==", "null", ")", "{", "$", "contextSlug", "=", "$", "slug", ";", "}", "break", ";", "case", "ModelHistory", "::", "CONTEXT_TYPE_CONTROLLER", ":", "if", "(", "!", "$", "dataObject", "instanceof", "Request", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'You have to specify a Request data object for this context type.'", ")", ";", "}", "$", "context", "=", "[", "'params'", "=>", "$", "dataObject", "->", "params", ",", "'method'", "=>", "$", "dataObject", "->", "method", "(", ")", "]", ";", "if", "(", "$", "slug", "!==", "null", ")", "{", "$", "contextSlug", "=", "$", "slug", ";", "}", "else", "{", "$", "contextSlug", "=", "Text", "::", "insert", "(", "':plugin/:controller/:action'", ",", "[", "'plugin'", "=>", "$", "context", "[", "'params'", "]", "[", "'plugin'", "]", ",", "'controller'", "=>", "$", "context", "[", "'params'", "]", "[", "'controller'", "]", ",", "'action'", "=>", "$", "context", "[", "'params'", "]", "[", "'action'", "]", "]", ")", ";", "}", "break", ";", "case", "ModelHistory", "::", "CONTEXT_TYPE_SLUG", ":", "default", ":", "$", "context", "=", "[", "]", ";", "if", "(", "$", "slug", "===", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'You have to specify a slug for this context type.'", ")", ";", "}", "$", "contextSlug", "=", "$", "slug", ";", "break", ";", "}", "$", "this", "->", "_context", "=", "Hash", "::", "merge", "(", "[", "'type'", "=>", "$", "type", ",", "'namespace'", "=>", "get_class", "(", "$", "this", ")", "]", ",", "$", "context", ")", ";", "$", "this", "->", "_contextSlug", "=", "$", "contextSlug", ";", "$", "this", "->", "_contextType", "=", "$", "type", ";", "}" ]
Sets a context given through a request to identify the creation point of the revision. @param string $type Context type @param object $dataObject Optional dataobject to get additional data from @param string $slug Optional slug. Must implement getContexts() when using @return void
[ "Sets", "a", "context", "given", "through", "a", "request", "to", "identify", "the", "creation", "point", "of", "the", "revision", "." ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/HistoryContextTrait.php#L48-L109
233,585
yeephp/yeephp
Yee/Yee.php
Yee.getDefaultSettings
public static function getDefaultSettings() { return array( // Application 'mode' => 'development', // Debugging 'debug' => true, // Logging 'log.writer' => null, 'log.level' => \Yee\Log::DEBUG, 'log.enabled' => true, // View 'templates.path' => './templates', 'view' => '\Yee\View', // Cookies 'cookies.encrypt' => false, 'cookies.lifetime' => '20 minutes', 'cookies.path' => '/', 'cookies.domain' => null, 'cookies.secure' => false, 'cookies.httponly' => false, // Encryption 'cookies.secret_key' => 'CHANGE_ME', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, // HTTP 'http.version' => '1.1', // Routing 'routes.case_sensitive' => true ); }
php
public static function getDefaultSettings() { return array( // Application 'mode' => 'development', // Debugging 'debug' => true, // Logging 'log.writer' => null, 'log.level' => \Yee\Log::DEBUG, 'log.enabled' => true, // View 'templates.path' => './templates', 'view' => '\Yee\View', // Cookies 'cookies.encrypt' => false, 'cookies.lifetime' => '20 minutes', 'cookies.path' => '/', 'cookies.domain' => null, 'cookies.secure' => false, 'cookies.httponly' => false, // Encryption 'cookies.secret_key' => 'CHANGE_ME', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, // HTTP 'http.version' => '1.1', // Routing 'routes.case_sensitive' => true ); }
[ "public", "static", "function", "getDefaultSettings", "(", ")", "{", "return", "array", "(", "// Application", "'mode'", "=>", "'development'", ",", "// Debugging", "'debug'", "=>", "true", ",", "// Logging", "'log.writer'", "=>", "null", ",", "'log.level'", "=>", "\\", "Yee", "\\", "Log", "::", "DEBUG", ",", "'log.enabled'", "=>", "true", ",", "// View", "'templates.path'", "=>", "'./templates'", ",", "'view'", "=>", "'\\Yee\\View'", ",", "// Cookies", "'cookies.encrypt'", "=>", "false", ",", "'cookies.lifetime'", "=>", "'20 minutes'", ",", "'cookies.path'", "=>", "'/'", ",", "'cookies.domain'", "=>", "null", ",", "'cookies.secure'", "=>", "false", ",", "'cookies.httponly'", "=>", "false", ",", "// Encryption", "'cookies.secret_key'", "=>", "'CHANGE_ME'", ",", "'cookies.cipher'", "=>", "MCRYPT_RIJNDAEL_256", ",", "'cookies.cipher_mode'", "=>", "MCRYPT_MODE_CBC", ",", "// HTTP", "'http.version'", "=>", "'1.1'", ",", "// Routing", "'routes.case_sensitive'", "=>", "true", ")", ";", "}" ]
Get default application settings @return array
[ "Get", "default", "application", "settings" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L292-L322
233,586
yeephp/yeephp
Yee/Yee.php
Yee.config
public function config($name, $value = null) { $c = $this->container; if (is_array($name)) { if (true === $value) { $c['settings'] = array_merge_recursive($c['settings'], $name); } else { $c['settings'] = array_merge($c['settings'], $name); } } elseif (func_num_args() === 1) { return isset($c['settings'][$name]) ? $c['settings'][$name] : null; } else { $settings = $c['settings']; $settings[$name] = $value; $c['settings'] = $settings; } }
php
public function config($name, $value = null) { $c = $this->container; if (is_array($name)) { if (true === $value) { $c['settings'] = array_merge_recursive($c['settings'], $name); } else { $c['settings'] = array_merge($c['settings'], $name); } } elseif (func_num_args() === 1) { return isset($c['settings'][$name]) ? $c['settings'][$name] : null; } else { $settings = $c['settings']; $settings[$name] = $value; $c['settings'] = $settings; } }
[ "public", "function", "config", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "c", "=", "$", "this", "->", "container", ";", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "if", "(", "true", "===", "$", "value", ")", "{", "$", "c", "[", "'settings'", "]", "=", "array_merge_recursive", "(", "$", "c", "[", "'settings'", "]", ",", "$", "name", ")", ";", "}", "else", "{", "$", "c", "[", "'settings'", "]", "=", "array_merge", "(", "$", "c", "[", "'settings'", "]", ",", "$", "name", ")", ";", "}", "}", "elseif", "(", "func_num_args", "(", ")", "===", "1", ")", "{", "return", "isset", "(", "$", "c", "[", "'settings'", "]", "[", "$", "name", "]", ")", "?", "$", "c", "[", "'settings'", "]", "[", "$", "name", "]", ":", "null", ";", "}", "else", "{", "$", "settings", "=", "$", "c", "[", "'settings'", "]", ";", "$", "settings", "[", "$", "name", "]", "=", "$", "value", ";", "$", "c", "[", "'settings'", "]", "=", "$", "settings", ";", "}", "}" ]
Configure Yee Settings This method defines application settings and acts as a setter and a getter. If only one argument is specified and that argument is a string, the value of the setting identified by the first argument will be returned, or NULL if that setting does not exist. If only one argument is specified and that argument is an associative array, the array will be merged into the existing application settings. If two arguments are provided, the first argument is the name of the setting to be created or updated, and the second argument is the setting value. @param string|array $name If a string, the name of the setting to set or retrieve. Else an associated array of setting names and values @param mixed $value If name is a string, the value of the setting identified by $name @return mixed The value of a setting if only one argument is a string
[ "Configure", "Yee", "Settings" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L343-L360
233,587
yeephp/yeephp
Yee/Yee.php
Yee.put
public function put() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PUT); }
php
public function put() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PUT); }
[ "public", "function", "put", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "$", "this", "->", "mapRoute", "(", "$", "args", ")", "->", "via", "(", "\\", "Yee", "\\", "Http", "\\", "Request", "::", "METHOD_PUT", ")", ";", "}" ]
Add PUT route @see mapRoute() @return \Yee\Route
[ "Add", "PUT", "route" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L500-L505
233,588
yeephp/yeephp
Yee/Yee.php
Yee.patch
public function patch() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PATCH); }
php
public function patch() { $args = func_get_args(); return $this->mapRoute($args)->via(\Yee\Http\Request::METHOD_PATCH); }
[ "public", "function", "patch", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "$", "this", "->", "mapRoute", "(", "$", "args", ")", "->", "via", "(", "\\", "Yee", "\\", "Http", "\\", "Request", "::", "METHOD_PATCH", ")", ";", "}" ]
Add PATCH route @see mapRoute() @return \Yee\Route
[ "Add", "PATCH", "route" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L512-L517
233,589
yeephp/yeephp
Yee/Yee.php
Yee.getCookie
public function getCookie($name, $deleteIfInvalid = true) { // Get cookie value $value = $this->request->cookies->get($name); // Decode if encrypted if ($this->config('cookies.encrypt')) { $value = \Yee\Http\Util::decodeSecureCookie( $value, $this->config('cookies.secret_key'), $this->config('cookies.cipher'), $this->config('cookies.cipher_mode') ); if ($value === false && $deleteIfInvalid) { $this->deleteCookie($name); } } return $value; }
php
public function getCookie($name, $deleteIfInvalid = true) { // Get cookie value $value = $this->request->cookies->get($name); // Decode if encrypted if ($this->config('cookies.encrypt')) { $value = \Yee\Http\Util::decodeSecureCookie( $value, $this->config('cookies.secret_key'), $this->config('cookies.cipher'), $this->config('cookies.cipher_mode') ); if ($value === false && $deleteIfInvalid) { $this->deleteCookie($name); } } return $value; }
[ "public", "function", "getCookie", "(", "$", "name", ",", "$", "deleteIfInvalid", "=", "true", ")", "{", "// Get cookie value", "$", "value", "=", "$", "this", "->", "request", "->", "cookies", "->", "get", "(", "$", "name", ")", ";", "// Decode if encrypted", "if", "(", "$", "this", "->", "config", "(", "'cookies.encrypt'", ")", ")", "{", "$", "value", "=", "\\", "Yee", "\\", "Http", "\\", "Util", "::", "decodeSecureCookie", "(", "$", "value", ",", "$", "this", "->", "config", "(", "'cookies.secret_key'", ")", ",", "$", "this", "->", "config", "(", "'cookies.cipher'", ")", ",", "$", "this", "->", "config", "(", "'cookies.cipher_mode'", ")", ")", ";", "if", "(", "$", "value", "===", "false", "&&", "$", "deleteIfInvalid", ")", "{", "$", "this", "->", "deleteCookie", "(", "$", "name", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Get value of HTTP cookie from the current HTTP request Return the value of a cookie from the current HTTP request, or return NULL if cookie does not exist. Cookies created during the current request will not be available until the next request. @param string $name @param bool $deleteIfInvalid @return string|null
[ "Get", "value", "of", "HTTP", "cookie", "from", "the", "current", "HTTP", "request" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L898-L917
233,590
yeephp/yeephp
Yee/Yee.php
Yee.setEncryptedCookie
public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false) { $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly); }
php
public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false) { $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly); }
[ "public", "function", "setEncryptedCookie", "(", "$", "name", ",", "$", "value", ",", "$", "expires", "=", "null", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httponly", "=", "false", ")", "{", "$", "this", "->", "setCookie", "(", "$", "name", ",", "$", "value", ",", "$", "expires", ",", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httponly", ")", ";", "}" ]
DEPRECATION WARNING! Use `setCookie` with the `cookies.encrypt` app setting set to `true`. Set encrypted HTTP cookie @param string $name The cookie name @param mixed $value The cookie value @param mixed $expires The duration of the cookie; If integer, should be UNIX timestamp; If string, converted to UNIX timestamp with `strtotime`; @param string $path The path on the server in which the cookie will be available on @param string $domain The domain that the cookie is available to @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
[ "DEPRECATION", "WARNING!", "Use", "setCookie", "with", "the", "cookies", ".", "encrypt", "app", "setting", "set", "to", "true", "." ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L935-L938
233,591
yeephp/yeephp
Yee/Yee.php
Yee.urlFor
public function urlFor($name, $params = array()) { return $this->request->getRootUri() . $this->router->urlFor($name, $params); }
php
public function urlFor($name, $params = array()) { return $this->request->getRootUri() . $this->router->urlFor($name, $params); }
[ "public", "function", "urlFor", "(", "$", "name", ",", "$", "params", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "request", "->", "getRootUri", "(", ")", ".", "$", "this", "->", "router", "->", "urlFor", "(", "$", "name", ",", "$", "params", ")", ";", "}" ]
Get the URL for a named route @param string $name The route name @param array $params Associative array of URL parameters and replacement values @throws \RuntimeException If named route does not exist @return string
[ "Get", "the", "URL", "for", "a", "named", "route" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1087-L1090
233,592
yeephp/yeephp
Yee/Yee.php
Yee.flash
public function flash($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->set($key, $value); } }
php
public function flash($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->set($key, $value); } }
[ "public", "function", "flash", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "environment", "[", "'yee.flash'", "]", ")", ")", "{", "$", "this", "->", "environment", "[", "'yee.flash'", "]", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Set flash message for subsequent request @param string $key @param mixed $value
[ "Set", "flash", "message", "for", "subsequent", "request" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1119-L1124
233,593
yeephp/yeephp
Yee/Yee.php
Yee.flashNow
public function flashNow($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->now($key, $value); } }
php
public function flashNow($key, $value) { if (isset($this->environment['yee.flash'])) { $this->environment['yee.flash']->now($key, $value); } }
[ "public", "function", "flashNow", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "environment", "[", "'yee.flash'", "]", ")", ")", "{", "$", "this", "->", "environment", "[", "'yee.flash'", "]", "->", "now", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Set flash message for current request @param string $key @param mixed $value
[ "Set", "flash", "message", "for", "current", "request" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L1131-L1136
233,594
simplesamlphp/simplesamlphp-module-aggregator
lib/Aggregator.php
sspmod_aggregator_Aggregator.exclude
public function exclude($exclude) { $this->excludeTags = array_merge($this->excludeTags, SimpleSAML_Utilities::arrayize($exclude)); }
php
public function exclude($exclude) { $this->excludeTags = array_merge($this->excludeTags, SimpleSAML_Utilities::arrayize($exclude)); }
[ "public", "function", "exclude", "(", "$", "exclude", ")", "{", "$", "this", "->", "excludeTags", "=", "array_merge", "(", "$", "this", "->", "excludeTags", ",", "SimpleSAML_Utilities", "::", "arrayize", "(", "$", "exclude", ")", ")", ";", "}" ]
Add tag to excelude when collecting source metadata. $exclude May be string or array identifying a tag to exclude.
[ "Add", "tag", "to", "excelude", "when", "collecting", "source", "metadata", "." ]
1afd0913392193bc4d0b94cfc9a5020daac0fdbe
https://github.com/simplesamlphp/simplesamlphp-module-aggregator/blob/1afd0913392193bc4d0b94cfc9a5020daac0fdbe/lib/Aggregator.php#L70-L72
233,595
simplesamlphp/simplesamlphp-module-aggregator
lib/Aggregator.php
sspmod_aggregator_Aggregator.getSources
public function getSources() { $sourcesDef = $this->aConfig->getArray('sources'); try { $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef); } catch (Exception $e) { throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage()); } /* Find list of all available entities. */ $entities = array(); foreach ($sources as $source) { foreach ($this->sets as $set) { foreach ($source->getMetadataSet($set) as $entityId => $metadata) { $metadata['entityid'] = $entityId; $metadata['metadata-set'] = $set; if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) { \SimpleSAML\Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']'); continue; } else { #echo('<pre>'); print_r($metadata); exit; } if (!array_key_exists($entityId, $entities)) $entities[$entityId] = array(); if (array_key_exists($set, $entities[$entityId])) { /* Entity already has metadata for the given set. */ continue; } $entities[$entityId][$set] = $metadata; } } } return $entities; }
php
public function getSources() { $sourcesDef = $this->aConfig->getArray('sources'); try { $sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesDef); } catch (Exception $e) { throw new Exception('Invalid aggregator source configuration for aggregator ' . var_export($id, TRUE) . ': ' . $e->getMessage()); } /* Find list of all available entities. */ $entities = array(); foreach ($sources as $source) { foreach ($this->sets as $set) { foreach ($source->getMetadataSet($set) as $entityId => $metadata) { $metadata['entityid'] = $entityId; $metadata['metadata-set'] = $set; if (isset($metadata['tags']) && count(array_intersect($this->excludeTags, $metadata['tags'])) > 0) { \SimpleSAML\Logger::debug('Excluding entity ID [' . $entityId . '] becuase it is tagged with one of [' . var_export($this->excludeTags, TRUE) . ']'); continue; } else { #echo('<pre>'); print_r($metadata); exit; } if (!array_key_exists($entityId, $entities)) $entities[$entityId] = array(); if (array_key_exists($set, $entities[$entityId])) { /* Entity already has metadata for the given set. */ continue; } $entities[$entityId][$set] = $metadata; } } } return $entities; }
[ "public", "function", "getSources", "(", ")", "{", "$", "sourcesDef", "=", "$", "this", "->", "aConfig", "->", "getArray", "(", "'sources'", ")", ";", "try", "{", "$", "sources", "=", "SimpleSAML_Metadata_MetaDataStorageSource", "::", "parseSources", "(", "$", "sourcesDef", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Invalid aggregator source configuration for aggregator '", ".", "var_export", "(", "$", "id", ",", "TRUE", ")", ".", "': '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "/* Find list of all available entities. */", "$", "entities", "=", "array", "(", ")", ";", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "foreach", "(", "$", "this", "->", "sets", "as", "$", "set", ")", "{", "foreach", "(", "$", "source", "->", "getMetadataSet", "(", "$", "set", ")", "as", "$", "entityId", "=>", "$", "metadata", ")", "{", "$", "metadata", "[", "'entityid'", "]", "=", "$", "entityId", ";", "$", "metadata", "[", "'metadata-set'", "]", "=", "$", "set", ";", "if", "(", "isset", "(", "$", "metadata", "[", "'tags'", "]", ")", "&&", "count", "(", "array_intersect", "(", "$", "this", "->", "excludeTags", ",", "$", "metadata", "[", "'tags'", "]", ")", ")", ">", "0", ")", "{", "\\", "SimpleSAML", "\\", "Logger", "::", "debug", "(", "'Excluding entity ID ['", ".", "$", "entityId", ".", "'] becuase it is tagged with one of ['", ".", "var_export", "(", "$", "this", "->", "excludeTags", ",", "TRUE", ")", ".", "']'", ")", ";", "continue", ";", "}", "else", "{", "#echo('<pre>'); print_r($metadata); exit;", "}", "if", "(", "!", "array_key_exists", "(", "$", "entityId", ",", "$", "entities", ")", ")", "$", "entities", "[", "$", "entityId", "]", "=", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "set", ",", "$", "entities", "[", "$", "entityId", "]", ")", ")", "{", "/* Entity already has metadata for the given set. */", "continue", ";", "}", "$", "entities", "[", "$", "entityId", "]", "[", "$", "set", "]", "=", "$", "metadata", ";", "}", "}", "}", "return", "$", "entities", ";", "}" ]
Returns a list of entities with metadata
[ "Returns", "a", "list", "of", "entities", "with", "metadata" ]
1afd0913392193bc4d0b94cfc9a5020daac0fdbe
https://github.com/simplesamlphp/simplesamlphp-module-aggregator/blob/1afd0913392193bc4d0b94cfc9a5020daac0fdbe/lib/Aggregator.php#L77-L122
233,596
morilog/InfinityCache
src/Builder.php
Builder.get
public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); if ($this->isTimeAwareQuery) { // Cache results for $cacheLifeTime minutes $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime); } else { // Cache results forever $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } } return $results; }
php
public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); if ($this->isTimeAwareQuery) { // Cache results for $cacheLifeTime minutes $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime); } else { // Cache results forever $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } } return $results; }
[ "public", "function", "get", "(", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "cacheKey", "=", "$", "this", "->", "generateCacheKey", "(", ")", ";", "if", "(", "null", "===", "(", "$", "results", "=", "$", "this", "->", "cache", "->", "tags", "(", "$", "this", "->", "cacheTag", ")", "->", "get", "(", "$", "cacheKey", ")", ")", ")", "{", "$", "results", "=", "parent", "::", "get", "(", "$", "columns", ")", ";", "if", "(", "$", "this", "->", "isTimeAwareQuery", ")", "{", "// Cache results for $cacheLifeTime minutes", "$", "this", "->", "cache", "->", "tags", "(", "$", "this", "->", "cacheTag", ")", "->", "put", "(", "$", "cacheKey", ",", "$", "results", ",", "$", "this", "->", "cacheLifeTime", ")", ";", "}", "else", "{", "// Cache results forever", "$", "this", "->", "cache", "->", "tags", "(", "$", "this", "->", "cacheTag", ")", "->", "forever", "(", "$", "cacheKey", ",", "$", "results", ")", ";", "}", "}", "return", "$", "results", ";", "}" ]
Execute the query as a "select" statement. All Cached results will be flushed after every CUD operations @param array $columns @return array|static[]
[ "Execute", "the", "query", "as", "a", "select", "statement", ".", "All", "Cached", "results", "will", "be", "flushed", "after", "every", "CUD", "operations" ]
c87231b9995fbbcfdd0a67ab5ffc2697382031d7
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L64-L82
233,597
morilog/InfinityCache
src/Builder.php
Builder.newQuery
public function newQuery() { return new static( $this->cache, $this->connection, $this->grammar, $this->processor, $this->cacheTag ); }
php
public function newQuery() { return new static( $this->cache, $this->connection, $this->grammar, $this->processor, $this->cacheTag ); }
[ "public", "function", "newQuery", "(", ")", "{", "return", "new", "static", "(", "$", "this", "->", "cache", ",", "$", "this", "->", "connection", ",", "$", "this", "->", "grammar", ",", "$", "this", "->", "processor", ",", "$", "this", "->", "cacheTag", ")", ";", "}" ]
Get a new instance of the query builder. @return Builder
[ "Get", "a", "new", "instance", "of", "the", "query", "builder", "." ]
c87231b9995fbbcfdd0a67ab5ffc2697382031d7
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L89-L98
233,598
morilog/InfinityCache
src/Builder.php
Builder.generateCacheKey
protected function generateCacheKey() { $bindings = array_map(function ($param) { // Round datetime if ($param instanceof \DateTime) { $this->isTimeAwareQuery = true; return $this->getRoundedDateTime($param); } return $param; }, $this->getBindings()); return sha1($this->connection->getName() . $this->toSql() . serialize($bindings)); }
php
protected function generateCacheKey() { $bindings = array_map(function ($param) { // Round datetime if ($param instanceof \DateTime) { $this->isTimeAwareQuery = true; return $this->getRoundedDateTime($param); } return $param; }, $this->getBindings()); return sha1($this->connection->getName() . $this->toSql() . serialize($bindings)); }
[ "protected", "function", "generateCacheKey", "(", ")", "{", "$", "bindings", "=", "array_map", "(", "function", "(", "$", "param", ")", "{", "// Round datetime", "if", "(", "$", "param", "instanceof", "\\", "DateTime", ")", "{", "$", "this", "->", "isTimeAwareQuery", "=", "true", ";", "return", "$", "this", "->", "getRoundedDateTime", "(", "$", "param", ")", ";", "}", "return", "$", "param", ";", "}", ",", "$", "this", "->", "getBindings", "(", ")", ")", ";", "return", "sha1", "(", "$", "this", "->", "connection", "->", "getName", "(", ")", ".", "$", "this", "->", "toSql", "(", ")", ".", "serialize", "(", "$", "bindings", ")", ")", ";", "}" ]
Generate unique cache key from query and it bindings parameters @return string
[ "Generate", "unique", "cache", "key", "from", "query", "and", "it", "bindings", "parameters" ]
c87231b9995fbbcfdd0a67ab5ffc2697382031d7
https://github.com/morilog/InfinityCache/blob/c87231b9995fbbcfdd0a67ab5ffc2697382031d7/src/Builder.php#L105-L121
233,599
budde377/Part
lib/model/page/PageImpl.php
PageImpl.getTemplate
public function getTemplate() { if($this->template != ''){ return $this->template; } if(($defaultTemplate = $this->container->getConfigInstance()->getDefaultTemplateName()) == null){ return ''; } return $defaultTemplate; }
php
public function getTemplate() { if($this->template != ''){ return $this->template; } if(($defaultTemplate = $this->container->getConfigInstance()->getDefaultTemplateName()) == null){ return ''; } return $defaultTemplate; }
[ "public", "function", "getTemplate", "(", ")", "{", "if", "(", "$", "this", "->", "template", "!=", "''", ")", "{", "return", "$", "this", "->", "template", ";", "}", "if", "(", "(", "$", "defaultTemplate", "=", "$", "this", "->", "container", "->", "getConfigInstance", "(", ")", "->", "getDefaultTemplateName", "(", ")", ")", "==", "null", ")", "{", "return", "''", ";", "}", "return", "$", "defaultTemplate", ";", "}" ]
The return string should match a template in some config. @return string
[ "The", "return", "string", "should", "match", "a", "template", "in", "some", "config", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageImpl.php#L91-L102