repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
rosell-dk/webp-convert | src/Convert/Converters/ImagickBinary.php | ImagickBinary.webPDelegateInstalled | public static function webPDelegateInstalled()
{
exec('convert -list delegate', $output, $returnCode);
foreach ($output as $line) {
if (preg_match('#webp\\s*=#i', $line)) {
return true;
}
}
// try other command
exec('convert -list con... | php | public static function webPDelegateInstalled()
{
exec('convert -list delegate', $output, $returnCode);
foreach ($output as $line) {
if (preg_match('#webp\\s*=#i', $line)) {
return true;
}
}
// try other command
exec('convert -list con... | [
"public",
"static",
"function",
"webPDelegateInstalled",
"(",
")",
"{",
"exec",
"(",
"'convert -list delegate'",
",",
"$",
"output",
",",
"$",
"returnCode",
")",
";",
"foreach",
"(",
"$",
"output",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"preg_match",
"(",... | Check if webp delegate is installed | [
"Check",
"if",
"webp",
"delegate",
"is",
"installed"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/ImagickBinary.php#L40-L61 |
rosell-dk/webp-convert | src/Convert/Converters/Imagick.php | Imagick.checkOperationality | public function checkOperationality()
{
if (!extension_loaded('imagick')) {
throw new SystemRequirementsNotMetException('Required iMagick extension is not available.');
}
if (!class_exists('\\Imagick')) {
throw new SystemRequirementsNotMetException(
'... | php | public function checkOperationality()
{
if (!extension_loaded('imagick')) {
throw new SystemRequirementsNotMetException('Required iMagick extension is not available.');
}
if (!class_exists('\\Imagick')) {
throw new SystemRequirementsNotMetException(
'... | [
"public",
"function",
"checkOperationality",
"(",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"'imagick'",
")",
")",
"{",
"throw",
"new",
"SystemRequirementsNotMetException",
"(",
"'Required iMagick extension is not available.'",
")",
";",
"}",
"if",
"(",
"!"... | Check operationality of Imagick converter.
Note:
It may be that Gd has been compiled without jpeg support or png support.
We do not check for this here, as the converter could still be used for the other.
@throws SystemRequirementsNotMetException if system requirements are not met
@return void | [
"Check",
"operationality",
"of",
"Imagick",
"converter",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Imagick.php#L38-L54 |
rosell-dk/webp-convert | src/Convert/Converters/Ewww.php | Ewww.getKey | private function getKey()
{
if (!empty($this->options['key'])) {
return $this->options['key'];
}
if (!empty(getenv('EWWW_API_KEY'))) {
return getenv('EWWW_API_KEY');
}
return false;
} | php | private function getKey()
{
if (!empty($this->options['key'])) {
return $this->options['key'];
}
if (!empty(getenv('EWWW_API_KEY'))) {
return getenv('EWWW_API_KEY');
}
return false;
} | [
"private",
"function",
"getKey",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'key'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
"[",
"'key'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"ge... | Get api key from options or environment variable
@return string|false api key or false if none is set | [
"Get",
"api",
"key",
"from",
"options",
"or",
"environment",
"variable"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Ewww.php#L34-L43 |
rosell-dk/webp-convert | src/Convert/Converters/Ewww.php | Ewww.checkOperationality | public function checkOperationality()
{
// First check for curl requirements
parent::checkOperationality();
$apiKey = $this->getKey();
if ($apiKey === false) {
throw new InvalidApiKeyException('Missing API key.');
}
if (strlen($apiKey) < 20) {
... | php | public function checkOperationality()
{
// First check for curl requirements
parent::checkOperationality();
$apiKey = $this->getKey();
if ($apiKey === false) {
throw new InvalidApiKeyException('Missing API key.');
}
if (strlen($apiKey) < 20) {
... | [
"public",
"function",
"checkOperationality",
"(",
")",
"{",
"// First check for curl requirements",
"parent",
"::",
"checkOperationality",
"(",
")",
";",
"$",
"apiKey",
"=",
"$",
"this",
"->",
"getKey",
"(",
")",
";",
"if",
"(",
"$",
"apiKey",
"===",
"false",
... | Check operationality of Ewww converter.
@throws SystemRequirementsNotMetException if system requirements are not met (curl)
@throws ConverterNotOperationalException if key is missing or invalid, or quota has exceeded | [
"Check",
"operationality",
"of",
"Ewww",
"converter",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Ewww.php#L52-L80 |
rosell-dk/webp-convert | src/Convert/Converters/Ewww.php | Ewww.doActualConvert | protected function doActualConvert()
{
$options = $this->options;
$ch = self::initCurl();
//$this->logLn('api key:' . $this->getKey());
$postData = [
'api_key' => $this->getKey(),
'webp' => '1',
'file' => curl_file_create($this->source),
... | php | protected function doActualConvert()
{
$options = $this->options;
$ch = self::initCurl();
//$this->logLn('api key:' . $this->getKey());
$postData = [
'api_key' => $this->getKey(),
'webp' => '1',
'file' => curl_file_create($this->source),
... | [
"protected",
"function",
"doActualConvert",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"ch",
"=",
"self",
"::",
"initCurl",
"(",
")",
";",
"//$this->logLn('api key:' . $this->getKey());",
"$",
"postData",
"=",
"[",
"'api_key'",... | takes care of preparing stuff before calling doConvert, and validating after. | [
"takes",
"care",
"of",
"preparing",
"stuff",
"before",
"calling",
"doConvert",
"and",
"validating",
"after",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Ewww.php#L85-L159 |
rosell-dk/webp-convert | src/Convert/Converters/Ewww.php | Ewww.keepSubscriptionAlive | public static function keepSubscriptionAlive($source, $key)
{
try {
$ch = curl_init();
} catch (\Exception $e) {
return 'curl is not installed';
}
if ($ch === false) {
return 'curl could not be initialized';
}
curl_setopt_array(
... | php | public static function keepSubscriptionAlive($source, $key)
{
try {
$ch = curl_init();
} catch (\Exception $e) {
return 'curl is not installed';
}
if ($ch === false) {
return 'curl could not be initialized';
}
curl_setopt_array(
... | [
"public",
"static",
"function",
"keepSubscriptionAlive",
"(",
"$",
"source",
",",
"$",
"key",
")",
"{",
"try",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"'curl is not installed'",... | Keep subscription alive by optimizing a jpeg
(ewww closes accounts after 6 months of inactivity - and webp conversions seems not to be counted? ) | [
"Keep",
"subscription",
"alive",
"by",
"optimizing",
"a",
"jpeg",
"(",
"ewww",
"closes",
"accounts",
"after",
"6",
"months",
"of",
"inactivity",
"-",
"and",
"webp",
"conversions",
"seems",
"not",
"to",
"be",
"counted?",
")"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Ewww.php#L165-L220 |
rosell-dk/webp-convert | src/Convert/Converters/Ewww.php | Ewww.getKeyStatus | public static function getKeyStatus($key)
{
$ch = self::initCurl();
curl_setopt($ch, CURLOPT_URL, "https://optimize.exactlywww.com/verify/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
[
'api_... | php | public static function getKeyStatus($key)
{
$ch = self::initCurl();
curl_setopt($ch, CURLOPT_URL, "https://optimize.exactlywww.com/verify/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
[
'api_... | [
"public",
"static",
"function",
"getKeyStatus",
"(",
"$",
"key",
")",
"{",
"$",
"ch",
"=",
"self",
"::",
"initCurl",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"\"https://optimize.exactlywww.com/verify/\"",
")",
";",
"curl_setopt",
... | Return "great", "exceeded" or "invalid" | [
"Return",
"great",
"exceeded",
"or",
"invalid"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Ewww.php#L234-L287 |
rosell-dk/webp-convert | src/Convert/Helpers/JpegQualityDetector.php | JpegQualityDetector.detectQualityOfJpgUsingImagickExtension | private static function detectQualityOfJpgUsingImagickExtension($filename)
{
if (extension_loaded('imagick') && class_exists('\\Imagick')) {
try {
$img = new \Imagick($filename);
// The required function is available as from PECL imagick v2.2.2
if... | php | private static function detectQualityOfJpgUsingImagickExtension($filename)
{
if (extension_loaded('imagick') && class_exists('\\Imagick')) {
try {
$img = new \Imagick($filename);
// The required function is available as from PECL imagick v2.2.2
if... | [
"private",
"static",
"function",
"detectQualityOfJpgUsingImagickExtension",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"'imagick'",
")",
"&&",
"class_exists",
"(",
"'\\\\Imagick'",
")",
")",
"{",
"try",
"{",
"$",
"img",
"=",
"new",
"\\... | Try to detect quality of jpeg using imagick extension
@param string $filename A complete file path to file to be examined
@return int|null Quality, or null if it was not possible to detect quality | [
"Try",
"to",
"detect",
"quality",
"of",
"jpeg",
"using",
"imagick",
"extension"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Helpers/JpegQualityDetector.php#L21-L37 |
rosell-dk/webp-convert | src/Convert/Helpers/JpegQualityDetector.php | JpegQualityDetector.detectQualityOfJpgUsingImagickBinary | private static function detectQualityOfJpgUsingImagickBinary($filename)
{
if (function_exists('exec')) {
// Try Imagick using exec, and routing stderr to stdout (the "2>$1" magic)
exec("identify -format '%Q' " . escapeshellarg($filename) . " 2>&1", $output, $returnCode);
... | php | private static function detectQualityOfJpgUsingImagickBinary($filename)
{
if (function_exists('exec')) {
// Try Imagick using exec, and routing stderr to stdout (the "2>$1" magic)
exec("identify -format '%Q' " . escapeshellarg($filename) . " 2>&1", $output, $returnCode);
... | [
"private",
"static",
"function",
"detectQualityOfJpgUsingImagickBinary",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'exec'",
")",
")",
"{",
"// Try Imagick using exec, and routing stderr to stdout (the \"2>$1\" magic)",
"exec",
"(",
"\"identify -forma... | Try to detect quality of jpeg using imagick binary
@param string $filename A complete file path to file to be examined
@return int|null Quality, or null if it was not possible to detect quality | [
"Try",
"to",
"detect",
"quality",
"of",
"jpeg",
"using",
"imagick",
"binary"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Helpers/JpegQualityDetector.php#L46-L57 |
rosell-dk/webp-convert | src/Convert/Helpers/JpegQualityDetector.php | JpegQualityDetector.detectQualityOfJpg | public static function detectQualityOfJpg($filename)
{
//trigger_error('warning test', E_USER_WARNING);
// Test that file exists in order not to break things.
if (!file_exists($filename)) {
// One could argue that it would be better to throw an Exception...?
return ... | php | public static function detectQualityOfJpg($filename)
{
//trigger_error('warning test', E_USER_WARNING);
// Test that file exists in order not to break things.
if (!file_exists($filename)) {
// One could argue that it would be better to throw an Exception...?
return ... | [
"public",
"static",
"function",
"detectQualityOfJpg",
"(",
"$",
"filename",
")",
"{",
"//trigger_error('warning test', E_USER_WARNING);",
"// Test that file exists in order not to break things.",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"// One co... | Try to detect quality of jpeg.
Note: This method does not throw errors, but might dispatch warnings.
You can use the WarningsIntoExceptions class if it is critical to you that nothing gets "printed"
@param string $filename A complete file path to file to be examined
@return int|null Quality, or null if it was not... | [
"Try",
"to",
"detect",
"quality",
"of",
"jpeg",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Helpers/JpegQualityDetector.php#L88-L111 |
rosell-dk/webp-convert | src/Convert/Helpers/PhpIniSizes.php | PhpIniSizes.parseShortHandSize | public static function parseShortHandSize($shortHandSize)
{
$result = preg_match("#^\\s*(\\d+(?:\\.\\d+)?)([bkmgtpezy]?)\\s*$#i", $shortHandSize, $matches);
if ($result !== 1) {
return false;
}
// Truncate, because that is what php does.
$digitsValue = floor($ma... | php | public static function parseShortHandSize($shortHandSize)
{
$result = preg_match("#^\\s*(\\d+(?:\\.\\d+)?)([bkmgtpezy]?)\\s*$#i", $shortHandSize, $matches);
if ($result !== 1) {
return false;
}
// Truncate, because that is what php does.
$digitsValue = floor($ma... | [
"public",
"static",
"function",
"parseShortHandSize",
"(",
"$",
"shortHandSize",
")",
"{",
"$",
"result",
"=",
"preg_match",
"(",
"\"#^\\\\s*(\\\\d+(?:\\\\.\\\\d+)?)([bkmgtpezy]?)\\\\s*$#i\"",
",",
"$",
"shortHandSize",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",... | Parse a shordhandsize string as the ones returned by ini_get()
Parse a shorthandsize string having the syntax allowed in php.ini and returned by ini_get().
Ie "1K" => 1024.
Strings without units are also accepted.
The shorthandbytes syntax is described here: https://www.php.net/manual/en/faq.using.php#faq.using.shorth... | [
"Parse",
"a",
"shordhandsize",
"string",
"as",
"the",
"ones",
"returned",
"by",
"ini_get",
"()"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Helpers/PhpIniSizes.php#L29-L51 |
rosell-dk/webp-convert | src/Convert/Helpers/PhpIniSizes.php | PhpIniSizes.getIniBytes | public static function getIniBytes($iniVarName)
{
$iniVarValue = ini_get($iniVarName);
if (($iniVarValue == '') || $iniVarValue === false) {
return false;
}
return self::parseShortHandSize($iniVarValue);
} | php | public static function getIniBytes($iniVarName)
{
$iniVarValue = ini_get($iniVarName);
if (($iniVarValue == '') || $iniVarValue === false) {
return false;
}
return self::parseShortHandSize($iniVarValue);
} | [
"public",
"static",
"function",
"getIniBytes",
"(",
"$",
"iniVarName",
")",
"{",
"$",
"iniVarValue",
"=",
"ini_get",
"(",
"$",
"iniVarName",
")",
";",
"if",
"(",
"(",
"$",
"iniVarValue",
"==",
"''",
")",
"||",
"$",
"iniVarValue",
"===",
"false",
")",
"... | /*
Get the size of an php.ini option.
Calls ini_get() and parses the size to a number.
If the configuration option is null, does not exist, or cannot be parsed as a shorthandsize, false is returned
@param string $varname The configuration option name.
@return float|false The parsed size or false if the configurat... | [
"/",
"*",
"Get",
"the",
"size",
"of",
"an",
"php",
".",
"ini",
"option",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Helpers/PhpIniSizes.php#L62-L69 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.createInstance | public static function createInstance($source, $destination, $options = [], $logger = null)
{
return new static($source, $destination, $options, $logger);
} | php | public static function createInstance($source, $destination, $options = [], $logger = null)
{
return new static($source, $destination, $options, $logger);
} | [
"public",
"static",
"function",
"createInstance",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"logger",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"source",
",",
"$",
"destination",
",",
... | Create an instance of this class
@param string $source The path to the file to convert
@param string $destination The path to save the converted file to
@param array $options (optional)
@param \WebPConvert\Loggers\BaseLogger $logger (optional)
@return static | [
"Create",
"an",
"instance",
"of",
"this",
"class"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L136-L139 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.doConvert | public function doConvert()
{
$beginTime = microtime(true);
$this->activateWarningLogger();
//set_error_handler(array($this, "errorHandler"));
try {
// Prepare options
//$this->prepareOptions();
$this->checkOptions();
// Prepare des... | php | public function doConvert()
{
$beginTime = microtime(true);
$this->activateWarningLogger();
//set_error_handler(array($this, "errorHandler"));
try {
// Prepare options
//$this->prepareOptions();
$this->checkOptions();
// Prepare des... | [
"public",
"function",
"doConvert",
"(",
")",
"{",
"$",
"beginTime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"activateWarningLogger",
"(",
")",
";",
"//set_error_handler(array($this, \"errorHandler\"));",
"try",
"{",
"// Prepare options",
"//$this... | $instance->logLn(self::getConverterDisplayName() . ' converter ignited'); | [
"$instance",
"-",
">",
"logLn",
"(",
"self",
"::",
"getConverterDisplayName",
"()",
".",
"converter",
"ignited",
")",
";"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L144-L216 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.convert | public static function convert($source, $destination, $options = [], $logger = null)
{
$instance = self::createInstance($source, $destination, $options, $logger);
$instance->doConvert();
//echo $instance->id;
} | php | public static function convert($source, $destination, $options = [], $logger = null)
{
$instance = self::createInstance($source, $destination, $options, $logger);
$instance->doConvert();
//echo $instance->id;
} | [
"public",
"static",
"function",
"convert",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"logger",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"createInstance",
"(",
"$",
"source",
",",
"$",... | Convert an image to webp.
@param string $source path to source file
@param string $destination path to destination
@param array $options (optional) options for conversion
@param \WebPConvert\Loggers\BaseLogger $logger (optional)
@return void | [
"Convert",
"an",
"image",
"to",
"webp",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L272-L277 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.getMimeTypeOfSource | public function getMimeTypeOfSource()
{
if (!isset($this->sourceMimeType)) {
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
}
return $this->sourceMimeType;
} | php | public function getMimeTypeOfSource()
{
if (!isset($this->sourceMimeType)) {
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
}
return $this->sourceMimeType;
} | [
"public",
"function",
"getMimeTypeOfSource",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"sourceMimeType",
")",
")",
"{",
"$",
"this",
"->",
"sourceMimeType",
"=",
"ImageMimeTypeGuesser",
"::",
"lenientGuess",
"(",
"$",
"this",
"->",
"s... | Get mime type for image (best guess).
It falls back to using file extension. If that fails too, false is returned
PS: Is it a security risk to fall back on file extension?
- By setting file extension to "jpg", one can lure our library into trying to convert a file, which isn't a jpg.
hmm, seems very unlikely, though ... | [
"Get",
"mime",
"type",
"for",
"image",
"(",
"best",
"guess",
")",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L292-L298 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.checkInput | private function checkInput()
{
// Check if source exists
if (!@file_exists($this->source)) {
throw new TargetNotFoundException('File or directory not found: ' . $this->source);
}
// Check if the provided file's mime type is valid
$fileMimeType = $this->getMimeTy... | php | private function checkInput()
{
// Check if source exists
if (!@file_exists($this->source)) {
throw new TargetNotFoundException('File or directory not found: ' . $this->source);
}
// Check if the provided file's mime type is valid
$fileMimeType = $this->getMimeTy... | [
"private",
"function",
"checkInput",
"(",
")",
"{",
"// Check if source exists",
"if",
"(",
"!",
"@",
"file_exists",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"throw",
"new",
"TargetNotFoundException",
"(",
"'File or directory not found: '",
".",
"$",
"th... | Note: As the input validations are only run one time in a stack,
this method is not overridable | [
"Note",
":",
"As",
"the",
"input",
"validations",
"are",
"only",
"run",
"one",
"time",
"in",
"a",
"stack",
"this",
"method",
"is",
"not",
"overridable"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L304-L320 |
rosell-dk/webp-convert | src/Convert/BaseConverters/AbstractConverter.php | AbstractConverter.createWritableDestinationFolder | private function createWritableDestinationFolder()
{
$filePath = $this->destination;
$folder = dirname($filePath);
if (!file_exists($folder)) {
$this->logLn('Destination folder does not exist. Creating folder: ' . $folder);
// TODO: what if this is outside open based... | php | private function createWritableDestinationFolder()
{
$filePath = $this->destination;
$folder = dirname($filePath);
if (!file_exists($folder)) {
$this->logLn('Destination folder does not exist. Creating folder: ' . $folder);
// TODO: what if this is outside open based... | [
"private",
"function",
"createWritableDestinationFolder",
"(",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"destination",
";",
"$",
"folder",
"=",
"dirname",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"folder",
")",
"... | also deletes the file at filePath (if it already exists) | [
"also",
"deletes",
"the",
"file",
"at",
"filePath",
"(",
"if",
"it",
"already",
"exists",
")"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/AbstractConverter.php#L359-L374 |
rosell-dk/webp-convert | src/WebPConvert.php | WebPConvert.convert | public static function convert($source, $destination, $options = [], $logger = null)
{
//return ConverterHelper::runConverterStack($source, $destination, $options, $logger);
//return Convert::runConverterStack($source, $destination, $options, $logger);
Stack::convert($source, $destination, $... | php | public static function convert($source, $destination, $options = [], $logger = null)
{
//return ConverterHelper::runConverterStack($source, $destination, $options, $logger);
//return Convert::runConverterStack($source, $destination, $options, $logger);
Stack::convert($source, $destination, $... | [
"public",
"static",
"function",
"convert",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"logger",
"=",
"null",
")",
"{",
"//return ConverterHelper::runConverterStack($source, $destination, $options, $logger);",
"//return C... | Convert jpeg or png into webp
Convenience method for calling Stack::convert.
@param string $source The image to convert (absolute,no backslashes)
Image must be jpeg or png.
@param string $destination Where to store the converted file (absolute path, no backslashes).
@param array $options (optional)... | [
"Convert",
"jpeg",
"or",
"png",
"into",
"webp"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/WebPConvert.php#L38-L43 |
rosell-dk/webp-convert | src/Convert/Converters/Vips.php | Vips.createImageResource | private function createImageResource()
{
// We are currently using vips_image_new_from_file(), but we could consider
// calling vips_jpegload / vips_pngload instead
$result = /** @scrutinizer ignore-call */ vips_image_new_from_file($this->source, []);
if ($result === -1) {
... | php | private function createImageResource()
{
// We are currently using vips_image_new_from_file(), but we could consider
// calling vips_jpegload / vips_pngload instead
$result = /** @scrutinizer ignore-call */ vips_image_new_from_file($this->source, []);
if ($result === -1) {
... | [
"private",
"function",
"createImageResource",
"(",
")",
"{",
"// We are currently using vips_image_new_from_file(), but we could consider",
"// calling vips_jpegload / vips_pngload instead",
"$",
"result",
"=",
"/** @scrutinizer ignore-call */",
"vips_image_new_from_file",
"(",
"$",
"t... | Create vips image resource from source file
@throws ConversionFailedException if image resource cannot be created
@return resource vips image resource | [
"Create",
"vips",
"image",
"resource",
"from",
"source",
"file"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Vips.php#L76-L104 |
rosell-dk/webp-convert | src/Convert/Converters/Vips.php | Vips.createParamsForVipsWebPSave | private function createParamsForVipsWebPSave()
{
// webpsave options are described here:
// https://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave
$options = [
"Q" => $this->getCalculatedQuality(),
'lossless' => $this->options['lossless'],
... | php | private function createParamsForVipsWebPSave()
{
// webpsave options are described here:
// https://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave
$options = [
"Q" => $this->getCalculatedQuality(),
'lossless' => $this->options['lossless'],
... | [
"private",
"function",
"createParamsForVipsWebPSave",
"(",
")",
"{",
"// webpsave options are described here:",
"// https://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave",
"$",
"options",
"=",
"[",
"\"Q\"",
"=>",
"$",
"this",
"->",
"getCalculatedQuality",... | Create parameters for webpsave
@return array the parameters as an array | [
"Create",
"parameters",
"for",
"webpsave"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Vips.php#L111-L146 |
rosell-dk/webp-convert | src/Convert/Converters/Vips.php | Vips.webpsave | private function webpsave($im, $options)
{
$result = /** @scrutinizer ignore-call */ vips_call('webpsave', $im, $this->destination, $options);
if ($result === -1) {
$message = /** @scrutinizer ignore-call */ vips_error_buffer();
// If the error
if (preg_match("#... | php | private function webpsave($im, $options)
{
$result = /** @scrutinizer ignore-call */ vips_call('webpsave', $im, $this->destination, $options);
if ($result === -1) {
$message = /** @scrutinizer ignore-call */ vips_error_buffer();
// If the error
if (preg_match("#... | [
"private",
"function",
"webpsave",
"(",
"$",
"im",
",",
"$",
"options",
")",
"{",
"$",
"result",
"=",
"/** @scrutinizer ignore-call */",
"vips_call",
"(",
"'webpsave'",
",",
"$",
"im",
",",
"$",
"this",
"->",
"destination",
",",
"$",
"options",
")",
";",
... | Convert with vips extension.
Tries to create image resource and save it as webp using the calculated options.
Vips fails when a parameter is not supported, but we detect this and unset that parameter and try again
(recursively call itself until there is no more of these kind of errors).
@param resource $im A vips ... | [
"Convert",
"with",
"vips",
"extension",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Vips.php#L158-L178 |
rosell-dk/webp-convert | src/Convert/Converters/Vips.php | Vips.doActualConvert | protected function doActualConvert()
{
/*
$im = \Jcupitt\Vips\Image::newFromFile($this->source);
//$im->writeToFile(__DIR__ . '/images/small-vips.webp', ["Q" => 10]);
$im->webpsave($this->destination, [
"Q" => 80,
//'near_lossless' => true
]);
return;... | php | protected function doActualConvert()
{
/*
$im = \Jcupitt\Vips\Image::newFromFile($this->source);
//$im->writeToFile(__DIR__ . '/images/small-vips.webp', ["Q" => 10]);
$im->webpsave($this->destination, [
"Q" => 80,
//'near_lossless' => true
]);
return;... | [
"protected",
"function",
"doActualConvert",
"(",
")",
"{",
"/*\n $im = \\Jcupitt\\Vips\\Image::newFromFile($this->source);\n //$im->writeToFile(__DIR__ . '/images/small-vips.webp', [\"Q\" => 10]);\n\n $im->webpsave($this->destination, [\n \"Q\" => 80,\n //'near... | Convert with vips extension.
Tries to create image resource and save it as webp using the calculated options.
Vips fails when a parameter is not supported, but we detect this and unset that parameter and try again
(repeat until success).
@throws ConversionFailedException if conversion fails. | [
"Convert",
"with",
"vips",
"extension",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Vips.php#L189-L204 |
rosell-dk/webp-convert | src/Convert/Converters/GmagickBinary.php | GmagickBinary.webPDelegateInstalled | public static function webPDelegateInstalled()
{
exec('gm -version', $output, $returnCode);
foreach ($output as $line) {
if (preg_match('#WebP.*yes#i', $line)) {
return true;
}
}
return false;
} | php | public static function webPDelegateInstalled()
{
exec('gm -version', $output, $returnCode);
foreach ($output as $line) {
if (preg_match('#WebP.*yes#i', $line)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"webPDelegateInstalled",
"(",
")",
"{",
"exec",
"(",
"'gm -version'",
",",
"$",
"output",
",",
"$",
"returnCode",
")",
";",
"foreach",
"(",
"$",
"output",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#WebP.... | Check if webp delegate is installed | [
"Check",
"if",
"webp",
"delegate",
"is",
"installed"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/GmagickBinary.php#L37-L46 |
rosell-dk/webp-convert | src/Convert/BaseConverters/BaseTraits/OptionsTrait.php | OptionsTrait.setProvidedOptions | public function setProvidedOptions($providedOptions = [])
{
$this->providedOptions = $providedOptions;
if (isset($this->providedOptions['png'])) {
if ($this->getMimeTypeOfSource() == 'image/png') {
$this->providedOptions = array_merge($this->providedOptions, $this->provi... | php | public function setProvidedOptions($providedOptions = [])
{
$this->providedOptions = $providedOptions;
if (isset($this->providedOptions['png'])) {
if ($this->getMimeTypeOfSource() == 'image/png') {
$this->providedOptions = array_merge($this->providedOptions, $this->provi... | [
"public",
"function",
"setProvidedOptions",
"(",
"$",
"providedOptions",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"providedOptions",
"=",
"$",
"providedOptions",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"providedOptions",
"[",
"'png'",
"]",
")",... | Set "provided options"
This also sets the internal options array, by merging in the default options
@param array $providedOptions (optional)
@return void | [
"Set",
"provided",
"options",
"This",
"also",
"sets",
"the",
"internal",
"options",
"array",
"by",
"merging",
"in",
"the",
"default",
"options"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/BaseTraits/OptionsTrait.php#L38-L56 |
rosell-dk/webp-convert | src/Convert/BaseConverters/BaseTraits/LoggerTrait.php | LoggerTrait.setLogger | public function setLogger($logger = null)
{
if (!isset($logger)) {
$logger = new \WebPConvert\Loggers\VoidLogger();
}
$this->logger = $logger;
} | php | public function setLogger($logger = null)
{
if (!isset($logger)) {
$logger = new \WebPConvert\Loggers\VoidLogger();
}
$this->logger = $logger;
} | [
"public",
"function",
"setLogger",
"(",
"$",
"logger",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"logger",
")",
")",
"{",
"$",
"logger",
"=",
"new",
"\\",
"WebPConvert",
"\\",
"Loggers",
"\\",
"VoidLogger",
"(",
")",
";",
"}",
"$",
... | Set logger
@param \WebPConvert\Loggers\BaseLogger $logger (optional) $logger
@return void | [
"Set",
"logger"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/BaseTraits/LoggerTrait.php#L16-L22 |
rosell-dk/webp-convert | src/Serve/ServeConvertedWebPWithErrorHandling.php | ServeConvertedWebPWithErrorHandling.serve | public static function serve($source, $destination, $options = [])
{
$options = array_merge(self::$defaultOptions, $options);
try {
ServeConvertedWebP::serve($source, $destination, $options);
} catch (\Exception $e) {
self::performFailAction(
$options... | php | public static function serve($source, $destination, $options = [])
{
$options = array_merge(self::$defaultOptions, $options);
try {
ServeConvertedWebP::serve($source, $destination, $options);
} catch (\Exception $e) {
self::performFailAction(
$options... | [
"public",
"static",
"function",
"serve",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"defaultOptions",
",",
"$",
"options",
")",
";",
"try",
"{... | Serve webp image and handle errors.
@throws ServeFailedException If an argument is invalid or source file does not exists
@return void | [
"Serve",
"webp",
"image",
"and",
"handle",
"errors",
"."
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Serve/ServeConvertedWebPWithErrorHandling.php#L66-L81 |
rosell-dk/webp-convert | src/Convert/BaseConverters/BaseTraits/WarningLoggerTrait.php | WarningLoggerTrait.warningHandler | protected function warningHandler($errno, $errstr, $errfile, $errline)
{
/*
We do NOT do the following (even though it is generally recommended):
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting, so let it fall
// through to ... | php | protected function warningHandler($errno, $errstr, $errfile, $errline)
{
/*
We do NOT do the following (even though it is generally recommended):
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting, so let it fall
// through to ... | [
"protected",
"function",
"warningHandler",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"/*\n We do NOT do the following (even though it is generally recommended):\n\n if (!(error_reporting() & $errno)) {\n // T... | Handle errors during conversion.
The function is a callback used with "set_error_handler". It logs | [
"Handle",
"errors",
"during",
"conversion",
".",
"The",
"function",
"is",
"a",
"callback",
"used",
"with",
"set_error_handler",
".",
"It",
"logs"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/BaseTraits/WarningLoggerTrait.php#L14-L72 |
rosell-dk/webp-convert | src/Convert/BaseConverters/BaseTraits/WarningLoggerTrait.php | WarningLoggerTrait.activateWarningLogger | protected function activateWarningLogger()
{
$this->previousErrorHandler = set_error_handler(
array($this, "warningHandler"),
E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_ERROR
);
} | php | protected function activateWarningLogger()
{
$this->previousErrorHandler = set_error_handler(
array($this, "warningHandler"),
E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_ERROR
);
} | [
"protected",
"function",
"activateWarningLogger",
"(",
")",
"{",
"$",
"this",
"->",
"previousErrorHandler",
"=",
"set_error_handler",
"(",
"array",
"(",
"$",
"this",
",",
"\"warningHandler\"",
")",
",",
"E_WARNING",
"|",
"E_USER_WARNING",
"|",
"E_NOTICE",
"|",
"... | /*
public function get_error_handler(){
$handler = set_error_handler(function(){});
restore_error_handler();
echo 'handler:' . $handler;
return $handler;
} | [
"/",
"*",
"public",
"function",
"get_error_handler",
"()",
"{",
"$handler",
"=",
"set_error_handler",
"(",
"function",
"()",
"{}",
")",
";",
"restore_error_handler",
"()",
";",
"echo",
"handler",
":",
".",
"$handler",
";",
"return",
"$handler",
";",
"}"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/BaseConverters/BaseTraits/WarningLoggerTrait.php#L82-L88 |
rosell-dk/webp-convert | src/Convert/Converters/Cwebp.php | Cwebp.createCommandLineOptions | private function createCommandLineOptions()
{
$options = $this->options;
$commandOptionsArray = [];
// Metadata (all, exif, icc, xmp or none (default))
// Comma-separated list of existing metadata to copy from input to output
$commandOptionsArray[] = '-metadata ' . $options... | php | private function createCommandLineOptions()
{
$options = $this->options;
$commandOptionsArray = [];
// Metadata (all, exif, icc, xmp or none (default))
// Comma-separated list of existing metadata to copy from input to output
$commandOptionsArray[] = '-metadata ' . $options... | [
"private",
"function",
"createCommandLineOptions",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"commandOptionsArray",
"=",
"[",
"]",
";",
"// Metadata (all, exif, icc, xmp or none (default))",
"// Comma-separated list of existing metadata to ... | Build command line options
@return string | [
"Build",
"command",
"line",
"options"
] | train | https://github.com/rosell-dk/webp-convert/blob/d54b23dbce745cae7955ee1c7ba912731f679ee1/src/Convert/Converters/Cwebp.php#L74-L170 |
laracasts/Laravel-5-Generators-Extended | src/Commands/PivotMigrationMakeCommand.php | PivotMigrationMakeCommand.getClassName | protected function getClassName()
{
$name = implode('', array_map('ucwords', $this->getSortedSingularTableNames()));
$name = preg_replace_callback('/(\_)([a-z]{1})/', function ($matches) {
return studly_case($matches[0]);
}, $name);
return "Create{$name}PivotTable";
... | php | protected function getClassName()
{
$name = implode('', array_map('ucwords', $this->getSortedSingularTableNames()));
$name = preg_replace_callback('/(\_)([a-z]{1})/', function ($matches) {
return studly_case($matches[0]);
}, $name);
return "Create{$name}PivotTable";
... | [
"protected",
"function",
"getClassName",
"(",
")",
"{",
"$",
"name",
"=",
"implode",
"(",
"''",
",",
"array_map",
"(",
"'ucwords'",
",",
"$",
"this",
"->",
"getSortedSingularTableNames",
"(",
")",
")",
")",
";",
"$",
"name",
"=",
"preg_replace_callback",
"... | Get the class name from table names.
@return string | [
"Get",
"the",
"class",
"name",
"from",
"table",
"names",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/PivotMigrationMakeCommand.php#L45-L54 |
laracasts/Laravel-5-Generators-Extended | src/Commands/PivotMigrationMakeCommand.php | PivotMigrationMakeCommand.replaceSchema | protected function replaceSchema(&$stub)
{
$tables = array_merge(
$this->getSortedSingularTableNames(),
$this->getSortedTableNames()
);
$stub = str_replace(
['{{columnOne}}', '{{columnTwo}}', '{{tableOne}}', '{{tableTwo}}'],
$tables,
... | php | protected function replaceSchema(&$stub)
{
$tables = array_merge(
$this->getSortedSingularTableNames(),
$this->getSortedTableNames()
);
$stub = str_replace(
['{{columnOne}}', '{{columnTwo}}', '{{tableOne}}', '{{tableTwo}}'],
$tables,
... | [
"protected",
"function",
"replaceSchema",
"(",
"&",
"$",
"stub",
")",
"{",
"$",
"tables",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getSortedSingularTableNames",
"(",
")",
",",
"$",
"this",
"->",
"getSortedTableNames",
"(",
")",
")",
";",
"$",
"stub",
... | Apply the correct schema to the stub.
@param string $stub
@return $this | [
"Apply",
"the",
"correct",
"schema",
"to",
"the",
"stub",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/PivotMigrationMakeCommand.php#L112-L126 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SyntaxBuilder.php | SyntaxBuilder.create | public function create($schema, $meta)
{
$up = $this->createSchemaForUpMethod($schema, $meta);
$down = $this->createSchemaForDownMethod($schema, $meta);
return compact('up', 'down');
} | php | public function create($schema, $meta)
{
$up = $this->createSchemaForUpMethod($schema, $meta);
$down = $this->createSchemaForDownMethod($schema, $meta);
return compact('up', 'down');
} | [
"public",
"function",
"create",
"(",
"$",
"schema",
",",
"$",
"meta",
")",
"{",
"$",
"up",
"=",
"$",
"this",
"->",
"createSchemaForUpMethod",
"(",
"$",
"schema",
",",
"$",
"meta",
")",
";",
"$",
"down",
"=",
"$",
"this",
"->",
"createSchemaForDownMetho... | Create the PHP syntax for the given schema.
@param array $schema
@param array $meta
@return string
@throws GeneratorException | [
"Create",
"the",
"PHP",
"syntax",
"for",
"the",
"given",
"schema",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SyntaxBuilder.php#L24-L30 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SyntaxBuilder.php | SyntaxBuilder.constructSchema | private function constructSchema($schema, $direction = 'Add')
{
if (!$schema) return '';
$fields = array_map(function ($field) use ($direction) {
$method = "{$direction}Column";
return $this->$method($field);
}, $schema);
return implode("\n" . str_repeat(' ... | php | private function constructSchema($schema, $direction = 'Add')
{
if (!$schema) return '';
$fields = array_map(function ($field) use ($direction) {
$method = "{$direction}Column";
return $this->$method($field);
}, $schema);
return implode("\n" . str_repeat(' ... | [
"private",
"function",
"constructSchema",
"(",
"$",
"schema",
",",
"$",
"direction",
"=",
"'Add'",
")",
"{",
"if",
"(",
"!",
"$",
"schema",
")",
"return",
"''",
";",
"$",
"fields",
"=",
"array_map",
"(",
"function",
"(",
"$",
"field",
")",
"use",
"("... | Construct the schema fields.
@param array $schema
@param string $direction
@return array | [
"Construct",
"the",
"schema",
"fields",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SyntaxBuilder.php#L150-L161 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SyntaxBuilder.php | SyntaxBuilder.addColumn | private function addColumn($field)
{
$syntax = sprintf("\$table->%s('%s')", $field['type'], $field['name']);
// If there are arguments for the schema type, like decimal('amount', 5, 2)
// then we have to remember to work those in.
if ($field['arguments']) {
$syntax = sub... | php | private function addColumn($field)
{
$syntax = sprintf("\$table->%s('%s')", $field['type'], $field['name']);
// If there are arguments for the schema type, like decimal('amount', 5, 2)
// then we have to remember to work those in.
if ($field['arguments']) {
$syntax = sub... | [
"private",
"function",
"addColumn",
"(",
"$",
"field",
")",
"{",
"$",
"syntax",
"=",
"sprintf",
"(",
"\"\\$table->%s('%s')\"",
",",
"$",
"field",
"[",
"'type'",
"]",
",",
"$",
"field",
"[",
"'name'",
"]",
")",
";",
"// If there are arguments for the schema typ... | Construct the syntax to add a column.
@param string $field
@return string | [
"Construct",
"the",
"syntax",
"to",
"add",
"a",
"column",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SyntaxBuilder.php#L170-L187 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.fire | public function fire()
{
$this->meta = (new NameParser)->parse($this->argument('name'));
$this->makeMigration();
$this->makeModel();
} | php | public function fire()
{
$this->meta = (new NameParser)->parse($this->argument('name'));
$this->makeMigration();
$this->makeModel();
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"this",
"->",
"meta",
"=",
"(",
"new",
"NameParser",
")",
"->",
"parse",
"(",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
";",
"$",
"this",
"->",
"makeMigration",
"(",
")",
";",
"$",
"... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L79-L85 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.makeMigration | protected function makeMigration()
{
$name = $this->argument('name');
if ($this->files->exists($path = $this->getPath($name))) {
return $this->error($this->type . ' already exists!');
}
$this->makeDirectory($path);
$this->files->put($path, $this->compileMigrati... | php | protected function makeMigration()
{
$name = $this->argument('name');
if ($this->files->exists($path = $this->getPath($name))) {
return $this->error($this->type . ' already exists!');
}
$this->makeDirectory($path);
$this->files->put($path, $this->compileMigrati... | [
"protected",
"function",
"makeMigration",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",... | Generate the desired migration. | [
"Generate",
"the",
"desired",
"migration",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L100-L115 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.makeModel | protected function makeModel()
{
$modelPath = $this->getModelPath($this->getModelName());
if ($this->option('model') && !$this->files->exists($modelPath)) {
$this->call('make:model', [
'name' => $this->getModelName()
]);
}
} | php | protected function makeModel()
{
$modelPath = $this->getModelPath($this->getModelName());
if ($this->option('model') && !$this->files->exists($modelPath)) {
$this->call('make:model', [
'name' => $this->getModelName()
]);
}
} | [
"protected",
"function",
"makeModel",
"(",
")",
"{",
"$",
"modelPath",
"=",
"$",
"this",
"->",
"getModelPath",
"(",
"$",
"this",
"->",
"getModelName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"&&",
"!",
"$",
... | Generate an Eloquent model, if the user wishes. | [
"Generate",
"an",
"Eloquent",
"model",
"if",
"the",
"user",
"wishes",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L120-L129 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.getModelPath | protected function getModelPath($name)
{
$name = str_replace($this->getAppNamespace(), '', $name);
return $this->laravel['path'] . '/' . str_replace('\\', '/', $name) . '.php';
} | php | protected function getModelPath($name)
{
$name = str_replace($this->getAppNamespace(), '', $name);
return $this->laravel['path'] . '/' . str_replace('\\', '/', $name) . '.php';
} | [
"protected",
"function",
"getModelPath",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"getAppNamespace",
"(",
")",
",",
"''",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"laravel",
"[",
"'path'",
"... | Get the destination class path.
@param string $name
@return string | [
"Get",
"the",
"destination",
"class",
"path",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L161-L166 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.compileMigrationStub | protected function compileMigrationStub()
{
$stub = $this->files->get(__DIR__ . '/../stubs/migration.stub');
$this->replaceClassName($stub)
->replaceSchema($stub)
->replaceTableName($stub);
return $stub;
} | php | protected function compileMigrationStub()
{
$stub = $this->files->get(__DIR__ . '/../stubs/migration.stub');
$this->replaceClassName($stub)
->replaceSchema($stub)
->replaceTableName($stub);
return $stub;
} | [
"protected",
"function",
"compileMigrationStub",
"(",
")",
"{",
"$",
"stub",
"=",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/migration.stub'",
")",
";",
"$",
"this",
"->",
"replaceClassName",
"(",
"$",
"stub",
")",
"->",
"rep... | Compile the migration stub.
@return string | [
"Compile",
"the",
"migration",
"stub",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L173-L182 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.replaceClassName | protected function replaceClassName(&$stub)
{
$className = ucwords(camel_case($this->argument('name')));
$stub = str_replace('{{class}}', $className, $stub);
return $this;
} | php | protected function replaceClassName(&$stub)
{
$className = ucwords(camel_case($this->argument('name')));
$stub = str_replace('{{class}}', $className, $stub);
return $this;
} | [
"protected",
"function",
"replaceClassName",
"(",
"&",
"$",
"stub",
")",
"{",
"$",
"className",
"=",
"ucwords",
"(",
"camel_case",
"(",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{class}}'",... | Replace the class name in the stub.
@param string $stub
@return $this | [
"Replace",
"the",
"class",
"name",
"in",
"the",
"stub",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L190-L197 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.replaceTableName | protected function replaceTableName(&$stub)
{
$table = $this->meta['table'];
$stub = str_replace('{{table}}', $table, $stub);
return $this;
} | php | protected function replaceTableName(&$stub)
{
$table = $this->meta['table'];
$stub = str_replace('{{table}}', $table, $stub);
return $this;
} | [
"protected",
"function",
"replaceTableName",
"(",
"&",
"$",
"stub",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"meta",
"[",
"'table'",
"]",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{table}}'",
",",
"$",
"table",
",",
"$",
"stub",
")",
";",
... | Replace the table name in the stub.
@param string $stub
@return $this | [
"Replace",
"the",
"table",
"name",
"in",
"the",
"stub",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L205-L212 |
laracasts/Laravel-5-Generators-Extended | src/Commands/MigrationMakeCommand.php | MigrationMakeCommand.replaceSchema | protected function replaceSchema(&$stub)
{
if ($schema = $this->option('schema')) {
$schema = (new SchemaParser)->parse($schema);
}
$schema = (new SyntaxBuilder)->create($schema, $this->meta);
$stub = str_replace(['{{schema_up}}', '{{schema_down}}'], $schema, $stub);
... | php | protected function replaceSchema(&$stub)
{
if ($schema = $this->option('schema')) {
$schema = (new SchemaParser)->parse($schema);
}
$schema = (new SyntaxBuilder)->create($schema, $this->meta);
$stub = str_replace(['{{schema_up}}', '{{schema_down}}'], $schema, $stub);
... | [
"protected",
"function",
"replaceSchema",
"(",
"&",
"$",
"stub",
")",
"{",
"if",
"(",
"$",
"schema",
"=",
"$",
"this",
"->",
"option",
"(",
"'schema'",
")",
")",
"{",
"$",
"schema",
"=",
"(",
"new",
"SchemaParser",
")",
"->",
"parse",
"(",
"$",
"sc... | Replace the schema for the stub.
@param string $stub
@return $this | [
"Replace",
"the",
"schema",
"for",
"the",
"stub",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Commands/MigrationMakeCommand.php#L220-L231 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SchemaParser.php | SchemaParser.parse | public function parse($schema)
{
$fields = $this->splitIntoFields($schema);
foreach ($fields as $field) {
$segments = $this->parseSegments($field);
if ($this->fieldNeedsForeignConstraint($segments)) {
unset($segments['options']['foreign']);
... | php | public function parse($schema)
{
$fields = $this->splitIntoFields($schema);
foreach ($fields as $field) {
$segments = $this->parseSegments($field);
if ($this->fieldNeedsForeignConstraint($segments)) {
unset($segments['options']['foreign']);
... | [
"public",
"function",
"parse",
"(",
"$",
"schema",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"splitIntoFields",
"(",
"$",
"schema",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"segments",
"=",
"$",
"this",
"->... | Parse the command line migration schema.
Ex: name:string, age:integer:nullable
@param string $schema
@return array | [
"Parse",
"the",
"command",
"line",
"migration",
"schema",
".",
"Ex",
":",
"name",
":",
"string",
"age",
":",
"integer",
":",
"nullable"
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SchemaParser.php#L21-L45 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SchemaParser.php | SchemaParser.parseSegments | private function parseSegments($field)
{
$segments = explode(':', $field);
$name = array_shift($segments);
$type = array_shift($segments);
$arguments = [];
$options = $this->parseOptions($segments);
// Do we have arguments being used here?
// Like: string(10... | php | private function parseSegments($field)
{
$segments = explode(':', $field);
$name = array_shift($segments);
$type = array_shift($segments);
$arguments = [];
$options = $this->parseOptions($segments);
// Do we have arguments being used here?
// Like: string(10... | [
"private",
"function",
"parseSegments",
"(",
"$",
"field",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"':'",
",",
"$",
"field",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"$",
"type",
"=",
"array_shift",
"(",
"$",... | Get the segments of the schema field.
@param string $field
@return array | [
"Get",
"the",
"segments",
"of",
"the",
"schema",
"field",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SchemaParser.php#L77-L94 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SchemaParser.php | SchemaParser.parseOptions | private function parseOptions($options)
{
if (empty($options)) return [];
foreach ($options as $option) {
if (str_contains($option, '(')) {
preg_match('/([a-z]+)\(([^\)]+)\)/i', $option, $matches);
$results[$matches[1]] = $matches[2];
} else ... | php | private function parseOptions($options)
{
if (empty($options)) return [];
foreach ($options as $option) {
if (str_contains($option, '(')) {
preg_match('/([a-z]+)\(([^\)]+)\)/i', $option, $matches);
$results[$matches[1]] = $matches[2];
} else ... | [
"private",
"function",
"parseOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"return",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"o... | Parse any given options into something usable.
@param array $options
@return array | [
"Parse",
"any",
"given",
"options",
"into",
"something",
"usable",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SchemaParser.php#L102-L117 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/SchemaParser.php | SchemaParser.addForeignConstraint | private function addForeignConstraint($segments)
{
$string = sprintf(
"%s:foreign:references('id'):on('%s')",
$segments['name'],
$this->getTableNameFromForeignKey($segments['name'])
);
$this->addField($this->parseSegments($string));
} | php | private function addForeignConstraint($segments)
{
$string = sprintf(
"%s:foreign:references('id'):on('%s')",
$segments['name'],
$this->getTableNameFromForeignKey($segments['name'])
);
$this->addField($this->parseSegments($string));
} | [
"private",
"function",
"addForeignConstraint",
"(",
"$",
"segments",
")",
"{",
"$",
"string",
"=",
"sprintf",
"(",
"\"%s:foreign:references('id'):on('%s')\"",
",",
"$",
"segments",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"getTableNameFromForeignKey",
"(",
"$",... | Add a foreign constraint field to the schema.
@param array $segments | [
"Add",
"a",
"foreign",
"constraint",
"field",
"to",
"the",
"schema",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/SchemaParser.php#L124-L133 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/NameParser.php | NameParser.parse | public function parse($name)
{
$segments = array_reverse(explode('_', $name));
if ($segments[0] == 'table') {
array_shift($segments);
}
return [
'action' => $this->getAction($segments),
'table' => $this->getTableName($segments)
];
} | php | public function parse($name)
{
$segments = array_reverse(explode('_', $name));
if ($segments[0] == 'table') {
array_shift($segments);
}
return [
'action' => $this->getAction($segments),
'table' => $this->getTableName($segments)
];
} | [
"public",
"function",
"parse",
"(",
"$",
"name",
")",
"{",
"$",
"segments",
"=",
"array_reverse",
"(",
"explode",
"(",
"'_'",
",",
"$",
"name",
")",
")",
";",
"if",
"(",
"$",
"segments",
"[",
"0",
"]",
"==",
"'table'",
")",
"{",
"array_shift",
"(",... | Parse the migration name into something we can use.
@param string $name
@return array | [
"Parse",
"the",
"migration",
"name",
"into",
"something",
"we",
"can",
"use",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/NameParser.php#L13-L25 |
laracasts/Laravel-5-Generators-Extended | src/Migrations/NameParser.php | NameParser.getTableName | private function getTableName($segments)
{
$tableName = [];
foreach ($segments as $segment) {
if ($this->isConnectingWord($segment)) {
break;
}
$tableName[] = $segment;
}
return implode('_', array_reverse($tableName));
} | php | private function getTableName($segments)
{
$tableName = [];
foreach ($segments as $segment) {
if ($this->isConnectingWord($segment)) {
break;
}
$tableName[] = $segment;
}
return implode('_', array_reverse($tableName));
} | [
"private",
"function",
"getTableName",
"(",
"$",
"segments",
")",
"{",
"$",
"tableName",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isConnectingWord",
"(",
"$",
"segment",
")",
... | Calculate the table name.
@param array $segments
@return array | [
"Calculate",
"the",
"table",
"name",
"."
] | train | https://github.com/laracasts/Laravel-5-Generators-Extended/blob/9c6066252b9181b61e0ab6f5361fbf508bc78313/src/Migrations/NameParser.php#L33-L46 |
swlib/saber | src/Saber.php | Saber.requests | public function requests(array $requests, array $default_options = []): ResponseMap
{
$req_queue = new RequestQueue(); //生成请求队列
self::transAlias(
$default_options,
self::$aliasMapOfRequests,
self::$aliasMapOfRequestsLength ?? self::$aliasMapOfRequestsLength = coun... | php | public function requests(array $requests, array $default_options = []): ResponseMap
{
$req_queue = new RequestQueue(); //生成请求队列
self::transAlias(
$default_options,
self::$aliasMapOfRequests,
self::$aliasMapOfRequestsLength ?? self::$aliasMapOfRequestsLength = coun... | [
"public",
"function",
"requests",
"(",
"array",
"$",
"requests",
",",
"array",
"$",
"default_options",
"=",
"[",
"]",
")",
":",
"ResponseMap",
"{",
"$",
"req_queue",
"=",
"new",
"RequestQueue",
"(",
")",
";",
"//生成请求队列",
"self",
"::",
"transAlias",
"(",
... | Multi requests
@param array $requests
@param array $default_options
@return ResponseMap|Response[] | [
"Multi",
"requests"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Saber.php#L257-L280 |
swlib/saber | src/Saber.php | Saber.exceptionReport | public function exceptionReport(?int $level = null): ?int
{
if ($level === null) {
return $this->options['exception_report'];
} else {
$this->setOptions(['exception_report' => $level]);
}
return null;
} | php | public function exceptionReport(?int $level = null): ?int
{
if ($level === null) {
return $this->options['exception_report'];
} else {
$this->setOptions(['exception_report' => $level]);
}
return null;
} | [
"public",
"function",
"exceptionReport",
"(",
"?",
"int",
"$",
"level",
"=",
"null",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"level",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"options",
"[",
"'exception_report'",
"]",
";",
"}",
"else"... | ****************************************************************************
Options Methods *
**************************************************************************** | [
"****************************************************************************",
"Options",
"Methods",
"*",
"****************************************************************************"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Saber.php#L333-L342 |
swlib/saber | src/Request.php | Request.withSSL | public function withSSL(int $mode = self::SSL_AUTO): self
{
$this->ssl = $mode;
return $this;
} | php | public function withSSL(int $mode = self::SSL_AUTO): self
{
$this->ssl = $mode;
return $this;
} | [
"public",
"function",
"withSSL",
"(",
"int",
"$",
"mode",
"=",
"self",
"::",
"SSL_AUTO",
")",
":",
"self",
"{",
"$",
"this",
"->",
"ssl",
"=",
"$",
"mode",
";",
"return",
"$",
"this",
";",
"}"
] | enable/disable ssl and set a ca file.
@param bool $mode
@param string $ca_file
@return $this | [
"enable",
"/",
"disable",
"ssl",
"and",
"set",
"a",
"ca",
"file",
"."
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L198-L203 |
swlib/saber | src/Request.php | Request.withBasicAuth | public function withBasicAuth(?string $username = null, string $password = null): self
{
if ($username === null) {
return $this->withoutHeader('Authorization');
} else {
$auth = base64_encode($username . ':' . $password);
return $this->withHeader('Authorization',... | php | public function withBasicAuth(?string $username = null, string $password = null): self
{
if ($username === null) {
return $this->withoutHeader('Authorization');
} else {
$auth = base64_encode($username . ':' . $password);
return $this->withHeader('Authorization',... | [
"public",
"function",
"withBasicAuth",
"(",
"?",
"string",
"$",
"username",
"=",
"null",
",",
"string",
"$",
"password",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"$",
"username",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"withoutHeade... | Add basic authorization header
@param string $username
@param string $password
@return $this | [
"Add",
"basic",
"authorization",
"header"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L271-L280 |
swlib/saber | src/Request.php | Request.withProxy | public function withProxy(string $host, int $port): self
{
$this->proxy = [
'http_proxy_host' => $host,
'http_proxy_port' => $port,
];
return $this;
} | php | public function withProxy(string $host, int $port): self
{
$this->proxy = [
'http_proxy_host' => $host,
'http_proxy_port' => $port,
];
return $this;
} | [
"public",
"function",
"withProxy",
"(",
"string",
"$",
"host",
",",
"int",
"$",
"port",
")",
":",
"self",
"{",
"$",
"this",
"->",
"proxy",
"=",
"[",
"'http_proxy_host'",
"=>",
"$",
"host",
",",
"'http_proxy_port'",
"=>",
"$",
"port",
",",
"]",
";",
"... | 配置HTTP代理
@param string $host
@param int $port
@return $this | [
"配置HTTP代理"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L304-L312 |
swlib/saber | src/Request.php | Request.withSocks5 | public function withSocks5(string $host, int $port, ?string $username, ?string $password): self
{
$this->proxy = [
'socks5_host' => $host,
'socks5_port' => $port,
'socks5_username' => $username,
'socks5_password' => $password,
];
return $this;... | php | public function withSocks5(string $host, int $port, ?string $username, ?string $password): self
{
$this->proxy = [
'socks5_host' => $host,
'socks5_port' => $port,
'socks5_username' => $username,
'socks5_password' => $password,
];
return $this;... | [
"public",
"function",
"withSocks5",
"(",
"string",
"$",
"host",
",",
"int",
"$",
"port",
",",
"?",
"string",
"$",
"username",
",",
"?",
"string",
"$",
"password",
")",
":",
"self",
"{",
"$",
"this",
"->",
"proxy",
"=",
"[",
"'socks5_host'",
"=>",
"$"... | enable socks5 proxy
@param string $host
@param int $port
@param null|string $username
@param null|string $password
@return $this | [
"enable",
"socks5",
"proxy"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L322-L332 |
swlib/saber | src/Request.php | Request.exec | public function exec()
{
/** reset temp attributes */
if (!($this->_form_flag & self::FROM_REDIRECT)) {
$this->clear();
}
/** interceptor after request */
$ret = $this->callInterceptor('request', $this);
if ($ret !== null) {
return $ret;
... | php | public function exec()
{
/** reset temp attributes */
if (!($this->_form_flag & self::FROM_REDIRECT)) {
$this->clear();
}
/** interceptor after request */
$ret = $this->callInterceptor('request', $this);
if ($ret !== null) {
return $ret;
... | [
"public",
"function",
"exec",
"(",
")",
"{",
"/** reset temp attributes */",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"_form_flag",
"&",
"self",
"::",
"FROM_REDIRECT",
")",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"}",
"/** interceptor after req... | 执行当前Request
@return $this|mixed | [
"执行当前Request"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L488-L612 |
swlib/saber | src/Request.php | Request.recv | public function recv()
{
_retry_recv:
if (self::STATUS_WAITING !== $this->_status) {
throw new BadMethodCallException('You can\'t recv because client is not in waiting stat.');
}
$this->client->recv($this->getTimeout());
$this->_status = self::STATUS_NONE;
... | php | public function recv()
{
_retry_recv:
if (self::STATUS_WAITING !== $this->_status) {
throw new BadMethodCallException('You can\'t recv because client is not in waiting stat.');
}
$this->client->recv($this->getTimeout());
$this->_status = self::STATUS_NONE;
... | [
"public",
"function",
"recv",
"(",
")",
"{",
"_retry_recv",
":",
"if",
"(",
"self",
"::",
"STATUS_WAITING",
"!==",
"$",
"this",
"->",
"_status",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You can\\'t recv because client is not in waiting stat.'",
")"... | 收包,处理重定向,对返回数据进行处理
@return Response|$this|mixed | [
"收包",
"处理重定向",
"对返回数据进行处理"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L619-L754 |
swlib/saber | src/Request.php | Request.clear | protected function clear()
{
$this->_redirect_times = 0;
$this->_redirect_headers = [];
$this->_start_time = 0;
$this->_time = 0.000;
if (!($this->_form_flag) & self::FROM_RETRY) {
$this->_retried_time = 0;
}
$this->incremental_cookies->reset();
... | php | protected function clear()
{
$this->_redirect_times = 0;
$this->_redirect_headers = [];
$this->_start_time = 0;
$this->_time = 0.000;
if (!($this->_form_flag) & self::FROM_RETRY) {
$this->_retried_time = 0;
}
$this->incremental_cookies->reset();
... | [
"protected",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"_redirect_times",
"=",
"0",
";",
"$",
"this",
"->",
"_redirect_headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_start_time",
"=",
"0",
";",
"$",
"this",
"->",
"_time",
"=",
"0.000... | clear tmp arguments | [
"clear",
"tmp",
"arguments"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/Request.php#L759-L772 |
swlib/saber | src/WebSocket.php | WebSocket.withMock | public function withMock(bool $ssl): self
{
$settings = ['websocket_mask' => true];
if ($ssl) {
$settings['ssl_host_name'] = $this->uri->getHost();
}
$this->client->set($settings);
return $this;
} | php | public function withMock(bool $ssl): self
{
$settings = ['websocket_mask' => true];
if ($ssl) {
$settings['ssl_host_name'] = $this->uri->getHost();
}
$this->client->set($settings);
return $this;
} | [
"public",
"function",
"withMock",
"(",
"bool",
"$",
"ssl",
")",
":",
"self",
"{",
"$",
"settings",
"=",
"[",
"'websocket_mask'",
"=>",
"true",
"]",
";",
"if",
"(",
"$",
"ssl",
")",
"{",
"$",
"settings",
"[",
"'ssl_host_name'",
"]",
"=",
"$",
"this",
... | enable mask to mock the browser | [
"enable",
"mask",
"to",
"mock",
"the",
"browser"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/WebSocket.php#L62-L71 |
swlib/saber | src/SaberGM.php | SaberGM.default | public static function default(array $options = null): ?array
{
if ($options === null) {
return Saber::getDefaultOptions();
} else {
Saber::setDefaultOptions($options); //global
self::getDefaultClient()->setOptions($options);
}
return null;
} | php | public static function default(array $options = null): ?array
{
if ($options === null) {
return Saber::getDefaultOptions();
} else {
Saber::setDefaultOptions($options); //global
self::getDefaultClient()->setOptions($options);
}
return null;
} | [
"public",
"static",
"function",
"default",
"(",
"array",
"$",
"options",
"=",
"null",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"options",
"===",
"null",
")",
"{",
"return",
"Saber",
"::",
"getDefaultOptions",
"(",
")",
";",
"}",
"else",
"{",
"Sab... | ****************************************************************************
Global Options *
**************************************************************************** | [
"****************************************************************************",
"Global",
"Options",
"*",
"****************************************************************************"
] | train | https://github.com/swlib/saber/blob/1188d0a67d18430d5c1a11f8dcdc135852fc1e31/src/SaberGM.php#L108-L118 |
spatie/menu | src/Html/Attributes.php | Attributes.setAttribute | public function setAttribute(string $attribute, string $value = '')
{
if ($attribute === 'class') {
$this->addClass($value);
return $this;
}
$this->attributes[$attribute] = $value;
return $this;
} | php | public function setAttribute(string $attribute, string $value = '')
{
if ($attribute === 'class') {
$this->addClass($value);
return $this;
}
$this->attributes[$attribute] = $value;
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"string",
"$",
"attribute",
",",
"string",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"attribute",
"===",
"'class'",
")",
"{",
"$",
"this",
"->",
"addClass",
"(",
"$",
"value",
")",
";",
"return",
"$... | @param string $attribute
@param string $value
@return $this | [
"@param",
"string",
"$attribute",
"@param",
"string",
"$value"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Html/Attributes.php#L48-L59 |
spatie/menu | src/Html/Attributes.php | Attributes.mergeWith | public function mergeWith(self $attributes)
{
$this->attributes = array_merge($this->attributes, $attributes->attributes);
$this->classes = array_merge($this->classes, $attributes->classes);
return $this;
} | php | public function mergeWith(self $attributes)
{
$this->attributes = array_merge($this->attributes, $attributes->attributes);
$this->classes = array_merge($this->classes, $attributes->classes);
return $this;
} | [
"public",
"function",
"mergeWith",
"(",
"self",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"attributes",
"->",
"attributes",
")",
";",
"$",
"this",
"->",
"classes",
"=... | @param \Spatie\Menu\Html\Attributes $attributes
@return $this | [
"@param",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Html",
"\\",
"Attributes",
"$attributes"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Html/Attributes.php#L84-L90 |
spatie/menu | src/Traits/Activatable.php | Activatable.setActive | public function setActive($active = true)
{
if (is_callable($active)) {
$this->active = $active($this);
return $this;
}
$this->active = (bool) $active;
return $this;
} | php | public function setActive($active = true)
{
if (is_callable($active)) {
$this->active = $active($this);
return $this;
}
$this->active = (bool) $active;
return $this;
} | [
"public",
"function",
"setActive",
"(",
"$",
"active",
"=",
"true",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"active",
")",
")",
"{",
"$",
"this",
"->",
"active",
"=",
"$",
"active",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}... | @param bool|callable $active
@return $this | [
"@param",
"bool|callable",
"$active"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/Activatable.php#L34-L45 |
spatie/menu | src/Traits/Activatable.php | Activatable.determineActiveForUrl | public function determineActiveForUrl(string $url, string $root = '/')
{
if (! $this->hasUrl()) {
return;
}
ActiveUrlChecker::check($this->url, $url, $root)
? $this->setActive()
: $this->setInactive();
ExactUrlChecker::check($this->url, $url, $ro... | php | public function determineActiveForUrl(string $url, string $root = '/')
{
if (! $this->hasUrl()) {
return;
}
ActiveUrlChecker::check($this->url, $url, $root)
? $this->setActive()
: $this->setInactive();
ExactUrlChecker::check($this->url, $url, $ro... | [
"public",
"function",
"determineActiveForUrl",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"root",
"=",
"'/'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasUrl",
"(",
")",
")",
"{",
"return",
";",
"}",
"ActiveUrlChecker",
"::",
"check",
"(",
"... | @param string $url
@param string $root
@return $this | [
"@param",
"string",
"$url",
"@param",
"string",
"$root"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/Activatable.php#L91-L104 |
spatie/menu | src/Traits/HasHtmlAttributes.php | HasHtmlAttributes.setAttribute | public function setAttribute(string $attribute, string $value = '')
{
$this->htmlAttributes->setAttribute($attribute, $value);
return $this;
} | php | public function setAttribute(string $attribute, string $value = '')
{
$this->htmlAttributes->setAttribute($attribute, $value);
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"string",
"$",
"attribute",
",",
"string",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"htmlAttributes",
"->",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",... | @param string $attribute
@param string $value
@return $this | [
"@param",
"string",
"$attribute",
"@param",
"string",
"$value"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/HasHtmlAttributes.php#L18-L23 |
spatie/menu | src/Traits/HasTextAttributes.php | HasTextAttributes.prependIf | public function prependIf($condition, string $prepend)
{
if ($this->resolveCondition($condition)) {
return $this->prepend($prepend);
}
return $this;
} | php | public function prependIf($condition, string $prepend)
{
if ($this->resolveCondition($condition)) {
return $this->prepend($prepend);
}
return $this;
} | [
"public",
"function",
"prependIf",
"(",
"$",
"condition",
",",
"string",
"$",
"prepend",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolveCondition",
"(",
"$",
"condition",
")",
")",
"{",
"return",
"$",
"this",
"->",
"prepend",
"(",
"$",
"prepend",
")",... | Prepend the text with a string of html on render if a certain condition is
met.
@param bool $condition
@param string $prepend
@return $this | [
"Prepend",
"the",
"text",
"with",
"a",
"string",
"of",
"html",
"on",
"render",
"if",
"a",
"certain",
"condition",
"is",
"met",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/HasTextAttributes.php#L30-L37 |
spatie/menu | src/Traits/HasTextAttributes.php | HasTextAttributes.appendIf | public function appendIf($condition, string $append)
{
if ($this->resolveCondition($condition)) {
return $this->append($append);
}
return $this;
} | php | public function appendIf($condition, string $append)
{
if ($this->resolveCondition($condition)) {
return $this->append($append);
}
return $this;
} | [
"public",
"function",
"appendIf",
"(",
"$",
"condition",
",",
"string",
"$",
"append",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolveCondition",
"(",
"$",
"condition",
")",
")",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"$",
"append",
")",
"... | Append the text with a string of html on render if a certain condition is
met.
@param bool $condition
@param string $append
@return static | [
"Append",
"the",
"text",
"with",
"a",
"string",
"of",
"html",
"on",
"render",
"if",
"a",
"certain",
"condition",
"is",
"met",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/HasTextAttributes.php#L62-L69 |
spatie/menu | src/Menu.php | Menu.build | public static function build($items, callable $callback, self $initial = null)
{
return ($initial ?: static::new())->fill($items, $callback);
} | php | public static function build($items, callable $callback, self $initial = null)
{
return ($initial ?: static::new())->fill($items, $callback);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"items",
",",
"callable",
"$",
"callback",
",",
"self",
"$",
"initial",
"=",
"null",
")",
"{",
"return",
"(",
"$",
"initial",
"?",
":",
"static",
"::",
"new",
"(",
")",
")",
"->",
"fill",
"(",
"$",... | Build a new menu from an array. The callback receives a menu instance as
the accumulator, the array item as the second parameter, and the item's
key as the third.
@param array|\Iterator $items
@param callable $callback
@param \Spatie\Menu\Menu|null $initial
@return static | [
"Build",
"a",
"new",
"menu",
"from",
"an",
"array",
".",
"The",
"callback",
"receives",
"a",
"menu",
"instance",
"as",
"the",
"accumulator",
"the",
"array",
"item",
"as",
"the",
"second",
"parameter",
"and",
"the",
"item",
"s",
"key",
"as",
"the",
"third... | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L85-L88 |
spatie/menu | src/Menu.php | Menu.fill | public function fill($items, callable $callback)
{
$menu = $this;
foreach ($items as $key => $item) {
$menu = $callback($menu, $item, $key) ?: $menu;
}
return $menu;
} | php | public function fill($items, callable $callback)
{
$menu = $this;
foreach ($items as $key => $item) {
$menu = $callback($menu, $item, $key) ?: $menu;
}
return $menu;
} | [
"public",
"function",
"fill",
"(",
"$",
"items",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"menu",
"=",
"$",
"callback",
"(",
... | Fill a menu from an array. The callback receives a menu instance as
the accumulator, the array item as the second parameter, and the item's
key as the third.
@param array|\Iterator $items
@param callable $callback
@return static | [
"Fill",
"a",
"menu",
"from",
"an",
"array",
".",
"The",
"callback",
"receives",
"a",
"menu",
"instance",
"as",
"the",
"accumulator",
"the",
"array",
"item",
"as",
"the",
"second",
"parameter",
"and",
"the",
"item",
"s",
"key",
"as",
"the",
"third",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L100-L109 |
spatie/menu | src/Menu.php | Menu.add | public function add(Item $item)
{
foreach ($this->filters as $filter) {
$this->applyFilter($filter, $item);
}
$this->items[] = $item;
return $this;
} | php | public function add(Item $item)
{
foreach ($this->filters as $filter) {
$this->applyFilter($filter, $item);
}
$this->items[] = $item;
return $this;
} | [
"public",
"function",
"add",
"(",
"Item",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"applyFilter",
"(",
"$",
"filter",
",",
"$",
"item",
")",
";",
"}",
"$",
"this",
"->"... | Add an item to the menu. This also applies all registered filters to the
item.
@param \Spatie\Menu\Item $item
@return $this | [
"Add",
"an",
"item",
"to",
"the",
"menu",
".",
"This",
"also",
"applies",
"all",
"registered",
"filters",
"to",
"the",
"item",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L119-L128 |
spatie/menu | src/Menu.php | Menu.addIf | public function addIf($condition, Item $item)
{
if ($this->resolveCondition($condition)) {
$this->add($item);
}
return $this;
} | php | public function addIf($condition, Item $item)
{
if ($this->resolveCondition($condition)) {
$this->add($item);
}
return $this;
} | [
"public",
"function",
"addIf",
"(",
"$",
"condition",
",",
"Item",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolveCondition",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"item",
")",
";",
"}",
"return",
... | Add an item to the menu if a (non-strict) condition is met.
@param bool $condition
@param \Spatie\Menu\Item $item
@return $this | [
"Add",
"an",
"item",
"to",
"the",
"menu",
"if",
"a",
"(",
"non",
"-",
"strict",
")",
"condition",
"is",
"met",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L138-L145 |
spatie/menu | src/Menu.php | Menu.link | public function link(string $url, string $text)
{
return $this->add(Link::to($url, $text));
} | php | public function link(string $url, string $text)
{
return $this->add(Link::to($url, $text));
} | [
"public",
"function",
"link",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"text",
")",
"{",
"return",
"$",
"this",
"->",
"add",
"(",
"Link",
"::",
"to",
"(",
"$",
"url",
",",
"$",
"text",
")",
")",
";",
"}"
] | Shortcut function to add a plain link to the menu.
@param string $url
@param string $text
@return $this | [
"Shortcut",
"function",
"to",
"add",
"a",
"plain",
"link",
"to",
"the",
"menu",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L155-L158 |
spatie/menu | src/Menu.php | Menu.linkIf | public function linkIf($condition, string $url, string $text)
{
if ($this->resolveCondition($condition)) {
$this->link($url, $text);
}
return $this;
} | php | public function linkIf($condition, string $url, string $text)
{
if ($this->resolveCondition($condition)) {
$this->link($url, $text);
}
return $this;
} | [
"public",
"function",
"linkIf",
"(",
"$",
"condition",
",",
"string",
"$",
"url",
",",
"string",
"$",
"text",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolveCondition",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"this",
"->",
"link",
"(",
"$",
"ur... | Add a link to the menu if a (non-strict) condition is met.
@param bool $condition
@param string $url
@param string $text
@return $this | [
"Add",
"a",
"link",
"to",
"the",
"menu",
"if",
"a",
"(",
"non",
"-",
"strict",
")",
"condition",
"is",
"met",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L179-L186 |
spatie/menu | src/Menu.php | Menu.html | public function html(string $html, array $parentAttributes = [])
{
return $this->add(Html::raw($html)->setParentAttributes($parentAttributes));
} | php | public function html(string $html, array $parentAttributes = [])
{
return $this->add(Html::raw($html)->setParentAttributes($parentAttributes));
} | [
"public",
"function",
"html",
"(",
"string",
"$",
"html",
",",
"array",
"$",
"parentAttributes",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"add",
"(",
"Html",
"::",
"raw",
"(",
"$",
"html",
")",
"->",
"setParentAttributes",
"(",
"$",
"par... | Shortcut function to add raw html to the menu.
@param string $html
@param array $parentAttributes
@return $this | [
"Shortcut",
"function",
"to",
"add",
"raw",
"html",
"to",
"the",
"menu",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L196-L199 |
spatie/menu | src/Menu.php | Menu.htmlIf | public function htmlIf($condition, string $html, array $parentAttributes = [])
{
if ($this->resolveCondition($condition)) {
$this->html($html, $parentAttributes);
}
return $this;
} | php | public function htmlIf($condition, string $html, array $parentAttributes = [])
{
if ($this->resolveCondition($condition)) {
$this->html($html, $parentAttributes);
}
return $this;
} | [
"public",
"function",
"htmlIf",
"(",
"$",
"condition",
",",
"string",
"$",
"html",
",",
"array",
"$",
"parentAttributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolveCondition",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"this",
"-... | Add a chunk of html if a (non-strict) condition is met.
@param bool $condition
@param string $html
@param array $parentAttributes
@return $this | [
"Add",
"a",
"chunk",
"of",
"html",
"if",
"a",
"(",
"non",
"-",
"strict",
")",
"condition",
"is",
"met",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L210-L217 |
spatie/menu | src/Menu.php | Menu.submenu | public function submenu($header, $menu = null)
{
list($header, $menu) = $this->parseSubmenuArgs(func_get_args());
$menu = $this->createSubmenuMenu($menu);
$header = $this->createSubmenuHeader($header);
return $this->add($menu->prependIf($header, $header));
} | php | public function submenu($header, $menu = null)
{
list($header, $menu) = $this->parseSubmenuArgs(func_get_args());
$menu = $this->createSubmenuMenu($menu);
$header = $this->createSubmenuHeader($header);
return $this->add($menu->prependIf($header, $header));
} | [
"public",
"function",
"submenu",
"(",
"$",
"header",
",",
"$",
"menu",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"header",
",",
"$",
"menu",
")",
"=",
"$",
"this",
"->",
"parseSubmenuArgs",
"(",
"func_get_args",
"(",
")",
")",
";",
"$",
"menu",
"=",... | @param callable|\Spatie\Menu\Menu|\Spatie\Menu\Item $header
@param callable|\Spatie\Menu\Menu|null $menu
@return $this | [
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Item",
"$header",
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|null",
"$menu"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L225-L233 |
spatie/menu | src/Menu.php | Menu.submenuIf | public function submenuIf($condition, $header, $menu = null)
{
if ($condition) {
$this->submenu($header, $menu);
}
return $this;
} | php | public function submenuIf($condition, $header, $menu = null)
{
if ($condition) {
$this->submenu($header, $menu);
}
return $this;
} | [
"public",
"function",
"submenuIf",
"(",
"$",
"condition",
",",
"$",
"header",
",",
"$",
"menu",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"condition",
")",
"{",
"$",
"this",
"->",
"submenu",
"(",
"$",
"header",
",",
"$",
"menu",
")",
";",
"}",
"retu... | @param bool $condition
@param callable|\Spatie\Menu\Menu|\Spatie\Menu\Item $header
@param callable|\Spatie\Menu\Menu|null $menu
@return $this | [
"@param",
"bool",
"$condition",
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Item",
"$header",
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|null",
"$menu"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L242-L249 |
spatie/menu | src/Menu.php | Menu.createSubmenuMenu | protected function createSubmenuMenu($menu): self
{
if (is_callable($menu)) {
$transformer = $menu;
$menu = $this->blueprint();
$transformer($menu);
}
return $menu;
} | php | protected function createSubmenuMenu($menu): self
{
if (is_callable($menu)) {
$transformer = $menu;
$menu = $this->blueprint();
$transformer($menu);
}
return $menu;
} | [
"protected",
"function",
"createSubmenuMenu",
"(",
"$",
"menu",
")",
":",
"self",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"menu",
")",
")",
"{",
"$",
"transformer",
"=",
"$",
"menu",
";",
"$",
"menu",
"=",
"$",
"this",
"->",
"blueprint",
"(",
")",
... | @param \Spatie\Menu\Menu|callable $menu
@return \Spatie\Menu\Menu | [
"@param",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|callable",
"$menu"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L265-L274 |
spatie/menu | src/Menu.php | Menu.each | public function each(callable $callable)
{
$type = Reflection::firstParameterType($callable);
foreach ($this->items as $item) {
if (! Reflection::itemMatchesType($item, $type)) {
continue;
}
$callable($item);
}
return $this;
... | php | public function each(callable $callable)
{
$type = Reflection::firstParameterType($callable);
foreach ($this->items as $item) {
if (! Reflection::itemMatchesType($item, $type)) {
continue;
}
$callable($item);
}
return $this;
... | [
"public",
"function",
"each",
"(",
"callable",
"$",
"callable",
")",
"{",
"$",
"type",
"=",
"Reflection",
"::",
"firstParameterType",
"(",
"$",
"callable",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
... | Iterate over all the items and apply a callback. If you typehint the
item parameter in the callable, it wil only be applied to items of that
type.
@param callable $callable
@return $this | [
"Iterate",
"over",
"all",
"the",
"items",
"and",
"apply",
"a",
"callback",
".",
"If",
"you",
"typehint",
"the",
"item",
"parameter",
"in",
"the",
"callable",
"it",
"wil",
"only",
"be",
"applied",
"to",
"items",
"of",
"that",
"type",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L299-L312 |
spatie/menu | src/Menu.php | Menu.applyFilter | protected function applyFilter(callable $filter, Item $item)
{
$type = Reflection::firstParameterType($filter);
if (! Reflection::itemMatchesType($item, $type)) {
return;
}
$filter($item);
} | php | protected function applyFilter(callable $filter, Item $item)
{
$type = Reflection::firstParameterType($filter);
if (! Reflection::itemMatchesType($item, $type)) {
return;
}
$filter($item);
} | [
"protected",
"function",
"applyFilter",
"(",
"callable",
"$",
"filter",
",",
"Item",
"$",
"item",
")",
"{",
"$",
"type",
"=",
"Reflection",
"::",
"firstParameterType",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"!",
"Reflection",
"::",
"itemMatchesType",
"("... | Apply a filter to an item. Returns the result of the filter.
@param callable $filter
@param \Spatie\Menu\Item $item | [
"Apply",
"a",
"filter",
"to",
"an",
"item",
".",
"Returns",
"the",
"result",
"of",
"the",
"filter",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L336-L345 |
spatie/menu | src/Menu.php | Menu.isActive | public function isActive(): bool
{
foreach ($this->items as $item) {
if ($item->isActive()) {
return true;
}
}
return false;
} | php | public function isActive(): bool
{
foreach ($this->items as $item) {
if ($item->isActive()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isActive",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false... | Determine whether the menu is active.
@return bool | [
"Determine",
"whether",
"the",
"menu",
"is",
"active",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L385-L394 |
spatie/menu | src/Menu.php | Menu.setActive | public function setActive($urlOrCallable, string $root = '/')
{
if (is_string($urlOrCallable)) {
return $this->setActiveFromUrl($urlOrCallable, $root);
}
if (is_callable($urlOrCallable)) {
return $this->setActiveFromCallable($urlOrCallable);
}
throw ... | php | public function setActive($urlOrCallable, string $root = '/')
{
if (is_string($urlOrCallable)) {
return $this->setActiveFromUrl($urlOrCallable, $root);
}
if (is_callable($urlOrCallable)) {
return $this->setActiveFromCallable($urlOrCallable);
}
throw ... | [
"public",
"function",
"setActive",
"(",
"$",
"urlOrCallable",
",",
"string",
"$",
"root",
"=",
"'/'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"urlOrCallable",
")",
")",
"{",
"return",
"$",
"this",
"->",
"setActiveFromUrl",
"(",
"$",
"urlOrCallable",
... | Set multiple items in the menu as active based on a callable that filters
through items. If you typehint the item parameter in the callable, it will
only be applied to items of that type.
@param callable|string $urlOrCallable
@param string $root
@return $this | [
"Set",
"multiple",
"items",
"in",
"the",
"menu",
"as",
"active",
"based",
"on",
"a",
"callable",
"that",
"filters",
"through",
"items",
".",
"If",
"you",
"typehint",
"the",
"item",
"parameter",
"in",
"the",
"callable",
"it",
"will",
"only",
"be",
"applied"... | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L416-L427 |
spatie/menu | src/Menu.php | Menu.setActiveFromUrl | public function setActiveFromUrl(string $url, string $root = '/')
{
$this->applyToAll(function (Menu $menu) use ($url, $root) {
$menu->setActiveFromUrl($url, $root);
});
$this->applyToAll(function (Activatable $item) use ($url, $root) {
$item->determineActiveForUrl($... | php | public function setActiveFromUrl(string $url, string $root = '/')
{
$this->applyToAll(function (Menu $menu) use ($url, $root) {
$menu->setActiveFromUrl($url, $root);
});
$this->applyToAll(function (Activatable $item) use ($url, $root) {
$item->determineActiveForUrl($... | [
"public",
"function",
"setActiveFromUrl",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"root",
"=",
"'/'",
")",
"{",
"$",
"this",
"->",
"applyToAll",
"(",
"function",
"(",
"Menu",
"$",
"menu",
")",
"use",
"(",
"$",
"url",
",",
"$",
"root",
")",
"... | Set all relevant children active based on the current request's URL.
/, /about, /contact => request to /about will set the about link active.
/en, /en/about, /en/contact => request to /en won't set /en active if the
request root is set to /en.
@param string $url The current request url.
@param string $root If the l... | [
"Set",
"all",
"relevant",
"children",
"active",
"based",
"on",
"the",
"current",
"request",
"s",
"URL",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L458-L469 |
spatie/menu | src/Menu.php | Menu.setActiveFromCallable | public function setActiveFromCallable(callable $callable)
{
$this->applyToAll(function (Menu $menu) use ($callable) {
$menu->setActiveFromCallable($callable);
});
$type = Reflection::firstParameterType($callable);
$this->applyToAll(function (Activatable $item) use ($cal... | php | public function setActiveFromCallable(callable $callable)
{
$this->applyToAll(function (Menu $menu) use ($callable) {
$menu->setActiveFromCallable($callable);
});
$type = Reflection::firstParameterType($callable);
$this->applyToAll(function (Activatable $item) use ($cal... | [
"public",
"function",
"setActiveFromCallable",
"(",
"callable",
"$",
"callable",
")",
"{",
"$",
"this",
"->",
"applyToAll",
"(",
"function",
"(",
"Menu",
"$",
"menu",
")",
"use",
"(",
"$",
"callable",
")",
"{",
"$",
"menu",
"->",
"setActiveFromCallable",
"... | @param callable $callable
@return $this | [
"@param",
"callable",
"$callable"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L476-L496 |
spatie/menu | src/Menu.php | Menu.setItemAttribute | public function setItemAttribute(string $attribute, string $value = '')
{
$this->applyToAll(function (HasHtmlAttributes $link) use ($attribute, $value) {
$link->setAttribute($attribute, $value);
});
return $this;
} | php | public function setItemAttribute(string $attribute, string $value = '')
{
$this->applyToAll(function (HasHtmlAttributes $link) use ($attribute, $value) {
$link->setAttribute($attribute, $value);
});
return $this;
} | [
"public",
"function",
"setItemAttribute",
"(",
"string",
"$",
"attribute",
",",
"string",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"applyToAll",
"(",
"function",
"(",
"HasHtmlAttributes",
"$",
"link",
")",
"use",
"(",
"$",
"attribute",
",",
... | Set an attribute on all items in the menu.
@param string $attribute
@param string $value
@return $this | [
"Set",
"an",
"attribute",
"on",
"all",
"items",
"in",
"the",
"menu",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L536-L543 |
spatie/menu | src/Menu.php | Menu.setItemParentAttribute | public function setItemParentAttribute(string $attribute, string $value = '')
{
$this->applyToAll(function (HasParentAttributes $item) use ($attribute, $value) {
$item->setParentAttribute($attribute, $value);
});
return $this;
} | php | public function setItemParentAttribute(string $attribute, string $value = '')
{
$this->applyToAll(function (HasParentAttributes $item) use ($attribute, $value) {
$item->setParentAttribute($attribute, $value);
});
return $this;
} | [
"public",
"function",
"setItemParentAttribute",
"(",
"string",
"$",
"attribute",
",",
"string",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"applyToAll",
"(",
"function",
"(",
"HasParentAttributes",
"$",
"item",
")",
"use",
"(",
"$",
"attribute",
... | Add a parent attribute to all items in the menu.
@param string $attribute
@param string $value
@return $this | [
"Add",
"a",
"parent",
"attribute",
"to",
"all",
"items",
"in",
"the",
"menu",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L569-L576 |
spatie/menu | src/Menu.php | Menu.render | public function render(): string
{
$tag = $this->wrapperTagName
? new Tag($this->wrapperTagName, $this->htmlAttributes)
: null;
$contents = array_map([$this, 'renderItem'], $this->items);
$wrappedContents = $tag ? $tag->withContents($contents) : implode('', $content... | php | public function render(): string
{
$tag = $this->wrapperTagName
? new Tag($this->wrapperTagName, $this->htmlAttributes)
: null;
$contents = array_map([$this, 'renderItem'], $this->items);
$wrappedContents = $tag ? $tag->withContents($contents) : implode('', $content... | [
"public",
"function",
"render",
"(",
")",
":",
"string",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"wrapperTagName",
"?",
"new",
"Tag",
"(",
"$",
"this",
"->",
"wrapperTagName",
",",
"$",
"this",
"->",
"htmlAttributes",
")",
":",
"null",
";",
"$",
"co... | Render the menu.
@return string | [
"Render",
"the",
"menu",
"."
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Menu.php#L686-L703 |
spatie/menu | src/Traits/HasParentAttributes.php | HasParentAttributes.setParentAttribute | public function setParentAttribute(string $attribute, string $value = '')
{
$this->parentAttributes->setAttribute($attribute, $value);
return $this;
} | php | public function setParentAttribute(string $attribute, string $value = '')
{
$this->parentAttributes->setAttribute($attribute, $value);
return $this;
} | [
"public",
"function",
"setParentAttribute",
"(",
"string",
"$",
"attribute",
",",
"string",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"parentAttributes",
"->",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
";",
"return",
"$",
... | @param string $attribute
@param string $value
@return $this | [
"@param",
"string",
"$attribute",
"@param",
"string",
"$value"
] | train | https://github.com/spatie/menu/blob/e710666fddb42ac80fd345fc124717553bfdb74d/src/Traits/HasParentAttributes.php#L29-L34 |
laravolt/avatar | src/LumenServiceProvider.php | LumenServiceProvider.register | public function register()
{
$this->app->bind('avatar', function (Application $app) {
$config = $app->make('config');
$cache = $app->make('cache.store');
$avatar = new Avatar($config->get('laravolt.avatar'), $cache);
$avatar->setGenerator($app['avatar.generat... | php | public function register()
{
$this->app->bind('avatar', function (Application $app) {
$config = $app->make('config');
$cache = $app->make('cache.store');
$avatar = new Avatar($config->get('laravolt.avatar'), $cache);
$avatar->setGenerator($app['avatar.generat... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'avatar'",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"cach... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/laravolt/avatar/blob/0bd373ca7f19600b9b78316dffafba9247cdfbc2/src/LumenServiceProvider.php#L22-L40 |
laravolt/avatar | src/LumenServiceProvider.php | LumenServiceProvider.registerConfigurations | protected function registerConfigurations()
{
$this->mergeConfigFrom($this->packagePath('config/config.php'), 'laravolt.avatar');
$this->publishes([$this->packagePath('config/config.php') => config_path('laravolt/avatar.php')], 'config');
} | php | protected function registerConfigurations()
{
$this->mergeConfigFrom($this->packagePath('config/config.php'), 'laravolt.avatar');
$this->publishes([$this->packagePath('config/config.php') => config_path('laravolt/avatar.php')], 'config');
} | [
"protected",
"function",
"registerConfigurations",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"$",
"this",
"->",
"packagePath",
"(",
"'config/config.php'",
")",
",",
"'laravolt.avatar'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
... | Register the package configurations.
@return void | [
"Register",
"the",
"package",
"configurations",
"."
] | train | https://github.com/laravolt/avatar/blob/0bd373ca7f19600b9b78316dffafba9247cdfbc2/src/LumenServiceProvider.php#L62-L66 |
GrafiteInc/Builder | src/Packages/Starter/app/Http/Middleware/Admin.php | Admin.handle | public function handle($request, Closure $next)
{
if (Gate::allows('admin', $this->auth->user())) {
return $next($request);
}
return response()->view('errors.401', [], 401);
} | php | public function handle($request, Closure $next)
{
if (Gate::allows('admin', $this->auth->user())) {
return $next($request);
}
return response()->view('errors.401', [], 401);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"if",
"(",
"Gate",
"::",
"allows",
"(",
"'admin'",
",",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
")",
")",
"{",
"return",
"$",
"next",
"(",
"$",... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Starter/app/Http/Middleware/Admin.php#L36-L43 |
GrafiteInc/Builder | src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php | QueueController.index | public function index(Request $request)
{
$jobs = $this->service->activeJobs();
return view('admin.queue.index')
->with('jobs', $jobs);
} | php | public function index(Request $request)
{
$jobs = $this->service->activeJobs();
return view('admin.queue.index')
->with('jobs', $jobs);
} | [
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"service",
"->",
"activeJobs",
"(",
")",
";",
"return",
"view",
"(",
"'admin.queue.index'",
")",
"->",
"with",
"(",
"'jobs'",
",",
"$",
"jobs"... | Display a listing of the active jobs.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"active",
"jobs",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php#L35-L41 |
GrafiteInc/Builder | src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php | QueueController.upcoming | public function upcoming(Request $request)
{
$jobs = $this->service->upcomingJobs();
return view('admin.queue.index')
->with('jobs', $jobs);
} | php | public function upcoming(Request $request)
{
$jobs = $this->service->upcomingJobs();
return view('admin.queue.index')
->with('jobs', $jobs);
} | [
"public",
"function",
"upcoming",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"service",
"->",
"upcomingJobs",
"(",
")",
";",
"return",
"view",
"(",
"'admin.queue.index'",
")",
"->",
"with",
"(",
"'jobs'",
",",
"$",
"... | Display a listing of the upcoming jobs.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"upcoming",
"jobs",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php#L48-L54 |
GrafiteInc/Builder | src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php | QueueController.failed | public function failed(Request $request)
{
$jobs = $this->service->failedJobs();
return view('admin.queue.failed')
->with('jobs', $jobs);
} | php | public function failed(Request $request)
{
$jobs = $this->service->failedJobs();
return view('admin.queue.failed')
->with('jobs', $jobs);
} | [
"public",
"function",
"failed",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"service",
"->",
"failedJobs",
"(",
")",
";",
"return",
"view",
"(",
"'admin.queue.failed'",
")",
"->",
"with",
"(",
"'jobs'",
",",
"$",
"job... | Display a listing of the failed jobs.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"failed",
"jobs",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php#L61-L67 |
GrafiteInc/Builder | src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php | QueueController.retry | public function retry($id)
{
if ($this->service->retry($id)) {
return back()->with('message', 'The job was successfully added back into the queue.');
}
return back()->withErrors('Failed to retry the job');
} | php | public function retry($id)
{
if ($this->service->retry($id)) {
return back()->with('message', 'The job was successfully added back into the queue.');
}
return back()->withErrors('Failed to retry the job');
} | [
"public",
"function",
"retry",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"service",
"->",
"retry",
"(",
"$",
"id",
")",
")",
"{",
"return",
"back",
"(",
")",
"->",
"with",
"(",
"'message'",
",",
"'The job was successfully added back into th... | Retry the job
@param int $id
@return Response | [
"Retry",
"the",
"job"
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php#L76-L83 |
GrafiteInc/Builder | src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php | QueueController.cancel | public function cancel($id, $table)
{
if ($this->service->cancel($id, $table)) {
return back()->with('message', 'The job was successfully cancelled');
}
return back()->withErrors('Failed to cancel the job');
} | php | public function cancel($id, $table)
{
if ($this->service->cancel($id, $table)) {
return back()->with('message', 'The job was successfully cancelled');
}
return back()->withErrors('Failed to cancel the job');
} | [
"public",
"function",
"cancel",
"(",
"$",
"id",
",",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"service",
"->",
"cancel",
"(",
"$",
"id",
",",
"$",
"table",
")",
")",
"{",
"return",
"back",
"(",
")",
"->",
"with",
"(",
"'message'",
... | Cancel the job
@param int $id
@param string $table
@return Response | [
"Cancel",
"the",
"job"
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Queue/app/Http/Controllers/Admin/QueueController.php#L93-L100 |
GrafiteInc/Builder | src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php | SocialiteAuthController.redirectToProvider | public function redirectToProvider($provider)
{
return Socialite::driver($provider)->scopes(Config::get('services.'.$provider.'.scopes'))->redirect();
} | php | public function redirectToProvider($provider)
{
return Socialite::driver($provider)->scopes(Config::get('services.'.$provider.'.scopes'))->redirect();
} | [
"public",
"function",
"redirectToProvider",
"(",
"$",
"provider",
")",
"{",
"return",
"Socialite",
"::",
"driver",
"(",
"$",
"provider",
")",
"->",
"scopes",
"(",
"Config",
"::",
"get",
"(",
"'services.'",
".",
"$",
"provider",
".",
"'.scopes'",
")",
")",
... | Redirect the user to the GitHub authentication page.
@return Response | [
"Redirect",
"the",
"user",
"to",
"the",
"GitHub",
"authentication",
"page",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php#L29-L32 |
GrafiteInc/Builder | src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php | SocialiteAuthController.handleProviderCallback | public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
$localUser = $this->service->findByEmail($user->getEmail());
// If we cannot find user by email locally
if (! $localUser) {
$data = [
'name' => $user->getNam... | php | public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
$localUser = $this->service->findByEmail($user->getEmail());
// If we cannot find user by email locally
if (! $localUser) {
$data = [
'name' => $user->getNam... | [
"public",
"function",
"handleProviderCallback",
"(",
"$",
"provider",
")",
"{",
"$",
"user",
"=",
"Socialite",
"::",
"driver",
"(",
"$",
"provider",
")",
"->",
"user",
"(",
")",
";",
"$",
"localUser",
"=",
"$",
"this",
"->",
"service",
"->",
"findByEmail... | Obtain the user information from GitHub.
@return Response | [
"Obtain",
"the",
"user",
"information",
"from",
"GitHub",
"."
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php#L39-L60 |
GrafiteInc/Builder | src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php | SocialiteAuthController.createUser | public function createUser($data)
{
return DB::transaction(function() use ($data) {
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
return $this->servi... | php | public function createUser($data)
{
return DB::transaction(function() use ($data) {
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
return $this->servi... | [
"public",
"function",
"createUser",
"(",
"$",
"data",
")",
"{",
"return",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"data",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"create",
"(",
"[",
"'name'",
"=>",
"$",
"data",
"[",... | Create a user
@param array $data
@return User | [
"Create",
"a",
"user"
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Socialite/app/Http/Controllers/Auth/SocialiteAuthController.php#L69-L80 |
GrafiteInc/Builder | src/Packages/Billing/app/Services/AccountService.php | AccountService.canAccess | public function canAccess($area)
{
$accessCollection = $this->config['plans'][$this->subscription->stripe_plan]['access'];
if (in_array($area, $accessCollection)) {
return true;
}
return false;
} | php | public function canAccess($area)
{
$accessCollection = $this->config['plans'][$this->subscription->stripe_plan]['access'];
if (in_array($area, $accessCollection)) {
return true;
}
return false;
} | [
"public",
"function",
"canAccess",
"(",
"$",
"area",
")",
"{",
"$",
"accessCollection",
"=",
"$",
"this",
"->",
"config",
"[",
"'plans'",
"]",
"[",
"$",
"this",
"->",
"subscription",
"->",
"stripe_plan",
"]",
"[",
"'access'",
"]",
";",
"if",
"(",
"in_a... | Validates a user can access
@param string $area
@return bool | [
"Validates",
"a",
"user",
"can",
"access"
] | train | https://github.com/GrafiteInc/Builder/blob/d67ae09e693580354eb4c143fe7a201656557cc3/src/Packages/Billing/app/Services/AccountService.php#L46-L55 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.