repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
CHH/pipe
lib/Pipe/Environment.php
Environment.setJsCompressor
function setJsCompressor($compressor) { if (!isset($this->compressors[$compressor])) { throw new \InvalidArgumentException(sprintf('Undefined compressor "%s"', $compressor)); } $js = $this->contentType('.js'); if ($this->jsCompressor !== null) { $this->bundleProcessors->unregister($js, $this->compressors[$this->jsCompressor]); } $this->jsCompressor = $compressor; $this->bundleProcessors->register($js, $this->compressors[$compressor]); }
php
function setJsCompressor($compressor) { if (!isset($this->compressors[$compressor])) { throw new \InvalidArgumentException(sprintf('Undefined compressor "%s"', $compressor)); } $js = $this->contentType('.js'); if ($this->jsCompressor !== null) { $this->bundleProcessors->unregister($js, $this->compressors[$this->jsCompressor]); } $this->jsCompressor = $compressor; $this->bundleProcessors->register($js, $this->compressors[$compressor]); }
[ "function", "setJsCompressor", "(", "$", "compressor", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "compressors", "[", "$", "compressor", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Undefined ...
Set the JS compressor Adds the compressor class as bundle processor for JavaScript files. See $compressors for all available compressors. @param string $compressor Identifier of the compressor
[ "Set", "the", "JS", "compressor" ]
306ee3a1e763ba6c0536ed8a0225d1c81f780e83
https://github.com/CHH/pipe/blob/306ee3a1e763ba6c0536ed8a0225d1c81f780e83/lib/Pipe/Environment.php#L175-L189
train
CHH/pipe
lib/Pipe/Environment.php
Environment.setCssCompressor
function setCssCompressor($compressor) { if (!isset($this->compressors[$compressor])) { throw new \InvalidArgumentException(sprintf('Undefined compressor "%s"', $compressor)); } $css = $this->contentType('.css'); if ($this->cssCompressor !== null) { $this->bundleProcessors->unregister($css, $this->compressors[$this->cssCompressor]); } $this->cssCompressor = $compressor; $this->bundleProcessors->register($css, $this->compressors[$compressor]); }
php
function setCssCompressor($compressor) { if (!isset($this->compressors[$compressor])) { throw new \InvalidArgumentException(sprintf('Undefined compressor "%s"', $compressor)); } $css = $this->contentType('.css'); if ($this->cssCompressor !== null) { $this->bundleProcessors->unregister($css, $this->compressors[$this->cssCompressor]); } $this->cssCompressor = $compressor; $this->bundleProcessors->register($css, $this->compressors[$compressor]); }
[ "function", "setCssCompressor", "(", "$", "compressor", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "compressors", "[", "$", "compressor", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Undefined...
Set the CSS compressor Adds the compressor class as bundle processor for CSS files. See $compressors for all available compressors. @param string $compressor Identifier of the compressor
[ "Set", "the", "CSS", "compressor" ]
306ee3a1e763ba6c0536ed8a0225d1c81f780e83
https://github.com/CHH/pipe/blob/306ee3a1e763ba6c0536ed8a0225d1c81f780e83/lib/Pipe/Environment.php#L199-L213
train
lordthorzonus/yii2-algolia
src/ActiveRecord/ActiveQueryChunker.php
ActiveQueryChunker.chunk
public function chunk(ActiveQueryInterface $query, $size, callable $callback) { $pageNumber = 1; $records = $this->paginateRecords($query, $pageNumber, $size)->all(); $results = []; while (count($records) > 0) { // On each chunk, pass the records to the callback and then let the // developer take care of everything within the callback. This allows to // keep the memory low when looping through large result sets. $callableResults = $callback($records); if ($callableResults === false) { break; } // If the results of the given callable function were an array // merge them into the result array which is returned at the end of the chunking. if (\is_array($callableResults)) { $results = \array_merge($results, $callableResults); } $pageNumber++; $records = $this->paginateRecords($query, $pageNumber, $size)->all(); } return $results; }
php
public function chunk(ActiveQueryInterface $query, $size, callable $callback) { $pageNumber = 1; $records = $this->paginateRecords($query, $pageNumber, $size)->all(); $results = []; while (count($records) > 0) { // On each chunk, pass the records to the callback and then let the // developer take care of everything within the callback. This allows to // keep the memory low when looping through large result sets. $callableResults = $callback($records); if ($callableResults === false) { break; } // If the results of the given callable function were an array // merge them into the result array which is returned at the end of the chunking. if (\is_array($callableResults)) { $results = \array_merge($results, $callableResults); } $pageNumber++; $records = $this->paginateRecords($query, $pageNumber, $size)->all(); } return $results; }
[ "public", "function", "chunk", "(", "ActiveQueryInterface", "$", "query", ",", "$", "size", ",", "callable", "$", "callback", ")", "{", "$", "pageNumber", "=", "1", ";", "$", "records", "=", "$", "this", "->", "paginateRecords", "(", "$", "query", ",", ...
Chunk the results of an ActiveQuery. @param ActiveQueryInterface $query @param int $size The size of chunk retrieved from the query. @param callable $callback @return array
[ "Chunk", "the", "results", "of", "an", "ActiveQuery", "." ]
29593c356b727f6d52c2cb4080fc0c232d27c3bb
https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/ActiveRecord/ActiveQueryChunker.php#L18-L45
train
lordthorzonus/yii2-algolia
src/ActiveRecord/ActiveQueryChunker.php
ActiveQueryChunker.paginateRecords
private function paginateRecords(ActiveQueryInterface $query, $pageNumber, $count) { $offset = ($pageNumber - 1) * $count; $limit = $count; return $query->offset($offset)->limit($limit); }
php
private function paginateRecords(ActiveQueryInterface $query, $pageNumber, $count) { $offset = ($pageNumber - 1) * $count; $limit = $count; return $query->offset($offset)->limit($limit); }
[ "private", "function", "paginateRecords", "(", "ActiveQueryInterface", "$", "query", ",", "$", "pageNumber", ",", "$", "count", ")", "{", "$", "offset", "=", "(", "$", "pageNumber", "-", "1", ")", "*", "$", "count", ";", "$", "limit", "=", "$", "count"...
Paginate the results of the query. @param ActiveQueryInterface $query @param int $pageNumber @param int $count @return ActiveQueryInterface
[ "Paginate", "the", "results", "of", "the", "query", "." ]
29593c356b727f6d52c2cb4080fc0c232d27c3bb
https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/ActiveRecord/ActiveQueryChunker.php#L56-L62
train
Speelpenning-nl/laravel-authentication
src/Http/Controllers/PasswordResetController.php
PasswordResetController.store
public function store(SendPasswordResetLinkRequest $request) { $this->dispatch(new SendPasswordResetLink($request->get('email'))); return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.created' => trans('authentication::password-reset.created'), ]); }
php
public function store(SendPasswordResetLinkRequest $request) { $this->dispatch(new SendPasswordResetLink($request->get('email'))); return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.created' => trans('authentication::password-reset.created'), ]); }
[ "public", "function", "store", "(", "SendPasswordResetLinkRequest", "$", "request", ")", "{", "$", "this", "->", "dispatch", "(", "new", "SendPasswordResetLink", "(", "$", "request", "->", "get", "(", "'email'", ")", ")", ")", ";", "return", "redirect", "(",...
Attempts to send the password reset link to the user. @param SendPasswordResetLinkRequest $request @return RedirectResponse
[ "Attempts", "to", "send", "the", "password", "reset", "link", "to", "the", "user", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/PasswordResetController.php#L36-L43
train
Speelpenning-nl/laravel-authentication
src/Http/Controllers/PasswordResetController.php
PasswordResetController.edit
public function edit($token, PasswordResetRepository $resets) { if ($resets->exists($token)) { return view('authentication::password-reset.edit')->with('token', $token); } else { return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.expired' => trans('authentication::password-reset.expired'), ]); } }
php
public function edit($token, PasswordResetRepository $resets) { if ($resets->exists($token)) { return view('authentication::password-reset.edit')->with('token', $token); } else { return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.expired' => trans('authentication::password-reset.expired'), ]); } }
[ "public", "function", "edit", "(", "$", "token", ",", "PasswordResetRepository", "$", "resets", ")", "{", "if", "(", "$", "resets", "->", "exists", "(", "$", "token", ")", ")", "{", "return", "view", "(", "'authentication::password-reset.edit'", ")", "->", ...
Shows the password reset form. @param string $token @param PasswordResetRepository $resets @return View|RedirectResponse
[ "Shows", "the", "password", "reset", "form", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/PasswordResetController.php#L52-L61
train
Speelpenning-nl/laravel-authentication
src/Http/Controllers/PasswordResetController.php
PasswordResetController.update
public function update(ResetPasswordRequest $request) { try { $this->dispatch(new ResetPassword($request->get('token'), $request->get('email'), $request->get('password'))); return redirect()->route('authentication::session.create')->withErrors([ 'authentication::password-reset.updated' => trans('authentication::password-reset.updated'), ]); } catch (TokenIsExpired $e) { return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.expired' => trans('authentication::password-reset.expired'), ]); } }
php
public function update(ResetPasswordRequest $request) { try { $this->dispatch(new ResetPassword($request->get('token'), $request->get('email'), $request->get('password'))); return redirect()->route('authentication::session.create')->withErrors([ 'authentication::password-reset.updated' => trans('authentication::password-reset.updated'), ]); } catch (TokenIsExpired $e) { return redirect()->route('authentication::password-reset.create')->withErrors([ 'authentication::password-reset.expired' => trans('authentication::password-reset.expired'), ]); } }
[ "public", "function", "update", "(", "ResetPasswordRequest", "$", "request", ")", "{", "try", "{", "$", "this", "->", "dispatch", "(", "new", "ResetPassword", "(", "$", "request", "->", "get", "(", "'token'", ")", ",", "$", "request", "->", "get", "(", ...
Attempts to reset the password. @param ResetPasswordRequest $request @return RedirectResponse
[ "Attempts", "to", "reset", "the", "password", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/PasswordResetController.php#L69-L82
train
meritoo/common-bundle
src/Service/ApplicationService.php
ApplicationService.getVersion
private function getVersion(): ?Version { // Oops, unknown/empty path of a file who contains version if (empty($this->versionFilePath)) { throw EmptyVersionFilePathException::create(); } // Oops, not readable/accessible file who contains version if (!is_readable($this->versionFilePath)) { throw UnreadableVersionFileException::create($this->versionFilePath); } $contents = file_get_contents($this->versionFilePath); return Version::fromString($contents); }
php
private function getVersion(): ?Version { // Oops, unknown/empty path of a file who contains version if (empty($this->versionFilePath)) { throw EmptyVersionFilePathException::create(); } // Oops, not readable/accessible file who contains version if (!is_readable($this->versionFilePath)) { throw UnreadableVersionFileException::create($this->versionFilePath); } $contents = file_get_contents($this->versionFilePath); return Version::fromString($contents); }
[ "private", "function", "getVersion", "(", ")", ":", "?", "Version", "{", "// Oops, unknown/empty path of a file who contains version", "if", "(", "empty", "(", "$", "this", "->", "versionFilePath", ")", ")", "{", "throw", "EmptyVersionFilePathException", "::", "create...
Returns version of application @return null|Version
[ "Returns", "version", "of", "application" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/ApplicationService.php#L76-L91
train
meritoo/common-bundle
src/Service/ApplicationService.php
ApplicationService.createDescriptor
private function createDescriptor(string $name, string $description): void { $version = $this->getVersion(); $this->descriptor = new Descriptor($name, $description, $version); }
php
private function createDescriptor(string $name, string $description): void { $version = $this->getVersion(); $this->descriptor = new Descriptor($name, $description, $version); }
[ "private", "function", "createDescriptor", "(", "string", "$", "name", ",", "string", "$", "description", ")", ":", "void", "{", "$", "version", "=", "$", "this", "->", "getVersion", "(", ")", ";", "$", "this", "->", "descriptor", "=", "new", "Descriptor...
Creates descriptor of application @param string $name Name of application. May be displayed near logo. @param string $description Description of application. May be displayed near logo.
[ "Creates", "descriptor", "of", "application" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/ApplicationService.php#L99-L103
train
JantaoDev/SitemapBundle
Controller/RobotsFileController.php
RobotsFileController.indexAction
public function indexAction(Request $request) { $hosts = $this->getParameter('jantao_dev_sitemap.hosts'); $webDir = rtrim($this->getParameter('jantao_dev_sitemap.web_dir'), '/'); if (!empty($hosts)) { $host = $request->getHttpHost(); if (strpos($host, ':') !== false) { $host = substr($host, 0, strpos($host, ':')); } if (in_array($host, $hosts) && file_exists("$webDir/robots.$host.txt")) { return new BinaryFileResponse("$webDir/robots.$host.txt"); } } if (file_exists("$webDir/robots.txt")) { return new BinaryFileResponse("$webDir/robots.txt"); } else { throw $this->createNotFoundException('robots.txt not found'); } }
php
public function indexAction(Request $request) { $hosts = $this->getParameter('jantao_dev_sitemap.hosts'); $webDir = rtrim($this->getParameter('jantao_dev_sitemap.web_dir'), '/'); if (!empty($hosts)) { $host = $request->getHttpHost(); if (strpos($host, ':') !== false) { $host = substr($host, 0, strpos($host, ':')); } if (in_array($host, $hosts) && file_exists("$webDir/robots.$host.txt")) { return new BinaryFileResponse("$webDir/robots.$host.txt"); } } if (file_exists("$webDir/robots.txt")) { return new BinaryFileResponse("$webDir/robots.txt"); } else { throw $this->createNotFoundException('robots.txt not found'); } }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "hosts", "=", "$", "this", "->", "getParameter", "(", "'jantao_dev_sitemap.hosts'", ")", ";", "$", "webDir", "=", "rtrim", "(", "$", "this", "->", "getParameter", "(", "'ja...
Switch robots.txt files by requested host and configuration @param Request $request @return BinaryFileResponse @throws NotFoundException
[ "Switch", "robots", ".", "txt", "files", "by", "requested", "host", "and", "configuration" ]
be21aafc2384d0430ee566bc8cec84de4a45ab03
https://github.com/JantaoDev/SitemapBundle/blob/be21aafc2384d0430ee566bc8cec84de4a45ab03/Controller/RobotsFileController.php#L28-L46
train
digbang/security
src/Configurations/SecurityContextConfiguration.php
SecurityContextConfiguration.setPrefix
public function setPrefix($prefix) { if ($prefix != '') { $prefix = rtrim($prefix, '_').'_'; } $this->prefix = $prefix; return $this; }
php
public function setPrefix($prefix) { if ($prefix != '') { $prefix = rtrim($prefix, '_').'_'; } $this->prefix = $prefix; return $this; }
[ "public", "function", "setPrefix", "(", "$", "prefix", ")", "{", "if", "(", "$", "prefix", "!=", "''", ")", "{", "$", "prefix", "=", "rtrim", "(", "$", "prefix", ",", "'_'", ")", ".", "'_'", ";", "}", "$", "this", "->", "prefix", "=", "$", "pre...
Set the global table prefix. By default, the context name will be used, with a trailing underscore. A trailing underscore will be added to the given prefix automatically, if needed. To unset the global prefix, use an empty string as prefix. @param string $prefix @return $this
[ "Set", "the", "global", "table", "prefix", ".", "By", "default", "the", "context", "name", "will", "be", "used", "with", "a", "trailing", "underscore", ".", "A", "trailing", "underscore", "will", "be", "added", "to", "the", "given", "prefix", "automatically"...
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Configurations/SecurityContextConfiguration.php#L270-L279
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.section
public function section(string $section): SectionTwigExtension { $this->options[ReadOptions::SECTION] = $section; return $this; }
php
public function section(string $section): SectionTwigExtension { $this->options[ReadOptions::SECTION] = $section; return $this; }
[ "public", "function", "section", "(", "string", "$", "section", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "SECTION", "]", "=", "$", "section", ";", "return", "$", "this", ";", "}" ]
Returns entries that belong to a specific section. In the future it will be possible to fetch entries of multiple sections at once. A section can be passed by it's FQCN: Fully.Qualified.Example Or by it's handle: example @param string $section @return SectionTwigExtension
[ "Returns", "entries", "that", "belong", "to", "a", "specific", "section", ".", "In", "the", "future", "it", "will", "be", "possible", "to", "fetch", "entries", "of", "multiple", "sections", "at", "once", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L56-L61
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.limit
public function limit(int $limit): SectionTwigExtension { $this->options[ReadOptions::LIMIT] = $limit; return $this; }
php
public function limit(int $limit): SectionTwigExtension { $this->options[ReadOptions::LIMIT] = $limit; return $this; }
[ "public", "function", "limit", "(", "int", "$", "limit", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "LIMIT", "]", "=", "$", "limit", ";", "return", "$", "this", ";", "}" ]
Limit returned entries @param int $limit @return SectionTwigExtension
[ "Limit", "returned", "entries" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L69-L74
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.offset
public function offset(int $offset): SectionTwigExtension { $this->options[ReadOptions::OFFSET] = $offset; return $this; }
php
public function offset(int $offset): SectionTwigExtension { $this->options[ReadOptions::OFFSET] = $offset; return $this; }
[ "public", "function", "offset", "(", "int", "$", "offset", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "OFFSET", "]", "=", "$", "offset", ";", "return", "$", "this", ";", "}" ]
Offset returned entries @param int $offset @return SectionTwigExtension
[ "Offset", "returned", "entries" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L82-L87
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.sort
public function sort(string $sort): SectionTwigExtension { $this->options[ReadOptions::SORT] = $sort; return $this; }
php
public function sort(string $sort): SectionTwigExtension { $this->options[ReadOptions::SORT] = $sort; return $this; }
[ "public", "function", "sort", "(", "string", "$", "sort", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "SORT", "]", "=", "$", "sort", ";", "return", "$", "this", ";", "}" ]
Specify sort direction ASC|DESC @param string $sort @return SectionTwigExtension
[ "Specify", "sort", "direction" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L110-L115
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.before
public function before(string $before): SectionTwigExtension { $this->options[ReadOptions::BEFORE] = new \DateTime($before); return $this; }
php
public function before(string $before): SectionTwigExtension { $this->options[ReadOptions::BEFORE] = new \DateTime($before); return $this; }
[ "public", "function", "before", "(", "string", "$", "before", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "BEFORE", "]", "=", "new", "\\", "DateTime", "(", "$", "before", ")", ";", "return", "$", "this",...
Only fetch entries with a Post Date that is before the given date. @param string $before @return SectionTwigExtension
[ "Only", "fetch", "entries", "with", "a", "Post", "Date", "that", "is", "before", "the", "given", "date", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L123-L128
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.after
public function after(string $after): SectionTwigExtension { $this->options[ReadOptions::AFTER] = new \DateTime($after); return $this; }
php
public function after(string $after): SectionTwigExtension { $this->options[ReadOptions::AFTER] = new \DateTime($after); return $this; }
[ "public", "function", "after", "(", "string", "$", "after", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "AFTER", "]", "=", "new", "\\", "DateTime", "(", "$", "after", ")", ";", "return", "$", "this", "...
Only fetch entries with a Post Date that is on or after the given date. @param string $after @return SectionTwigExtension
[ "Only", "fetch", "entries", "with", "a", "Post", "Date", "that", "is", "on", "or", "after", "the", "given", "date", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L136-L141
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.locale
public function locale(string $locale): SectionTwigExtension { $this->options[ReadOptions::LOCALE] = $locale; return $this; }
php
public function locale(string $locale): SectionTwigExtension { $this->options[ReadOptions::LOCALE] = $locale; return $this; }
[ "public", "function", "locale", "(", "string", "$", "locale", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "LOCALE", "]", "=", "$", "locale", ";", "return", "$", "this", ";", "}" ]
Fetch just the entries for a specific locale. @param string $locale @return SectionTwigExtension
[ "Fetch", "just", "the", "entries", "for", "a", "specific", "locale", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L162-L167
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.id
public function id(int $id): SectionTwigExtension { $this->throwNotFound = true; $this->options[ReadOptions::ID] = $id; return $this; }
php
public function id(int $id): SectionTwigExtension { $this->throwNotFound = true; $this->options[ReadOptions::ID] = $id; return $this; }
[ "public", "function", "id", "(", "int", "$", "id", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "throwNotFound", "=", "true", ";", "$", "this", "->", "options", "[", "ReadOptions", "::", "ID", "]", "=", "$", "id", ";", "return", "$", "th...
Only fetch the entry with the given ID. @param int $id @return SectionTwigExtension
[ "Only", "fetch", "the", "entry", "with", "the", "given", "ID", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L175-L181
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.slug
public function slug(string $slug): SectionTwigExtension { $this->throwNotFound = true; $this->options[ReadOptions::SLUG] = $slug; return $this; }
php
public function slug(string $slug): SectionTwigExtension { $this->throwNotFound = true; $this->options[ReadOptions::SLUG] = $slug; return $this; }
[ "public", "function", "slug", "(", "string", "$", "slug", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "throwNotFound", "=", "true", ";", "$", "this", "->", "options", "[", "ReadOptions", "::", "SLUG", "]", "=", "$", "slug", ";", "return", ...
Only fetch the entry with the given slug. @param string $slug @return SectionTwigExtension
[ "Only", "fetch", "the", "entry", "with", "the", "given", "slug", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L189-L195
train
dionsnoeijen/sexy-field
src/Twig/SectionTwigExtension.php
SectionTwigExtension.search
public function search(string $searchQuery): SectionTwigExtension { $this->options[ReadOptions::SEARCH] = $searchQuery; return $this; }
php
public function search(string $searchQuery): SectionTwigExtension { $this->options[ReadOptions::SEARCH] = $searchQuery; return $this; }
[ "public", "function", "search", "(", "string", "$", "searchQuery", ")", ":", "SectionTwigExtension", "{", "$", "this", "->", "options", "[", "ReadOptions", "::", "SEARCH", "]", "=", "$", "searchQuery", ";", "return", "$", "this", ";", "}" ]
This method requires some extra thinking. How are we going to handle searching in the context of SexyField intelligently? What version of SexyField will this be available? @param string $searchQuery @return SectionTwigExtension
[ "This", "method", "requires", "some", "extra", "thinking", ".", "How", "are", "we", "going", "to", "handle", "searching", "in", "the", "context", "of", "SexyField", "intelligently?", "What", "version", "of", "SexyField", "will", "this", "be", "available?" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Twig/SectionTwigExtension.php#L206-L211
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.getURI
public function getURI(array $criteria) { $uris = $this->getURIs($criteria); return $uris->count() > 0 ? $uris->first() : false; }
php
public function getURI(array $criteria) { $uris = $this->getURIs($criteria); return $uris->count() > 0 ? $uris->first() : false; }
[ "public", "function", "getURI", "(", "array", "$", "criteria", ")", "{", "$", "uris", "=", "$", "this", "->", "getURIs", "(", "$", "criteria", ")", ";", "return", "$", "uris", "->", "count", "(", ")", ">", "0", "?", "$", "uris", "->", "first", "(...
Get the first URI that matches the given criteria. @since 0.1.0 @param array $criteria Criteria to match. @return string|false URI that matches the criteria or false if none found.
[ "Get", "the", "first", "URI", "that", "matches", "the", "given", "criteria", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L72-L79
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.getURIs
public function getURIs(array $criteria): URIs { $uris = new URIs(); foreach ($this->extensions as $extension) { $finder = new Finder(); try { $finder->files() ->name($this->getNamePattern($criteria, $extension)) ->in($this->getPathPattern($this->getRelativePath($criteria))); foreach ($finder as $file) { /** @var SplFileInfo $file */ $uris->add($file->getPathname()); } } catch (Exception $exception) { // Fail silently; } } return $uris; }
php
public function getURIs(array $criteria): URIs { $uris = new URIs(); foreach ($this->extensions as $extension) { $finder = new Finder(); try { $finder->files() ->name($this->getNamePattern($criteria, $extension)) ->in($this->getPathPattern($this->getRelativePath($criteria))); foreach ($finder as $file) { /** @var SplFileInfo $file */ $uris->add($file->getPathname()); } } catch (Exception $exception) { // Fail silently; } } return $uris; }
[ "public", "function", "getURIs", "(", "array", "$", "criteria", ")", ":", "URIs", "{", "$", "uris", "=", "new", "URIs", "(", ")", ";", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "extension", ")", "{", "$", "finder", "=", "new", "Fi...
Get all URIs that match the given criteria. @since 0.1.1 @param array $criteria Criteria to match. @return URIs URIs that match the criteria or an empty collection if none found.
[ "Get", "all", "URIs", "that", "match", "the", "given", "criteria", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L90-L111
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.getNamePattern
protected function getNamePattern(array $criteria, string $extension): string { $names = []; $names[] = array_map(function ($criterion) use ($extension) { $uriExtension = URIHelper::containsExtension($criterion); if (! empty($extension)) { $extension = ltrim($extension, '.'); if ($uriExtension === $extension) { $criterion = substr($criterion,0,-strlen(".{$extension}")); } } else { $extension = URIHelper::containsExtension($criterion); if (!empty($extension)) { $criterion = substr($criterion,0,-strlen(".{$extension}")); } } $criterion = preg_quote(URIHelper::getFilename($criterion), chr(1)); return (empty($extension) || URIHelper::hasExtension($criterion, $extension)) ? "{$criterion}(?:\..*?)$" : "{$criterion}\.{$extension}$"; }, $criteria)[0]; return chr(1) . implode('|', array_unique($names)) . chr(1); }
php
protected function getNamePattern(array $criteria, string $extension): string { $names = []; $names[] = array_map(function ($criterion) use ($extension) { $uriExtension = URIHelper::containsExtension($criterion); if (! empty($extension)) { $extension = ltrim($extension, '.'); if ($uriExtension === $extension) { $criterion = substr($criterion,0,-strlen(".{$extension}")); } } else { $extension = URIHelper::containsExtension($criterion); if (!empty($extension)) { $criterion = substr($criterion,0,-strlen(".{$extension}")); } } $criterion = preg_quote(URIHelper::getFilename($criterion), chr(1)); return (empty($extension) || URIHelper::hasExtension($criterion, $extension)) ? "{$criterion}(?:\..*?)$" : "{$criterion}\.{$extension}$"; }, $criteria)[0]; return chr(1) . implode('|', array_unique($names)) . chr(1); }
[ "protected", "function", "getNamePattern", "(", "array", "$", "criteria", ",", "string", "$", "extension", ")", ":", "string", "{", "$", "names", "=", "[", "]", ";", "$", "names", "[", "]", "=", "array_map", "(", "function", "(", "$", "criterion", ")",...
Get the name pattern to pass to the file finder. @since 0.1.3 @param array $criteria Criteria to match. @param string $extension Extension to match. @return string Name pattern to pass to the file finder.
[ "Get", "the", "name", "pattern", "to", "pass", "to", "the", "file", "finder", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L123-L150
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.getPathPattern
protected function getPathPattern(string $relativePath): string { if (empty($relativePath)) { return $this->path; } return rtrim($this->path,'/') . '/' . ltrim($relativePath, '/'); }
php
protected function getPathPattern(string $relativePath): string { if (empty($relativePath)) { return $this->path; } return rtrim($this->path,'/') . '/' . ltrim($relativePath, '/'); }
[ "protected", "function", "getPathPattern", "(", "string", "$", "relativePath", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "relativePath", ")", ")", "{", "return", "$", "this", "->", "path", ";", "}", "return", "rtrim", "(", "$", "this", "->...
Get the path pattern to pass to the file finder. @since 0.4.7 @param string $relativePath Relative path that was included in the criterion. @return string Path pattern to pass to the file finder.
[ "Get", "the", "path", "pattern", "to", "pass", "to", "the", "file", "finder", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L161-L168
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.getRelativePath
protected function getRelativePath($criteria): string { $criterion = current($criteria); $components = explode('/', $criterion); if (count($components) < 2) { return ''; } return implode('/', array_slice($components, 0, -1)); }
php
protected function getRelativePath($criteria): string { $criterion = current($criteria); $components = explode('/', $criterion); if (count($components) < 2) { return ''; } return implode('/', array_slice($components, 0, -1)); }
[ "protected", "function", "getRelativePath", "(", "$", "criteria", ")", ":", "string", "{", "$", "criterion", "=", "current", "(", "$", "criteria", ")", ";", "$", "components", "=", "explode", "(", "'/'", ",", "$", "criterion", ")", ";", "if", "(", "cou...
Get the relative path that is included in the criterion. @since 0.4.7 @param array $criteria Criteria to extract the relative path from. @return string Relative path included in the criterion.
[ "Get", "the", "relative", "path", "that", "is", "included", "in", "the", "criterion", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L178-L188
train
brightnucleus/view
src/View/Location/FilesystemLocation.php
FilesystemLocation.validateExtensions
protected function validateExtensions($extensions): Extensions { if (empty($extensions)) { $extensions = new Extensions(['']); } if (! $extensions instanceof Extensions) { $extensions = new Extensions((array)$extensions); } return $extensions; }
php
protected function validateExtensions($extensions): Extensions { if (empty($extensions)) { $extensions = new Extensions(['']); } if (! $extensions instanceof Extensions) { $extensions = new Extensions((array)$extensions); } return $extensions; }
[ "protected", "function", "validateExtensions", "(", "$", "extensions", ")", ":", "Extensions", "{", "if", "(", "empty", "(", "$", "extensions", ")", ")", "{", "$", "extensions", "=", "new", "Extensions", "(", "[", "''", "]", ")", ";", "}", "if", "(", ...
Validate the extensions and return a collection. @since 0.1.1 @param Extensions|array|string|null $extensions Extensions to validate. @return Extensions Validated extensions collection.
[ "Validate", "the", "extensions", "and", "return", "a", "collection", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/FilesystemLocation.php#L199-L210
train
MichaelPavlista/palette
src/Effect/Resize.php
Resize.resizeImagick
private function resizeImagick(Imagick $imagick, Picture $picture) { if(!$this->resizeSmaller && $this->height > $imagick->getImageHeight() && $this->width > $imagick->getImageWidth()) { return; } if($this->resizeMode === $this::MODE_CROP) { $imagick->cropThumbnailImage($this->width, $this->height); } elseif($this->resizeMode === $this::MODE_FILL) { $ratioH = $this->height / $imagick->getImageHeight(); $ratioW = $this->width / $imagick->getImageWidth(); $width = max($imagick->getImageWidth() * $ratioH, $imagick->getImageWidth() * $ratioW); $height = max($imagick->getImageHeight() * $ratioH, $imagick->getImageHeight() * $ratioW); $ratio = max($width / $imagick->getImageWidth(), $height / $imagick->getImageHeight()); $imagick->scaleImage(round($imagick->getImageWidth() * $ratio), round($imagick->getImageHeight() * $ratio), TRUE); } elseif($this->resizeMode === $this::MODE_STRETCH) { $imagick->scaleImage($this->width, $this->height, FALSE); } elseif($this->resizeMode === $this::MODE_EXACT) { $imagick->scaleImage($this->width, $this->height, TRUE); $rectangle = $picture->createImagick(); $rectangle->setFormat('png'); $rectangle->newImage($this->width, $this->height, new \ImagickPixel($this->color ?: 'transparent')); $rectangle->compositeImage($imagick, $imagick->getImageCompose(), ($rectangle->getImageWidth() - $imagick->getImageWidth()) / 2, ($rectangle->getImageHeight() - $imagick->getImageHeight()) / 2 ); $picture->setResource($rectangle); } else { $imagick->scaleImage($this->width, $this->height, TRUE); } }
php
private function resizeImagick(Imagick $imagick, Picture $picture) { if(!$this->resizeSmaller && $this->height > $imagick->getImageHeight() && $this->width > $imagick->getImageWidth()) { return; } if($this->resizeMode === $this::MODE_CROP) { $imagick->cropThumbnailImage($this->width, $this->height); } elseif($this->resizeMode === $this::MODE_FILL) { $ratioH = $this->height / $imagick->getImageHeight(); $ratioW = $this->width / $imagick->getImageWidth(); $width = max($imagick->getImageWidth() * $ratioH, $imagick->getImageWidth() * $ratioW); $height = max($imagick->getImageHeight() * $ratioH, $imagick->getImageHeight() * $ratioW); $ratio = max($width / $imagick->getImageWidth(), $height / $imagick->getImageHeight()); $imagick->scaleImage(round($imagick->getImageWidth() * $ratio), round($imagick->getImageHeight() * $ratio), TRUE); } elseif($this->resizeMode === $this::MODE_STRETCH) { $imagick->scaleImage($this->width, $this->height, FALSE); } elseif($this->resizeMode === $this::MODE_EXACT) { $imagick->scaleImage($this->width, $this->height, TRUE); $rectangle = $picture->createImagick(); $rectangle->setFormat('png'); $rectangle->newImage($this->width, $this->height, new \ImagickPixel($this->color ?: 'transparent')); $rectangle->compositeImage($imagick, $imagick->getImageCompose(), ($rectangle->getImageWidth() - $imagick->getImageWidth()) / 2, ($rectangle->getImageHeight() - $imagick->getImageHeight()) / 2 ); $picture->setResource($rectangle); } else { $imagick->scaleImage($this->width, $this->height, TRUE); } }
[ "private", "function", "resizeImagick", "(", "Imagick", "$", "imagick", ",", "Picture", "$", "picture", ")", "{", "if", "(", "!", "$", "this", "->", "resizeSmaller", "&&", "$", "this", "->", "height", ">", "$", "imagick", "->", "getImageHeight", "(", ")"...
Resizing an image using Imagick @param Imagick $imagick
[ "Resizing", "an", "image", "using", "Imagick" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Effect/Resize.php#L147-L192
train
koolkode/async
src/PromiseResolution.php
PromiseResolution.resolve
protected function resolve($value = null): void { if (~$this->state & AbstractPromise::PENDING) { return; } if ($value instanceof Promise) { $value->when(function (?\Throwable $e, $v = null): void { if ($e === null) { $this->resolve($v); } else { $this->fail($e); } }); return; } $callbacks = $this->result; $this->state ^= AbstractPromise::PENDING | AbstractPromise::SUCCEEDED; $this->result = $value; if ($this instanceof Cancellable) { $this->context->unregisterCancellation($this); } if ($callbacks) { if (\is_array($callbacks)) { foreach ($callbacks as $callback) { try { $callback(null, $value); } catch (\Throwable $e) { $this->context->handleError($e); } } } else { try { $callbacks(null, $value); } catch (\Throwable $e) { $this->context->handleError($e); } } } }
php
protected function resolve($value = null): void { if (~$this->state & AbstractPromise::PENDING) { return; } if ($value instanceof Promise) { $value->when(function (?\Throwable $e, $v = null): void { if ($e === null) { $this->resolve($v); } else { $this->fail($e); } }); return; } $callbacks = $this->result; $this->state ^= AbstractPromise::PENDING | AbstractPromise::SUCCEEDED; $this->result = $value; if ($this instanceof Cancellable) { $this->context->unregisterCancellation($this); } if ($callbacks) { if (\is_array($callbacks)) { foreach ($callbacks as $callback) { try { $callback(null, $value); } catch (\Throwable $e) { $this->context->handleError($e); } } } else { try { $callbacks(null, $value); } catch (\Throwable $e) { $this->context->handleError($e); } } } }
[ "protected", "function", "resolve", "(", "$", "value", "=", "null", ")", ":", "void", "{", "if", "(", "~", "$", "this", "->", "state", "&", "AbstractPromise", "::", "PENDING", ")", "{", "return", ";", "}", "if", "(", "$", "value", "instanceof", "Prom...
Resolve the promise with the given value. Passing a promise as value will defer resolution until the promise resolves.
[ "Resolve", "the", "promise", "with", "the", "given", "value", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/PromiseResolution.php#L36-L80
train
koolkode/async
src/PromiseResolution.php
PromiseResolution.fail
protected function fail(\Throwable $error): void { if (~$this->state & AbstractPromise::PENDING) { return; } $callbacks = $this->result; $this->state ^= AbstractPromise::PENDING | AbstractPromise::FAILED; $this->result = $error; if ($this instanceof Cancellable) { $this->context->unregisterCancellation($this); } if ($callbacks) { if (\is_array($callbacks)) { foreach ($callbacks as $callback) { try { $callback($error); } catch (\Throwable $e) { $this->context->handleError($e); } } } else { try { $callbacks($error); } catch (\Throwable $e) { $this->context->handleError($e); } } } }
php
protected function fail(\Throwable $error): void { if (~$this->state & AbstractPromise::PENDING) { return; } $callbacks = $this->result; $this->state ^= AbstractPromise::PENDING | AbstractPromise::FAILED; $this->result = $error; if ($this instanceof Cancellable) { $this->context->unregisterCancellation($this); } if ($callbacks) { if (\is_array($callbacks)) { foreach ($callbacks as $callback) { try { $callback($error); } catch (\Throwable $e) { $this->context->handleError($e); } } } else { try { $callbacks($error); } catch (\Throwable $e) { $this->context->handleError($e); } } } }
[ "protected", "function", "fail", "(", "\\", "Throwable", "$", "error", ")", ":", "void", "{", "if", "(", "~", "$", "this", "->", "state", "&", "AbstractPromise", "::", "PENDING", ")", "{", "return", ";", "}", "$", "callbacks", "=", "$", "this", "->",...
Fail the promise with the given error.
[ "Fail", "the", "promise", "with", "the", "given", "error", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/PromiseResolution.php#L85-L117
train
wikimedia/wait-condition-loop
src/WaitConditionLoop.php
WaitConditionLoop.popAndRunBusyCallback
private function popAndRunBusyCallback() { if ( $this->busyCallbacks ) { reset( $this->busyCallbacks ); $key = key( $this->busyCallbacks ); /** @var callable $workCallback */ $workCallback =& $this->busyCallbacks[$key]; try { $workCallback(); } catch ( \Exception $e ) { $workCallback = function () use ( $e ) { throw $e; }; } unset( $this->busyCallbacks[$key] ); // consume return true; } return false; }
php
private function popAndRunBusyCallback() { if ( $this->busyCallbacks ) { reset( $this->busyCallbacks ); $key = key( $this->busyCallbacks ); /** @var callable $workCallback */ $workCallback =& $this->busyCallbacks[$key]; try { $workCallback(); } catch ( \Exception $e ) { $workCallback = function () use ( $e ) { throw $e; }; } unset( $this->busyCallbacks[$key] ); // consume return true; } return false; }
[ "private", "function", "popAndRunBusyCallback", "(", ")", "{", "if", "(", "$", "this", "->", "busyCallbacks", ")", "{", "reset", "(", "$", "this", "->", "busyCallbacks", ")", ";", "$", "key", "=", "key", "(", "$", "this", "->", "busyCallbacks", ")", ";...
Run one of the callbacks that does work ahead of time for another caller @return bool Whether a callback was executed
[ "Run", "one", "of", "the", "callbacks", "that", "does", "work", "ahead", "of", "time", "for", "another", "caller" ]
860475eea39ae3b9409a7122691152ca5fa1defe
https://github.com/wikimedia/wait-condition-loop/blob/860475eea39ae3b9409a7122691152ca5fa1defe/src/WaitConditionLoop.php#L174-L193
train
UndefinedOffset/silverstripe-markdown
code/renderer/GithubMarkdownRenderer.php
GithubMarkdownRenderer.getRenderedHTML
public function getRenderedHTML($value) { //Build object to send $sendObj=new stdClass(); $sendObj->text=$value; $sendObj->mode=(self::$useGFM ? 'gmf':'markdown'); $content=json_encode($sendObj); //Build headers $headers=array("Content-type: application/json", "User-Agent: curl"); if(self::$useBasicAuth) { $encoded=base64_encode(self::$username.':'.self::$password); $headers[]="Authorization: Basic $encoded"; } //Build curl request to github's api $curl=curl_init('https://api.github.com/markdown'); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $content); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //Send request and verify response $response=curl_exec($curl); $status=curl_getinfo($curl, CURLINFO_HTTP_CODE); if($status!=200) { user_error("Error: Call to api.github.com failed with status $status, response $response, curl_error ".curl_error($curl).", curl_errno ".curl_errno($curl), E_USER_WARNING); } //Close curl connection curl_close($curl); return $response; }
php
public function getRenderedHTML($value) { //Build object to send $sendObj=new stdClass(); $sendObj->text=$value; $sendObj->mode=(self::$useGFM ? 'gmf':'markdown'); $content=json_encode($sendObj); //Build headers $headers=array("Content-type: application/json", "User-Agent: curl"); if(self::$useBasicAuth) { $encoded=base64_encode(self::$username.':'.self::$password); $headers[]="Authorization: Basic $encoded"; } //Build curl request to github's api $curl=curl_init('https://api.github.com/markdown'); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $content); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //Send request and verify response $response=curl_exec($curl); $status=curl_getinfo($curl, CURLINFO_HTTP_CODE); if($status!=200) { user_error("Error: Call to api.github.com failed with status $status, response $response, curl_error ".curl_error($curl).", curl_errno ".curl_errno($curl), E_USER_WARNING); } //Close curl connection curl_close($curl); return $response; }
[ "public", "function", "getRenderedHTML", "(", "$", "value", ")", "{", "//Build object to send", "$", "sendObj", "=", "new", "stdClass", "(", ")", ";", "$", "sendObj", "->", "text", "=", "$", "value", ";", "$", "sendObj", "->", "mode", "=", "(", "self", ...
Returns the supplied Markdown as rendered HTML @param {string} $markdown The markdown to render @return {string} The rendered HTML
[ "Returns", "the", "supplied", "Markdown", "as", "rendered", "HTML" ]
e55d8478733dfdc1e8ba43dc536c3e029ad0b83d
https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/renderer/GithubMarkdownRenderer.php#L27-L62
train
UndefinedOffset/silverstripe-markdown
code/renderer/GithubMarkdownRenderer.php
GithubMarkdownRenderer.useBasicAuth
public function useBasicAuth($username=false, $password=false) { self::$useBasicAuth=($username!==false && $password!==false); self::$username=$username; self::$password=$password; }
php
public function useBasicAuth($username=false, $password=false) { self::$useBasicAuth=($username!==false && $password!==false); self::$username=$username; self::$password=$password; }
[ "public", "function", "useBasicAuth", "(", "$", "username", "=", "false", ",", "$", "password", "=", "false", ")", "{", "self", "::", "$", "useBasicAuth", "=", "(", "$", "username", "!==", "false", "&&", "$", "password", "!==", "false", ")", ";", "self...
Sets whether or not to include the Authorization header in GitHub API requests, both parameters are required to enable basic auth @param {string} $username Github Username @param {string} $password Github Password
[ "Sets", "whether", "or", "not", "to", "include", "the", "Authorization", "header", "in", "GitHub", "API", "requests", "both", "parameters", "are", "required", "to", "enable", "basic", "auth" ]
e55d8478733dfdc1e8ba43dc536c3e029ad0b83d
https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/renderer/GithubMarkdownRenderer.php#L85-L89
train
dazzle-php/promise
src/Promise/Partial/PromiseTrait.php
PromiseTrait.doReject
public static function doReject($promiseOrValue = null) { if (!$promiseOrValue instanceof PromiseInterface) { return new PromiseRejected($promiseOrValue); } return self::doResolve($promiseOrValue)->then(function($value) { return new PromiseRejected($value); }); }
php
public static function doReject($promiseOrValue = null) { if (!$promiseOrValue instanceof PromiseInterface) { return new PromiseRejected($promiseOrValue); } return self::doResolve($promiseOrValue)->then(function($value) { return new PromiseRejected($value); }); }
[ "public", "static", "function", "doReject", "(", "$", "promiseOrValue", "=", "null", ")", "{", "if", "(", "!", "$", "promiseOrValue", "instanceof", "PromiseInterface", ")", "{", "return", "new", "PromiseRejected", "(", "$", "promiseOrValue", ")", ";", "}", "...
Reject Promise or value. @param PromiseInterface|mixed $promiseOrValue @return PromiseInterface @rejects Error|Exception|string|null
[ "Reject", "Promise", "or", "value", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Partial/PromiseTrait.php#L41-L51
train
dazzle-php/promise
src/Promise/Partial/PromiseTrait.php
PromiseTrait.doCancel
public static function doCancel($promiseOrValue = null) { if (!$promiseOrValue instanceof PromiseInterface) { return new PromiseCancelled($promiseOrValue); } return self::doResolve($promiseOrValue) ->then( function($value) { return new PromiseCancelled($value); }, function($value) { return new PromiseCancelled($value); } ); }
php
public static function doCancel($promiseOrValue = null) { if (!$promiseOrValue instanceof PromiseInterface) { return new PromiseCancelled($promiseOrValue); } return self::doResolve($promiseOrValue) ->then( function($value) { return new PromiseCancelled($value); }, function($value) { return new PromiseCancelled($value); } ); }
[ "public", "static", "function", "doCancel", "(", "$", "promiseOrValue", "=", "null", ")", "{", "if", "(", "!", "$", "promiseOrValue", "instanceof", "PromiseInterface", ")", "{", "return", "new", "PromiseCancelled", "(", "$", "promiseOrValue", ")", ";", "}", ...
Cancel Promise or value. @param PromiseInterface|mixed $promiseOrValue @return PromiseInterface @cancels Error|Exception|string|null
[ "Cancel", "Promise", "or", "value", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Partial/PromiseTrait.php#L60-L76
train
dazzle-php/promise
src/Promise/Partial/PromiseTrait.php
PromiseTrait.race
public static function race($promisesOrValues) { $cancellationQueue = new CancellationQueue(); return new Promise(function($resolve, $reject, $cancel) use($promisesOrValues, $cancellationQueue) { self::doResolve($promisesOrValues) ->done(function($array) use($resolve, $reject, $cancel, $cancellationQueue) { if (!is_array($array) || !$array) { $resolve(); return; } $fulfiller = function($value) use($resolve, $cancellationQueue) { $resolve($value); $cancellationQueue(); }; $rejecter = function($reason) use($reject, $cancellationQueue) { $reject($reason); $cancellationQueue(); }; foreach ($array as $promiseOrValue) { $cancellationQueue->enqueue($promiseOrValue); self::doResolve($promiseOrValue) ->done($fulfiller, $rejecter, $cancel); } }, $reject, $cancel); }, $cancellationQueue); }
php
public static function race($promisesOrValues) { $cancellationQueue = new CancellationQueue(); return new Promise(function($resolve, $reject, $cancel) use($promisesOrValues, $cancellationQueue) { self::doResolve($promisesOrValues) ->done(function($array) use($resolve, $reject, $cancel, $cancellationQueue) { if (!is_array($array) || !$array) { $resolve(); return; } $fulfiller = function($value) use($resolve, $cancellationQueue) { $resolve($value); $cancellationQueue(); }; $rejecter = function($reason) use($reject, $cancellationQueue) { $reject($reason); $cancellationQueue(); }; foreach ($array as $promiseOrValue) { $cancellationQueue->enqueue($promiseOrValue); self::doResolve($promiseOrValue) ->done($fulfiller, $rejecter, $cancel); } }, $reject, $cancel); }, $cancellationQueue); }
[ "public", "static", "function", "race", "(", "$", "promisesOrValues", ")", "{", "$", "cancellationQueue", "=", "new", "CancellationQueue", "(", ")", ";", "return", "new", "Promise", "(", "function", "(", "$", "resolve", ",", "$", "reject", ",", "$", "cance...
Initiate a competitive race that allows one winner. Initiate a competitive race that allows one winner. Returns a promise which is resolved in the same way the first settled promise resolves. @param PromiseInterface[]|mixed[] $promisesOrValues @return PromiseInterface @resolves mixed @rejects Error|Exception|string|null @cancels Error|Exception|string|null
[ "Initiate", "a", "competitive", "race", "that", "allows", "one", "winner", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Partial/PromiseTrait.php#L110-L142
train
Speelpenning-nl/laravel-authentication
src/PasswordReset.php
PasswordReset.generate
public static function generate(Authenticatable $user) { return new static([ 'email' => $user->email, 'token' => hash_hmac('sha256', Str::random(40), config('app.key')), 'created_at' => Carbon::now(), ]); }
php
public static function generate(Authenticatable $user) { return new static([ 'email' => $user->email, 'token' => hash_hmac('sha256', Str::random(40), config('app.key')), 'created_at' => Carbon::now(), ]); }
[ "public", "static", "function", "generate", "(", "Authenticatable", "$", "user", ")", "{", "return", "new", "static", "(", "[", "'email'", "=>", "$", "user", "->", "email", ",", "'token'", "=>", "hash_hmac", "(", "'sha256'", ",", "Str", "::", "random", "...
Generates a new password token. @param Authenticatable $user @return PasswordReset
[ "Generates", "a", "new", "password", "token", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/PasswordReset.php#L25-L32
train
opis/view
src/EngineResolver.php
EngineResolver.register
public function register(callable $factory, $priority = 0): self { array_unshift($this->engines, [$factory, $priority]); $this->cache = null; $sorted = false; while (!$sorted) { $sorted = true; for ($i = 0, $l = count($this->engines) - 1; $i < $l; $i++) { if ($this->engines[$i][1] < $this->engines[$i + 1][1]) { $tmp = $this->engines[$i]; $this->engines[$i] = $this->engines[$i + 1]; $this->engines[$i + 1] = $tmp; $sorted = false; } } } return $this; }
php
public function register(callable $factory, $priority = 0): self { array_unshift($this->engines, [$factory, $priority]); $this->cache = null; $sorted = false; while (!$sorted) { $sorted = true; for ($i = 0, $l = count($this->engines) - 1; $i < $l; $i++) { if ($this->engines[$i][1] < $this->engines[$i + 1][1]) { $tmp = $this->engines[$i]; $this->engines[$i] = $this->engines[$i + 1]; $this->engines[$i + 1] = $tmp; $sorted = false; } } } return $this; }
[ "public", "function", "register", "(", "callable", "$", "factory", ",", "$", "priority", "=", "0", ")", ":", "self", "{", "array_unshift", "(", "$", "this", "->", "engines", ",", "[", "$", "factory", ",", "$", "priority", "]", ")", ";", "$", "this", ...
Register a new view engine @param callable $factory @param int $priority @return EngineResolver
[ "Register", "a", "new", "view", "engine" ]
8aaee4d1de4372539db2bc3ed82063438426e311
https://github.com/opis/view/blob/8aaee4d1de4372539db2bc3ed82063438426e311/src/EngineResolver.php#L50-L69
train
opis/view
src/EngineResolver.php
EngineResolver.resolve
public function resolve(string $path): IEngine { if ($this->cache === null) { $this->cache = []; foreach ($this->engines as $engine) { $this->cache[] = $engine[0]($this->renderer); } } foreach ($this->cache as $engine) { if ($engine->canHandle($path)) { return $engine; } } return $this->renderer->getDefaultEngine(); }
php
public function resolve(string $path): IEngine { if ($this->cache === null) { $this->cache = []; foreach ($this->engines as $engine) { $this->cache[] = $engine[0]($this->renderer); } } foreach ($this->cache as $engine) { if ($engine->canHandle($path)) { return $engine; } } return $this->renderer->getDefaultEngine(); }
[ "public", "function", "resolve", "(", "string", "$", "path", ")", ":", "IEngine", "{", "if", "(", "$", "this", "->", "cache", "===", "null", ")", "{", "$", "this", "->", "cache", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "engines", "...
Resolve a path to a render engine @param string $path @return IEngine
[ "Resolve", "a", "path", "to", "a", "render", "engine" ]
8aaee4d1de4372539db2bc3ed82063438426e311
https://github.com/opis/view/blob/8aaee4d1de4372539db2bc3ed82063438426e311/src/EngineResolver.php#L78-L94
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByHasFeatureAvValue
public function filterByHasFeatureAvValue($hasFeatureAvValue = null, $comparison = null) { if (is_array($hasFeatureAvValue)) { $useMinMax = false; if (isset($hasFeatureAvValue['min'])) { $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($hasFeatureAvValue['max'])) { $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue, $comparison); }
php
public function filterByHasFeatureAvValue($hasFeatureAvValue = null, $comparison = null) { if (is_array($hasFeatureAvValue)) { $useMinMax = false; if (isset($hasFeatureAvValue['min'])) { $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($hasFeatureAvValue['max'])) { $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::HAS_FEATURE_AV_VALUE, $hasFeatureAvValue, $comparison); }
[ "public", "function", "filterByHasFeatureAvValue", "(", "$", "hasFeatureAvValue", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "hasFeatureAvValue", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(...
Filter the query on the has_feature_av_value column Example usage: <code> $query->filterByHasFeatureAvValue(1234); // WHERE has_feature_av_value = 1234 $query->filterByHasFeatureAvValue(array(12, 34)); // WHERE has_feature_av_value IN (12, 34) $query->filterByHasFeatureAvValue(array('min' => 12)); // WHERE has_feature_av_value > 12 </code> @param mixed $hasFeatureAvValue The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "has_feature_av_value", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L368-L389
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByIsMultilingualFeatureAvValue
public function filterByIsMultilingualFeatureAvValue($isMultilingualFeatureAvValue = null, $comparison = null) { if (is_array($isMultilingualFeatureAvValue)) { $useMinMax = false; if (isset($isMultilingualFeatureAvValue['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($isMultilingualFeatureAvValue['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue, $comparison); }
php
public function filterByIsMultilingualFeatureAvValue($isMultilingualFeatureAvValue = null, $comparison = null) { if (is_array($isMultilingualFeatureAvValue)) { $useMinMax = false; if (isset($isMultilingualFeatureAvValue['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($isMultilingualFeatureAvValue['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IS_MULTILINGUAL_FEATURE_AV_VALUE, $isMultilingualFeatureAvValue, $comparison); }
[ "public", "function", "filterByIsMultilingualFeatureAvValue", "(", "$", "isMultilingualFeatureAvValue", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "isMultilingualFeatureAvValue", ")", ")", "{", "$", "useMinMax", "=...
Filter the query on the is_multilingual_feature_av_value column Example usage: <code> $query->filterByIsMultilingualFeatureAvValue(1234); // WHERE is_multilingual_feature_av_value = 1234 $query->filterByIsMultilingualFeatureAvValue(array(12, 34)); // WHERE is_multilingual_feature_av_value IN (12, 34) $query->filterByIsMultilingualFeatureAvValue(array('min' => 12)); // WHERE is_multilingual_feature_av_value > 12 </code> @param mixed $isMultilingualFeatureAvValue The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "is_multilingual_feature_av_value", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L409-L430
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByCssClass
public function filterByCssClass($cssClass = null, $comparison = null) { if (null === $comparison) { if (is_array($cssClass)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $cssClass)) { $cssClass = str_replace('*', '%', $cssClass); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(FeatureTypeTableMap::CSS_CLASS, $cssClass, $comparison); }
php
public function filterByCssClass($cssClass = null, $comparison = null) { if (null === $comparison) { if (is_array($cssClass)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $cssClass)) { $cssClass = str_replace('*', '%', $cssClass); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(FeatureTypeTableMap::CSS_CLASS, $cssClass, $comparison); }
[ "public", "function", "filterByCssClass", "(", "$", "cssClass", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "cssClass", ")", ")", "{", "$", "compa...
Filter the query on the css_class column Example usage: <code> $query->filterByCssClass('fooValue'); // WHERE css_class = 'fooValue' $query->filterByCssClass('%fooValue%'); // WHERE css_class LIKE '%fooValue%' </code> @param string $cssClass The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "css_class", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L476-L488
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByInputType
public function filterByInputType($inputType = null, $comparison = null) { if (null === $comparison) { if (is_array($inputType)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $inputType)) { $inputType = str_replace('*', '%', $inputType); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(FeatureTypeTableMap::INPUT_TYPE, $inputType, $comparison); }
php
public function filterByInputType($inputType = null, $comparison = null) { if (null === $comparison) { if (is_array($inputType)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $inputType)) { $inputType = str_replace('*', '%', $inputType); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(FeatureTypeTableMap::INPUT_TYPE, $inputType, $comparison); }
[ "public", "function", "filterByInputType", "(", "$", "inputType", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "inputType", ")", ")", "{", "$", "co...
Filter the query on the input_type column Example usage: <code> $query->filterByInputType('fooValue'); // WHERE input_type = 'fooValue' $query->filterByInputType('%fooValue%'); // WHERE input_type LIKE '%fooValue%' </code> @param string $inputType The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "input_type", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L505-L517
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByMax
public function filterByMax($max = null, $comparison = null) { if (is_array($max)) { $useMinMax = false; if (isset($max['min'])) { $this->addUsingAlias(FeatureTypeTableMap::MAX, $max['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($max['max'])) { $this->addUsingAlias(FeatureTypeTableMap::MAX, $max['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::MAX, $max, $comparison); }
php
public function filterByMax($max = null, $comparison = null) { if (is_array($max)) { $useMinMax = false; if (isset($max['min'])) { $this->addUsingAlias(FeatureTypeTableMap::MAX, $max['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($max['max'])) { $this->addUsingAlias(FeatureTypeTableMap::MAX, $max['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::MAX, $max, $comparison); }
[ "public", "function", "filterByMax", "(", "$", "max", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "max", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "max", "["...
Filter the query on the max column Example usage: <code> $query->filterByMax(1234); // WHERE max = 1234 $query->filterByMax(array(12, 34)); // WHERE max IN (12, 34) $query->filterByMax(array('min' => 12)); // WHERE max > 12 </code> @param mixed $max The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "max", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L537-L558
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByMin
public function filterByMin($min = null, $comparison = null) { if (is_array($min)) { $useMinMax = false; if (isset($min['min'])) { $this->addUsingAlias(FeatureTypeTableMap::MIN, $min['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($min['max'])) { $this->addUsingAlias(FeatureTypeTableMap::MIN, $min['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::MIN, $min, $comparison); }
php
public function filterByMin($min = null, $comparison = null) { if (is_array($min)) { $useMinMax = false; if (isset($min['min'])) { $this->addUsingAlias(FeatureTypeTableMap::MIN, $min['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($min['max'])) { $this->addUsingAlias(FeatureTypeTableMap::MIN, $min['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::MIN, $min, $comparison); }
[ "public", "function", "filterByMin", "(", "$", "min", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "min", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "min", "["...
Filter the query on the min column Example usage: <code> $query->filterByMin(1234); // WHERE min = 1234 $query->filterByMin(array(12, 34)); // WHERE min IN (12, 34) $query->filterByMin(array('min' => 12)); // WHERE min > 12 </code> @param mixed $min The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "min", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L578-L599
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByStep
public function filterByStep($step = null, $comparison = null) { if (is_array($step)) { $useMinMax = false; if (isset($step['min'])) { $this->addUsingAlias(FeatureTypeTableMap::STEP, $step['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($step['max'])) { $this->addUsingAlias(FeatureTypeTableMap::STEP, $step['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::STEP, $step, $comparison); }
php
public function filterByStep($step = null, $comparison = null) { if (is_array($step)) { $useMinMax = false; if (isset($step['min'])) { $this->addUsingAlias(FeatureTypeTableMap::STEP, $step['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($step['max'])) { $this->addUsingAlias(FeatureTypeTableMap::STEP, $step['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::STEP, $step, $comparison); }
[ "public", "function", "filterByStep", "(", "$", "step", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "step", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "step", ...
Filter the query on the step column Example usage: <code> $query->filterByStep(1234); // WHERE step = 1234 $query->filterByStep(array(12, 34)); // WHERE step IN (12, 34) $query->filterByStep(array('min' => 12)); // WHERE step > 12 </code> @param mixed $step The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "step", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L619-L640
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByImageMaxWidth
public function filterByImageMaxWidth($imageMaxWidth = null, $comparison = null) { if (is_array($imageMaxWidth)) { $useMinMax = false; if (isset($imageMaxWidth['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($imageMaxWidth['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth, $comparison); }
php
public function filterByImageMaxWidth($imageMaxWidth = null, $comparison = null) { if (is_array($imageMaxWidth)) { $useMinMax = false; if (isset($imageMaxWidth['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($imageMaxWidth['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_WIDTH, $imageMaxWidth, $comparison); }
[ "public", "function", "filterByImageMaxWidth", "(", "$", "imageMaxWidth", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "imageMaxWidth", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset"...
Filter the query on the image_max_width column Example usage: <code> $query->filterByImageMaxWidth(1234); // WHERE image_max_width = 1234 $query->filterByImageMaxWidth(array(12, 34)); // WHERE image_max_width IN (12, 34) $query->filterByImageMaxWidth(array('min' => 12)); // WHERE image_max_width > 12 </code> @param mixed $imageMaxWidth The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "image_max_width", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L660-L681
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByImageMaxHeight
public function filterByImageMaxHeight($imageMaxHeight = null, $comparison = null) { if (is_array($imageMaxHeight)) { $useMinMax = false; if (isset($imageMaxHeight['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($imageMaxHeight['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight, $comparison); }
php
public function filterByImageMaxHeight($imageMaxHeight = null, $comparison = null) { if (is_array($imageMaxHeight)) { $useMinMax = false; if (isset($imageMaxHeight['min'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($imageMaxHeight['max'])) { $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureTypeTableMap::IMAGE_MAX_HEIGHT, $imageMaxHeight, $comparison); }
[ "public", "function", "filterByImageMaxHeight", "(", "$", "imageMaxHeight", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "imageMaxHeight", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "iss...
Filter the query on the image_max_height column Example usage: <code> $query->filterByImageMaxHeight(1234); // WHERE image_max_height = 1234 $query->filterByImageMaxHeight(array(12, 34)); // WHERE image_max_height IN (12, 34) $query->filterByImageMaxHeight(array('min' => 12)); // WHERE image_max_height > 12 </code> @param mixed $imageMaxHeight The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "image_max_height", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L701-L722
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.filterByFeatureTypeI18n
public function filterByFeatureTypeI18n($featureTypeI18n, $comparison = null) { if ($featureTypeI18n instanceof \FeatureType\Model\FeatureTypeI18n) { return $this ->addUsingAlias(FeatureTypeTableMap::ID, $featureTypeI18n->getId(), $comparison); } elseif ($featureTypeI18n instanceof ObjectCollection) { return $this ->useFeatureTypeI18nQuery() ->filterByPrimaryKeys($featureTypeI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByFeatureTypeI18n() only accepts arguments of type \FeatureType\Model\FeatureTypeI18n or Collection'); } }
php
public function filterByFeatureTypeI18n($featureTypeI18n, $comparison = null) { if ($featureTypeI18n instanceof \FeatureType\Model\FeatureTypeI18n) { return $this ->addUsingAlias(FeatureTypeTableMap::ID, $featureTypeI18n->getId(), $comparison); } elseif ($featureTypeI18n instanceof ObjectCollection) { return $this ->useFeatureTypeI18nQuery() ->filterByPrimaryKeys($featureTypeI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByFeatureTypeI18n() only accepts arguments of type \FeatureType\Model\FeatureTypeI18n or Collection'); } }
[ "public", "function", "filterByFeatureTypeI18n", "(", "$", "featureTypeI18n", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "featureTypeI18n", "instanceof", "\\", "FeatureType", "\\", "Model", "\\", "FeatureTypeI18n", ")", "{", "return", "$", ...
Filter the query by a related \FeatureType\Model\FeatureTypeI18n object @param \FeatureType\Model\FeatureTypeI18n|ObjectCollection $featureTypeI18n the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "FeatureType", "\\", "Model", "\\", "FeatureTypeI18n", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L932-L945
train
thelia-modules/FeatureType
Model/Base/FeatureTypeQuery.php
FeatureTypeQuery.useFeatureTypeI18nQuery
public function useFeatureTypeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinFeatureTypeI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureTypeI18n', '\FeatureType\Model\FeatureTypeI18nQuery'); }
php
public function useFeatureTypeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinFeatureTypeI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureTypeI18n', '\FeatureType\Model\FeatureTypeI18nQuery'); }
[ "public", "function", "useFeatureTypeI18nQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "'LEFT JOIN'", ")", "{", "return", "$", "this", "->", "joinFeatureTypeI18n", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQue...
Use the FeatureTypeI18n relation FeatureTypeI18n object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \FeatureType\Model\FeatureTypeI18nQuery A secondary query class using the current class as primary query
[ "Use", "the", "FeatureTypeI18n", "relation", "FeatureTypeI18n", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeQuery.php#L990-L995
train
BlackBonjour/stdlib
src/Util/Arrays.php
Arrays.fill
public function fill($newValue): self { foreach ($this->values as $index => $value) { $this->values[$index] = $newValue; } return $this; }
php
public function fill($newValue): self { foreach ($this->values as $index => $value) { $this->values[$index] = $newValue; } return $this; }
[ "public", "function", "fill", "(", "$", "newValue", ")", ":", "self", "{", "foreach", "(", "$", "this", "->", "values", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "this", "->", "values", "[", "$", "index", "]", "=", "$", "newValue", "...
Fills array with specified value @param mixed $newValue @return static
[ "Fills", "array", "with", "specified", "value" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/Arrays.php#L67-L74
train
MichaelPavlista/palette
src/Picture.php
Picture.loadImageResource
protected function loadImageResource() { if(empty($this->resource)) { if((is_null($this->worker) || $this->worker === $this::WORKER_IMAGICK) && $this->imagickAvailable()) { $this->resource = $this->createImagick($this->image); } elseif((is_null($this->worker) || $this->worker === $this::WORKER_GD) && $this->gdAvailable()) { $this->resource = $this->getGdResource($this->image); } else { throw new Exception('Required extensions missing, extension GD or Imagick is required'); } } }
php
protected function loadImageResource() { if(empty($this->resource)) { if((is_null($this->worker) || $this->worker === $this::WORKER_IMAGICK) && $this->imagickAvailable()) { $this->resource = $this->createImagick($this->image); } elseif((is_null($this->worker) || $this->worker === $this::WORKER_GD) && $this->gdAvailable()) { $this->resource = $this->getGdResource($this->image); } else { throw new Exception('Required extensions missing, extension GD or Imagick is required'); } } }
[ "protected", "function", "loadImageResource", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "resource", ")", ")", "{", "if", "(", "(", "is_null", "(", "$", "this", "->", "worker", ")", "||", "$", "this", "->", "worker", "===", "$", "th...
Loads an image as a resource for applying effects and transformations @throws Exception
[ "Loads", "an", "image", "as", "a", "resource", "for", "applying", "effects", "and", "transformations" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L215-L232
train
MichaelPavlista/palette
src/Picture.php
Picture.convertResource
protected function convertResource($convertTo) { $this->tmpImage[] = $tmpImage = tempnam(sys_get_temp_dir(), 'picture'); if($this->isGd()) { imagepng($this->resource, $tmpImage, 0); } else { $this->resource->writeImage($tmpImage); } if($convertTo === $this::WORKER_GD) { return $this->getGdResource($tmpImage); } else { return $this->createImagick($tmpImage); } }
php
protected function convertResource($convertTo) { $this->tmpImage[] = $tmpImage = tempnam(sys_get_temp_dir(), 'picture'); if($this->isGd()) { imagepng($this->resource, $tmpImage, 0); } else { $this->resource->writeImage($tmpImage); } if($convertTo === $this::WORKER_GD) { return $this->getGdResource($tmpImage); } else { return $this->createImagick($tmpImage); } }
[ "protected", "function", "convertResource", "(", "$", "convertTo", ")", "{", "$", "this", "->", "tmpImage", "[", "]", "=", "$", "tmpImage", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'picture'", ")", ";", "if", "(", "$", "this", "->", "is...
Performs conversion between GD and Imagick resource instances. @param string $convertTo worker constant @return Imagick|resource @throws Exception
[ "Performs", "conversion", "between", "GD", "and", "Imagick", "resource", "instances", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L286-L307
train
MichaelPavlista/palette
src/Picture.php
Picture.setResource
public function setResource($resource) { if($this->getWorker($resource) === $this->getWorker($this->resource)) { $this->resource = $resource; } $this->tmpImage[] = $tmpImage = tempnam(sys_get_temp_dir(), 'picture'); if($this->getWorker($resource) === $this::WORKER_GD) { imagepng($resource, $tmpImage, 0); } else { $resource->writeImage($tmpImage); } if($this->isGd()) { $this->resource = $this->getGdResource($tmpImage); } else { $this->resource = $this->createImagick($tmpImage); } }
php
public function setResource($resource) { if($this->getWorker($resource) === $this->getWorker($this->resource)) { $this->resource = $resource; } $this->tmpImage[] = $tmpImage = tempnam(sys_get_temp_dir(), 'picture'); if($this->getWorker($resource) === $this::WORKER_GD) { imagepng($resource, $tmpImage, 0); } else { $resource->writeImage($tmpImage); } if($this->isGd()) { $this->resource = $this->getGdResource($tmpImage); } else { $this->resource = $this->createImagick($tmpImage); } }
[ "public", "function", "setResource", "(", "$", "resource", ")", "{", "if", "(", "$", "this", "->", "getWorker", "(", "$", "resource", ")", "===", "$", "this", "->", "getWorker", "(", "$", "this", "->", "resource", ")", ")", "{", "$", "this", "->", ...
Sets the resource picture to another @param Imagick|resource $resource
[ "Sets", "the", "resource", "picture", "to", "another" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L325-L351
train
MichaelPavlista/palette
src/Picture.php
Picture.normalizeGdResource
protected function normalizeGdResource($resource) { if(imageistruecolor($resource)) { imagesavealpha($resource, TRUE); return $resource; } $width = imagesx($resource); $height = imagesy($resource); $trueColor = imagecreatetruecolor($width, $height); imagealphablending($trueColor, FALSE); $transparent = imagecolorallocatealpha($trueColor, 255, 255, 255, 127); imagefilledrectangle($trueColor, 0, 0, $width, $height, $transparent); imagealphablending($trueColor, TRUE); imagecopy($trueColor, $resource, 0, 0, 0, 0, $width, $height); imagedestroy($resource); imagesavealpha($trueColor, TRUE); return $trueColor; }
php
protected function normalizeGdResource($resource) { if(imageistruecolor($resource)) { imagesavealpha($resource, TRUE); return $resource; } $width = imagesx($resource); $height = imagesy($resource); $trueColor = imagecreatetruecolor($width, $height); imagealphablending($trueColor, FALSE); $transparent = imagecolorallocatealpha($trueColor, 255, 255, 255, 127); imagefilledrectangle($trueColor, 0, 0, $width, $height, $transparent); imagealphablending($trueColor, TRUE); imagecopy($trueColor, $resource, 0, 0, 0, 0, $width, $height); imagedestroy($resource); imagesavealpha($trueColor, TRUE); return $trueColor; }
[ "protected", "function", "normalizeGdResource", "(", "$", "resource", ")", "{", "if", "(", "imageistruecolor", "(", "$", "resource", ")", ")", "{", "imagesavealpha", "(", "$", "resource", ",", "TRUE", ")", ";", "return", "$", "resource", ";", "}", "$", "...
Normalize GD resource @param $resource @return resource
[ "Normalize", "GD", "resource" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L359-L386
train
MichaelPavlista/palette
src/Picture.php
Picture.getGdResource
protected function getGdResource($imageFile) { $imageInfo = getimagesize($imageFile); switch($imageInfo['mime']) { case 'image/jpg': case 'image/jpeg': return $this->normalizeGdResource(imagecreatefromjpeg($imageFile)); case 'image/gif': return $this->normalizeGdResource(imagecreatefromgif($imageFile)); case 'image/png': return $this->normalizeGdResource(imagecreatefrompng($imageFile)); } throw new Exception('GD resource not supported image extension'); }
php
protected function getGdResource($imageFile) { $imageInfo = getimagesize($imageFile); switch($imageInfo['mime']) { case 'image/jpg': case 'image/jpeg': return $this->normalizeGdResource(imagecreatefromjpeg($imageFile)); case 'image/gif': return $this->normalizeGdResource(imagecreatefromgif($imageFile)); case 'image/png': return $this->normalizeGdResource(imagecreatefrompng($imageFile)); } throw new Exception('GD resource not supported image extension'); }
[ "protected", "function", "getGdResource", "(", "$", "imageFile", ")", "{", "$", "imageInfo", "=", "getimagesize", "(", "$", "imageFile", ")", ";", "switch", "(", "$", "imageInfo", "[", "'mime'", "]", ")", "{", "case", "'image/jpg'", ":", "case", "'image/jp...
Creating a resource of GD image file @param string $imageFile image file path @return resource @throws Exception
[ "Creating", "a", "resource", "of", "GD", "image", "file" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L395-L413
train
MichaelPavlista/palette
src/Picture.php
Picture.getImageQuery
public function getImageQuery() { $command = ''; foreach($this->effect as $effect) { if($effect instanceof PictureEffect) { $command .= $effect->__toString() . '&'; } } $command .= 'Quality;' . $this->quality . '&'; if($this->progressive) { $command .= 'Progressive&'; } return substr($command, 0, strlen($command) - 1); }
php
public function getImageQuery() { $command = ''; foreach($this->effect as $effect) { if($effect instanceof PictureEffect) { $command .= $effect->__toString() . '&'; } } $command .= 'Quality;' . $this->quality . '&'; if($this->progressive) { $command .= 'Progressive&'; } return substr($command, 0, strlen($command) - 1); }
[ "public", "function", "getImageQuery", "(", ")", "{", "$", "command", "=", "''", ";", "foreach", "(", "$", "this", "->", "effect", "as", "$", "effect", ")", "{", "if", "(", "$", "effect", "instanceof", "PictureEffect", ")", "{", "$", "command", ".=", ...
Get image query string to create image with the actual effects @return string
[ "Get", "image", "query", "string", "to", "create", "image", "with", "the", "actual", "effects" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L446-L466
train
MichaelPavlista/palette
src/Picture.php
Picture.effect
public function effect($effect) { $args = array_slice(func_get_args(), 1); if($effect instanceof PictureEffect) { $this->effect[] = $effect; } else { $effectClass = "Palette\\Effect\\" . $effect; if(class_exists($effectClass)) { $reflection = new ReflectionClass($effectClass); $this->effect[] = $reflection->newInstanceArgs($args); } else { throw new Exception('Unknown Palette effect instance'); } } }
php
public function effect($effect) { $args = array_slice(func_get_args(), 1); if($effect instanceof PictureEffect) { $this->effect[] = $effect; } else { $effectClass = "Palette\\Effect\\" . $effect; if(class_exists($effectClass)) { $reflection = new ReflectionClass($effectClass); $this->effect[] = $reflection->newInstanceArgs($args); } else { throw new Exception('Unknown Palette effect instance'); } } }
[ "public", "function", "effect", "(", "$", "effect", ")", "{", "$", "args", "=", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "if", "(", "$", "effect", "instanceof", "PictureEffect", ")", "{", "$", "this", "->", "effect", "[", "]...
Add new picture effect @param $effect @throws Exception
[ "Add", "new", "picture", "effect" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L474-L496
train
MichaelPavlista/palette
src/Picture.php
Picture.resize
public function resize($width, $height = NULL, $resizeMode = NULL) { if(!$height) { $height = $width; } $this->effect[] = new Resize($width, $height, $resizeMode); }
php
public function resize($width, $height = NULL, $resizeMode = NULL) { if(!$height) { $height = $width; } $this->effect[] = new Resize($width, $height, $resizeMode); }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", "=", "NULL", ",", "$", "resizeMode", "=", "NULL", ")", "{", "if", "(", "!", "$", "height", ")", "{", "$", "height", "=", "$", "width", ";", "}", "$", "this", "->", "effect", ...
Resize picture by specified dimensions @param int $width @param int $height @param null $resizeMode (Palette\Effect\Resize constant)
[ "Resize", "picture", "by", "specified", "dimensions" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L505-L513
train
MichaelPavlista/palette
src/Picture.php
Picture.setProgressive
public function setProgressive($progressive = TRUE) { if(is_bool($progressive)) { $this->progressive = $progressive; } else { trigger_error('Picture progressive mode must be boolean', E_USER_WARNING); } }
php
public function setProgressive($progressive = TRUE) { if(is_bool($progressive)) { $this->progressive = $progressive; } else { trigger_error('Picture progressive mode must be boolean', E_USER_WARNING); } }
[ "public", "function", "setProgressive", "(", "$", "progressive", "=", "TRUE", ")", "{", "if", "(", "is_bool", "(", "$", "progressive", ")", ")", "{", "$", "this", "->", "progressive", "=", "$", "progressive", ";", "}", "else", "{", "trigger_error", "(", ...
Set picture saving mode as progressive image? @param bool $progressive
[ "Set", "picture", "saving", "mode", "as", "progressive", "image?" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L537-L547
train
MichaelPavlista/palette
src/Picture.php
Picture.save
public function save($file = NULL) { if(is_null($file) && $this->storage) { $this->storage->save($this); } elseif(!is_null($file)) { $this->savePicture($file); } else { trigger_error('Image file to save is not defined', E_USER_WARNING); } }
php
public function save($file = NULL) { if(is_null($file) && $this->storage) { $this->storage->save($this); } elseif(!is_null($file)) { $this->savePicture($file); } else { trigger_error('Image file to save is not defined', E_USER_WARNING); } }
[ "public", "function", "save", "(", "$", "file", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "file", ")", "&&", "$", "this", "->", "storage", ")", "{", "$", "this", "->", "storage", "->", "save", "(", "$", "this", ")", ";", "}", "else...
Save the edited image to the repository, or specific location @param null $file
[ "Save", "the", "edited", "image", "to", "the", "repository", "or", "specific", "location" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L554-L568
train
MichaelPavlista/palette
src/Picture.php
Picture.output
public function output() { $imageFile = $this->storage->getPath($this); if(file_exists($imageFile)) { header('Content-Type: image'); header('Content-Length: ' . filesize($imageFile)); readfile($imageFile); exit; } }
php
public function output() { $imageFile = $this->storage->getPath($this); if(file_exists($imageFile)) { header('Content-Type: image'); header('Content-Length: ' . filesize($imageFile)); readfile($imageFile); exit; } }
[ "public", "function", "output", "(", ")", "{", "$", "imageFile", "=", "$", "this", "->", "storage", "->", "getPath", "(", "$", "this", ")", ";", "if", "(", "file_exists", "(", "$", "imageFile", ")", ")", "{", "header", "(", "'Content-Type: image'", ")"...
Output the image to the browser @return void @exit
[ "Output", "the", "image", "to", "the", "browser" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L800-L812
train
MichaelPavlista/palette
src/Picture.php
Picture.getUrl
public function getUrl() { if($this->storage) { $this->save(); return $this->storage->getUrl($this); } return NULL; }
php
public function getUrl() { if($this->storage) { $this->save(); return $this->storage->getUrl($this); } return NULL; }
[ "public", "function", "getUrl", "(", ")", "{", "if", "(", "$", "this", "->", "storage", ")", "{", "$", "this", "->", "save", "(", ")", ";", "return", "$", "this", "->", "storage", "->", "getUrl", "(", "$", "this", ")", ";", "}", "return", "NULL",...
Returns the URL of the image, if is needed save this image @return null|string
[ "Returns", "the", "URL", "of", "the", "image", "if", "is", "needed", "save", "this", "image" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L819-L829
train
MichaelPavlista/palette
src/Picture.php
Picture.getDimensions
public function getDimensions() { $imageDimension = getimagesize($this->image); $width = $imageDimension[0]; $height = $imageDimension[1]; foreach($this->effect as $effect) { if($effect instanceof PictureEffect) { $modified = $effect->getNewDimensions($width, $height); $width = $modified['w']; $height = $modified['h']; } } return array( 'w' => $width, 'h' => $height, ); }
php
public function getDimensions() { $imageDimension = getimagesize($this->image); $width = $imageDimension[0]; $height = $imageDimension[1]; foreach($this->effect as $effect) { if($effect instanceof PictureEffect) { $modified = $effect->getNewDimensions($width, $height); $width = $modified['w']; $height = $modified['h']; } } return array( 'w' => $width, 'h' => $height, ); }
[ "public", "function", "getDimensions", "(", ")", "{", "$", "imageDimension", "=", "getimagesize", "(", "$", "this", "->", "image", ")", ";", "$", "width", "=", "$", "imageDimension", "[", "0", "]", ";", "$", "height", "=", "$", "imageDimension", "[", "...
Getting new dimensions for applying effects to an image, the image does not save @return array w,h
[ "Getting", "new", "dimensions", "for", "applying", "effects", "to", "an", "image", "the", "image", "does", "not", "save" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Picture.php#L836-L859
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.perspective
public function perspective($dx1, $dy1, $dx2, $dy2, $dx3, $dy3, $dx4, $dy4, $sx1 = null, $sy1 = null, $sx2 = null, $sy2 = null, $sx3 = null, $sy3 = null, $sx4 = null, $sy4 = null) { if (!is_null($sx1) || !is_null($sy1) || !is_null($sx2) || !is_null($sy2) || !is_null($sx3) || !is_null($sy3) || !is_null($sx4) || !is_null($sy4)) { $params = [$sx1, $sy1, $dx1, $dy1, $sx2, $sy2, $dx2, $dy2, $sx3, $sy3, $dx3, $dy3, $sx4, $sy4, $dx4, $dy4]; } else { $params = [$dx1, $dy1, $dx2, $dy2, $dx3, $dy3, $dx4, $dy4]; } return $this->addItem('e', 'perspective', implode(',', $params)); }
php
public function perspective($dx1, $dy1, $dx2, $dy2, $dx3, $dy3, $dx4, $dy4, $sx1 = null, $sy1 = null, $sx2 = null, $sy2 = null, $sx3 = null, $sy3 = null, $sx4 = null, $sy4 = null) { if (!is_null($sx1) || !is_null($sy1) || !is_null($sx2) || !is_null($sy2) || !is_null($sx3) || !is_null($sy3) || !is_null($sx4) || !is_null($sy4)) { $params = [$sx1, $sy1, $dx1, $dy1, $sx2, $sy2, $dx2, $dy2, $sx3, $sy3, $dx3, $dy3, $sx4, $sy4, $dx4, $dy4]; } else { $params = [$dx1, $dy1, $dx2, $dy2, $dx3, $dy3, $dx4, $dy4]; } return $this->addItem('e', 'perspective', implode(',', $params)); }
[ "public", "function", "perspective", "(", "$", "dx1", ",", "$", "dy1", ",", "$", "dx2", ",", "$", "dy2", ",", "$", "dx3", ",", "$", "dy3", ",", "$", "dx4", ",", "$", "dy4", ",", "$", "sx1", "=", "null", ",", "$", "sy1", "=", "null", ",", "$...
Add perspective transformation. @param int $dx1 destination x1 @param int $dy1 destination y1 @param int $dx2 destination x2 @param int $dy2 destination y2 @param int $dx3 destination x3 @param int $dy3 destination y3 @param int $dx4 destination x4 @param int $dy4 destination y4 @param int $sx1 source x1 @param int $sy1 source y1 @param int $sx2 source x2 @param int $sy2 source y2 @param int $sx3 source x3 @param int $sy3 source y3 @param int $sx4 source x4 @param int $sy4 source y4 @return \self
[ "Add", "perspective", "transformation", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L607-L615
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.border
public function border($top, $right = null, $bottom = null, $left = null) { return $this->addItem('border', implode(',', func_get_args())); }
php
public function border($top, $right = null, $bottom = null, $left = null) { return $this->addItem('border', implode(',', func_get_args())); }
[ "public", "function", "border", "(", "$", "top", ",", "$", "right", "=", "null", ",", "$", "bottom", "=", "null", ",", "$", "left", "=", "null", ")", "{", "return", "$", "this", "->", "addItem", "(", "'border'", ",", "implode", "(", "','", ",", "...
Applies a border to the image. Use <b>color()</b> to specify the color of the border. Parameters behave like CSS border sizes, the number of given parameters modifies the function behaviour. <li>If 1 parameter is given, all borders have the same size. <li>If 2 parameters are given, the parameters are interpreted as vertical and horizontal borders. <li>If 3 parameters are given, the parameters are interpreted as top, vertical and bottom borders. <li>If 4 parameters are given, all borders have their respective sizes. @param int $top All/vertical/top border size @param int $right Horizontal/right border size @param int $bottom Bottom border size @param int $left Left border size @return \self
[ "Applies", "a", "border", "to", "the", "image", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L659-L662
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.round
public function round($topLeft, $topRight = null, $bottomRight = null, $bottomLeft = null) { return $this->addItem('ro', implode(',', func_get_args())); }
php
public function round($topLeft, $topRight = null, $bottomRight = null, $bottomLeft = null) { return $this->addItem('ro', implode(',', func_get_args())); }
[ "public", "function", "round", "(", "$", "topLeft", ",", "$", "topRight", "=", "null", ",", "$", "bottomRight", "=", "null", ",", "$", "bottomLeft", "=", "null", ")", "{", "return", "$", "this", "->", "addItem", "(", "'ro'", ",", "implode", "(", "','...
Rounds the corners of the image. Parameters behave like CSS border radiuses, the number of given parameters modifies the function behaviour. Either 1 or 4 parameters are required. <li>If 1 parameter is given, all corners are rounded with the same radius. <li>If 4 parameters are given, corners are rounded with their respective radiuses. @param type $topLeft General radius or radius on the top left corner @param type $topRight Radius on the top right corner @param type $bottomRight Radius on the bottom right corner @param type $bottomLeft Radius on the bottom left corner @return \self
[ "Rounds", "the", "corners", "of", "the", "image", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L683-L686
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.jpegoptim
public function jpegoptim($quality = null) { return $quality === null ? $this->addItem('q', 'jpegoptim') : $this->addItem('q', 'jpegoptim', $quality); }
php
public function jpegoptim($quality = null) { return $quality === null ? $this->addItem('q', 'jpegoptim') : $this->addItem('q', 'jpegoptim', $quality); }
[ "public", "function", "jpegoptim", "(", "$", "quality", "=", "null", ")", "{", "return", "$", "quality", "===", "null", "?", "$", "this", "->", "addItem", "(", "'q'", ",", "'jpegoptim'", ")", ":", "$", "this", "->", "addItem", "(", "'q'", ",", "'jpeg...
Turns on jpegoptim, which greatly reduces the size of jpeg images. @param int $quality maximum quality @return \self
[ "Turns", "on", "jpegoptim", "which", "greatly", "reduces", "the", "size", "of", "jpeg", "images", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L769-L772
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.addItem
private function addItem() { $args = func_get_args(); if (in_array($args[0], self::$appendableTransformations)) { $i = $this->findLastTransformation($args[0]); if ($i !== false) { $this->items[$i]['rendered'] .= ','.implode(':', array_slice($args, 1)); return $this; } } if ($args[0] != '/' && $this->itemCount && in_array($this->items[$this->itemCount - 1]['type'], self::$forcedLastTransformations)) { $lastTransformation = array_pop($this->items); } $this->items[] = [ 'type' => $args[0], 'rendered' => implode(':', $args), ]; ++$this->itemCount; if (isset($lastTransformation)) { $this->items[] = $lastTransformation; } return $this; }
php
private function addItem() { $args = func_get_args(); if (in_array($args[0], self::$appendableTransformations)) { $i = $this->findLastTransformation($args[0]); if ($i !== false) { $this->items[$i]['rendered'] .= ','.implode(':', array_slice($args, 1)); return $this; } } if ($args[0] != '/' && $this->itemCount && in_array($this->items[$this->itemCount - 1]['type'], self::$forcedLastTransformations)) { $lastTransformation = array_pop($this->items); } $this->items[] = [ 'type' => $args[0], 'rendered' => implode(':', $args), ]; ++$this->itemCount; if (isset($lastTransformation)) { $this->items[] = $lastTransformation; } return $this; }
[ "private", "function", "addItem", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "in_array", "(", "$", "args", "[", "0", "]", ",", "self", "::", "$", "appendableTransformations", ")", ")", "{", "$", "i", "=", "$", "this...
Adds a new transformation item to the chain. @return \self
[ "Adds", "a", "new", "transformation", "item", "to", "the", "chain", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L978-L1002
train
shardimage/shardimage-php
src/factories/Transformation.php
Transformation.render
private function render() { $transformation = implode('_', array_column($this->items, 'rendered')); $transformation = preg_replace('#(_?/_?)+#isu', '/', $transformation); $transformation = trim($transformation, '/_'); return $transformation; }
php
private function render() { $transformation = implode('_', array_column($this->items, 'rendered')); $transformation = preg_replace('#(_?/_?)+#isu', '/', $transformation); $transformation = trim($transformation, '/_'); return $transformation; }
[ "private", "function", "render", "(", ")", "{", "$", "transformation", "=", "implode", "(", "'_'", ",", "array_column", "(", "$", "this", "->", "items", ",", "'rendered'", ")", ")", ";", "$", "transformation", "=", "preg_replace", "(", "'#(_?/_?)+#isu'", "...
Renders the transformation URL string. @return string
[ "Renders", "the", "transformation", "URL", "string", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Transformation.php#L1022-L1029
train
dazzle-php/channel-socket
src/Channel-Socket/Socket.php
Socket.stopHeartbeat
private function stopHeartbeat() { if ($this->hTimer !== null) { $this->hTimer->cancel(); $this->hTimer = null; } }
php
private function stopHeartbeat() { if ($this->hTimer !== null) { $this->hTimer->cancel(); $this->hTimer = null; } }
[ "private", "function", "stopHeartbeat", "(", ")", "{", "if", "(", "$", "this", "->", "hTimer", "!==", "null", ")", "{", "$", "this", "->", "hTimer", "->", "cancel", "(", ")", ";", "$", "this", "->", "hTimer", "=", "null", ";", "}", "}" ]
Stop hearbeat.
[ "Stop", "hearbeat", "." ]
1be56e6d819945fb559f0848b1d533901dbcbe7b
https://github.com/dazzle-php/channel-socket/blob/1be56e6d819945fb559f0848b1d533901dbcbe7b/src/Channel-Socket/Socket.php#L878-L885
train
dazzle-php/channel-socket
src/Channel-Socket/Socket.php
Socket.clearConnectionPool
private function clearConnectionPool() { $deleted = $this->connectionPool->removeInvalid(); foreach ($deleted as $deletedid) { $this->emit('disconnect', [ $deletedid ]); } }
php
private function clearConnectionPool() { $deleted = $this->connectionPool->removeInvalid(); foreach ($deleted as $deletedid) { $this->emit('disconnect', [ $deletedid ]); } }
[ "private", "function", "clearConnectionPool", "(", ")", "{", "$", "deleted", "=", "$", "this", "->", "connectionPool", "->", "removeInvalid", "(", ")", ";", "foreach", "(", "$", "deleted", "as", "$", "deletedid", ")", "{", "$", "this", "->", "emit", "(",...
Clear connection pool.
[ "Clear", "connection", "pool", "." ]
1be56e6d819945fb559f0848b1d533901dbcbe7b
https://github.com/dazzle-php/channel-socket/blob/1be56e6d819945fb559f0848b1d533901dbcbe7b/src/Channel-Socket/Socket.php#L890-L898
train
dazzle-php/channel-socket
src/Channel-Socket/Socket.php
Socket.startTimeRegister
private function startTimeRegister() { if ($this->rTimer === null && $this->flags['enableHeartbeat'] === true && $this->flags['enableTimeRegister'] === true) { $proxy = $this; $this->rTimer = $this->loop->addPeriodicTimer(($this->options['timeRegisterInterval']/1000), function() use($proxy) { $now = round(microtime(true)*1000); $proxy->connectionPool->setNow(function() use($now) { return $now; }); }); } }
php
private function startTimeRegister() { if ($this->rTimer === null && $this->flags['enableHeartbeat'] === true && $this->flags['enableTimeRegister'] === true) { $proxy = $this; $this->rTimer = $this->loop->addPeriodicTimer(($this->options['timeRegisterInterval']/1000), function() use($proxy) { $now = round(microtime(true)*1000); $proxy->connectionPool->setNow(function() use($now) { return $now; }); }); } }
[ "private", "function", "startTimeRegister", "(", ")", "{", "if", "(", "$", "this", "->", "rTimer", "===", "null", "&&", "$", "this", "->", "flags", "[", "'enableHeartbeat'", "]", "===", "true", "&&", "$", "this", "->", "flags", "[", "'enableTimeRegister'",...
Start time register. Time register purpose is to cyclically increase timestamp representing last time of tick of event loop. This method allows model to not mark external sockets wrongly as offline because of its own heavy load.
[ "Start", "time", "register", "." ]
1be56e6d819945fb559f0848b1d533901dbcbe7b
https://github.com/dazzle-php/channel-socket/blob/1be56e6d819945fb559f0848b1d533901dbcbe7b/src/Channel-Socket/Socket.php#L906-L918
train
dazzle-php/channel-socket
src/Channel-Socket/Socket.php
Socket.stopTimeRegister
private function stopTimeRegister() { if ($this->rTimer !== null) { $this->rTimer->cancel(); $this->rTimer = null; $this->connectionPool->resetNow(); } }
php
private function stopTimeRegister() { if ($this->rTimer !== null) { $this->rTimer->cancel(); $this->rTimer = null; $this->connectionPool->resetNow(); } }
[ "private", "function", "stopTimeRegister", "(", ")", "{", "if", "(", "$", "this", "->", "rTimer", "!==", "null", ")", "{", "$", "this", "->", "rTimer", "->", "cancel", "(", ")", ";", "$", "this", "->", "rTimer", "=", "null", ";", "$", "this", "->",...
Stop time register.
[ "Stop", "time", "register", "." ]
1be56e6d819945fb559f0848b1d533901dbcbe7b
https://github.com/dazzle-php/channel-socket/blob/1be56e6d819945fb559f0848b1d533901dbcbe7b/src/Channel-Socket/Socket.php#L923-L931
train
klermonte/zerg
src/Zerg/Field/Enum.php
Enum.read
public function read(AbstractStream $stream) { $key = parent::read($stream); $values = $this->getValues(); if (array_key_exists($key, $values)) { $value = $values[$key]; } else { $value = $this->getDefault(); } if ($value === null) { throw new InvalidKeyException( "Value '{$key}' does not correspond to a valid enum key. Presented keys: '" . implode("', '", array_keys($values)) . "'" ); } return $value; }
php
public function read(AbstractStream $stream) { $key = parent::read($stream); $values = $this->getValues(); if (array_key_exists($key, $values)) { $value = $values[$key]; } else { $value = $this->getDefault(); } if ($value === null) { throw new InvalidKeyException( "Value '{$key}' does not correspond to a valid enum key. Presented keys: '" . implode("', '", array_keys($values)) . "'" ); } return $value; }
[ "public", "function", "read", "(", "AbstractStream", "$", "stream", ")", "{", "$", "key", "=", "parent", "::", "read", "(", "$", "stream", ")", ";", "$", "values", "=", "$", "this", "->", "getValues", "(", ")", ";", "if", "(", "array_key_exists", "("...
Read key from Stream, and return value by this key or default value. @param AbstractStream $stream Stream from which resolved field reads. @return object|integer|double|string|array|boolean|callable Value by read key or default value if present. @throws InvalidKeyException If read key is not exist and default value is not presented.
[ "Read", "key", "from", "Stream", "and", "return", "value", "by", "this", "key", "or", "default", "value", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Enum.php#L40-L59
train
RyanNielson/shareable
src/RyanNielson/Shareable/Shareable.php
Shareable.all
public function all() { $defaultButtons = Config::get('shareable::default_buttons', array()); $buttons = array(); $output = ''; foreach ($defaultButtons as $button) { $buttons[] = call_user_func(array($this, $button)); } return $this->view->make('shareable::all', array('buttons' => $buttons)); }
php
public function all() { $defaultButtons = Config::get('shareable::default_buttons', array()); $buttons = array(); $output = ''; foreach ($defaultButtons as $button) { $buttons[] = call_user_func(array($this, $button)); } return $this->view->make('shareable::all', array('buttons' => $buttons)); }
[ "public", "function", "all", "(", ")", "{", "$", "defaultButtons", "=", "Config", "::", "get", "(", "'shareable::default_buttons'", ",", "array", "(", ")", ")", ";", "$", "buttons", "=", "array", "(", ")", ";", "$", "output", "=", "''", ";", "foreach",...
Returns all social sharing buttons. @return string
[ "Returns", "all", "social", "sharing", "buttons", "." ]
cc766f7685a31680e672d9b7086ce0603ce5b12e
https://github.com/RyanNielson/shareable/blob/cc766f7685a31680e672d9b7086ce0603ce5b12e/src/RyanNielson/Shareable/Shareable.php#L23-L34
train
scherersoftware/cake-cktools
src/Model/Behavior/StrictPasswordBehavior.php
StrictPasswordBehavior.buildValidator
public function buildValidator(Event $event, Validator $validator, string $name): void { $this->validationStrictPassword($validator); }
php
public function buildValidator(Event $event, Validator $validator, string $name): void { $this->validationStrictPassword($validator); }
[ "public", "function", "buildValidator", "(", "Event", "$", "event", ",", "Validator", "$", "validator", ",", "string", "$", "name", ")", ":", "void", "{", "$", "this", "->", "validationStrictPassword", "(", "$", "validator", ")", ";", "}" ]
Set strict validation @param \Cake\Event\Event $event Event @param \Cake\Validation\Validator $validator Validator @param string $name Name @return void
[ "Set", "strict", "validation" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/StrictPasswordBehavior.php#L63-L66
train
scherersoftware/cake-cktools
src/Model/Behavior/StrictPasswordBehavior.php
StrictPasswordBehavior.validationStrictPassword
public function validationStrictPassword(Validator $validator): Validator { $validator ->add('password', [ 'minLength' => [ 'rule' => ['minLength', $this->getConfig('minPasswordLength')], 'last' => true, 'message' => __d('ck_tools', 'validation.user.password_min_length'), ], ]) ->add('password', 'passwordFormat', [ 'rule' => function ($value, $context) { return $this->validFormat($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_invalid_format'), ]) ->add('password', 'passwordNoUserName', [ 'rule' => function ($value, $context) { return $this->checkForUserName($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_user_name_not_allowed'), ]) ->add('password', 'passwordUsedBefore', [ 'rule' => function ($value, $context) { return $this->checkLastPasswords($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_used_before'), ]); return $validator; }
php
public function validationStrictPassword(Validator $validator): Validator { $validator ->add('password', [ 'minLength' => [ 'rule' => ['minLength', $this->getConfig('minPasswordLength')], 'last' => true, 'message' => __d('ck_tools', 'validation.user.password_min_length'), ], ]) ->add('password', 'passwordFormat', [ 'rule' => function ($value, $context) { return $this->validFormat($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_invalid_format'), ]) ->add('password', 'passwordNoUserName', [ 'rule' => function ($value, $context) { return $this->checkForUserName($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_user_name_not_allowed'), ]) ->add('password', 'passwordUsedBefore', [ 'rule' => function ($value, $context) { return $this->checkLastPasswords($value, $context); }, 'message' => __d('ck_tools', 'validation.user.password_used_before'), ]); return $validator; }
[ "public", "function", "validationStrictPassword", "(", "Validator", "$", "validator", ")", ":", "Validator", "{", "$", "validator", "->", "add", "(", "'password'", ",", "[", "'minLength'", "=>", "[", "'rule'", "=>", "[", "'minLength'", ",", "$", "this", "->"...
Strict password validation rules. @param \Cake\Validation\Validator $validator Validator instance. @return \Cake\Validation\Validator
[ "Strict", "password", "validation", "rules", "." ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/StrictPasswordBehavior.php#L74-L104
train
scherersoftware/cake-cktools
src/Model/Behavior/StrictPasswordBehavior.php
StrictPasswordBehavior.checkForUserName
public function checkForUserName(string $value, array $context): bool { // return true if config is not set if (empty($this->getConfig('noUserName'))) { return true; } // Get Config $firstNameField = $this->getConfig('userNameFields.firstname'); $lastNameField = $this->getConfig('userNameFields.lastname'); // No Usernames in Context if (empty($context['data'][$firstNameField]) || empty($context['data'][$lastNameField])) { if (!empty($context['data']['id'])) { $user = $this->_table->get($context['data']['id']); $firstname = $user->$firstNameField; $lastname = $user->$lastNameField; } else { // no name to check return true; } } else { $firstname = $context['data'][$firstNameField]; $lastname = $context['data'][$lastNameField]; } // validate password if (!empty($firstname) && strpos(strtolower($value), strtolower($firstname)) !== false) { return false; } if (!empty($lastname) && strpos(strtolower($value), strtolower($lastname)) !== false) { return false; } return true; }
php
public function checkForUserName(string $value, array $context): bool { // return true if config is not set if (empty($this->getConfig('noUserName'))) { return true; } // Get Config $firstNameField = $this->getConfig('userNameFields.firstname'); $lastNameField = $this->getConfig('userNameFields.lastname'); // No Usernames in Context if (empty($context['data'][$firstNameField]) || empty($context['data'][$lastNameField])) { if (!empty($context['data']['id'])) { $user = $this->_table->get($context['data']['id']); $firstname = $user->$firstNameField; $lastname = $user->$lastNameField; } else { // no name to check return true; } } else { $firstname = $context['data'][$firstNameField]; $lastname = $context['data'][$lastNameField]; } // validate password if (!empty($firstname) && strpos(strtolower($value), strtolower($firstname)) !== false) { return false; } if (!empty($lastname) && strpos(strtolower($value), strtolower($lastname)) !== false) { return false; } return true; }
[ "public", "function", "checkForUserName", "(", "string", "$", "value", ",", "array", "$", "context", ")", ":", "bool", "{", "// return true if config is not set", "if", "(", "empty", "(", "$", "this", "->", "getConfig", "(", "'noUserName'", ")", ")", ")", "{...
Check for username used in password @param string $value password @param array $context context data @return bool
[ "Check", "for", "username", "used", "in", "password" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/StrictPasswordBehavior.php#L142-L176
train
scherersoftware/cake-cktools
src/Model/Behavior/StrictPasswordBehavior.php
StrictPasswordBehavior.checkLastPasswords
public function checkLastPasswords(string $value, array $context): bool { // return true if config is not set if (empty($this->getConfig('oldPasswordCount'))) { return true; } // ignore on new user if (empty($context['data']['id'])) { return true; } $user = $this->_table->get($context['data']['id']); if (is_array($user->last_passwords)) { foreach ($user->last_passwords as $oldPasswordHash) { if ((new DefaultPasswordHasher)->check($value, $oldPasswordHash)) { return false; } } } return true; }
php
public function checkLastPasswords(string $value, array $context): bool { // return true if config is not set if (empty($this->getConfig('oldPasswordCount'))) { return true; } // ignore on new user if (empty($context['data']['id'])) { return true; } $user = $this->_table->get($context['data']['id']); if (is_array($user->last_passwords)) { foreach ($user->last_passwords as $oldPasswordHash) { if ((new DefaultPasswordHasher)->check($value, $oldPasswordHash)) { return false; } } } return true; }
[ "public", "function", "checkLastPasswords", "(", "string", "$", "value", ",", "array", "$", "context", ")", ":", "bool", "{", "// return true if config is not set", "if", "(", "empty", "(", "$", "this", "->", "getConfig", "(", "'oldPasswordCount'", ")", ")", "...
Check for reusage of old passwords @param string $value password @param array $context context data @return bool
[ "Check", "for", "reusage", "of", "old", "passwords" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/StrictPasswordBehavior.php#L185-L207
train
scherersoftware/cake-cktools
src/Model/Behavior/StrictPasswordBehavior.php
StrictPasswordBehavior.beforeSave
public function beforeSave(Event $event, EntityInterface $entity): bool { if (empty($this->getConfig('oldPasswordCount')) || !is_numeric($this->getConfig('oldPasswordCount'))) { return true; } if (!is_array($entity->last_passwords)) { $entity->last_passwords = []; } $lastPasswords = $entity->last_passwords; if (count($lastPasswords) == $this->getConfig('oldPasswordCount')) { array_shift($lastPasswords); } $lastPasswords[] = $entity->password; $entity->setAccess('last_passwords', true); $this->_table->patchEntity($entity, [ 'last_passwords' => $lastPasswords, ]); return true; }
php
public function beforeSave(Event $event, EntityInterface $entity): bool { if (empty($this->getConfig('oldPasswordCount')) || !is_numeric($this->getConfig('oldPasswordCount'))) { return true; } if (!is_array($entity->last_passwords)) { $entity->last_passwords = []; } $lastPasswords = $entity->last_passwords; if (count($lastPasswords) == $this->getConfig('oldPasswordCount')) { array_shift($lastPasswords); } $lastPasswords[] = $entity->password; $entity->setAccess('last_passwords', true); $this->_table->patchEntity($entity, [ 'last_passwords' => $lastPasswords, ]); return true; }
[ "public", "function", "beforeSave", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "this", "->", "getConfig", "(", "'oldPasswordCount'", ")", ")", "||", "!", "is_numeric", "(", "$",...
BeforeSave Event to update last passwords @param \Cake\Event\Event $event Event @param \Cake\Datasource\EntityInterface $entity Entity @return bool
[ "BeforeSave", "Event", "to", "update", "last", "passwords" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/StrictPasswordBehavior.php#L216-L237
train
koolkode/async
src/Concurrent/Process/RemoteProcessFactory.php
RemoteProcessFactory.spawnProcess
protected static function spawnProcess(string $cmd, array $spec, ?array & $pipes, ?string $dir = null, ?array $env = null, bool $bypassShell = false) { return @\proc_open($cmd, $spec, $pipes, $dir, $env, $bypassShell ? [ 'bypass_shell' => true ] : []); }
php
protected static function spawnProcess(string $cmd, array $spec, ?array & $pipes, ?string $dir = null, ?array $env = null, bool $bypassShell = false) { return @\proc_open($cmd, $spec, $pipes, $dir, $env, $bypassShell ? [ 'bypass_shell' => true ] : []); }
[ "protected", "static", "function", "spawnProcess", "(", "string", "$", "cmd", ",", "array", "$", "spec", ",", "?", "array", "&", "$", "pipes", ",", "?", "string", "$", "dir", "=", "null", ",", "?", "array", "$", "env", "=", "null", ",", "bool", "$"...
Spawn a new process. @param string $cmd Command to be executed. @param array $spec IO pipe specification. @param array $pipes Will be populated with pipes created for the process. @param string $dir Working directory to be used by the spawned process. @param array $env Environment variables to be passed to the process. @return resource Process resource or false in case of an error.
[ "Spawn", "a", "new", "process", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Process/RemoteProcessFactory.php#L207-L212
train
Speelpenning-nl/laravel-authentication
src/Http/Controllers/UserController.php
UserController.store
public function store(StoreUserRequest $request, Repository $config) { $this->dispatch(new RegisterUser($request->get('name'), $request->get('email'), $request->get('password'))); return redirect($config->get('authentication.registration.redirectUri')); }
php
public function store(StoreUserRequest $request, Repository $config) { $this->dispatch(new RegisterUser($request->get('name'), $request->get('email'), $request->get('password'))); return redirect($config->get('authentication.registration.redirectUri')); }
[ "public", "function", "store", "(", "StoreUserRequest", "$", "request", ",", "Repository", "$", "config", ")", "{", "$", "this", "->", "dispatch", "(", "new", "RegisterUser", "(", "$", "request", "->", "get", "(", "'name'", ")", ",", "$", "request", "->"...
Attempts to register the user. @param StoreUserRequest $request @param Repository $config @return RedirectResponse
[ "Attempts", "to", "register", "the", "user", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/UserController.php#L36-L41
train
opichon/UAMDatatablesBundle
Controller/DatatablesEnabledControllerTrait.php
DatatablesEnabledControllerTrait.listAction
public function listAction(Request $request) { $manager = $this->getEntityManager(); $total_count = $manager->getTotalCount($request); $filtered_count = $manager->getFilteredCount($request); $entities = $manager->getEntities($request); return array_merge( $this->getExtraTemplateParameters($request), array( 'total_count' => $total_count, 'filtered_count' => $filtered_count, 'entities' => $entities, ) ); }
php
public function listAction(Request $request) { $manager = $this->getEntityManager(); $total_count = $manager->getTotalCount($request); $filtered_count = $manager->getFilteredCount($request); $entities = $manager->getEntities($request); return array_merge( $this->getExtraTemplateParameters($request), array( 'total_count' => $total_count, 'filtered_count' => $filtered_count, 'entities' => $entities, ) ); }
[ "public", "function", "listAction", "(", "Request", "$", "request", ")", "{", "$", "manager", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "total_count", "=", "$", "manager", "->", "getTotalCount", "(", "$", "request", ")", ";", "$", ...
List action. Returns the records data in JSON format. This action is the target of the dataTables plugin's ajax request for obtaining server-side data. @param Request $request the current request @return Array An array of template parameters. These include: * `entities`: the PropelCollection or array of entities returned by the Propel query * `total_count`: the total number of records (before any filters are applied) * `filtered_count`: the number of records after filters are applied @uses getLimit()
[ "List", "action", ".", "Returns", "the", "records", "data", "in", "JSON", "format", ".", "This", "action", "is", "the", "target", "of", "the", "dataTables", "plugin", "s", "ajax", "request", "for", "obtaining", "server", "-", "side", "data", "." ]
48a3fcee4d768837b568c3753527c47f57422dca
https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Controller/DatatablesEnabledControllerTrait.php#L58-L76
train
opichon/UAMDatatablesBundle
Controller/DatatablesEnabledControllerTrait.php
DatatablesEnabledControllerTrait.getFilter
protected function getFilter(Request $request) { if ($filter_type = $this->getEntityManager()->getFilterType($request)) { return $this->createForm($filter_type); } }
php
protected function getFilter(Request $request) { if ($filter_type = $this->getEntityManager()->getFilterType($request)) { return $this->createForm($filter_type); } }
[ "protected", "function", "getFilter", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "filter_type", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "getFilterType", "(", "$", "request", ")", ")", "{", "return", "$", "this", "->", ...
Returns a form that will be used by the `index` action to create a view which is then passed to the `index.html.twig` template as a parameter named `filter`. @param Request $request the current request @return Symfony\Component\Form\FormInterface|null a form @uses EntityManagerInterface::getFilterType
[ "Returns", "a", "form", "that", "will", "be", "used", "by", "the", "index", "action", "to", "create", "a", "view", "which", "is", "then", "passed", "to", "the", "index", ".", "html", ".", "twig", "template", "as", "a", "parameter", "named", "filter", "...
48a3fcee4d768837b568c3753527c47f57422dca
https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Controller/DatatablesEnabledControllerTrait.php#L102-L107
train
scherersoftware/cake-cktools
src/Utility/TypeAwareTrait.php
TypeAwareTrait.getTypeDescription
public static function getTypeDescription(?string $type): ?string { $descriptions = self::typeDescriptions(); if (isset($descriptions[$type])) { return $descriptions[$type]; } return $type; }
php
public static function getTypeDescription(?string $type): ?string { $descriptions = self::typeDescriptions(); if (isset($descriptions[$type])) { return $descriptions[$type]; } return $type; }
[ "public", "static", "function", "getTypeDescription", "(", "?", "string", "$", "type", ")", ":", "?", "string", "{", "$", "descriptions", "=", "self", "::", "typeDescriptions", "(", ")", ";", "if", "(", "isset", "(", "$", "descriptions", "[", "$", "type"...
Get the description for the given type @param string|null $type type to get description of @return string
[ "Get", "the", "description", "for", "the", "given", "type" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/TypeAwareTrait.php#L28-L36
train
kassko/data-mapper
src/Result/IterableResultHydrator.php
IterableResultHydrator.hydrate
public function hydrate($objectClass, array $data, $indexOfBy = false) { $this->objectClass = $objectClass; if (0 == count($data)) { yield $this->createObjectToHydrate($this->objectClass); } elseif (! is_array(current($data))) { yield $this->hydrateItem($this->objectClass, $data); } elseif (false === $indexOfBy) { foreach ($data as $item) { yield $this->hydrateItem($this->objectClass, $item); } } else { foreach ($this->hydrateBy($data, $indexOfBy) as $valueOfBy => $item) { yield $valueOfBy => $item; } } }
php
public function hydrate($objectClass, array $data, $indexOfBy = false) { $this->objectClass = $objectClass; if (0 == count($data)) { yield $this->createObjectToHydrate($this->objectClass); } elseif (! is_array(current($data))) { yield $this->hydrateItem($this->objectClass, $data); } elseif (false === $indexOfBy) { foreach ($data as $item) { yield $this->hydrateItem($this->objectClass, $item); } } else { foreach ($this->hydrateBy($data, $indexOfBy) as $valueOfBy => $item) { yield $valueOfBy => $item; } } }
[ "public", "function", "hydrate", "(", "$", "objectClass", ",", "array", "$", "data", ",", "$", "indexOfBy", "=", "false", ")", "{", "$", "this", "->", "objectClass", "=", "$", "objectClass", ";", "if", "(", "0", "==", "count", "(", "$", "data", ")", ...
Hydrate results. @param array $data Raw results. @return Generator
[ "Hydrate", "results", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/Result/IterableResultHydrator.php#L21-L42
train
koolkode/async
src/Loop/Busy.php
Busy.done
public function done() { if ($this->watcher) { if ($this->watcher->count > 0) { $this->watcher->count--; } $this->watcher = null; } }
php
public function done() { if ($this->watcher) { if ($this->watcher->count > 0) { $this->watcher->count--; } $this->watcher = null; } }
[ "public", "function", "done", "(", ")", "{", "if", "(", "$", "this", "->", "watcher", ")", "{", "if", "(", "$", "this", "->", "watcher", "->", "count", ">", "0", ")", "{", "$", "this", "->", "watcher", "->", "count", "--", ";", "}", "$", "this"...
Stop the event loop from being busy due to this object.
[ "Stop", "the", "event", "loop", "from", "being", "busy", "due", "to", "this", "object", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Loop/Busy.php#L57-L66
train
dionsnoeijen/sexy-field
src/SectionField/Service/DoctrineSectionManager.php
DoctrineSectionManager.restoreFromHistory
public function restoreFromHistory(SectionInterface $sectionFromHistory): SectionInterface { /** @var SectionInterface $activeSection */ $activeSection = $this->readByHandle($sectionFromHistory->getHandle()); // 1 /** @var SectionInterface $newSectionHistory */ $newSectionHistory = $this->copySectionDataToSectionHistoryEntity($activeSection); // 2 $newSectionHistory->setVersioned(new \DateTime()); // 3 $version = $this->getHighestVersion($newSectionHistory->getHandle()); $newSectionHistory->setVersion(1 + $version->toInt()); $this->sectionHistoryManager->create($newSectionHistory); // 3 $updatedActiveSection = $this->copySectionHistoryDataToSectionEntity($sectionFromHistory, $activeSection); // 4 $updatedActiveSection->removeFields(); // 5 $this->entityManager->persist($updatedActiveSection); $this->entityManager->flush(); $fields = $this->fieldManager->readByHandles($updatedActiveSection->getConfig()->getFields()); // 6 foreach ($fields as $field) { $updatedActiveSection->addField($field); } // 7 $this->entityManager->persist($updatedActiveSection); $this->entityManager->flush(); return $updatedActiveSection; }
php
public function restoreFromHistory(SectionInterface $sectionFromHistory): SectionInterface { /** @var SectionInterface $activeSection */ $activeSection = $this->readByHandle($sectionFromHistory->getHandle()); // 1 /** @var SectionInterface $newSectionHistory */ $newSectionHistory = $this->copySectionDataToSectionHistoryEntity($activeSection); // 2 $newSectionHistory->setVersioned(new \DateTime()); // 3 $version = $this->getHighestVersion($newSectionHistory->getHandle()); $newSectionHistory->setVersion(1 + $version->toInt()); $this->sectionHistoryManager->create($newSectionHistory); // 3 $updatedActiveSection = $this->copySectionHistoryDataToSectionEntity($sectionFromHistory, $activeSection); // 4 $updatedActiveSection->removeFields(); // 5 $this->entityManager->persist($updatedActiveSection); $this->entityManager->flush(); $fields = $this->fieldManager->readByHandles($updatedActiveSection->getConfig()->getFields()); // 6 foreach ($fields as $field) { $updatedActiveSection->addField($field); } // 7 $this->entityManager->persist($updatedActiveSection); $this->entityManager->flush(); return $updatedActiveSection; }
[ "public", "function", "restoreFromHistory", "(", "SectionInterface", "$", "sectionFromHistory", ")", ":", "SectionInterface", "{", "/** @var SectionInterface $activeSection */", "$", "activeSection", "=", "$", "this", "->", "readByHandle", "(", "$", "sectionFromHistory", ...
Restore an old version of a section by it's handle and version 1. Fetch the currently active section 2. Copy the section history data to the active section entity, including the version 3. Move the currently active section to history 4. Clean the field associations from the updated active section 5. Fetch the fields from the 'old' section config 6. Assign the fields to the section 7. Persist the active section This section might be generated from an updated config yml. Meaning the current config might not comply with the active section configuration anymore. This will only update the config stored in the database. The generators will have to be called to make the version change complete. @param $sectionFromHistory @return SectionInterface
[ "Restore", "an", "old", "version", "of", "a", "section", "by", "it", "s", "handle", "and", "version" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/DoctrineSectionManager.php#L156-L184
train
dionsnoeijen/sexy-field
src/SectionField/Service/DoctrineSectionManager.php
DoctrineSectionManager.updateByConfig
public function updateByConfig( SectionConfig $sectionConfig, SectionInterface $section, bool $history = false ): SectionInterface { if ($history) { /** @var SectionInterface $sectionHistory */ $sectionHistory = $this->copySectionDataToSectionHistoryEntity($section); // 1 $sectionHistory->setVersioned(new \DateTime()); // 2 $this->sectionHistoryManager->create($sectionHistory); // 2 $version = $this->getHighestVersion($section->getHandle()); $section->setVersion(1 + $version->toInt()); // 3 } $section->removeFields(); // 4 $fields = $this->fieldManager->readByHandles($sectionConfig->getFields()); // 5 foreach ($fields as $field) { $section->addField($field); } // 6 $section->setName((string) $sectionConfig->getName()); // 7 $section->setHandle((string) $sectionConfig->getHandle()); // 7 $section->setConfig($sectionConfig->toArray()); // 8 $this->entityManager->persist($section); // 9 $this->entityManager->flush(); // 9 return $section; }
php
public function updateByConfig( SectionConfig $sectionConfig, SectionInterface $section, bool $history = false ): SectionInterface { if ($history) { /** @var SectionInterface $sectionHistory */ $sectionHistory = $this->copySectionDataToSectionHistoryEntity($section); // 1 $sectionHistory->setVersioned(new \DateTime()); // 2 $this->sectionHistoryManager->create($sectionHistory); // 2 $version = $this->getHighestVersion($section->getHandle()); $section->setVersion(1 + $version->toInt()); // 3 } $section->removeFields(); // 4 $fields = $this->fieldManager->readByHandles($sectionConfig->getFields()); // 5 foreach ($fields as $field) { $section->addField($field); } // 6 $section->setName((string) $sectionConfig->getName()); // 7 $section->setHandle((string) $sectionConfig->getHandle()); // 7 $section->setConfig($sectionConfig->toArray()); // 8 $this->entityManager->persist($section); // 9 $this->entityManager->flush(); // 9 return $section; }
[ "public", "function", "updateByConfig", "(", "SectionConfig", "$", "sectionConfig", ",", "SectionInterface", "$", "section", ",", "bool", "$", "history", "=", "false", ")", ":", "SectionInterface", "{", "if", "(", "$", "history", ")", "{", "/** @var SectionInter...
A section config is stored in the section history before it's updated. 1. Copy the data from the Section entity to the SectionHistory entity 2. Persist it in the entity history 3. Bump the version (+1) 4. Clear the field many to many relationships 5. Fetch the fields based on the config 6. Add them to the Section entity 7. Set the fields with the config values 8. Set the config 9. Persist the entity This new section might be created from an updated config yml. It's recommended to copy the old config yml before you update it. That way the config yml's history will be in compliance with the config stored in the database. This will only update the config stored in the database. The generators will have to be called to make the version change complete. @param SectionConfig $sectionConfig @param SectionInterface $section @param bool $history @return SectionInterface
[ "A", "section", "config", "is", "stored", "in", "the", "section", "history", "before", "it", "s", "updated", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/DoctrineSectionManager.php#L212-L243
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/Coanda.php
Coanda.loadModules
public function loadModules() { $core_modules = [ 'CoandaCMS\Coanda\Pages\PagesModuleProvider', 'CoandaCMS\Coanda\Media\MediaModuleProvider', 'CoandaCMS\Coanda\Users\UsersModuleProvider', 'CoandaCMS\Coanda\Layout\LayoutModuleProvider', 'CoandaCMS\Coanda\Urls\UrlModuleProvider', 'CoandaCMS\Coanda\History\HistoryModuleProvider' ]; $enabled_modules = $this->config->get('coanda::coanda.enabled_modules'); $modules = array_merge($core_modules, $enabled_modules); foreach ($modules as $module) { if (class_exists($module)) { $enabled_module = new $module($this); $enabled_module->boot($this); $this->modules[$enabled_module->name] = $enabled_module; } } }
php
public function loadModules() { $core_modules = [ 'CoandaCMS\Coanda\Pages\PagesModuleProvider', 'CoandaCMS\Coanda\Media\MediaModuleProvider', 'CoandaCMS\Coanda\Users\UsersModuleProvider', 'CoandaCMS\Coanda\Layout\LayoutModuleProvider', 'CoandaCMS\Coanda\Urls\UrlModuleProvider', 'CoandaCMS\Coanda\History\HistoryModuleProvider' ]; $enabled_modules = $this->config->get('coanda::coanda.enabled_modules'); $modules = array_merge($core_modules, $enabled_modules); foreach ($modules as $module) { if (class_exists($module)) { $enabled_module = new $module($this); $enabled_module->boot($this); $this->modules[$enabled_module->name] = $enabled_module; } } }
[ "public", "function", "loadModules", "(", ")", "{", "$", "core_modules", "=", "[", "'CoandaCMS\\Coanda\\Pages\\PagesModuleProvider'", ",", "'CoandaCMS\\Coanda\\Media\\MediaModuleProvider'", ",", "'CoandaCMS\\Coanda\\Users\\UsersModuleProvider'", ",", "'CoandaCMS\\Coanda\\Layout\\Layo...
Get all the enabled modules from the config and boots them up. Also adds to modules array for future use.
[ "Get", "all", "the", "enabled", "modules", "from", "the", "config", "and", "boots", "them", "up", ".", "Also", "adds", "to", "modules", "array", "for", "future", "use", "." ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/Coanda.php#L251-L276
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/Coanda.php
Coanda.filters
public function filters() { Route::filter('admin_auth', function() { if (!App::make('coanda')->isLoggedIn()) { Session::put('pre_auth_path', Request::path()); Session::put('pre_auth_query_string', Request::getQueryString()); return Redirect::to('/' . Config::get('coanda::coanda.admin_path') . '/login'); } }); }
php
public function filters() { Route::filter('admin_auth', function() { if (!App::make('coanda')->isLoggedIn()) { Session::put('pre_auth_path', Request::path()); Session::put('pre_auth_query_string', Request::getQueryString()); return Redirect::to('/' . Config::get('coanda::coanda.admin_path') . '/login'); } }); }
[ "public", "function", "filters", "(", ")", "{", "Route", "::", "filter", "(", "'admin_auth'", ",", "function", "(", ")", "{", "if", "(", "!", "App", "::", "make", "(", "'coanda'", ")", "->", "isLoggedIn", "(", ")", ")", "{", "Session", "::", "put", ...
Creates all the required filters
[ "Creates", "all", "the", "required", "filters" ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/Coanda.php#L281-L294
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/Coanda.php
Coanda.routes
public function routes() { Route::group(array('prefix' => $this->config->get('coanda::coanda.admin_path')), function() { // All module admin routes should be wrapper in the auth filter Route::group(array('before' => 'admin_auth'), function() { foreach ($this->modules as $module) { $module->adminRoutes(); } }); // We will put the main admin controller outside the group so it can handle its own filters Route::controller('/', 'CoandaCMS\Coanda\Controllers\AdminController'); }); // Let the module output any front end 'user' routes foreach ($this->modules as $module) { $module->userRoutes(); } App::before( function () { Route::match(['GET', 'POST'], 'search', function () { // Pass this route to the search provider, it can do whatever it likes! return Coanda::search()->handleSearch(); }); Route::match(['GET', 'POST'], '{slug}', function ($slug) { return Coanda::route($slug); })->where('slug', '[\.\/_\-\_A-Za-z0-9]+'); Route::match(['GET', 'POST'], '/', function () { return Coanda::routeHome(); }); }); }
php
public function routes() { Route::group(array('prefix' => $this->config->get('coanda::coanda.admin_path')), function() { // All module admin routes should be wrapper in the auth filter Route::group(array('before' => 'admin_auth'), function() { foreach ($this->modules as $module) { $module->adminRoutes(); } }); // We will put the main admin controller outside the group so it can handle its own filters Route::controller('/', 'CoandaCMS\Coanda\Controllers\AdminController'); }); // Let the module output any front end 'user' routes foreach ($this->modules as $module) { $module->userRoutes(); } App::before( function () { Route::match(['GET', 'POST'], 'search', function () { // Pass this route to the search provider, it can do whatever it likes! return Coanda::search()->handleSearch(); }); Route::match(['GET', 'POST'], '{slug}', function ($slug) { return Coanda::route($slug); })->where('slug', '[\.\/_\-\_A-Za-z0-9]+'); Route::match(['GET', 'POST'], '/', function () { return Coanda::routeHome(); }); }); }
[ "public", "function", "routes", "(", ")", "{", "Route", "::", "group", "(", "array", "(", "'prefix'", "=>", "$", "this", "->", "config", "->", "get", "(", "'coanda::coanda.admin_path'", ")", ")", ",", "function", "(", ")", "{", "// All module admin routes sh...
Outputs all the routes, including those added by modules
[ "Outputs", "all", "the", "routes", "including", "those", "added", "by", "modules" ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/Coanda.php#L299-L346
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/Coanda.php
Coanda.bindings
public function bindings($app) { $app->bind('CoandaCMS\Coanda\Urls\Repositories\UrlRepositoryInterface', 'CoandaCMS\Coanda\Urls\Repositories\Eloquent\EloquentUrlRepository'); $search_provider = $this->config->get('coanda::coanda.search_provider'); if (class_exists($search_provider)) { $app->bind('CoandaCMS\Coanda\Search\CoandaSearchProvider', $search_provider); } else { $app->bind('CoandaCMS\Coanda\Search\CoandaSearchProvider', 'CoandaCMS\Coanda\Search\Basic\CoandaBasicSearchProvider'); } // Let the module output any bindings foreach ($this->modules as $module) { $module->bindings($app); } }
php
public function bindings($app) { $app->bind('CoandaCMS\Coanda\Urls\Repositories\UrlRepositoryInterface', 'CoandaCMS\Coanda\Urls\Repositories\Eloquent\EloquentUrlRepository'); $search_provider = $this->config->get('coanda::coanda.search_provider'); if (class_exists($search_provider)) { $app->bind('CoandaCMS\Coanda\Search\CoandaSearchProvider', $search_provider); } else { $app->bind('CoandaCMS\Coanda\Search\CoandaSearchProvider', 'CoandaCMS\Coanda\Search\Basic\CoandaBasicSearchProvider'); } // Let the module output any bindings foreach ($this->modules as $module) { $module->bindings($app); } }
[ "public", "function", "bindings", "(", "$", "app", ")", "{", "$", "app", "->", "bind", "(", "'CoandaCMS\\Coanda\\Urls\\Repositories\\UrlRepositoryInterface'", ",", "'CoandaCMS\\Coanda\\Urls\\Repositories\\Eloquent\\EloquentUrlRepository'", ")", ";", "$", "search_provider", "=...
Runs through all the bindings @param Illuminate\Foundation\Application $app
[ "Runs", "through", "all", "the", "bindings" ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/Coanda.php#L352-L372
train
phug-php/lexer
src/Phug/Lexer.php
Lexer.updateOptions
public function updateOptions() { if ($onLex = $this->getOption('on_lex')) { $this->attach(LexerEvent::LEX, $onLex); } if ($onLex = $this->getOption('on_lex_end')) { $this->attach(LexerEvent::END_LEX, $onLex); } if ($onToken = $this->getOption('on_token')) { $this->attach(LexerEvent::TOKEN, $onToken); } $this->addModules($this->getOption('lexer_modules')); }
php
public function updateOptions() { if ($onLex = $this->getOption('on_lex')) { $this->attach(LexerEvent::LEX, $onLex); } if ($onLex = $this->getOption('on_lex_end')) { $this->attach(LexerEvent::END_LEX, $onLex); } if ($onToken = $this->getOption('on_token')) { $this->attach(LexerEvent::TOKEN, $onToken); } $this->addModules($this->getOption('lexer_modules')); }
[ "public", "function", "updateOptions", "(", ")", "{", "if", "(", "$", "onLex", "=", "$", "this", "->", "getOption", "(", "'on_lex'", ")", ")", "{", "$", "this", "->", "attach", "(", "LexerEvent", "::", "LEX", ",", "$", "onLex", ")", ";", "}", "if",...
Synchronize the lexer to the new options values.
[ "Synchronize", "the", "lexer", "to", "the", "new", "options", "values", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer.php#L106-L121
train
phug-php/lexer
src/Phug/Lexer.php
Lexer.prependScanner
public function prependScanner($name, $scanner) { $this->filterScanner($scanner); $scanners = [ $name => $scanner, ]; foreach ($this->getScanners() as $scannerName => $classNameOrInstance) { if ($scannerName !== $name) { $scanners[$scannerName] = $classNameOrInstance; } } return $this->setOption('scanners', $scanners); }
php
public function prependScanner($name, $scanner) { $this->filterScanner($scanner); $scanners = [ $name => $scanner, ]; foreach ($this->getScanners() as $scannerName => $classNameOrInstance) { if ($scannerName !== $name) { $scanners[$scannerName] = $classNameOrInstance; } } return $this->setOption('scanners', $scanners); }
[ "public", "function", "prependScanner", "(", "$", "name", ",", "$", "scanner", ")", "{", "$", "this", "->", "filterScanner", "(", "$", "scanner", ")", ";", "$", "scanners", "=", "[", "$", "name", "=>", "$", "scanner", ",", "]", ";", "foreach", "(", ...
Adds a new scanner class to use in the lexing process at the top of scanning order. The scanner class needs to extend Phug\Lexer\ScannerInterface. It can be the class name itself or an instance of it. @param string $name @param ScannerInterface|string $scanner @return $this
[ "Adds", "a", "new", "scanner", "class", "to", "use", "in", "the", "lexing", "process", "at", "the", "top", "of", "scanning", "order", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer.php#L144-L159
train
phug-php/lexer
src/Phug/Lexer.php
Lexer.addScanner
public function addScanner($name, $scanner) { $this->filterScanner($scanner); return $this->setOption(['scanners', $name], $scanner); }
php
public function addScanner($name, $scanner) { $this->filterScanner($scanner); return $this->setOption(['scanners', $name], $scanner); }
[ "public", "function", "addScanner", "(", "$", "name", ",", "$", "scanner", ")", "{", "$", "this", "->", "filterScanner", "(", "$", "scanner", ")", ";", "return", "$", "this", "->", "setOption", "(", "[", "'scanners'", ",", "$", "name", "]", ",", "$",...
Adds a new scanner class to use in the lexing process. The scanner class needs to extend Phug\Lexer\ScannerInterface. It can be the class name itself or an instance of it. @param string $name @param ScannerInterface|string $scanner @return $this
[ "Adds", "a", "new", "scanner", "class", "to", "use", "in", "the", "lexing", "process", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer.php#L172-L177
train
phug-php/lexer
src/Phug/Lexer.php
Lexer.lex
public function lex($input, $path = null) { $stateClassName = $this->getOption('lexer_state_class_name'); $lexEvent = new LexEvent($input, $path, $stateClassName, [ 'encoding' => $this->getOption('encoding'), 'indent_style' => $this->getOption('indent_style'), 'indent_width' => $this->getOption('indent_width'), 'allow_mixed_indent' => $this->getOption('allow_mixed_indent'), 'multiline_markup_enabled' => $this->getOption('multiline_markup_enabled'), 'level' => $this->getOption('level'), ]); $this->trigger($lexEvent); $input = $lexEvent->getInput(); $path = $lexEvent->getPath(); $stateClassName = $lexEvent->getStateClassName(); $stateOptions = $lexEvent->getStateOptions(); $stateOptions['path'] = $path; $stateOptions['keyword_names'] = array_keys($this->getOption('keywords') ?: []); if (!is_a($stateClassName, State::class, true)) { throw new \InvalidArgumentException( 'lexer_state_class_name needs to be a valid '.State::class.' sub class, '. $stateClassName.' given' ); } //Put together our initial state $this->state = new $stateClassName($this, $input, $stateOptions); $scanners = $this->getOption('scanners'); //We always scan for text at the very end. $scanners['final_plain_text'] = TextScanner::class; //Scan for tokens //N> yield from $this->handleTokens($this->>state->loopScan($scanners)); $tokens = $this->state->loopScan($scanners); foreach ($this->handleTokens($tokens) as $token) { yield $token; } $this->trigger(new EndLexEvent($lexEvent)); //Free state $this->state = null; $this->lastToken = null; }
php
public function lex($input, $path = null) { $stateClassName = $this->getOption('lexer_state_class_name'); $lexEvent = new LexEvent($input, $path, $stateClassName, [ 'encoding' => $this->getOption('encoding'), 'indent_style' => $this->getOption('indent_style'), 'indent_width' => $this->getOption('indent_width'), 'allow_mixed_indent' => $this->getOption('allow_mixed_indent'), 'multiline_markup_enabled' => $this->getOption('multiline_markup_enabled'), 'level' => $this->getOption('level'), ]); $this->trigger($lexEvent); $input = $lexEvent->getInput(); $path = $lexEvent->getPath(); $stateClassName = $lexEvent->getStateClassName(); $stateOptions = $lexEvent->getStateOptions(); $stateOptions['path'] = $path; $stateOptions['keyword_names'] = array_keys($this->getOption('keywords') ?: []); if (!is_a($stateClassName, State::class, true)) { throw new \InvalidArgumentException( 'lexer_state_class_name needs to be a valid '.State::class.' sub class, '. $stateClassName.' given' ); } //Put together our initial state $this->state = new $stateClassName($this, $input, $stateOptions); $scanners = $this->getOption('scanners'); //We always scan for text at the very end. $scanners['final_plain_text'] = TextScanner::class; //Scan for tokens //N> yield from $this->handleTokens($this->>state->loopScan($scanners)); $tokens = $this->state->loopScan($scanners); foreach ($this->handleTokens($tokens) as $token) { yield $token; } $this->trigger(new EndLexEvent($lexEvent)); //Free state $this->state = null; $this->lastToken = null; }
[ "public", "function", "lex", "(", "$", "input", ",", "$", "path", "=", "null", ")", "{", "$", "stateClassName", "=", "$", "this", "->", "getOption", "(", "'lexer_state_class_name'", ")", ";", "$", "lexEvent", "=", "new", "LexEvent", "(", "$", "input", ...
Returns a generator that will lex the passed input sequentially. If you don't move the generator, the lexer does nothing. Only as soon as you iterate the generator or call `next()`/`current()` on it the lexer will start its work and spit out tokens sequentially. This approach requires less memory during the lexing process. The returned tokens are required to be `Phug\Lexer\TokenInterface` instances. @param string $input the pug-string to lex into tokens. @param null $path @return \Generator a generator that can be iterated sequentially
[ "Returns", "a", "generator", "that", "will", "lex", "the", "passed", "input", "sequentially", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer.php#L194-L243
train
koolkode/async
src/DNS/Message.php
Message.addQuestion
public function addQuestion(string $host, int $type, int $class = self::CLASS_IN): void { $this->questions[] = [ 'host' => $host, 'type' => $type, 'class' => $class ]; }
php
public function addQuestion(string $host, int $type, int $class = self::CLASS_IN): void { $this->questions[] = [ 'host' => $host, 'type' => $type, 'class' => $class ]; }
[ "public", "function", "addQuestion", "(", "string", "$", "host", ",", "int", "$", "type", ",", "int", "$", "class", "=", "self", "::", "CLASS_IN", ")", ":", "void", "{", "$", "this", "->", "questions", "[", "]", "=", "[", "'host'", "=>", "$", "host...
Add a question record to the message. @param string $host The queried host name. @param int $type Question type (A / AAAA / MX / ...). @param int $class Record class (only internet supported).
[ "Add", "a", "question", "record", "to", "the", "message", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L239-L246
train
koolkode/async
src/DNS/Message.php
Message.addAnswer
public function addAnswer(string $host, int $type, int $class, string $data, int $ttl): void { $this->answers[] = [ 'host' => $host, 'type' => $type, 'class' => $class, 'data' => $data, 'ttl' => $ttl ]; }
php
public function addAnswer(string $host, int $type, int $class, string $data, int $ttl): void { $this->answers[] = [ 'host' => $host, 'type' => $type, 'class' => $class, 'data' => $data, 'ttl' => $ttl ]; }
[ "public", "function", "addAnswer", "(", "string", "$", "host", ",", "int", "$", "type", ",", "int", "$", "class", ",", "string", "$", "data", ",", "int", "$", "ttl", ")", ":", "void", "{", "$", "this", "->", "answers", "[", "]", "=", "[", "'host'...
Add an answer record to the message. @param string $host The queried host name. @param int $type Answer type (A / AAAA / MX / ...). @param int $class Record class (only internet supported). @param string $data Unencoded answer data. @param int $ttl Time to live of the answer record (in seconds).
[ "Add", "an", "answer", "record", "to", "the", "message", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L265-L274
train