id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
226,900
CoopBelvedere/laravel-basecamp-api
src/Sections/Comments.php
Comments.index
public function index($page = null) { $url = sprintf('buckets/%d/recordings/%d/comments.json', $this->bucket, $this->parent); $comments = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($comments, Comment::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/recordings/%d/comments.json', $this->bucket, $this->parent); $comments = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($comments, Comment::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/recordings/%d/comments.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "comments", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "comments", ",", "Comment", "::", "class", ")", ";", "}" ]
Index all comments. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "comments", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Comments.php#L18-L29
226,901
CoopBelvedere/laravel-basecamp-api
src/Sections/Comments.php
Comments.store
public function store($content) { $comment = $this->client->post( sprintf('buckets/%d/recordings/%d/comments.json', $this->bucket, $this->parent), [ 'json' => [ 'content' => $content, ], ] ); return new Comment($this->response($comment)); }
php
public function store($content) { $comment = $this->client->post( sprintf('buckets/%d/recordings/%d/comments.json', $this->bucket, $this->parent), [ 'json' => [ 'content' => $content, ], ] ); return new Comment($this->response($comment)); }
[ "public", "function", "store", "(", "$", "content", ")", "{", "$", "comment", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/recordings/%d/comments.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ",", "[", "'json'", "=>", "[", "'content'", "=>", "$", "content", ",", "]", ",", "]", ")", ";", "return", "new", "Comment", "(", "$", "this", "->", "response", "(", "$", "comment", ")", ")", ";", "}" ]
Store a comment. @param string $content @return \Illuminate\Support\Collection
[ "Store", "a", "comment", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Comments.php#L52-L64
226,902
CoopBelvedere/laravel-basecamp-api
src/Sections/Webhooks.php
Webhooks.index
public function index($page = null) { $url = sprintf('buckets/%d/webhooks.json', $this->bucket); $webhooks = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($webhooks, Webhook::class)->map(function ($webhook) { $webhook->inContext($this->bucket); return $webhook; }); }
php
public function index($page = null) { $url = sprintf('buckets/%d/webhooks.json', $this->bucket); $webhooks = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($webhooks, Webhook::class)->map(function ($webhook) { $webhook->inContext($this->bucket); return $webhook; }); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/webhooks.json'", ",", "$", "this", "->", "bucket", ")", ";", "$", "webhooks", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "webhooks", ",", "Webhook", "::", "class", ")", "->", "map", "(", "function", "(", "$", "webhook", ")", "{", "$", "webhook", "->", "inContext", "(", "$", "this", "->", "bucket", ")", ";", "return", "$", "webhook", ";", "}", ")", ";", "}" ]
Index all webhooks. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "webhooks", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Webhooks.php#L15-L29
226,903
CoopBelvedere/laravel-basecamp-api
src/Sections/Webhooks.php
Webhooks.store
public function store(array $data) { $webhook = $this->client->post( sprintf('buckets/%d/webhooks.json', $this->bucket), [ 'json' => $data, ] ); $webhook = new Webhook($this->response($webhook)); $webhook->inContext($this->bucket); return $webhook; }
php
public function store(array $data) { $webhook = $this->client->post( sprintf('buckets/%d/webhooks.json', $this->bucket), [ 'json' => $data, ] ); $webhook = new Webhook($this->response($webhook)); $webhook->inContext($this->bucket); return $webhook; }
[ "public", "function", "store", "(", "array", "$", "data", ")", "{", "$", "webhook", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/webhooks.json'", ",", "$", "this", "->", "bucket", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "$", "webhook", "=", "new", "Webhook", "(", "$", "this", "->", "response", "(", "$", "webhook", ")", ")", ";", "$", "webhook", "->", "inContext", "(", "$", "this", "->", "bucket", ")", ";", "return", "$", "webhook", ";", "}" ]
Store a webhook. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "webhook", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Webhooks.php#L54-L66
226,904
neilime/zf2-assets-bundle
src/AssetsBundle/View/Renderer/JsCustomRenderer.php
JsCustomRenderer.setResolver
public function setResolver(\Zend\View\Resolver\ResolverInterface $oResolver) { $this->resolver = $oResolver; return $this; }
php
public function setResolver(\Zend\View\Resolver\ResolverInterface $oResolver) { $this->resolver = $oResolver; return $this; }
[ "public", "function", "setResolver", "(", "\\", "Zend", "\\", "View", "\\", "Resolver", "\\", "ResolverInterface", "$", "oResolver", ")", "{", "$", "this", "->", "resolver", "=", "$", "oResolver", ";", "return", "$", "this", ";", "}" ]
Set the resolver used to map a template name to a resource the renderer may consume. @param \Zend\View\Resolver\ResolverInterface $oResolver @return \AssetsBundle\View\Renderer\JsRenderer
[ "Set", "the", "resolver", "used", "to", "map", "a", "template", "name", "to", "a", "resource", "the", "renderer", "may", "consume", "." ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/View/Renderer/JsCustomRenderer.php#L24-L27
226,905
neilime/zf2-assets-bundle
src/AssetsBundle/View/Renderer/JsCustomRenderer.php
JsCustomRenderer.render
public function render($oViewModel, $aValues = null) { if (!($oViewModel instanceof \Zend\View\Model\ViewModel)) { throw new \InvalidArgumentException(sprintf( 'View Model expects an instance of \Zend\View\Model\ViewModel, "%s" given', is_object($oViewModel) ? get_class($oViewModel) : gettype($oViewModel) )); } $aJsFiles = $oViewModel->getVariable('jsCustomFiles'); if (!is_array($aJsFiles)) { throw new \LogicException('JsFiles expects an array "' . gettype($aJsFiles) . '" given'); } $sRetour = ''; foreach ($aJsFiles as $oJsAssetFile) { if ($oJsAssetFile instanceof \AssetsBundle\AssetFile\AssetFile) { $sRetour .= $oJsAssetFile->getAssetFileContents() . PHP_EOL; } else { throw new \LogicException('Js asset file expects an instance of \AssetsBundle\AssetFile\AssetFile, "' . (is_object($oJsAssetFile) ? get_class($oJsAssetFile) : gettype($oJsAssetFile)) . '" given'); } } return $sRetour; }
php
public function render($oViewModel, $aValues = null) { if (!($oViewModel instanceof \Zend\View\Model\ViewModel)) { throw new \InvalidArgumentException(sprintf( 'View Model expects an instance of \Zend\View\Model\ViewModel, "%s" given', is_object($oViewModel) ? get_class($oViewModel) : gettype($oViewModel) )); } $aJsFiles = $oViewModel->getVariable('jsCustomFiles'); if (!is_array($aJsFiles)) { throw new \LogicException('JsFiles expects an array "' . gettype($aJsFiles) . '" given'); } $sRetour = ''; foreach ($aJsFiles as $oJsAssetFile) { if ($oJsAssetFile instanceof \AssetsBundle\AssetFile\AssetFile) { $sRetour .= $oJsAssetFile->getAssetFileContents() . PHP_EOL; } else { throw new \LogicException('Js asset file expects an instance of \AssetsBundle\AssetFile\AssetFile, "' . (is_object($oJsAssetFile) ? get_class($oJsAssetFile) : gettype($oJsAssetFile)) . '" given'); } } return $sRetour; }
[ "public", "function", "render", "(", "$", "oViewModel", ",", "$", "aValues", "=", "null", ")", "{", "if", "(", "!", "(", "$", "oViewModel", "instanceof", "\\", "Zend", "\\", "View", "\\", "Model", "\\", "ViewModel", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'View Model expects an instance of \\Zend\\View\\Model\\ViewModel, \"%s\" given'", ",", "is_object", "(", "$", "oViewModel", ")", "?", "get_class", "(", "$", "oViewModel", ")", ":", "gettype", "(", "$", "oViewModel", ")", ")", ")", ";", "}", "$", "aJsFiles", "=", "$", "oViewModel", "->", "getVariable", "(", "'jsCustomFiles'", ")", ";", "if", "(", "!", "is_array", "(", "$", "aJsFiles", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'JsFiles expects an array \"'", ".", "gettype", "(", "$", "aJsFiles", ")", ".", "'\" given'", ")", ";", "}", "$", "sRetour", "=", "''", ";", "foreach", "(", "$", "aJsFiles", "as", "$", "oJsAssetFile", ")", "{", "if", "(", "$", "oJsAssetFile", "instanceof", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", ")", "{", "$", "sRetour", ".=", "$", "oJsAssetFile", "->", "getAssetFileContents", "(", ")", ".", "PHP_EOL", ";", "}", "else", "{", "throw", "new", "\\", "LogicException", "(", "'Js asset file expects an instance of \\AssetsBundle\\AssetFile\\AssetFile, \"'", ".", "(", "is_object", "(", "$", "oJsAssetFile", ")", "?", "get_class", "(", "$", "oJsAssetFile", ")", ":", "gettype", "(", "$", "oJsAssetFile", ")", ")", ".", "'\" given'", ")", ";", "}", "}", "return", "$", "sRetour", ";", "}" ]
Renders js files contents @param \AssetsBundle\View\Renderer\ViewModel $oViewModel @param null|array|\ArrayAccess $aValues @return string @throws \InvalidArgumentException @throws \LogicException
[ "Renders", "js", "files", "contents" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/View/Renderer/JsCustomRenderer.php#L37-L56
226,906
CoopBelvedere/laravel-basecamp-api
src/Sections/QuestionAnswers.php
QuestionAnswers.index
public function index($page = null) { $url = sprintf('buckets/%d/questions/%d/answers.json', $this->bucket, $this->parent); $answers = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($answers, QuestionAnswer::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/questions/%d/answers.json', $this->bucket, $this->parent); $answers = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($answers, QuestionAnswer::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/questions/%d/answers.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "answers", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "answers", ",", "QuestionAnswer", "::", "class", ")", ";", "}" ]
Index all the question answers. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "the", "question", "answers", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/QuestionAnswers.php#L15-L26
226,907
CoopBelvedere/laravel-basecamp-api
src/Sections/QuestionAnswers.php
QuestionAnswers.show
public function show($bucket, $id) { $answer = $this->client->get( sprintf('buckets/%d/question_answers/%d.json', $this->bucket, $id) ); return new QuestionAnswer($this->response($answer)); }
php
public function show($bucket, $id) { $answer = $this->client->get( sprintf('buckets/%d/question_answers/%d.json', $this->bucket, $id) ); return new QuestionAnswer($this->response($answer)); }
[ "public", "function", "show", "(", "$", "bucket", ",", "$", "id", ")", "{", "$", "answer", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/question_answers/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "QuestionAnswer", "(", "$", "this", "->", "response", "(", "$", "answer", ")", ")", ";", "}" ]
Get a question answer. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "question", "answer", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/QuestionAnswers.php#L34-L41
226,908
ASlatius/yii2-nestable
nestable/NestableBehavior.php
NestableBehavior.nodeMove
public function nodeMove($value, $depth) { $this->node = $this->owner; parent::moveNode($value, $depth); }
php
public function nodeMove($value, $depth) { $this->node = $this->owner; parent::moveNode($value, $depth); }
[ "public", "function", "nodeMove", "(", "$", "value", ",", "$", "depth", ")", "{", "$", "this", "->", "node", "=", "$", "this", "->", "owner", ";", "parent", "::", "moveNode", "(", "$", "value", ",", "$", "depth", ")", ";", "}" ]
Wrapper function to be able to use the protected method of the NestedSetsBehavior @param integer $value @param integer $depth
[ "Wrapper", "function", "to", "be", "able", "to", "use", "the", "protected", "method", "of", "the", "NestedSetsBehavior" ]
7e40e678013b2fe6c96de99c29a1820fd92f0b8f
https://github.com/ASlatius/yii2-nestable/blob/7e40e678013b2fe6c96de99c29a1820fd92f0b8f/nestable/NestableBehavior.php#L28-L31
226,909
mlanin/laravel-email-templates-optimization
src/Compiler.php
Compiler.getCssFilesContent
protected function getCssFilesContent(array $files) { $css = ''; foreach ($files as $file) { $css .= $this->files->get($file); } return $css; }
php
protected function getCssFilesContent(array $files) { $css = ''; foreach ($files as $file) { $css .= $this->files->get($file); } return $css; }
[ "protected", "function", "getCssFilesContent", "(", "array", "$", "files", ")", "{", "$", "css", "=", "''", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "css", ".=", "$", "this", "->", "files", "->", "get", "(", "$", "file", ")", ";", "}", "return", "$", "css", ";", "}" ]
Concat all css files. @param array $files @return string
[ "Concat", "all", "css", "files", "." ]
4831a2e885de955e5eef661a158cd8bb0edd9821
https://github.com/mlanin/laravel-email-templates-optimization/blob/4831a2e885de955e5eef661a158cd8bb0edd9821/src/Compiler.php#L41-L49
226,910
CoopBelvedere/laravel-basecamp-api
src/Sections/Projects.php
Projects.index
public function index($page = null, $status = null) { $url = 'projects.json'; $projects = $this->client->get($url, [ 'query' => [ 'status' => $status, 'page' => $page, ], ]); return $this->indexResponse($projects, Project::class); }
php
public function index($page = null, $status = null) { $url = 'projects.json'; $projects = $this->client->get($url, [ 'query' => [ 'status' => $status, 'page' => $page, ], ]); return $this->indexResponse($projects, Project::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ",", "$", "status", "=", "null", ")", "{", "$", "url", "=", "'projects.json'", ";", "$", "projects", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'status'", "=>", "$", "status", ",", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "projects", ",", "Project", "::", "class", ")", ";", "}" ]
Index all projects. @param int $page @param string $status @return \Illuminate\Support\Collection
[ "Index", "all", "projects", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Projects.php#L16-L28
226,911
CoopBelvedere/laravel-basecamp-api
src/Sections/Projects.php
Projects.show
public function show($id) { $project = $this->client->get(sprintf('projects/%d.json', $id)); return new Project($this->response($project)); }
php
public function show($id) { $project = $this->client->get(sprintf('projects/%d.json', $id)); return new Project($this->response($project)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "project", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'projects/%d.json'", ",", "$", "id", ")", ")", ";", "return", "new", "Project", "(", "$", "this", "->", "response", "(", "$", "project", ")", ")", ";", "}" ]
Show a single project. @param int $id @return \Illuminate\Support\Collection
[ "Show", "a", "single", "project", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Projects.php#L58-L63
226,912
CoopBelvedere/laravel-basecamp-api
src/Sections/Projects.php
Projects.store
public function store(array $data) { $project = $this->client->post('projects.json', [ 'json' => $data, ]); if (property_exists($project, 'error')) throw new \Exception($project->error); return new Project($this->response($project)); }
php
public function store(array $data) { $project = $this->client->post('projects.json', [ 'json' => $data, ]); if (property_exists($project, 'error')) throw new \Exception($project->error); return new Project($this->response($project)); }
[ "public", "function", "store", "(", "array", "$", "data", ")", "{", "$", "project", "=", "$", "this", "->", "client", "->", "post", "(", "'projects.json'", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "if", "(", "property_exists", "(", "$", "project", ",", "'error'", ")", ")", "throw", "new", "\\", "Exception", "(", "$", "project", "->", "error", ")", ";", "return", "new", "Project", "(", "$", "this", "->", "response", "(", "$", "project", ")", ")", ";", "}" ]
Store a project. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "project", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Projects.php#L71-L81
226,913
CoopBelvedere/laravel-basecamp-api
src/Sections/TodoListGroups.php
TodoListGroups.index
public function index($page = null, $status = null) { $url = sprintf('buckets/%d/todolists/%d/groups.json', $this->bucket, $this->parent); $todolistGroups = $this->client->get($url, [ 'query' => [ 'status' => $status, 'page' => $page, ], ]); return $this->indexResponse($todolistGroups, TodoListGroup::class); }
php
public function index($page = null, $status = null) { $url = sprintf('buckets/%d/todolists/%d/groups.json', $this->bucket, $this->parent); $todolistGroups = $this->client->get($url, [ 'query' => [ 'status' => $status, 'page' => $page, ], ]); return $this->indexResponse($todolistGroups, TodoListGroup::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ",", "$", "status", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/todolists/%d/groups.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "todolistGroups", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'status'", "=>", "$", "status", ",", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "todolistGroups", ",", "TodoListGroup", "::", "class", ")", ";", "}" ]
Index all to-do list groups. @param int $page @param string $status @return \Illuminate\Support\Collection
[ "Index", "all", "to", "-", "do", "list", "groups", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/TodoListGroups.php#L16-L28
226,914
CoopBelvedere/laravel-basecamp-api
src/Sections/TodoListGroups.php
TodoListGroups.show
public function show($id) { $todolistGroup = $this->client->get( sprintf('buckets/%d/todolists/%d.json', $this->bucket, $id) ); return new TodoListGroup($this->response($todolistGroup)); }
php
public function show($id) { $todolistGroup = $this->client->get( sprintf('buckets/%d/todolists/%d.json', $this->bucket, $id) ); return new TodoListGroup($this->response($todolistGroup)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "todolistGroup", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/todolists/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "TodoListGroup", "(", "$", "this", "->", "response", "(", "$", "todolistGroup", ")", ")", ";", "}" ]
Get a to-do list group. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "to", "-", "do", "list", "group", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/TodoListGroups.php#L58-L65
226,915
CoopBelvedere/laravel-basecamp-api
src/Sections/TodoListGroups.php
TodoListGroups.store
public function store(array $data) { $todolistGroup = $this->client->post( sprintf('buckets/%d/todolists/%d/groups.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new TodoListGroup($this->response($todolistGroup)); }
php
public function store(array $data) { $todolistGroup = $this->client->post( sprintf('buckets/%d/todolists/%d/groups.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new TodoListGroup($this->response($todolistGroup)); }
[ "public", "function", "store", "(", "array", "$", "data", ")", "{", "$", "todolistGroup", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/todolists/%d/groups.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "TodoListGroup", "(", "$", "this", "->", "response", "(", "$", "todolistGroup", ")", ")", ";", "}" ]
Store a to-do list group. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "to", "-", "do", "list", "group", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/TodoListGroups.php#L73-L83
226,916
CoopBelvedere/laravel-basecamp-api
src/Sections/TodoListGroups.php
TodoListGroups.reposition
public function reposition($id, $position) { return $this->client->put( sprintf('buckets/%d/todolists/groups/%d/position.json', $this->bucket, $id), [ 'json' => [ 'position' => $position, ], ] ); }
php
public function reposition($id, $position) { return $this->client->put( sprintf('buckets/%d/todolists/groups/%d/position.json', $this->bucket, $id), [ 'json' => [ 'position' => $position, ], ] ); }
[ "public", "function", "reposition", "(", "$", "id", ",", "$", "position", ")", "{", "return", "$", "this", "->", "client", "->", "put", "(", "sprintf", "(", "'buckets/%d/todolists/groups/%d/position.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ",", "[", "'json'", "=>", "[", "'position'", "=>", "$", "position", ",", "]", ",", "]", ")", ";", "}" ]
Reposition a to-do list group. @param int $id @param int $position @return \Illuminate\Support\Collection
[ "Reposition", "a", "to", "-", "do", "list", "group", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/TodoListGroups.php#L92-L102
226,917
Dachande663/PHP-Validation
src/HybridLogic/Validation/ClientSide/jQueryValidator.php
jQueryValidator.generate
public function generate() { $methods = array(); // Actual validation methods $rules = array(); // Individual field rules $messages = array(); // Field error messages $php_rules = $this->validator->get_rules(); foreach($php_rules as $field_name => $field_rules) { $rules[$field_name] = array(); foreach($field_rules as $rule) { if( ! ($rule instanceof jQueryValidationRule) ) continue; $rule_name = $rule->jquery__get_rule_name(); if(!isset($methods[$rule_name])) { $method = method_exists($rule, 'jquery__get_method_definition') ? $rule->jquery__get_method_definition() : null; if($method) $methods[$rule_name] = $method; } $js_rule = $rule->jquery__get_rule_definition(); if(is_array($js_rule)) { $rules[$field_name] = array_merge($rules[$field_name], $js_rule); } else { $rules[$field_name][$js_rule] = true; } $messages[$field_name][$rule_name] = $rule->get_error_message($field_name, null, $this->validator); } if(empty($rules[$field_name])) unset($rules[$field_name]); if(empty($messages[$field_name])) unset($messages[$field_name]); } return array( 'rules' => $rules, 'messages' => $messages, 'methods' => $methods, ); }
php
public function generate() { $methods = array(); // Actual validation methods $rules = array(); // Individual field rules $messages = array(); // Field error messages $php_rules = $this->validator->get_rules(); foreach($php_rules as $field_name => $field_rules) { $rules[$field_name] = array(); foreach($field_rules as $rule) { if( ! ($rule instanceof jQueryValidationRule) ) continue; $rule_name = $rule->jquery__get_rule_name(); if(!isset($methods[$rule_name])) { $method = method_exists($rule, 'jquery__get_method_definition') ? $rule->jquery__get_method_definition() : null; if($method) $methods[$rule_name] = $method; } $js_rule = $rule->jquery__get_rule_definition(); if(is_array($js_rule)) { $rules[$field_name] = array_merge($rules[$field_name], $js_rule); } else { $rules[$field_name][$js_rule] = true; } $messages[$field_name][$rule_name] = $rule->get_error_message($field_name, null, $this->validator); } if(empty($rules[$field_name])) unset($rules[$field_name]); if(empty($messages[$field_name])) unset($messages[$field_name]); } return array( 'rules' => $rules, 'messages' => $messages, 'methods' => $methods, ); }
[ "public", "function", "generate", "(", ")", "{", "$", "methods", "=", "array", "(", ")", ";", "// Actual validation methods", "$", "rules", "=", "array", "(", ")", ";", "// Individual field rules", "$", "messages", "=", "array", "(", ")", ";", "// Field error messages", "$", "php_rules", "=", "$", "this", "->", "validator", "->", "get_rules", "(", ")", ";", "foreach", "(", "$", "php_rules", "as", "$", "field_name", "=>", "$", "field_rules", ")", "{", "$", "rules", "[", "$", "field_name", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "field_rules", "as", "$", "rule", ")", "{", "if", "(", "!", "(", "$", "rule", "instanceof", "jQueryValidationRule", ")", ")", "continue", ";", "$", "rule_name", "=", "$", "rule", "->", "jquery__get_rule_name", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "methods", "[", "$", "rule_name", "]", ")", ")", "{", "$", "method", "=", "method_exists", "(", "$", "rule", ",", "'jquery__get_method_definition'", ")", "?", "$", "rule", "->", "jquery__get_method_definition", "(", ")", ":", "null", ";", "if", "(", "$", "method", ")", "$", "methods", "[", "$", "rule_name", "]", "=", "$", "method", ";", "}", "$", "js_rule", "=", "$", "rule", "->", "jquery__get_rule_definition", "(", ")", ";", "if", "(", "is_array", "(", "$", "js_rule", ")", ")", "{", "$", "rules", "[", "$", "field_name", "]", "=", "array_merge", "(", "$", "rules", "[", "$", "field_name", "]", ",", "$", "js_rule", ")", ";", "}", "else", "{", "$", "rules", "[", "$", "field_name", "]", "[", "$", "js_rule", "]", "=", "true", ";", "}", "$", "messages", "[", "$", "field_name", "]", "[", "$", "rule_name", "]", "=", "$", "rule", "->", "get_error_message", "(", "$", "field_name", ",", "null", ",", "$", "this", "->", "validator", ")", ";", "}", "if", "(", "empty", "(", "$", "rules", "[", "$", "field_name", "]", ")", ")", "unset", "(", "$", "rules", "[", "$", "field_name", "]", ")", ";", "if", "(", "empty", "(", "$", "messages", "[", "$", "field_name", "]", ")", ")", "unset", "(", "$", "messages", "[", "$", "field_name", "]", ")", ";", "}", "return", "array", "(", "'rules'", "=>", "$", "rules", ",", "'messages'", "=>", "$", "messages", ",", "'methods'", "=>", "$", "methods", ",", ")", ";", "}" ]
Return necessary Client Side Validation representation @return array Output
[ "Return", "necessary", "Client", "Side", "Validation", "representation" ]
17be45d5c5c5897e33032c89efa2f6769af5de41
https://github.com/Dachande663/PHP-Validation/blob/17be45d5c5c5897e33032c89efa2f6769af5de41/src/HybridLogic/Validation/ClientSide/jQueryValidator.php#L38-L87
226,918
CoopBelvedere/laravel-basecamp-api
src/Sections/Schedules.php
Schedules.show
public function show($id) { $schedule = $this->client->get( sprintf('buckets/%d/schedules/%d.json', $this->bucket, $id) ); return new Schedule($this->response($schedule)); }
php
public function show($id) { $schedule = $this->client->get( sprintf('buckets/%d/schedules/%d.json', $this->bucket, $id) ); return new Schedule($this->response($schedule)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "schedule", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/schedules/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "Schedule", "(", "$", "this", "->", "response", "(", "$", "schedule", ")", ")", ";", "}" ]
Get a schedule. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "schedule", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Schedules.php#L15-L22
226,919
neilime/zf2-assets-bundle
src/AssetsBundle/Service/ServiceOptions.php
ServiceOptions.getRealPath
public function getRealPath($sPathToResolve, \AssetsBundle\AssetFile\AssetFile $oAssetFile = null) { if (!is_string($sPathToResolve)) { throw new \InvalidArgumentException('Argument "$sPathToResolve" expects a string, "' . (is_object($sPathToResolve) ? get_class($sPathToResolve) : gettype($sPathToResolve)) . '" given'); } if (!$sPathToResolve) { throw new \InvalidArgumentException('Argument "$sPathToResolve" is empty'); } // Define resolved paths key $sResolvedPathsKey = ($oAssetFile ? $oAssetFile->getAssetFilePath() . '_' : '') . $sPathToResolve; if (isset($this->resolvedPaths[$sResolvedPathsKey])) { return $this->resolvedPaths[$sResolvedPathsKey]; } // If path is "/", assets path is prefered if ($sPathToResolve === DIRECTORY_SEPARATOR && $this->hasAssetsPath()) { return $this->resolvedPaths[$sResolvedPathsKey] = $this->getAssetsPath(); } // Path is absolute if (strpos($sPathToResolve, '@zfRootPath') !== false) { $sPathToResolve = str_ireplace('@zfRootPath', getcwd(), $sPathToResolve); } if (strpos($sPathToResolve, '@zfAssetsPath') !== false) { $sPathToResolve = str_ireplace('@zfAssetsPath', $this->getAssetsPath(), $sPathToResolve); } if (($sRealPath = realpath($sPathToResolve)) !== false) { return $this->resolvedPaths[$sResolvedPathsKey] = $sRealPath; } // Try to define real path with given asset file path if ($oAssetFile && $this->safeFileExists($sRealPath = dirname($oAssetFile->getAssetFilePath()) . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } // Try to guess real path with root path or asset path (if defined) if ($this->hasAssetsPath() && $this->safeFileExists($sRealPath = $this->getAssetsPath() . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } if ($this->safeFileExists($sRealPath = getcwd() . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } return false; }
php
public function getRealPath($sPathToResolve, \AssetsBundle\AssetFile\AssetFile $oAssetFile = null) { if (!is_string($sPathToResolve)) { throw new \InvalidArgumentException('Argument "$sPathToResolve" expects a string, "' . (is_object($sPathToResolve) ? get_class($sPathToResolve) : gettype($sPathToResolve)) . '" given'); } if (!$sPathToResolve) { throw new \InvalidArgumentException('Argument "$sPathToResolve" is empty'); } // Define resolved paths key $sResolvedPathsKey = ($oAssetFile ? $oAssetFile->getAssetFilePath() . '_' : '') . $sPathToResolve; if (isset($this->resolvedPaths[$sResolvedPathsKey])) { return $this->resolvedPaths[$sResolvedPathsKey]; } // If path is "/", assets path is prefered if ($sPathToResolve === DIRECTORY_SEPARATOR && $this->hasAssetsPath()) { return $this->resolvedPaths[$sResolvedPathsKey] = $this->getAssetsPath(); } // Path is absolute if (strpos($sPathToResolve, '@zfRootPath') !== false) { $sPathToResolve = str_ireplace('@zfRootPath', getcwd(), $sPathToResolve); } if (strpos($sPathToResolve, '@zfAssetsPath') !== false) { $sPathToResolve = str_ireplace('@zfAssetsPath', $this->getAssetsPath(), $sPathToResolve); } if (($sRealPath = realpath($sPathToResolve)) !== false) { return $this->resolvedPaths[$sResolvedPathsKey] = $sRealPath; } // Try to define real path with given asset file path if ($oAssetFile && $this->safeFileExists($sRealPath = dirname($oAssetFile->getAssetFilePath()) . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } // Try to guess real path with root path or asset path (if defined) if ($this->hasAssetsPath() && $this->safeFileExists($sRealPath = $this->getAssetsPath() . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } if ($this->safeFileExists($sRealPath = getcwd() . DIRECTORY_SEPARATOR . $sPathToResolve)) { return $this->resolvedPaths[$sResolvedPathsKey] = realpath($sRealPath); } return false; }
[ "public", "function", "getRealPath", "(", "$", "sPathToResolve", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "$", "oAssetFile", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "sPathToResolve", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Argument \"$sPathToResolve\" expects a string, \"'", ".", "(", "is_object", "(", "$", "sPathToResolve", ")", "?", "get_class", "(", "$", "sPathToResolve", ")", ":", "gettype", "(", "$", "sPathToResolve", ")", ")", ".", "'\" given'", ")", ";", "}", "if", "(", "!", "$", "sPathToResolve", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Argument \"$sPathToResolve\" is empty'", ")", ";", "}", "// Define resolved paths key", "$", "sResolvedPathsKey", "=", "(", "$", "oAssetFile", "?", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ".", "'_'", ":", "''", ")", ".", "$", "sPathToResolve", ";", "if", "(", "isset", "(", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", ")", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", ";", "}", "// If path is \"/\", assets path is prefered", "if", "(", "$", "sPathToResolve", "===", "DIRECTORY_SEPARATOR", "&&", "$", "this", "->", "hasAssetsPath", "(", ")", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", "=", "$", "this", "->", "getAssetsPath", "(", ")", ";", "}", "// Path is absolute", "if", "(", "strpos", "(", "$", "sPathToResolve", ",", "'@zfRootPath'", ")", "!==", "false", ")", "{", "$", "sPathToResolve", "=", "str_ireplace", "(", "'@zfRootPath'", ",", "getcwd", "(", ")", ",", "$", "sPathToResolve", ")", ";", "}", "if", "(", "strpos", "(", "$", "sPathToResolve", ",", "'@zfAssetsPath'", ")", "!==", "false", ")", "{", "$", "sPathToResolve", "=", "str_ireplace", "(", "'@zfAssetsPath'", ",", "$", "this", "->", "getAssetsPath", "(", ")", ",", "$", "sPathToResolve", ")", ";", "}", "if", "(", "(", "$", "sRealPath", "=", "realpath", "(", "$", "sPathToResolve", ")", ")", "!==", "false", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", "=", "$", "sRealPath", ";", "}", "// Try to define real path with given asset file path", "if", "(", "$", "oAssetFile", "&&", "$", "this", "->", "safeFileExists", "(", "$", "sRealPath", "=", "dirname", "(", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "sPathToResolve", ")", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", "=", "realpath", "(", "$", "sRealPath", ")", ";", "}", "// Try to guess real path with root path or asset path (if defined)", "if", "(", "$", "this", "->", "hasAssetsPath", "(", ")", "&&", "$", "this", "->", "safeFileExists", "(", "$", "sRealPath", "=", "$", "this", "->", "getAssetsPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "sPathToResolve", ")", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", "=", "realpath", "(", "$", "sRealPath", ")", ";", "}", "if", "(", "$", "this", "->", "safeFileExists", "(", "$", "sRealPath", "=", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "sPathToResolve", ")", ")", "{", "return", "$", "this", "->", "resolvedPaths", "[", "$", "sResolvedPathsKey", "]", "=", "realpath", "(", "$", "sRealPath", ")", ";", "}", "return", "false", ";", "}" ]
Try to retrieve realpath for a given path (manage @zfRootPath) @param string $sPathToResolve @return string|boolean @throws \InvalidArgumentException
[ "Try", "to", "retrieve", "realpath", "for", "a", "given", "path", "(", "manage" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/Service/ServiceOptions.php#L698-L744
226,920
neilime/zf2-assets-bundle
src/AssetsBundle/Service/ServiceOptions.php
ServiceOptions.safeFileExists
protected function safeFileExists($sFilePath) { if (!is_string($sFilePath)) { throw new \InvalidArgumentException('Argument "$sFilePath" expects a string, "' . (is_object($sFilePath) ? get_class($sFilePath) : gettype($sFilePath)) . '" given'); } // Retrieve "open_basedir" restriction if ($this->openBaseDirPaths === null) { if ($sOpenBaseDir = ini_get('open_basedir')) { $this->openBaseDirPaths = explode(PATH_SEPARATOR, $sOpenBaseDir); } else { $this->openBaseDirPaths = array(); } } if (!$this->openBaseDirPaths) { return file_exists($sFilePath); } foreach ($this->openBaseDirPaths as $sAllowedPath) { if (strpos($sFilePath, $sAllowedPath)) { return file_exists($sFilePath); } } return false; }
php
protected function safeFileExists($sFilePath) { if (!is_string($sFilePath)) { throw new \InvalidArgumentException('Argument "$sFilePath" expects a string, "' . (is_object($sFilePath) ? get_class($sFilePath) : gettype($sFilePath)) . '" given'); } // Retrieve "open_basedir" restriction if ($this->openBaseDirPaths === null) { if ($sOpenBaseDir = ini_get('open_basedir')) { $this->openBaseDirPaths = explode(PATH_SEPARATOR, $sOpenBaseDir); } else { $this->openBaseDirPaths = array(); } } if (!$this->openBaseDirPaths) { return file_exists($sFilePath); } foreach ($this->openBaseDirPaths as $sAllowedPath) { if (strpos($sFilePath, $sAllowedPath)) { return file_exists($sFilePath); } } return false; }
[ "protected", "function", "safeFileExists", "(", "$", "sFilePath", ")", "{", "if", "(", "!", "is_string", "(", "$", "sFilePath", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Argument \"$sFilePath\" expects a string, \"'", ".", "(", "is_object", "(", "$", "sFilePath", ")", "?", "get_class", "(", "$", "sFilePath", ")", ":", "gettype", "(", "$", "sFilePath", ")", ")", ".", "'\" given'", ")", ";", "}", "// Retrieve \"open_basedir\" restriction", "if", "(", "$", "this", "->", "openBaseDirPaths", "===", "null", ")", "{", "if", "(", "$", "sOpenBaseDir", "=", "ini_get", "(", "'open_basedir'", ")", ")", "{", "$", "this", "->", "openBaseDirPaths", "=", "explode", "(", "PATH_SEPARATOR", ",", "$", "sOpenBaseDir", ")", ";", "}", "else", "{", "$", "this", "->", "openBaseDirPaths", "=", "array", "(", ")", ";", "}", "}", "if", "(", "!", "$", "this", "->", "openBaseDirPaths", ")", "{", "return", "file_exists", "(", "$", "sFilePath", ")", ";", "}", "foreach", "(", "$", "this", "->", "openBaseDirPaths", "as", "$", "sAllowedPath", ")", "{", "if", "(", "strpos", "(", "$", "sFilePath", ",", "$", "sAllowedPath", ")", ")", "{", "return", "file_exists", "(", "$", "sFilePath", ")", ";", "}", "}", "return", "false", ";", "}" ]
Check if file exists, only search in "open_basedir" path if defined @param string $sFilePath @return boolean @throws \InvalidArgumentException
[ "Check", "if", "file", "exists", "only", "search", "in", "open_basedir", "path", "if", "defined" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/Service/ServiceOptions.php#L752-L776
226,921
neilime/zf2-assets-bundle
src/AssetsBundle/Service/ServiceOptions.php
ServiceOptions.getCacheFileName
public function getCacheFileName() { $aAssets = $this->getAssets(); $sCacheFileName = isset($aAssets[$sModuleName = $this->getModuleName()]) ? $sModuleName : \AssetsBundle\Service\ServiceOptions::NO_MODULE; $aUnwantedKeys = array( \AssetsBundle\AssetFile\AssetFile::ASSET_CSS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_LESS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_JS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA => true ); $aAvailableModuleAssets = array_diff_key($aAssets, $aUnwantedKeys); $bControllerNameFound = false; $sControllerName = $this->getControllerName(); foreach ($aAvailableModuleAssets as $aModuleConfig) { if (isset($aModuleConfig[$sControllerName])) { $bControllerNameFound = true; break; } } $sCacheFileName .= '_' . ($bControllerNameFound ? $sControllerName : \AssetsBundle\Service\ServiceOptions::NO_CONTROLLER); $bActionNameFound = false; $sActionName = $this->getActionName(); reset($aAvailableModuleAssets); foreach ($aAvailableModuleAssets as $aModuleConfig) { foreach (array_diff_key($aModuleConfig, $aUnwantedKeys) as $aControllerConfig) { if (isset($aControllerConfig[$sActionName])) { $bActionNameFound = true; } } } $sCacheFileName .= '_' . ($bActionNameFound ? $sActionName : \AssetsBundle\Service\ServiceOptions::NO_ACTION); return md5($sCacheFileName); }
php
public function getCacheFileName() { $aAssets = $this->getAssets(); $sCacheFileName = isset($aAssets[$sModuleName = $this->getModuleName()]) ? $sModuleName : \AssetsBundle\Service\ServiceOptions::NO_MODULE; $aUnwantedKeys = array( \AssetsBundle\AssetFile\AssetFile::ASSET_CSS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_LESS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_JS => true, \AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA => true ); $aAvailableModuleAssets = array_diff_key($aAssets, $aUnwantedKeys); $bControllerNameFound = false; $sControllerName = $this->getControllerName(); foreach ($aAvailableModuleAssets as $aModuleConfig) { if (isset($aModuleConfig[$sControllerName])) { $bControllerNameFound = true; break; } } $sCacheFileName .= '_' . ($bControllerNameFound ? $sControllerName : \AssetsBundle\Service\ServiceOptions::NO_CONTROLLER); $bActionNameFound = false; $sActionName = $this->getActionName(); reset($aAvailableModuleAssets); foreach ($aAvailableModuleAssets as $aModuleConfig) { foreach (array_diff_key($aModuleConfig, $aUnwantedKeys) as $aControllerConfig) { if (isset($aControllerConfig[$sActionName])) { $bActionNameFound = true; } } } $sCacheFileName .= '_' . ($bActionNameFound ? $sActionName : \AssetsBundle\Service\ServiceOptions::NO_ACTION); return md5($sCacheFileName); }
[ "public", "function", "getCacheFileName", "(", ")", "{", "$", "aAssets", "=", "$", "this", "->", "getAssets", "(", ")", ";", "$", "sCacheFileName", "=", "isset", "(", "$", "aAssets", "[", "$", "sModuleName", "=", "$", "this", "->", "getModuleName", "(", ")", "]", ")", "?", "$", "sModuleName", ":", "\\", "AssetsBundle", "\\", "Service", "\\", "ServiceOptions", "::", "NO_MODULE", ";", "$", "aUnwantedKeys", "=", "array", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", "=>", "true", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_LESS", "=>", "true", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", "=>", "true", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_MEDIA", "=>", "true", ")", ";", "$", "aAvailableModuleAssets", "=", "array_diff_key", "(", "$", "aAssets", ",", "$", "aUnwantedKeys", ")", ";", "$", "bControllerNameFound", "=", "false", ";", "$", "sControllerName", "=", "$", "this", "->", "getControllerName", "(", ")", ";", "foreach", "(", "$", "aAvailableModuleAssets", "as", "$", "aModuleConfig", ")", "{", "if", "(", "isset", "(", "$", "aModuleConfig", "[", "$", "sControllerName", "]", ")", ")", "{", "$", "bControllerNameFound", "=", "true", ";", "break", ";", "}", "}", "$", "sCacheFileName", ".=", "'_'", ".", "(", "$", "bControllerNameFound", "?", "$", "sControllerName", ":", "\\", "AssetsBundle", "\\", "Service", "\\", "ServiceOptions", "::", "NO_CONTROLLER", ")", ";", "$", "bActionNameFound", "=", "false", ";", "$", "sActionName", "=", "$", "this", "->", "getActionName", "(", ")", ";", "reset", "(", "$", "aAvailableModuleAssets", ")", ";", "foreach", "(", "$", "aAvailableModuleAssets", "as", "$", "aModuleConfig", ")", "{", "foreach", "(", "array_diff_key", "(", "$", "aModuleConfig", ",", "$", "aUnwantedKeys", ")", "as", "$", "aControllerConfig", ")", "{", "if", "(", "isset", "(", "$", "aControllerConfig", "[", "$", "sActionName", "]", ")", ")", "{", "$", "bActionNameFound", "=", "true", ";", "}", "}", "}", "$", "sCacheFileName", ".=", "'_'", ".", "(", "$", "bActionNameFound", "?", "$", "sActionName", ":", "\\", "AssetsBundle", "\\", "Service", "\\", "ServiceOptions", "::", "NO_ACTION", ")", ";", "return", "md5", "(", "$", "sCacheFileName", ")", ";", "}" ]
Retrieve cache file name for given module name, controller name and action name @return string
[ "Retrieve", "cache", "file", "name", "for", "given", "module", "name", "controller", "name", "and", "action", "name" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/Service/ServiceOptions.php#L782-L817
226,922
THECALLR/sdk-php
src/CALLR/Objects/App/App.php
App.create
public function create() { if ($this->apiObjectName === null) { throw new LocalException('Missing Object Name in "'.get_class($this).'"'); } $result = $this->api->call('apps.create', [$this->apiObjectName, $this->name, $this->p]); $this->setProperties($result); return true; }
php
public function create() { if ($this->apiObjectName === null) { throw new LocalException('Missing Object Name in "'.get_class($this).'"'); } $result = $this->api->call('apps.create', [$this->apiObjectName, $this->name, $this->p]); $this->setProperties($result); return true; }
[ "public", "function", "create", "(", ")", "{", "if", "(", "$", "this", "->", "apiObjectName", "===", "null", ")", "{", "throw", "new", "LocalException", "(", "'Missing Object Name in \"'", ".", "get_class", "(", "$", "this", ")", ".", "'\"'", ")", ";", "}", "$", "result", "=", "$", "this", "->", "api", "->", "call", "(", "'apps.create'", ",", "[", "$", "this", "->", "apiObjectName", ",", "$", "this", "->", "name", ",", "$", "this", "->", "p", "]", ")", ";", "$", "this", "->", "setProperties", "(", "$", "result", ")", ";", "return", "true", ";", "}" ]
Create a new Voice App @throws \CALLR\API\Exception\LocalException if missing $apiObjectName @return boolean true or throws Exception otherwise
[ "Create", "a", "new", "Voice", "App" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Objects/App/App.php#L35-L43
226,923
CoopBelvedere/laravel-basecamp-api
src/Sections/Forwards.php
Forwards.index
public function index($page = null) { $url = sprintf('buckets/%d/inboxes/%d/forwards.json', $this->bucket, $this->parent); $forwards = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($forwards, Forward::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/inboxes/%d/forwards.json', $this->bucket, $this->parent); $forwards = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($forwards, Forward::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/inboxes/%d/forwards.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "forwards", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "forwards", ",", "Forward", "::", "class", ")", ";", "}" ]
Index all forwards. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "forwards", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Forwards.php#L18-L29
226,924
CoopBelvedere/laravel-basecamp-api
src/Sections/Forwards.php
Forwards.show
public function show($id) { $forward = $this->client->get( sprintf('buckets/%d/inbox_forwards/%d.json', $this->bucket, $id) ); return new Forward($this->response($forward)); }
php
public function show($id) { $forward = $this->client->get( sprintf('buckets/%d/inbox_forwards/%d.json', $this->bucket, $id) ); return new Forward($this->response($forward)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "forward", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/inbox_forwards/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "Forward", "(", "$", "this", "->", "response", "(", "$", "forward", ")", ")", ";", "}" ]
Get a forward. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "forward", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Forwards.php#L37-L44
226,925
PurpleBooth/htmlstrip
src/PurpleBooth/HtmlStripperImplementation.php
HtmlStripperImplementation.toText
public function toText($html) { $parser = new Parser(); $xmlParser = xml_parser_create(); xml_set_element_handler($xmlParser, [$parser, 'startElement'], [$parser, 'endElement']); xml_set_character_data_handler($xmlParser, [$parser, 'characterData']); $wrappedHtml = "<root>$html</root>"; $returnStatus = xml_parse($xmlParser, $wrappedHtml, true); if (!$returnStatus) { return $html; } return $parser->getText(); }
php
public function toText($html) { $parser = new Parser(); $xmlParser = xml_parser_create(); xml_set_element_handler($xmlParser, [$parser, 'startElement'], [$parser, 'endElement']); xml_set_character_data_handler($xmlParser, [$parser, 'characterData']); $wrappedHtml = "<root>$html</root>"; $returnStatus = xml_parse($xmlParser, $wrappedHtml, true); if (!$returnStatus) { return $html; } return $parser->getText(); }
[ "public", "function", "toText", "(", "$", "html", ")", "{", "$", "parser", "=", "new", "Parser", "(", ")", ";", "$", "xmlParser", "=", "xml_parser_create", "(", ")", ";", "xml_set_element_handler", "(", "$", "xmlParser", ",", "[", "$", "parser", ",", "'startElement'", "]", ",", "[", "$", "parser", ",", "'endElement'", "]", ")", ";", "xml_set_character_data_handler", "(", "$", "xmlParser", ",", "[", "$", "parser", ",", "'characterData'", "]", ")", ";", "$", "wrappedHtml", "=", "\"<root>$html</root>\"", ";", "$", "returnStatus", "=", "xml_parse", "(", "$", "xmlParser", ",", "$", "wrappedHtml", ",", "true", ")", ";", "if", "(", "!", "$", "returnStatus", ")", "{", "return", "$", "html", ";", "}", "return", "$", "parser", "->", "getText", "(", ")", ";", "}" ]
Parse the text. The actual logic of this function is to setup the XML parsing extension. @param string $html @return string
[ "Parse", "the", "text", "." ]
af2f64fd87df8d3a534d0f362fc3be1754ffb25b
https://github.com/PurpleBooth/htmlstrip/blob/af2f64fd87df8d3a534d0f362fc3be1754ffb25b/src/PurpleBooth/HtmlStripperImplementation.php#L26-L42
226,926
THECALLR/sdk-php
src/CALLR/Objects/Object.php
Object.export
public function export() { $result = new \stdClass; $class = new \ReflectionClass(get_class($this)); $plist = $class->getProperties(\ReflectionProperty::IS_PUBLIC); foreach ($plist as $property) { $result->{$property->getName()} = $this->{$property->getName()}; } return $result; }
php
public function export() { $result = new \stdClass; $class = new \ReflectionClass(get_class($this)); $plist = $class->getProperties(\ReflectionProperty::IS_PUBLIC); foreach ($plist as $property) { $result->{$property->getName()} = $this->{$property->getName()}; } return $result; }
[ "public", "function", "export", "(", ")", "{", "$", "result", "=", "new", "\\", "stdClass", ";", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "plist", "=", "$", "class", "->", "getProperties", "(", "\\", "ReflectionProperty", "::", "IS_PUBLIC", ")", ";", "foreach", "(", "$", "plist", "as", "$", "property", ")", "{", "$", "result", "->", "{", "$", "property", "->", "getName", "(", ")", "}", "=", "$", "this", "->", "{", "$", "property", "->", "getName", "(", ")", "}", ";", "}", "return", "$", "result", ";", "}" ]
Export public properties as an object @return object Public properties
[ "Export", "public", "properties", "as", "an", "object" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Objects/Object.php#L11-L20
226,927
DavidHavl/DhErrorLogging
src/DhErrorLogging/Filter/ExceptionFilter.php
ExceptionFilter.isAllowed
public function isAllowed($exception) { if (empty($exception) || !$exception instanceof \Exception) { return true; } if (!empty($this->blacklist)) { foreach ($this->blacklist as $excType) { if (is_a($exception, $excType, true)) { return false; } } } return true; }
php
public function isAllowed($exception) { if (empty($exception) || !$exception instanceof \Exception) { return true; } if (!empty($this->blacklist)) { foreach ($this->blacklist as $excType) { if (is_a($exception, $excType, true)) { return false; } } } return true; }
[ "public", "function", "isAllowed", "(", "$", "exception", ")", "{", "if", "(", "empty", "(", "$", "exception", ")", "||", "!", "$", "exception", "instanceof", "\\", "Exception", ")", "{", "return", "true", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "blacklist", ")", ")", "{", "foreach", "(", "$", "this", "->", "blacklist", "as", "$", "excType", ")", "{", "if", "(", "is_a", "(", "$", "exception", ",", "$", "excType", ",", "true", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check if the given exception is allowed @param \Exception $exception @return bool
[ "Check", "if", "the", "given", "exception", "is", "allowed" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Filter/ExceptionFilter.php#L29-L44
226,928
beheh/flaps
src/Flaps/Flap.php
Flap.pushThrottlingStrategy
public function pushThrottlingStrategy(ThrottlingStrategyInterface $throttlingStrategy) { $throttlingStrategy->setStorage($this->storage); $this->throttlingStrategies[] = $throttlingStrategy; }
php
public function pushThrottlingStrategy(ThrottlingStrategyInterface $throttlingStrategy) { $throttlingStrategy->setStorage($this->storage); $this->throttlingStrategies[] = $throttlingStrategy; }
[ "public", "function", "pushThrottlingStrategy", "(", "ThrottlingStrategyInterface", "$", "throttlingStrategy", ")", "{", "$", "throttlingStrategy", "->", "setStorage", "(", "$", "this", "->", "storage", ")", ";", "$", "this", "->", "throttlingStrategies", "[", "]", "=", "$", "throttlingStrategy", ";", "}" ]
Adds the throttling strategy to the internal list of throttling strategies. @param BehEh\Flaps\ViolationHandlerInterface
[ "Adds", "the", "throttling", "strategy", "to", "the", "internal", "list", "of", "throttling", "strategies", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Flap.php#L49-L53
226,929
beheh/flaps
src/Flaps/Flap.php
Flap.limit
public function limit($identifier) { if ($this->isViolator($identifier)) { $this->ensureViolationHandler(); return $this->violationHandler->handleViolation(); } return true; }
php
public function limit($identifier) { if ($this->isViolator($identifier)) { $this->ensureViolationHandler(); return $this->violationHandler->handleViolation(); } return true; }
[ "public", "function", "limit", "(", "$", "identifier", ")", "{", "if", "(", "$", "this", "->", "isViolator", "(", "$", "identifier", ")", ")", "{", "$", "this", "->", "ensureViolationHandler", "(", ")", ";", "return", "$", "this", "->", "violationHandler", "->", "handleViolation", "(", ")", ";", "}", "return", "true", ";", "}" ]
Requests violation handling from the violation handler if identifier violates any throttling strategy. @param string $identifier @return mixed true, if no throttling strategy is violated, otherwise the return value of the violation handler's handleViolation
[ "Requests", "violation", "handling", "from", "the", "violation", "handler", "if", "identifier", "violates", "any", "throttling", "strategy", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Flap.php#L88-L95
226,930
beheh/flaps
src/Flaps/Flap.php
Flap.isViolator
public function isViolator($identifier) { $violation = false; foreach ($this->throttlingStrategies as $throttlingStrategy) { /** @var ThrottlingStrategyInterface $throttlingHandler */ if ($throttlingStrategy->isViolator($this->name.':'.$identifier)) { $violation = true; } } return $violation; }
php
public function isViolator($identifier) { $violation = false; foreach ($this->throttlingStrategies as $throttlingStrategy) { /** @var ThrottlingStrategyInterface $throttlingHandler */ if ($throttlingStrategy->isViolator($this->name.':'.$identifier)) { $violation = true; } } return $violation; }
[ "public", "function", "isViolator", "(", "$", "identifier", ")", "{", "$", "violation", "=", "false", ";", "foreach", "(", "$", "this", "->", "throttlingStrategies", "as", "$", "throttlingStrategy", ")", "{", "/** @var ThrottlingStrategyInterface $throttlingHandler */", "if", "(", "$", "throttlingStrategy", "->", "isViolator", "(", "$", "this", "->", "name", ".", "':'", ".", "$", "identifier", ")", ")", "{", "$", "violation", "=", "true", ";", "}", "}", "return", "$", "violation", ";", "}" ]
Checks whether the entity violates any throttling strategy. @param string $identifier a unique string identifying the entity to check @return bool true if the entity violates any strategy
[ "Checks", "whether", "the", "entity", "violates", "any", "throttling", "strategy", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Flap.php#L102-L112
226,931
DavidHavl/DhErrorLogging
src/DhErrorLogging/Processor/Extras.php
Extras.getTrace
private function getTrace() { $trace = array(); if (PHP_VERSION_ID >= 50400) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); } else if (PHP_VERSION_ID >= 50306) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } else { $trace = debug_backtrace(); } if (empty($trace)) { return ''; } array_shift($trace); // ignore $this->getTrace(); array_shift($trace); // ignore $this->process() $i = 0; $returnArray = array(); while (isset($trace[$i]['class']) && false === strpos($trace[$i]['class'], 'Zend\\Log') && false === strpos($trace[$i]['class'], 'DhErrorLogging')) { $i++; $returnArray[] = array( 'file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : null, 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : null, 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, ); } return $returnArray; }
php
private function getTrace() { $trace = array(); if (PHP_VERSION_ID >= 50400) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); } else if (PHP_VERSION_ID >= 50306) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } else { $trace = debug_backtrace(); } if (empty($trace)) { return ''; } array_shift($trace); // ignore $this->getTrace(); array_shift($trace); // ignore $this->process() $i = 0; $returnArray = array(); while (isset($trace[$i]['class']) && false === strpos($trace[$i]['class'], 'Zend\\Log') && false === strpos($trace[$i]['class'], 'DhErrorLogging')) { $i++; $returnArray[] = array( 'file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : null, 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : null, 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, ); } return $returnArray; }
[ "private", "function", "getTrace", "(", ")", "{", "$", "trace", "=", "array", "(", ")", ";", "if", "(", "PHP_VERSION_ID", ">=", "50400", ")", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ",", "10", ")", ";", "}", "else", "if", "(", "PHP_VERSION_ID", ">=", "50306", ")", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ")", ";", "}", "else", "{", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "trace", ")", ")", "{", "return", "''", ";", "}", "array_shift", "(", "$", "trace", ")", ";", "// ignore $this->getTrace();", "array_shift", "(", "$", "trace", ")", ";", "// ignore $this->process()", "$", "i", "=", "0", ";", "$", "returnArray", "=", "array", "(", ")", ";", "while", "(", "isset", "(", "$", "trace", "[", "$", "i", "]", "[", "'class'", "]", ")", "&&", "false", "===", "strpos", "(", "$", "trace", "[", "$", "i", "]", "[", "'class'", "]", ",", "'Zend\\\\Log'", ")", "&&", "false", "===", "strpos", "(", "$", "trace", "[", "$", "i", "]", "[", "'class'", "]", ",", "'DhErrorLogging'", ")", ")", "{", "$", "i", "++", ";", "$", "returnArray", "[", "]", "=", "array", "(", "'file'", "=>", "isset", "(", "$", "trace", "[", "$", "i", "]", "[", "'file'", "]", ")", "?", "$", "trace", "[", "$", "i", "]", "[", "'file'", "]", ":", "null", ",", "'line'", "=>", "isset", "(", "$", "trace", "[", "$", "i", "]", "[", "'line'", "]", ")", "?", "$", "trace", "[", "$", "i", "]", "[", "'line'", "]", ":", "null", ",", "'class'", "=>", "isset", "(", "$", "trace", "[", "$", "i", "]", "[", "'class'", "]", ")", "?", "$", "trace", "[", "$", "i", "]", "[", "'class'", "]", ":", "null", ",", "'function'", "=>", "isset", "(", "$", "trace", "[", "$", "i", "]", "[", "'function'", "]", ")", "?", "$", "trace", "[", "$", "i", "]", "[", "'function'", "]", ":", "null", ",", ")", ";", "}", "return", "$", "returnArray", ";", "}" ]
Get back trace @return array|null
[ "Get", "back", "trace" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Processor/Extras.php#L92-L122
226,932
CoopBelvedere/laravel-basecamp-api
src/Models/MessageType.php
MessageType.update
public function update(array $data) { $messageType = Basecamp::messageTypes($this->bucket->id) ->update($this->id, $data); $this->setAttributes($messageType); return $messageType; }
php
public function update(array $data) { $messageType = Basecamp::messageTypes($this->bucket->id) ->update($this->id, $data); $this->setAttributes($messageType); return $messageType; }
[ "public", "function", "update", "(", "array", "$", "data", ")", "{", "$", "messageType", "=", "Basecamp", "::", "messageTypes", "(", "$", "this", "->", "bucket", "->", "id", ")", "->", "update", "(", "$", "this", "->", "id", ",", "$", "data", ")", ";", "$", "this", "->", "setAttributes", "(", "$", "messageType", ")", ";", "return", "$", "messageType", ";", "}" ]
Update the message type. @param array $data @return \Illuminate\Http\Collection
[ "Update", "the", "message", "type", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Models/MessageType.php#L13-L21
226,933
platforg/adobe-connect
src/AdobeConnect/Connection.php
Connection.connect
public function connect() { if (! $this->getCookie()) { $response = $this->doRequest('common-info'); $this->setCookie($response->getXmlResponse()->common->cookie); } $this->connected = true; }
php
public function connect() { if (! $this->getCookie()) { $response = $this->doRequest('common-info'); $this->setCookie($response->getXmlResponse()->common->cookie); } $this->connected = true; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getCookie", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "doRequest", "(", "'common-info'", ")", ";", "$", "this", "->", "setCookie", "(", "$", "response", "->", "getXmlResponse", "(", ")", "->", "common", "->", "cookie", ")", ";", "}", "$", "this", "->", "connected", "=", "true", ";", "}" ]
Establish a connection to AdobeConnect's server
[ "Establish", "a", "connection", "to", "AdobeConnect", "s", "server" ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/Connection.php#L47-L56
226,934
platforg/adobe-connect
src/AdobeConnect/Connection.php
Connection.doRequest
protected function doRequest($action, $params = array()) { if ('common-info' != $action && 'login' != $action) { $this->checkIfIsConnected(); $this->checkIfIsLoggedIn(); } if ($this->cookie && ! isset($params['session'])) { $params['session'] = $this->getCookie(); } return new Response(new Request($this->config->getHost(), $action, $params)); }
php
protected function doRequest($action, $params = array()) { if ('common-info' != $action && 'login' != $action) { $this->checkIfIsConnected(); $this->checkIfIsLoggedIn(); } if ($this->cookie && ! isset($params['session'])) { $params['session'] = $this->getCookie(); } return new Response(new Request($this->config->getHost(), $action, $params)); }
[ "protected", "function", "doRequest", "(", "$", "action", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "'common-info'", "!=", "$", "action", "&&", "'login'", "!=", "$", "action", ")", "{", "$", "this", "->", "checkIfIsConnected", "(", ")", ";", "$", "this", "->", "checkIfIsLoggedIn", "(", ")", ";", "}", "if", "(", "$", "this", "->", "cookie", "&&", "!", "isset", "(", "$", "params", "[", "'session'", "]", ")", ")", "{", "$", "params", "[", "'session'", "]", "=", "$", "this", "->", "getCookie", "(", ")", ";", "}", "return", "new", "Response", "(", "new", "Request", "(", "$", "this", "->", "config", "->", "getHost", "(", ")", ",", "$", "action", ",", "$", "params", ")", ")", ";", "}" ]
Call to an action from AdobeConnect's Server @param string $action @param array $params @return Response
[ "Call", "to", "an", "action", "from", "AdobeConnect", "s", "Server" ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/Connection.php#L112-L124
226,935
DavidHavl/DhErrorLogging
src/DhErrorLogging/Writer/DoctrineWriter.php
DoctrineWriter.populateEntityFromEvent
protected function populateEntityFromEvent($eventData, $entity) { if (empty($eventData)) { return $entity; } if (isset($eventData['extra'])) { $eventData = array_merge($eventData, $eventData['extra']); } foreach ($eventData as $name => $value) { if ($name === 'priorityName') { $name = 'priority'; } if (method_exists($entity, 'set' . ucfirst($name))) { $entity->{'set' . ucfirst($name)}($value); } } return $entity; }
php
protected function populateEntityFromEvent($eventData, $entity) { if (empty($eventData)) { return $entity; } if (isset($eventData['extra'])) { $eventData = array_merge($eventData, $eventData['extra']); } foreach ($eventData as $name => $value) { if ($name === 'priorityName') { $name = 'priority'; } if (method_exists($entity, 'set' . ucfirst($name))) { $entity->{'set' . ucfirst($name)}($value); } } return $entity; }
[ "protected", "function", "populateEntityFromEvent", "(", "$", "eventData", ",", "$", "entity", ")", "{", "if", "(", "empty", "(", "$", "eventData", ")", ")", "{", "return", "$", "entity", ";", "}", "if", "(", "isset", "(", "$", "eventData", "[", "'extra'", "]", ")", ")", "{", "$", "eventData", "=", "array_merge", "(", "$", "eventData", ",", "$", "eventData", "[", "'extra'", "]", ")", ";", "}", "foreach", "(", "$", "eventData", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "name", "===", "'priorityName'", ")", "{", "$", "name", "=", "'priority'", ";", "}", "if", "(", "method_exists", "(", "$", "entity", ",", "'set'", ".", "ucfirst", "(", "$", "name", ")", ")", ")", "{", "$", "entity", "->", "{", "'set'", ".", "ucfirst", "(", "$", "name", ")", "}", "(", "$", "value", ")", ";", "}", "}", "return", "$", "entity", ";", "}" ]
Transform event into column for the @param array $eventData @param $entity @return object
[ "Transform", "event", "into", "column", "for", "the" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Writer/DoctrineWriter.php#L77-L96
226,936
THECALLR/sdk-php
src/CALLR/Realtime/CallFlow.php
CallFlow.getVariable
public function getVariable($key) { $key = (string) $key; return $this->hasVariable($key) ? $this->currentRequest->variables->$key : null; }
php
public function getVariable($key) { $key = (string) $key; return $this->hasVariable($key) ? $this->currentRequest->variables->$key : null; }
[ "public", "function", "getVariable", "(", "$", "key", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "return", "$", "this", "->", "hasVariable", "(", "$", "key", ")", "?", "$", "this", "->", "currentRequest", "->", "variables", "->", "$", "key", ":", "null", ";", "}" ]
Get variable from Call Flow @param string $key Key @return mixed Value
[ "Get", "variable", "from", "Call", "Flow" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Realtime/CallFlow.php#L43-L47
226,937
THECALLR/sdk-php
src/CALLR/Realtime/CallFlow.php
CallFlow.setVariable
public function setVariable($key, $value) { $key = (string) $key; $this->currentRequest->variables->$key = $value; return true; }
php
public function setVariable($key, $value) { $key = (string) $key; $this->currentRequest->variables->$key = $value; return true; }
[ "public", "function", "setVariable", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "$", "this", "->", "currentRequest", "->", "variables", "->", "$", "key", "=", "$", "value", ";", "return", "true", ";", "}" ]
Set variable in Call Flow @param string $key Key @param mixed $value Value
[ "Set", "variable", "in", "Call", "Flow" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Realtime/CallFlow.php#L54-L59
226,938
CoopBelvedere/laravel-basecamp-api
src/Models/TodoList.php
TodoList.update
public function update(array $data) { $todolist = Basecamp::todoLists($this->bucket->id) ->update($this->id, $data); $this->setAttributes($todolist); return $todolist; }
php
public function update(array $data) { $todolist = Basecamp::todoLists($this->bucket->id) ->update($this->id, $data); $this->setAttributes($todolist); return $todolist; }
[ "public", "function", "update", "(", "array", "$", "data", ")", "{", "$", "todolist", "=", "Basecamp", "::", "todoLists", "(", "$", "this", "->", "bucket", "->", "id", ")", "->", "update", "(", "$", "this", "->", "id", ",", "$", "data", ")", ";", "$", "this", "->", "setAttributes", "(", "$", "todolist", ")", ";", "return", "$", "todolist", ";", "}" ]
Update the todo list. @param array $data @return \Illuminate\Http\Collection
[ "Update", "the", "todo", "list", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Models/TodoList.php#L38-L46
226,939
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFile.php
AssetFile.getAssetFileLastModified
public function getAssetFileLastModified() { if ($this->isAssetFilePathUrl()) { if ( //Retrieve headers ($aHeaders = get_headers($sAssetFilePath = $this->getAssetFilePath(), 1)) //Assert return is OK && strstr($aHeaders[0], '200') !== false //Retrieve last modified as DateTime && !empty($aHeaders['Last-Modified']) && $oLastModified = new \DateTime($aHeaders['Last-Modified']) ) { return $oLastModified->getTimestamp(); } else { $oCurlHandle = curl_init($sAssetFilePath); curl_setopt($oCurlHandle, CURLOPT_NOBODY, true); curl_setopt($oCurlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($oCurlHandle, CURLOPT_FILETIME, true); if (curl_exec($oCurlHandle) === false) { return null; } return curl_getinfo($oCurlHandle, CURLINFO_FILETIME) ? : null; } } else { \Zend\Stdlib\ErrorHandler::start(); $iAssetFileFilemtime = filemtime($this->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); return $iAssetFileFilemtime ? : null; } }
php
public function getAssetFileLastModified() { if ($this->isAssetFilePathUrl()) { if ( //Retrieve headers ($aHeaders = get_headers($sAssetFilePath = $this->getAssetFilePath(), 1)) //Assert return is OK && strstr($aHeaders[0], '200') !== false //Retrieve last modified as DateTime && !empty($aHeaders['Last-Modified']) && $oLastModified = new \DateTime($aHeaders['Last-Modified']) ) { return $oLastModified->getTimestamp(); } else { $oCurlHandle = curl_init($sAssetFilePath); curl_setopt($oCurlHandle, CURLOPT_NOBODY, true); curl_setopt($oCurlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($oCurlHandle, CURLOPT_FILETIME, true); if (curl_exec($oCurlHandle) === false) { return null; } return curl_getinfo($oCurlHandle, CURLINFO_FILETIME) ? : null; } } else { \Zend\Stdlib\ErrorHandler::start(); $iAssetFileFilemtime = filemtime($this->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); return $iAssetFileFilemtime ? : null; } }
[ "public", "function", "getAssetFileLastModified", "(", ")", "{", "if", "(", "$", "this", "->", "isAssetFilePathUrl", "(", ")", ")", "{", "if", "(", "//Retrieve headers", "(", "$", "aHeaders", "=", "get_headers", "(", "$", "sAssetFilePath", "=", "$", "this", "->", "getAssetFilePath", "(", ")", ",", "1", ")", ")", "//Assert return is OK", "&&", "strstr", "(", "$", "aHeaders", "[", "0", "]", ",", "'200'", ")", "!==", "false", "//Retrieve last modified as DateTime", "&&", "!", "empty", "(", "$", "aHeaders", "[", "'Last-Modified'", "]", ")", "&&", "$", "oLastModified", "=", "new", "\\", "DateTime", "(", "$", "aHeaders", "[", "'Last-Modified'", "]", ")", ")", "{", "return", "$", "oLastModified", "->", "getTimestamp", "(", ")", ";", "}", "else", "{", "$", "oCurlHandle", "=", "curl_init", "(", "$", "sAssetFilePath", ")", ";", "curl_setopt", "(", "$", "oCurlHandle", ",", "CURLOPT_NOBODY", ",", "true", ")", ";", "curl_setopt", "(", "$", "oCurlHandle", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "oCurlHandle", ",", "CURLOPT_FILETIME", ",", "true", ")", ";", "if", "(", "curl_exec", "(", "$", "oCurlHandle", ")", "===", "false", ")", "{", "return", "null", ";", "}", "return", "curl_getinfo", "(", "$", "oCurlHandle", ",", "CURLINFO_FILETIME", ")", "?", ":", "null", ";", "}", "}", "else", "{", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", ")", ";", "$", "iAssetFileFilemtime", "=", "filemtime", "(", "$", "this", "->", "getAssetFilePath", "(", ")", ")", ";", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", "true", ")", ";", "return", "$", "iAssetFileFilemtime", "?", ":", "null", ";", "}", "}" ]
Retrieve asset file last modified timestamp @return int|null
[ "Retrieve", "asset", "file", "last", "modified", "timestamp" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFile.php#L220-L248
226,940
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFile.php
AssetFile.getAssetFileSize
public function getAssetFileSize(){ // Remote file if ($this->isAssetFilePathUrl()) { if ( // Retrieve headers ($aHeaders = get_headers($sAssetFilePath = $this->getAssetFilePath(), 1)) // Assert return is OK && strstr($aHeaders[0], '200') !== false // Retrieve content length && !empty($aHeaders['Content-Length']) && $iAssetFileSize = $aHeaders['Content-Length'] ) { return $iAssetFileSize; } $oCurlHandle = curl_init($sAssetFilePath); curl_setopt($oCurlHandle, CURLOPT_NOBODY, true); curl_setopt($oCurlHandle, CURLOPT_RETURNTRANSFER, true); if (curl_exec($oCurlHandle) === false) { return null; } return curl_getinfo($oCurlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? : null; } // Local file \Zend\Stdlib\ErrorHandler::start(); $iAssetFileSize = filesize($this->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); return $iAssetFileSize ? : null; }
php
public function getAssetFileSize(){ // Remote file if ($this->isAssetFilePathUrl()) { if ( // Retrieve headers ($aHeaders = get_headers($sAssetFilePath = $this->getAssetFilePath(), 1)) // Assert return is OK && strstr($aHeaders[0], '200') !== false // Retrieve content length && !empty($aHeaders['Content-Length']) && $iAssetFileSize = $aHeaders['Content-Length'] ) { return $iAssetFileSize; } $oCurlHandle = curl_init($sAssetFilePath); curl_setopt($oCurlHandle, CURLOPT_NOBODY, true); curl_setopt($oCurlHandle, CURLOPT_RETURNTRANSFER, true); if (curl_exec($oCurlHandle) === false) { return null; } return curl_getinfo($oCurlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? : null; } // Local file \Zend\Stdlib\ErrorHandler::start(); $iAssetFileSize = filesize($this->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); return $iAssetFileSize ? : null; }
[ "public", "function", "getAssetFileSize", "(", ")", "{", "// Remote file", "if", "(", "$", "this", "->", "isAssetFilePathUrl", "(", ")", ")", "{", "if", "(", "// Retrieve headers", "(", "$", "aHeaders", "=", "get_headers", "(", "$", "sAssetFilePath", "=", "$", "this", "->", "getAssetFilePath", "(", ")", ",", "1", ")", ")", "// Assert return is OK", "&&", "strstr", "(", "$", "aHeaders", "[", "0", "]", ",", "'200'", ")", "!==", "false", "// Retrieve content length", "&&", "!", "empty", "(", "$", "aHeaders", "[", "'Content-Length'", "]", ")", "&&", "$", "iAssetFileSize", "=", "$", "aHeaders", "[", "'Content-Length'", "]", ")", "{", "return", "$", "iAssetFileSize", ";", "}", "$", "oCurlHandle", "=", "curl_init", "(", "$", "sAssetFilePath", ")", ";", "curl_setopt", "(", "$", "oCurlHandle", ",", "CURLOPT_NOBODY", ",", "true", ")", ";", "curl_setopt", "(", "$", "oCurlHandle", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "if", "(", "curl_exec", "(", "$", "oCurlHandle", ")", "===", "false", ")", "{", "return", "null", ";", "}", "return", "curl_getinfo", "(", "$", "oCurlHandle", ",", "CURLINFO_CONTENT_LENGTH_DOWNLOAD", ")", "?", ":", "null", ";", "}", "// Local file", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", ")", ";", "$", "iAssetFileSize", "=", "filesize", "(", "$", "this", "->", "getAssetFilePath", "(", ")", ")", ";", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", "true", ")", ";", "return", "$", "iAssetFileSize", "?", ":", "null", ";", "}" ]
Retrieve asset file size @return integer|null
[ "Retrieve", "asset", "file", "size" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFile.php#L254-L283
226,941
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFile.php
AssetFile.assetFileTypeExists
public static function assetFileTypeExists($sAssetFileType) { if (!is_string($sAssetFileType)) { throw new \InvalidArgumentException('Asset file type expects string, "' . gettype($sAssetFileType) . '" given'); } switch ($sAssetFileType) { case self::ASSET_CSS: case self::ASSET_LESS: case self::ASSET_JS: case self::ASSET_MEDIA: return true; default: return false; } }
php
public static function assetFileTypeExists($sAssetFileType) { if (!is_string($sAssetFileType)) { throw new \InvalidArgumentException('Asset file type expects string, "' . gettype($sAssetFileType) . '" given'); } switch ($sAssetFileType) { case self::ASSET_CSS: case self::ASSET_LESS: case self::ASSET_JS: case self::ASSET_MEDIA: return true; default: return false; } }
[ "public", "static", "function", "assetFileTypeExists", "(", "$", "sAssetFileType", ")", "{", "if", "(", "!", "is_string", "(", "$", "sAssetFileType", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Asset file type expects string, \"'", ".", "gettype", "(", "$", "sAssetFileType", ")", ".", "'\" given'", ")", ";", "}", "switch", "(", "$", "sAssetFileType", ")", "{", "case", "self", "::", "ASSET_CSS", ":", "case", "self", "::", "ASSET_LESS", ":", "case", "self", "::", "ASSET_JS", ":", "case", "self", "::", "ASSET_MEDIA", ":", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}" ]
Check if asset file's type is valid @param string $sAssetFileType @throws \InvalidArgumentException @return boolean
[ "Check", "if", "asset", "file", "s", "type", "is", "valid" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFile.php#L291-L305
226,942
DavidHavl/DhErrorLogging
src/DhErrorLogging/Sender/ResponseSender.php
ResponseSender.send
public function send(SendResponseEvent $event) { // Console // if ($this->response instanceof ConsoleResponse) { $templateContent = $this->getTemplateContent('console'); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $this->response->setContent($templateContent); $this->response->setErrorLevel(1); return $this->sendResponse($this->response); } // HTTP // $this->response->setStatusCode(500); $requestHeaders = $this->request->getHeaders(); if ($requestHeaders->has('accept')) { $accept = $requestHeaders->get('Accept'); $responseHeaders = $this->response->getHeaders(); $responseHeaders->clearHeaders(); if ($accept->match('text/html') !== false) { // html // get template content $templateContent = $this->getTemplateContent($event->getParam('type')); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $contentType = 'text/html; charset=utf-8'; $responseHeaders->addHeaderLine('content-type', $contentType); $this->response->setContent($templateContent); } else if ($accept->match('application/json') !== false || $accept->match('application/hal+json') !== false) { // json // return api problem structured json $contentType = 'application/problem+json; charset=utf-8'; $responseHeaders->addHeaderLine('content-type', $contentType); // get template $templateContent = $this->getTemplateContent('json'); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $this->response->setContent($templateContent); } } $this->sendResponse($this->response); }
php
public function send(SendResponseEvent $event) { // Console // if ($this->response instanceof ConsoleResponse) { $templateContent = $this->getTemplateContent('console'); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $this->response->setContent($templateContent); $this->response->setErrorLevel(1); return $this->sendResponse($this->response); } // HTTP // $this->response->setStatusCode(500); $requestHeaders = $this->request->getHeaders(); if ($requestHeaders->has('accept')) { $accept = $requestHeaders->get('Accept'); $responseHeaders = $this->response->getHeaders(); $responseHeaders->clearHeaders(); if ($accept->match('text/html') !== false) { // html // get template content $templateContent = $this->getTemplateContent($event->getParam('type')); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $contentType = 'text/html; charset=utf-8'; $responseHeaders->addHeaderLine('content-type', $contentType); $this->response->setContent($templateContent); } else if ($accept->match('application/json') !== false || $accept->match('application/hal+json') !== false) { // json // return api problem structured json $contentType = 'application/problem+json; charset=utf-8'; $responseHeaders->addHeaderLine('content-type', $contentType); // get template $templateContent = $this->getTemplateContent('json'); // inject details $templateContent = $this->injectTemplateContent($templateContent, $event->getParams()); $this->response->setContent($templateContent); } } $this->sendResponse($this->response); }
[ "public", "function", "send", "(", "SendResponseEvent", "$", "event", ")", "{", "// Console //", "if", "(", "$", "this", "->", "response", "instanceof", "ConsoleResponse", ")", "{", "$", "templateContent", "=", "$", "this", "->", "getTemplateContent", "(", "'console'", ")", ";", "// inject details", "$", "templateContent", "=", "$", "this", "->", "injectTemplateContent", "(", "$", "templateContent", ",", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "this", "->", "response", "->", "setContent", "(", "$", "templateContent", ")", ";", "$", "this", "->", "response", "->", "setErrorLevel", "(", "1", ")", ";", "return", "$", "this", "->", "sendResponse", "(", "$", "this", "->", "response", ")", ";", "}", "// HTTP //", "$", "this", "->", "response", "->", "setStatusCode", "(", "500", ")", ";", "$", "requestHeaders", "=", "$", "this", "->", "request", "->", "getHeaders", "(", ")", ";", "if", "(", "$", "requestHeaders", "->", "has", "(", "'accept'", ")", ")", "{", "$", "accept", "=", "$", "requestHeaders", "->", "get", "(", "'Accept'", ")", ";", "$", "responseHeaders", "=", "$", "this", "->", "response", "->", "getHeaders", "(", ")", ";", "$", "responseHeaders", "->", "clearHeaders", "(", ")", ";", "if", "(", "$", "accept", "->", "match", "(", "'text/html'", ")", "!==", "false", ")", "{", "// html", "// get template content", "$", "templateContent", "=", "$", "this", "->", "getTemplateContent", "(", "$", "event", "->", "getParam", "(", "'type'", ")", ")", ";", "// inject details", "$", "templateContent", "=", "$", "this", "->", "injectTemplateContent", "(", "$", "templateContent", ",", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "contentType", "=", "'text/html; charset=utf-8'", ";", "$", "responseHeaders", "->", "addHeaderLine", "(", "'content-type'", ",", "$", "contentType", ")", ";", "$", "this", "->", "response", "->", "setContent", "(", "$", "templateContent", ")", ";", "}", "else", "if", "(", "$", "accept", "->", "match", "(", "'application/json'", ")", "!==", "false", "||", "$", "accept", "->", "match", "(", "'application/hal+json'", ")", "!==", "false", ")", "{", "// json", "// return api problem structured json", "$", "contentType", "=", "'application/problem+json; charset=utf-8'", ";", "$", "responseHeaders", "->", "addHeaderLine", "(", "'content-type'", ",", "$", "contentType", ")", ";", "// get template", "$", "templateContent", "=", "$", "this", "->", "getTemplateContent", "(", "'json'", ")", ";", "// inject details", "$", "templateContent", "=", "$", "this", "->", "injectTemplateContent", "(", "$", "templateContent", ",", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "this", "->", "response", "->", "setContent", "(", "$", "templateContent", ")", ";", "}", "}", "$", "this", "->", "sendResponse", "(", "$", "this", "->", "response", ")", ";", "}" ]
Processes and send response to browser @param SendResponseEvent $event event data
[ "Processes", "and", "send", "response", "to", "browser" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Sender/ResponseSender.php#L46-L101
226,943
DavidHavl/DhErrorLogging
src/DhErrorLogging/Sender/ResponseSender.php
ResponseSender.sendResponse
public function sendResponse($response) { // clean any previous output from buffer. Not effective in some cases while (ob_get_level() > 0) { ob_end_clean(); } // console // if ($response instanceof ConsoleResponse) { echo $response->getContent(); $errorLevel = (int) $response->getErrorLevel(); exit($errorLevel); } // http // // send headers foreach ($response->getHeaders() as $header) { header($header->toString()); } // send status $status = $response->renderStatusLine(); header($status); // send content echo $response->getContent(); exit(1); }
php
public function sendResponse($response) { // clean any previous output from buffer. Not effective in some cases while (ob_get_level() > 0) { ob_end_clean(); } // console // if ($response instanceof ConsoleResponse) { echo $response->getContent(); $errorLevel = (int) $response->getErrorLevel(); exit($errorLevel); } // http // // send headers foreach ($response->getHeaders() as $header) { header($header->toString()); } // send status $status = $response->renderStatusLine(); header($status); // send content echo $response->getContent(); exit(1); }
[ "public", "function", "sendResponse", "(", "$", "response", ")", "{", "// clean any previous output from buffer. Not effective in some cases", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_clean", "(", ")", ";", "}", "// console //", "if", "(", "$", "response", "instanceof", "ConsoleResponse", ")", "{", "echo", "$", "response", "->", "getContent", "(", ")", ";", "$", "errorLevel", "=", "(", "int", ")", "$", "response", "->", "getErrorLevel", "(", ")", ";", "exit", "(", "$", "errorLevel", ")", ";", "}", "// http //", "// send headers", "foreach", "(", "$", "response", "->", "getHeaders", "(", ")", "as", "$", "header", ")", "{", "header", "(", "$", "header", "->", "toString", "(", ")", ")", ";", "}", "// send status", "$", "status", "=", "$", "response", "->", "renderStatusLine", "(", ")", ";", "header", "(", "$", "status", ")", ";", "// send content", "echo", "$", "response", "->", "getContent", "(", ")", ";", "exit", "(", "1", ")", ";", "}" ]
Send response to the browser @param $response
[ "Send", "response", "to", "the", "browser" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Sender/ResponseSender.php#L108-L138
226,944
DavidHavl/DhErrorLogging
src/DhErrorLogging/Sender/ResponseSender.php
ResponseSender.getTemplateContent
public function getTemplateContent($type) { $type = strtolower($type); $templateContent = "An error has occured."; if ($this->getOptions()->getTemplate($type) && file_exists($this->getOptions()->getTemplate($type))) { $templatePath = $this->getOptions()->getTemplate($type); // read content of file $templateContent = file_get_contents($templatePath); } // TODO: translations? return $templateContent; }
php
public function getTemplateContent($type) { $type = strtolower($type); $templateContent = "An error has occured."; if ($this->getOptions()->getTemplate($type) && file_exists($this->getOptions()->getTemplate($type))) { $templatePath = $this->getOptions()->getTemplate($type); // read content of file $templateContent = file_get_contents($templatePath); } // TODO: translations? return $templateContent; }
[ "public", "function", "getTemplateContent", "(", "$", "type", ")", "{", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "$", "templateContent", "=", "\"An error has occured.\"", ";", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getTemplate", "(", "$", "type", ")", "&&", "file_exists", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getTemplate", "(", "$", "type", ")", ")", ")", "{", "$", "templatePath", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getTemplate", "(", "$", "type", ")", ";", "// read content of file", "$", "templateContent", "=", "file_get_contents", "(", "$", "templatePath", ")", ";", "}", "// TODO: translations?", "return", "$", "templateContent", ";", "}" ]
Get content of template @param string $type type of the template @return string
[ "Get", "content", "of", "template" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Sender/ResponseSender.php#L166-L180
226,945
DavidHavl/DhErrorLogging
src/DhErrorLogging/Sender/ResponseSender.php
ResponseSender.injectTemplateContent
public function injectTemplateContent($content, $params) { return str_replace( array( '%__ERROR_TYPE__%', '%__ERROR_REFERENCE__%', '%__ERROR_MESSAGE__%', '%__ERROR_FILE__%', '%__ERROR_LINE__%' ), array_map('addslashes',array( $params['type'], $params['reference'], $params['message'], $params['file'], $params['line'] )), $content ); }
php
public function injectTemplateContent($content, $params) { return str_replace( array( '%__ERROR_TYPE__%', '%__ERROR_REFERENCE__%', '%__ERROR_MESSAGE__%', '%__ERROR_FILE__%', '%__ERROR_LINE__%' ), array_map('addslashes',array( $params['type'], $params['reference'], $params['message'], $params['file'], $params['line'] )), $content ); }
[ "public", "function", "injectTemplateContent", "(", "$", "content", ",", "$", "params", ")", "{", "return", "str_replace", "(", "array", "(", "'%__ERROR_TYPE__%'", ",", "'%__ERROR_REFERENCE__%'", ",", "'%__ERROR_MESSAGE__%'", ",", "'%__ERROR_FILE__%'", ",", "'%__ERROR_LINE__%'", ")", ",", "array_map", "(", "'addslashes'", ",", "array", "(", "$", "params", "[", "'type'", "]", ",", "$", "params", "[", "'reference'", "]", ",", "$", "params", "[", "'message'", "]", ",", "$", "params", "[", "'file'", "]", ",", "$", "params", "[", "'line'", "]", ")", ")", ",", "$", "content", ")", ";", "}" ]
replace placeholders in template with actual values @param string $content @param array $params @return string
[ "replace", "placeholders", "in", "template", "with", "actual", "values" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Sender/ResponseSender.php#L188-L207
226,946
pingpong-labs/shortcode
Shortcode.php
Shortcode.unregister
public function unregister($name) { if ($this->exists($name)) { $this->handlers->remove($name); } return $this; }
php
public function unregister($name) { if ($this->exists($name)) { $this->handlers->remove($name); } return $this; }
[ "public", "function", "unregister", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "name", ")", ")", "{", "$", "this", "->", "handlers", "->", "remove", "(", "$", "name", ")", ";", "}", "return", "$", "this", ";", "}" ]
Unregister the specified shortcode by given name. @param string $name
[ "Unregister", "the", "specified", "shortcode", "by", "given", "name", "." ]
8d1b9ade67512179c8a6049b49485a2a34fa3ed7
https://github.com/pingpong-labs/shortcode/blob/8d1b9ade67512179c8a6049b49485a2a34fa3ed7/Shortcode.php#L49-L56
226,947
pingpong-labs/shortcode
Shortcode.php
Shortcode.parse
public function parse($content) { $processor = new Processor(new RegexParser(), $this->handlers); return $processor->process($content); }
php
public function parse($content) { $processor = new Processor(new RegexParser(), $this->handlers); return $processor->process($content); }
[ "public", "function", "parse", "(", "$", "content", ")", "{", "$", "processor", "=", "new", "Processor", "(", "new", "RegexParser", "(", ")", ",", "$", "this", "->", "handlers", ")", ";", "return", "$", "processor", "->", "process", "(", "$", "content", ")", ";", "}" ]
Parse content and replace parts of it using registered handlers @param $content @return string
[ "Parse", "content", "and", "replace", "parts", "of", "it", "using", "registered", "handlers" ]
8d1b9ade67512179c8a6049b49485a2a34fa3ed7
https://github.com/pingpong-labs/shortcode/blob/8d1b9ade67512179c8a6049b49485a2a34fa3ed7/Shortcode.php#L139-L144
226,948
THECALLR/sdk-php
src/CALLR/Realtime/Response.php
Response.getJSON
public function getJSON() { /* convert to proper types */ $o = new \stdClass; $o->command = (string) $this->command; $o->command_id = $this->command_id; $o->params = (object) $this->params; $o->variables = (object) $this->variables; /* json */ return json_encode($o); }
php
public function getJSON() { /* convert to proper types */ $o = new \stdClass; $o->command = (string) $this->command; $o->command_id = $this->command_id; $o->params = (object) $this->params; $o->variables = (object) $this->variables; /* json */ return json_encode($o); }
[ "public", "function", "getJSON", "(", ")", "{", "/* convert to proper types */", "$", "o", "=", "new", "\\", "stdClass", ";", "$", "o", "->", "command", "=", "(", "string", ")", "$", "this", "->", "command", ";", "$", "o", "->", "command_id", "=", "$", "this", "->", "command_id", ";", "$", "o", "->", "params", "=", "(", "object", ")", "$", "this", "->", "params", ";", "$", "o", "->", "variables", "=", "(", "object", ")", "$", "this", "->", "variables", ";", "/* json */", "return", "json_encode", "(", "$", "o", ")", ";", "}" ]
get json response
[ "get", "json", "response" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Realtime/Response.php#L28-L38
226,949
beheh/flaps
src/Flaps/Flaps.php
Flaps.getFlap
public function getFlap($name) { $flap = new Flap($this->adapter, $name); if ($this->defaultViolationHandler !== null) { $flap->setViolationHandler($this->defaultViolationHandler); } return $flap; }
php
public function getFlap($name) { $flap = new Flap($this->adapter, $name); if ($this->defaultViolationHandler !== null) { $flap->setViolationHandler($this->defaultViolationHandler); } return $flap; }
[ "public", "function", "getFlap", "(", "$", "name", ")", "{", "$", "flap", "=", "new", "Flap", "(", "$", "this", "->", "adapter", ",", "$", "name", ")", ";", "if", "(", "$", "this", "->", "defaultViolationHandler", "!==", "null", ")", "{", "$", "flap", "->", "setViolationHandler", "(", "$", "this", "->", "defaultViolationHandler", ")", ";", "}", "return", "$", "flap", ";", "}" ]
Creates a new Flap and returns it, setting default violation handler., @param string $name the name of the flap @return \BehEh\Flaps\Flap the created flap
[ "Creates", "a", "new", "Flap", "and", "returns", "it", "setting", "default", "violation", "handler", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Flaps.php#L40-L47
226,950
OXID-eSales/oxideshop-doctrine-migration-wrapper
src/MigrationAvailabilityChecker.php
MigrationAvailabilityChecker.migrationExists
public function migrationExists($pathToConfiguration) { if (!is_file($pathToConfiguration)) { return false; } $pathToMigrationsDirectory = $this->getPathToMigrations($pathToConfiguration); if ($this->atLeastOneMigrationFileExist($pathToMigrationsDirectory)) { return true; } return false; }
php
public function migrationExists($pathToConfiguration) { if (!is_file($pathToConfiguration)) { return false; } $pathToMigrationsDirectory = $this->getPathToMigrations($pathToConfiguration); if ($this->atLeastOneMigrationFileExist($pathToMigrationsDirectory)) { return true; } return false; }
[ "public", "function", "migrationExists", "(", "$", "pathToConfiguration", ")", "{", "if", "(", "!", "is_file", "(", "$", "pathToConfiguration", ")", ")", "{", "return", "false", ";", "}", "$", "pathToMigrationsDirectory", "=", "$", "this", "->", "getPathToMigrations", "(", "$", "pathToConfiguration", ")", ";", "if", "(", "$", "this", "->", "atLeastOneMigrationFileExist", "(", "$", "pathToMigrationsDirectory", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if migrations exist. At least one file for migrations must exist. For example configuration exists, but no migration exist yet would result false. @param string $pathToConfiguration path to file which describes configuration for Doctrine Migrations. @return bool
[ "Check", "if", "migrations", "exist", ".", "At", "least", "one", "file", "for", "migrations", "must", "exist", ".", "For", "example", "configuration", "exists", "but", "no", "migration", "exist", "yet", "would", "result", "false", "." ]
abf24ece893cb2327e4836c5779d508beb034f3b
https://github.com/OXID-eSales/oxideshop-doctrine-migration-wrapper/blob/abf24ece893cb2327e4836c5779d508beb034f3b/src/MigrationAvailabilityChecker.php#L35-L47
226,951
OXID-eSales/oxideshop-doctrine-migration-wrapper
src/MigrationAvailabilityChecker.php
MigrationAvailabilityChecker.getPathToMigrations
private function getPathToMigrations($pathToConfiguration) { $pathToMigrationsRootDirectory = dirname($pathToConfiguration); $pathToMigrationsDirectory = $pathToMigrationsRootDirectory . DIRECTORY_SEPARATOR . 'data'; if (strpos($pathToConfiguration, 'project_migrations')) { $pathToMigrationsDirectory = $pathToMigrationsRootDirectory . DIRECTORY_SEPARATOR . 'project_data'; } return $pathToMigrationsDirectory; }
php
private function getPathToMigrations($pathToConfiguration) { $pathToMigrationsRootDirectory = dirname($pathToConfiguration); $pathToMigrationsDirectory = $pathToMigrationsRootDirectory . DIRECTORY_SEPARATOR . 'data'; if (strpos($pathToConfiguration, 'project_migrations')) { $pathToMigrationsDirectory = $pathToMigrationsRootDirectory . DIRECTORY_SEPARATOR . 'project_data'; } return $pathToMigrationsDirectory; }
[ "private", "function", "getPathToMigrations", "(", "$", "pathToConfiguration", ")", "{", "$", "pathToMigrationsRootDirectory", "=", "dirname", "(", "$", "pathToConfiguration", ")", ";", "$", "pathToMigrationsDirectory", "=", "$", "pathToMigrationsRootDirectory", ".", "DIRECTORY_SEPARATOR", ".", "'data'", ";", "if", "(", "strpos", "(", "$", "pathToConfiguration", ",", "'project_migrations'", ")", ")", "{", "$", "pathToMigrationsDirectory", "=", "$", "pathToMigrationsRootDirectory", ".", "DIRECTORY_SEPARATOR", ".", "'project_data'", ";", "}", "return", "$", "pathToMigrationsDirectory", ";", "}" ]
Find path to migration directory. Different path returned for a project migrations. @param string $pathToConfiguration @return string
[ "Find", "path", "to", "migration", "directory", ".", "Different", "path", "returned", "for", "a", "project", "migrations", "." ]
abf24ece893cb2327e4836c5779d508beb034f3b
https://github.com/OXID-eSales/oxideshop-doctrine-migration-wrapper/blob/abf24ece893cb2327e4836c5779d508beb034f3b/src/MigrationAvailabilityChecker.php#L57-L67
226,952
CoopBelvedere/laravel-basecamp-api
src/Sections/ScheduleEntries.php
ScheduleEntries.index
public function index($page = null, $status = null) { $url = sprintf('buckets/%d/schedules/%d/entries.json', $this->bucket, $this->parent); $entries = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($entries, ScheduleEntry::class); }
php
public function index($page = null, $status = null) { $url = sprintf('buckets/%d/schedules/%d/entries.json', $this->bucket, $this->parent); $entries = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($entries, ScheduleEntry::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ",", "$", "status", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/schedules/%d/entries.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "entries", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "entries", ",", "ScheduleEntry", "::", "class", ")", ";", "}" ]
Index all the schedule entries. @param int $page @param string $status @return \Illuminate\Support\Collection
[ "Index", "all", "the", "schedule", "entries", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ScheduleEntries.php#L16-L27
226,953
CoopBelvedere/laravel-basecamp-api
src/Sections/ScheduleEntries.php
ScheduleEntries.show
public function show($id) { $entry = $this->client->get( sprintf('buckets/%d/schedule_entries/%d.json', $this->bucket, $id) ); return new ScheduleEntry($this->response($entry)); }
php
public function show($id) { $entry = $this->client->get( sprintf('buckets/%d/schedule_entries/%d.json', $this->bucket, $id) ); return new ScheduleEntry($this->response($entry)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "entry", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/schedule_entries/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "ScheduleEntry", "(", "$", "this", "->", "response", "(", "$", "entry", ")", ")", ";", "}" ]
Get a schedule entry. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "schedule", "entry", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ScheduleEntries.php#L57-L64
226,954
CoopBelvedere/laravel-basecamp-api
src/Sections/ScheduleEntries.php
ScheduleEntries.store
public function store(array $data) { $entry = $this->client->post( sprintf('buckets/%d/schedules/%d/entries.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new ScheduleEntry($this->response($entry)); }
php
public function store(array $data) { $entry = $this->client->post( sprintf('buckets/%d/schedules/%d/entries.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new ScheduleEntry($this->response($entry)); }
[ "public", "function", "store", "(", "array", "$", "data", ")", "{", "$", "entry", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/schedules/%d/entries.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "ScheduleEntry", "(", "$", "this", "->", "response", "(", "$", "entry", ")", ")", ";", "}" ]
Store a schedule entry. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "schedule", "entry", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ScheduleEntries.php#L72-L82
226,955
CoopBelvedere/laravel-basecamp-api
src/Sections/ScheduleEntries.php
ScheduleEntries.update
public function update($id, array $data) { $entry = $this->client->put( sprintf('buckets/%d/schedule_entries/%d.json', $this->bucket, $id), [ 'json' => $data, ] ); return new ScheduleEntry($this->response($entry)); }
php
public function update($id, array $data) { $entry = $this->client->put( sprintf('buckets/%d/schedule_entries/%d.json', $this->bucket, $id), [ 'json' => $data, ] ); return new ScheduleEntry($this->response($entry)); }
[ "public", "function", "update", "(", "$", "id", ",", "array", "$", "data", ")", "{", "$", "entry", "=", "$", "this", "->", "client", "->", "put", "(", "sprintf", "(", "'buckets/%d/schedule_entries/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "ScheduleEntry", "(", "$", "this", "->", "response", "(", "$", "entry", ")", ")", ";", "}" ]
Update a schedule entry. @param int $id @param array $data @return \Illuminate\Support\Collection
[ "Update", "a", "schedule", "entry", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ScheduleEntries.php#L91-L101
226,956
CoopBelvedere/laravel-basecamp-api
src/Sections/Chatbots.php
Chatbots.index
public function index($page = null) { $url = sprintf('buckets/%d/chats/%d/integrations.json', $this->bucket, $this->parent); $chatbots = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($chatbots, Chatbot::class)->map(function ($chatbot) { $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }); }
php
public function index($page = null) { $url = sprintf('buckets/%d/chats/%d/integrations.json', $this->bucket, $this->parent); $chatbots = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($chatbots, Chatbot::class)->map(function ($chatbot) { $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/chats/%d/integrations.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "chatbots", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "chatbots", ",", "Chatbot", "::", "class", ")", "->", "map", "(", "function", "(", "$", "chatbot", ")", "{", "$", "chatbot", "->", "inContext", "(", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "return", "$", "chatbot", ";", "}", ")", ";", "}" ]
Index all chatbots. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "chatbots", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Chatbots.php#L15-L29
226,957
CoopBelvedere/laravel-basecamp-api
src/Sections/Chatbots.php
Chatbots.show
public function show($id) { $chatbot = $this->client->get( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id) ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
php
public function show($id) { $chatbot = $this->client->get( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id) ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "chatbot", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/chats/%d/integrations/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ",", "$", "id", ")", ")", ";", "$", "chatbot", "=", "new", "Chatbot", "(", "$", "this", "->", "response", "(", "$", "chatbot", ")", ")", ";", "$", "chatbot", "->", "inContext", "(", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "return", "$", "chatbot", ";", "}" ]
Get a chatbot. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "chatbot", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Chatbots.php#L37-L46
226,958
CoopBelvedere/laravel-basecamp-api
src/Sections/Chatbots.php
Chatbots.store
public function store(array $data) { $chatbot = $this->client->post( sprintf('buckets/%d/chats/%d/integrations.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
php
public function store(array $data) { $chatbot = $this->client->post( sprintf('buckets/%d/chats/%d/integrations.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
[ "public", "function", "store", "(", "array", "$", "data", ")", "{", "$", "chatbot", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/chats/%d/integrations.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "$", "chatbot", "=", "new", "Chatbot", "(", "$", "this", "->", "response", "(", "$", "chatbot", ")", ")", ";", "$", "chatbot", "->", "inContext", "(", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "return", "$", "chatbot", ";", "}" ]
Create a chatbot. @param array $data @return \Illuminate\Support\Collection
[ "Create", "a", "chatbot", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Chatbots.php#L54-L66
226,959
CoopBelvedere/laravel-basecamp-api
src/Sections/Chatbots.php
Chatbots.update
public function update($id, array $data) { $chatbot = $this->client->put( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id), [ 'json' => $data ] ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
php
public function update($id, array $data) { $chatbot = $this->client->put( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id), [ 'json' => $data ] ); $chatbot = new Chatbot($this->response($chatbot)); $chatbot->inContext($this->bucket, $this->parent); return $chatbot; }
[ "public", "function", "update", "(", "$", "id", ",", "array", "$", "data", ")", "{", "$", "chatbot", "=", "$", "this", "->", "client", "->", "put", "(", "sprintf", "(", "'buckets/%d/chats/%d/integrations/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ",", "$", "id", ")", ",", "[", "'json'", "=>", "$", "data", "]", ")", ";", "$", "chatbot", "=", "new", "Chatbot", "(", "$", "this", "->", "response", "(", "$", "chatbot", ")", ")", ";", "$", "chatbot", "->", "inContext", "(", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "return", "$", "chatbot", ";", "}" ]
Update a chatbot. @param int $id @param array $data @return \Illuminate\Support\Collection
[ "Update", "a", "chatbot", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Chatbots.php#L75-L87
226,960
CoopBelvedere/laravel-basecamp-api
src/Sections/Chatbots.php
Chatbots.destroy
public function destroy($id) { return $this->client->delete( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id) ); }
php
public function destroy($id) { return $this->client->delete( sprintf('buckets/%d/chats/%d/integrations/%d.json', $this->bucket, $this->parent, $id) ); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "return", "$", "this", "->", "client", "->", "delete", "(", "sprintf", "(", "'buckets/%d/chats/%d/integrations/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ",", "$", "id", ")", ")", ";", "}" ]
Delete a chatbot. @param int $id @return \Illuminate\Support\Collection
[ "Delete", "a", "chatbot", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Chatbots.php#L95-L100
226,961
OXID-eSales/oxideshop-doctrine-migration-wrapper
src/DoctrineApplicationBuilder.php
DoctrineApplicationBuilder.build
public function build() { $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $doctrineApplication = \Doctrine\DBAL\Migrations\Tools\Console\ConsoleRunner::createApplication($helperSet); $doctrineApplication->setAutoExit(false); $doctrineApplication->setCatchExceptions(false); // we handle the exception on our own! return $doctrineApplication; }
php
public function build() { $helperSet = new \Symfony\Component\Console\Helper\HelperSet(); $doctrineApplication = \Doctrine\DBAL\Migrations\Tools\Console\ConsoleRunner::createApplication($helperSet); $doctrineApplication->setAutoExit(false); $doctrineApplication->setCatchExceptions(false); // we handle the exception on our own! return $doctrineApplication; }
[ "public", "function", "build", "(", ")", "{", "$", "helperSet", "=", "new", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Helper", "\\", "HelperSet", "(", ")", ";", "$", "doctrineApplication", "=", "\\", "Doctrine", "\\", "DBAL", "\\", "Migrations", "\\", "Tools", "\\", "Console", "\\", "ConsoleRunner", "::", "createApplication", "(", "$", "helperSet", ")", ";", "$", "doctrineApplication", "->", "setAutoExit", "(", "false", ")", ";", "$", "doctrineApplication", "->", "setCatchExceptions", "(", "false", ")", ";", "// we handle the exception on our own!", "return", "$", "doctrineApplication", ";", "}" ]
Return new application for each build. Application has a reference to command which has internal cache. Reusing same application object with same command leads to an errors due to an old configuration. For example first run with a CE migrations second run with PE migrations both runs would take path to CE migrations. @return \Symfony\Component\Console\Application
[ "Return", "new", "application", "for", "each", "build", ".", "Application", "has", "a", "reference", "to", "command", "which", "has", "internal", "cache", ".", "Reusing", "same", "application", "object", "with", "same", "command", "leads", "to", "an", "errors", "due", "to", "an", "old", "configuration", ".", "For", "example", "first", "run", "with", "a", "CE", "migrations", "second", "run", "with", "PE", "migrations", "both", "runs", "would", "take", "path", "to", "CE", "migrations", "." ]
abf24ece893cb2327e4836c5779d508beb034f3b
https://github.com/OXID-eSales/oxideshop-doctrine-migration-wrapper/blob/abf24ece893cb2327e4836c5779d508beb034f3b/src/DoctrineApplicationBuilder.php#L23-L31
226,962
DavidHavl/DhErrorLogging
src/DhErrorLogging/Options/ModuleOptions.php
ModuleOptions.getTemplate
public function getTemplate($key) { if (isset($this->templates[$key])) { return $this->templates[$key]; } return null; }
php
public function getTemplate($key) { if (isset($this->templates[$key])) { return $this->templates[$key]; } return null; }
[ "public", "function", "getTemplate", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "templates", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "templates", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Get template by key @param string $key key of the template @return string
[ "Get", "template", "by", "key" ]
107b34382d89d634312e54ebb0b20107ac0e0259
https://github.com/DavidHavl/DhErrorLogging/blob/107b34382d89d634312e54ebb0b20107ac0e0259/src/DhErrorLogging/Options/ModuleOptions.php#L151-L157
226,963
THECALLR/sdk-php
src/CALLR/API/Request.php
Request.send
public function send( $url, $auth = null, array $headers = [], $proxy = null, $raw_response = false ) { /* JSON-RPC request */ $request = new \stdClass; $request->id = (int) $this->id; $request->method = (string) $this->method; $request->params = (array) $this->convertParams(); $request->jsonrpc = self::JSON_RPC_VERSION; /* content type */ $headers[] = 'Content-Type: application/json-rpc; charset=utf-8'; $headers[] = 'User-Agent: sdk=PHP; sdk-version='.Client::SDK_VERSION.'; lang-version=' . phpversion() . '; platform='. PHP_OS; $headers[] = 'Expect:'; // avoid lighttpd bug /* curl */ $c = curl_init($url); if ($auth instanceof AuthenticationInterface) { $headers = array_merge($headers, array_values($auth->getHeaders())); $auth->applyCurlOptions($c); } elseif (!empty($auth)) { trigger_error('Using a string for auth is deprecated, use a proper Authenticator instead', E_USER_DEPRECATED); curl_setopt($c, CURLOPT_USERPWD, $auth); } curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_FAILONERROR, true); curl_setopt($c, CURLOPT_HTTPHEADER, $headers); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request)); curl_setopt($c, CURLOPT_FORBID_REUSE, false); if (is_string($proxy)) { curl_setopt($c, CURLOPT_PROXY, $proxy); } $data = curl_exec($c); /* curl error */ if ($data === false) { throw new Exception\LocalException('CURL_ERROR: '.curl_error($c), curl_errno($c)); } curl_close($c); /* response */ return $raw_response ? $data : new Response($data); }
php
public function send( $url, $auth = null, array $headers = [], $proxy = null, $raw_response = false ) { /* JSON-RPC request */ $request = new \stdClass; $request->id = (int) $this->id; $request->method = (string) $this->method; $request->params = (array) $this->convertParams(); $request->jsonrpc = self::JSON_RPC_VERSION; /* content type */ $headers[] = 'Content-Type: application/json-rpc; charset=utf-8'; $headers[] = 'User-Agent: sdk=PHP; sdk-version='.Client::SDK_VERSION.'; lang-version=' . phpversion() . '; platform='. PHP_OS; $headers[] = 'Expect:'; // avoid lighttpd bug /* curl */ $c = curl_init($url); if ($auth instanceof AuthenticationInterface) { $headers = array_merge($headers, array_values($auth->getHeaders())); $auth->applyCurlOptions($c); } elseif (!empty($auth)) { trigger_error('Using a string for auth is deprecated, use a proper Authenticator instead', E_USER_DEPRECATED); curl_setopt($c, CURLOPT_USERPWD, $auth); } curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_FAILONERROR, true); curl_setopt($c, CURLOPT_HTTPHEADER, $headers); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request)); curl_setopt($c, CURLOPT_FORBID_REUSE, false); if (is_string($proxy)) { curl_setopt($c, CURLOPT_PROXY, $proxy); } $data = curl_exec($c); /* curl error */ if ($data === false) { throw new Exception\LocalException('CURL_ERROR: '.curl_error($c), curl_errno($c)); } curl_close($c); /* response */ return $raw_response ? $data : new Response($data); }
[ "public", "function", "send", "(", "$", "url", ",", "$", "auth", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ",", "$", "proxy", "=", "null", ",", "$", "raw_response", "=", "false", ")", "{", "/* JSON-RPC request */", "$", "request", "=", "new", "\\", "stdClass", ";", "$", "request", "->", "id", "=", "(", "int", ")", "$", "this", "->", "id", ";", "$", "request", "->", "method", "=", "(", "string", ")", "$", "this", "->", "method", ";", "$", "request", "->", "params", "=", "(", "array", ")", "$", "this", "->", "convertParams", "(", ")", ";", "$", "request", "->", "jsonrpc", "=", "self", "::", "JSON_RPC_VERSION", ";", "/* content type */", "$", "headers", "[", "]", "=", "'Content-Type: application/json-rpc; charset=utf-8'", ";", "$", "headers", "[", "]", "=", "'User-Agent: sdk=PHP; sdk-version='", ".", "Client", "::", "SDK_VERSION", ".", "'; lang-version='", ".", "phpversion", "(", ")", ".", "'; platform='", ".", "PHP_OS", ";", "$", "headers", "[", "]", "=", "'Expect:'", ";", "// avoid lighttpd bug", "/* curl */", "$", "c", "=", "curl_init", "(", "$", "url", ")", ";", "if", "(", "$", "auth", "instanceof", "AuthenticationInterface", ")", "{", "$", "headers", "=", "array_merge", "(", "$", "headers", ",", "array_values", "(", "$", "auth", "->", "getHeaders", "(", ")", ")", ")", ";", "$", "auth", "->", "applyCurlOptions", "(", "$", "c", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "auth", ")", ")", "{", "trigger_error", "(", "'Using a string for auth is deprecated, use a proper Authenticator instead'", ",", "E_USER_DEPRECATED", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_USERPWD", ",", "$", "auth", ")", ";", "}", "curl_setopt", "(", "$", "c", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_FAILONERROR", ",", "true", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_POSTFIELDS", ",", "json_encode", "(", "$", "request", ")", ")", ";", "curl_setopt", "(", "$", "c", ",", "CURLOPT_FORBID_REUSE", ",", "false", ")", ";", "if", "(", "is_string", "(", "$", "proxy", ")", ")", "{", "curl_setopt", "(", "$", "c", ",", "CURLOPT_PROXY", ",", "$", "proxy", ")", ";", "}", "$", "data", "=", "curl_exec", "(", "$", "c", ")", ";", "/* curl error */", "if", "(", "$", "data", "===", "false", ")", "{", "throw", "new", "Exception", "\\", "LocalException", "(", "'CURL_ERROR: '", ".", "curl_error", "(", "$", "c", ")", ",", "curl_errno", "(", "$", "c", ")", ")", ";", "}", "curl_close", "(", "$", "c", ")", ";", "/* response */", "return", "$", "raw_response", "?", "$", "data", ":", "new", "Response", "(", "$", "data", ")", ";", "}" ]
Send the request! @param string $url Endpoint URL @param string|AuthenticationInterface $auth Endpoint HTTP Basic Authentication @param string[] $headers HTTP headers (array of "Key: Value" strings) @param bool $raw_response Returns the raw response @param string $proxy HTTP proxy to use @return \CALLR\API\Response Response object @throws \CALLR\API\Exception\LocalException
[ "Send", "the", "request!" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/API/Request.php#L28-L80
226,964
nstapelbroek/culpa-laravel-5
src/Facades/Schema.php
Schema.getSchemaBuilder
protected static function getSchemaBuilder(Connection $connection) { $schemaBuilder = $connection->getSchemaBuilder(); $schemaBuilder->blueprintResolver(function ($table, $callback) { return new Blueprint($table, $callback); }); return $schemaBuilder; }
php
protected static function getSchemaBuilder(Connection $connection) { $schemaBuilder = $connection->getSchemaBuilder(); $schemaBuilder->blueprintResolver(function ($table, $callback) { return new Blueprint($table, $callback); }); return $schemaBuilder; }
[ "protected", "static", "function", "getSchemaBuilder", "(", "Connection", "$", "connection", ")", "{", "$", "schemaBuilder", "=", "$", "connection", "->", "getSchemaBuilder", "(", ")", ";", "$", "schemaBuilder", "->", "blueprintResolver", "(", "function", "(", "$", "table", ",", "$", "callback", ")", "{", "return", "new", "Blueprint", "(", "$", "table", ",", "$", "callback", ")", ";", "}", ")", ";", "return", "$", "schemaBuilder", ";", "}" ]
Retrieve the schema builder for the database connection. And set a custom blueprint resolver to return an instance of the Culpa Blueprint class. @param Connection $connection @return \Illuminate\Database\Schema\Builder
[ "Retrieve", "the", "schema", "builder", "for", "the", "database", "connection", ".", "And", "set", "a", "custom", "blueprint", "resolver", "to", "return", "an", "instance", "of", "the", "Culpa", "Blueprint", "class", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Facades/Schema.php#L43-L51
226,965
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.updateBlameables
protected function updateBlameables(Model $model) { $user = $this->getActiveUser(); if (is_null($user)) { return; // Todo: might be wise to implement loggin here } // Set updated-by if it has not been touched on this model if ($this->isBlameable($model, 'updated') && !$model->isDirty($this->getColumn($model, 'updated'))) { $this->setUpdatedBy($model, $user); } // Determine if we need to touch the created stamp if ($model->exists) { return; } // Set created-by if the model does not exist if ($this->isBlameable($model, 'created') && !$model->isDirty($this->getColumn($model, 'created'))) { $this->setCreatedBy($model, $user); } }
php
protected function updateBlameables(Model $model) { $user = $this->getActiveUser(); if (is_null($user)) { return; // Todo: might be wise to implement loggin here } // Set updated-by if it has not been touched on this model if ($this->isBlameable($model, 'updated') && !$model->isDirty($this->getColumn($model, 'updated'))) { $this->setUpdatedBy($model, $user); } // Determine if we need to touch the created stamp if ($model->exists) { return; } // Set created-by if the model does not exist if ($this->isBlameable($model, 'created') && !$model->isDirty($this->getColumn($model, 'created'))) { $this->setCreatedBy($model, $user); } }
[ "protected", "function", "updateBlameables", "(", "Model", "$", "model", ")", "{", "$", "user", "=", "$", "this", "->", "getActiveUser", "(", ")", ";", "if", "(", "is_null", "(", "$", "user", ")", ")", "{", "return", ";", "// Todo: might be wise to implement loggin here", "}", "// Set updated-by if it has not been touched on this model", "if", "(", "$", "this", "->", "isBlameable", "(", "$", "model", ",", "'updated'", ")", "&&", "!", "$", "model", "->", "isDirty", "(", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'updated'", ")", ")", ")", "{", "$", "this", "->", "setUpdatedBy", "(", "$", "model", ",", "$", "user", ")", ";", "}", "// Determine if we need to touch the created stamp", "if", "(", "$", "model", "->", "exists", ")", "{", "return", ";", "}", "// Set created-by if the model does not exist", "if", "(", "$", "this", "->", "isBlameable", "(", "$", "model", ",", "'created'", ")", "&&", "!", "$", "model", "->", "isDirty", "(", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'created'", ")", ")", ")", "{", "$", "this", "->", "setCreatedBy", "(", "$", "model", ",", "$", "user", ")", ";", "}", "}" ]
Update the blameable fields. @param Model $model @throws \Exception
[ "Update", "the", "blameable", "fields", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L61-L83
226,966
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.updateDeleteBlameable
public function updateDeleteBlameable(Model $model) { $user = $this->getActiveUser(); if (is_null($user)) { return; } // Set deleted-at if it has not been touched if ($this->isBlameable($model, 'deleted') && !$model->isDirty($this->getColumn($model, 'deleted'))) { $this->setDeletedBy($model, $user); $model->save(); } }
php
public function updateDeleteBlameable(Model $model) { $user = $this->getActiveUser(); if (is_null($user)) { return; } // Set deleted-at if it has not been touched if ($this->isBlameable($model, 'deleted') && !$model->isDirty($this->getColumn($model, 'deleted'))) { $this->setDeletedBy($model, $user); $model->save(); } }
[ "public", "function", "updateDeleteBlameable", "(", "Model", "$", "model", ")", "{", "$", "user", "=", "$", "this", "->", "getActiveUser", "(", ")", ";", "if", "(", "is_null", "(", "$", "user", ")", ")", "{", "return", ";", "}", "// Set deleted-at if it has not been touched", "if", "(", "$", "this", "->", "isBlameable", "(", "$", "model", ",", "'deleted'", ")", "&&", "!", "$", "model", "->", "isDirty", "(", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'deleted'", ")", ")", ")", "{", "$", "this", "->", "setDeletedBy", "(", "$", "model", ",", "$", "user", ")", ";", "$", "model", "->", "save", "(", ")", ";", "}", "}" ]
Update the deletedBy blameable field. @param Model $model @throws \Exception
[ "Update", "the", "deletedBy", "blameable", "field", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L90-L104
226,967
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.getActiveUser
protected function getActiveUser() { if (!Config::has('culpa.users.active_user')) { return Auth::check() ? Auth::user() : null; } $fn = Config::get('culpa.users.active_user'); if (!is_callable($fn)) { throw new \Exception('culpa.users.active_user should be a closure'); } return $fn(); }
php
protected function getActiveUser() { if (!Config::has('culpa.users.active_user')) { return Auth::check() ? Auth::user() : null; } $fn = Config::get('culpa.users.active_user'); if (!is_callable($fn)) { throw new \Exception('culpa.users.active_user should be a closure'); } return $fn(); }
[ "protected", "function", "getActiveUser", "(", ")", "{", "if", "(", "!", "Config", "::", "has", "(", "'culpa.users.active_user'", ")", ")", "{", "return", "Auth", "::", "check", "(", ")", "?", "Auth", "::", "user", "(", ")", ":", "null", ";", "}", "$", "fn", "=", "Config", "::", "get", "(", "'culpa.users.active_user'", ")", ";", "if", "(", "!", "is_callable", "(", "$", "fn", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'culpa.users.active_user should be a closure'", ")", ";", "}", "return", "$", "fn", "(", ")", ";", "}" ]
Get the active user. @return User @throws \Exception
[ "Get", "the", "active", "user", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L112-L124
226,968
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.setCreatedBy
protected function setCreatedBy(Model $model, $user) { $model->{$this->getColumn($model, 'created')} = $user->id; if ($model instanceof CreatorAware) { $model->setRelation('creator', $user); } return $model; }
php
protected function setCreatedBy(Model $model, $user) { $model->{$this->getColumn($model, 'created')} = $user->id; if ($model instanceof CreatorAware) { $model->setRelation('creator', $user); } return $model; }
[ "protected", "function", "setCreatedBy", "(", "Model", "$", "model", ",", "$", "user", ")", "{", "$", "model", "->", "{", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'created'", ")", "}", "=", "$", "user", "->", "id", ";", "if", "(", "$", "model", "instanceof", "CreatorAware", ")", "{", "$", "model", "->", "setRelation", "(", "'creator'", ",", "$", "user", ")", ";", "}", "return", "$", "model", ";", "}" ]
Set the created-by field of the model. @param \Illuminate\Database\Eloquent\Model $model @param User $user @return \Illuminate\Database\Eloquent\Model
[ "Set", "the", "created", "-", "by", "field", "of", "the", "model", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L145-L154
226,969
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.setUpdatedBy
protected function setUpdatedBy(Model $model, $user) { $model->{$this->getColumn($model, 'updated')} = $user->id; if ($model instanceof UpdaterAware) { $model->setRelation('updater', $user); } return $model; }
php
protected function setUpdatedBy(Model $model, $user) { $model->{$this->getColumn($model, 'updated')} = $user->id; if ($model instanceof UpdaterAware) { $model->setRelation('updater', $user); } return $model; }
[ "protected", "function", "setUpdatedBy", "(", "Model", "$", "model", ",", "$", "user", ")", "{", "$", "model", "->", "{", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'updated'", ")", "}", "=", "$", "user", "->", "id", ";", "if", "(", "$", "model", "instanceof", "UpdaterAware", ")", "{", "$", "model", "->", "setRelation", "(", "'updater'", ",", "$", "user", ")", ";", "}", "return", "$", "model", ";", "}" ]
Set the updated-by field of the model. @param \Illuminate\Database\Eloquent\Model $model @param User $user @return \Illuminate\Database\Eloquent\Model
[ "Set", "the", "updated", "-", "by", "field", "of", "the", "model", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L164-L173
226,970
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.setDeletedBy
protected function setDeletedBy(Model $model, $user) { $model->{$this->getColumn($model, 'deleted')} = $user->id; if ($model instanceof EraserAware) { $model->setRelation('eraser', $user); } return $model; }
php
protected function setDeletedBy(Model $model, $user) { $model->{$this->getColumn($model, 'deleted')} = $user->id; if ($model instanceof EraserAware) { $model->setRelation('eraser', $user); } return $model; }
[ "protected", "function", "setDeletedBy", "(", "Model", "$", "model", ",", "$", "user", ")", "{", "$", "model", "->", "{", "$", "this", "->", "getColumn", "(", "$", "model", ",", "'deleted'", ")", "}", "=", "$", "user", "->", "id", ";", "if", "(", "$", "model", "instanceof", "EraserAware", ")", "{", "$", "model", "->", "setRelation", "(", "'eraser'", ",", "$", "user", ")", ";", "}", "return", "$", "model", ";", "}" ]
Set the deleted-by field of the model. @param \Illuminate\Database\Eloquent\Model $model @param User $user @return \Illuminate\Database\Eloquent\Model
[ "Set", "the", "deleted", "-", "by", "field", "of", "the", "model", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L183-L192
226,971
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.extractBlamableFields
protected static function extractBlamableFields(array $blameableValue) { $fields = array(); $checkedFields = array('created', 'updated', 'deleted'); foreach ($checkedFields as $possibleField) { if (array_key_exists($possibleField, $blameableValue)) { $fields[$possibleField] = $blameableValue[$possibleField]; continue; } if (in_array($possibleField, $blameableValue)) { $defaultValue = $possibleField . '_by'; $configKey = 'culpa.default_fields.' . $possibleField; $fields[$possibleField] = Config::get($configKey, $defaultValue); } } return $fields; }
php
protected static function extractBlamableFields(array $blameableValue) { $fields = array(); $checkedFields = array('created', 'updated', 'deleted'); foreach ($checkedFields as $possibleField) { if (array_key_exists($possibleField, $blameableValue)) { $fields[$possibleField] = $blameableValue[$possibleField]; continue; } if (in_array($possibleField, $blameableValue)) { $defaultValue = $possibleField . '_by'; $configKey = 'culpa.default_fields.' . $possibleField; $fields[$possibleField] = Config::get($configKey, $defaultValue); } } return $fields; }
[ "protected", "static", "function", "extractBlamableFields", "(", "array", "$", "blameableValue", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "checkedFields", "=", "array", "(", "'created'", ",", "'updated'", ",", "'deleted'", ")", ";", "foreach", "(", "$", "checkedFields", "as", "$", "possibleField", ")", "{", "if", "(", "array_key_exists", "(", "$", "possibleField", ",", "$", "blameableValue", ")", ")", "{", "$", "fields", "[", "$", "possibleField", "]", "=", "$", "blameableValue", "[", "$", "possibleField", "]", ";", "continue", ";", "}", "if", "(", "in_array", "(", "$", "possibleField", ",", "$", "blameableValue", ")", ")", "{", "$", "defaultValue", "=", "$", "possibleField", ".", "'_by'", ";", "$", "configKey", "=", "'culpa.default_fields.'", ".", "$", "possibleField", ";", "$", "fields", "[", "$", "possibleField", "]", "=", "Config", "::", "get", "(", "$", "configKey", ",", "$", "defaultValue", ")", ";", "}", "}", "return", "$", "fields", ";", "}" ]
Internal method that matches the extracted blamable property values with eloquent fields @param array $blameableValue @return array
[ "Internal", "method", "that", "matches", "the", "extracted", "blamable", "property", "values", "with", "eloquent", "fields" ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L268-L287
226,972
nstapelbroek/culpa-laravel-5
src/Observers/BlameableObserver.php
BlameableObserver.getBlameableFields
protected function getBlameableFields(Model $model) { if (isset($this->fields)) { return $this->fields; } $this->fields = self::findBlameableFields($model); return $this->fields; }
php
protected function getBlameableFields(Model $model) { if (isset($this->fields)) { return $this->fields; } $this->fields = self::findBlameableFields($model); return $this->fields; }
[ "protected", "function", "getBlameableFields", "(", "Model", "$", "model", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", ")", ")", "{", "return", "$", "this", "->", "fields", ";", "}", "$", "this", "->", "fields", "=", "self", "::", "findBlameableFields", "(", "$", "model", ")", ";", "return", "$", "this", "->", "fields", ";", "}" ]
Get the blameable fields. @param Model $model @return array
[ "Get", "the", "blameable", "fields", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Observers/BlameableObserver.php#L295-L304
226,973
forceedge01/behat-fail-aid
bootstrap/Context/FailureContext.php
FailureContext.gatherDebugBarDetails
public function gatherDebugBarDetails(array $debugBarSelectors, DocumentElement $page) { $details = ''; foreach ($debugBarSelectors as $name => $selector) { $details .= ' [' . strtoupper($name) . '] '; if ($detailText = $page->find('css', $selector)) { $details .= $detailText->getText(); } else { $details .= 'Element "' . $selector . '" Not Found.'; } $details .= PHP_EOL; } return $details; }
php
public function gatherDebugBarDetails(array $debugBarSelectors, DocumentElement $page) { $details = ''; foreach ($debugBarSelectors as $name => $selector) { $details .= ' [' . strtoupper($name) . '] '; if ($detailText = $page->find('css', $selector)) { $details .= $detailText->getText(); } else { $details .= 'Element "' . $selector . '" Not Found.'; } $details .= PHP_EOL; } return $details; }
[ "public", "function", "gatherDebugBarDetails", "(", "array", "$", "debugBarSelectors", ",", "DocumentElement", "$", "page", ")", "{", "$", "details", "=", "''", ";", "foreach", "(", "$", "debugBarSelectors", "as", "$", "name", "=>", "$", "selector", ")", "{", "$", "details", ".=", "' ['", ".", "strtoupper", "(", "$", "name", ")", ".", "'] '", ";", "if", "(", "$", "detailText", "=", "$", "page", "->", "find", "(", "'css'", ",", "$", "selector", ")", ")", "{", "$", "details", ".=", "$", "detailText", "->", "getText", "(", ")", ";", "}", "else", "{", "$", "details", ".=", "'Element \"'", ".", "$", "selector", ".", "'\" Not Found.'", ";", "}", "$", "details", ".=", "PHP_EOL", ";", "}", "return", "$", "details", ";", "}" ]
Override if gathering details is complex. @param array $debugBarSelectors @param DocumentElement $page @return string
[ "Override", "if", "gathering", "details", "is", "complex", "." ]
4f54700035954bde487e87dc4f632b119bab7f47
https://github.com/forceedge01/behat-fail-aid/blob/4f54700035954bde487e87dc4f632b119bab7f47/bootstrap/Context/FailureContext.php#L345-L358
226,974
CoopBelvedere/laravel-basecamp-api
src/Sections/MessageTypes.php
MessageTypes.index
public function index($page = null) { $url = sprintf('buckets/%d/categories.json', $this->bucket); $messageTypes = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($messageTypes, MessageType::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/categories.json', $this->bucket); $messageTypes = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($messageTypes, MessageType::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/categories.json'", ",", "$", "this", "->", "bucket", ")", ";", "$", "messageTypes", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "messageTypes", ",", "MessageType", "::", "class", ")", ";", "}" ]
Index all message types. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "message", "types", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/MessageTypes.php#L15-L26
226,975
CoopBelvedere/laravel-basecamp-api
src/Sections/MessageTypes.php
MessageTypes.show
public function show($id) { $messageType = $this->client->get( sprintf('buckets/%d/categories/%d.json', $this->bucket, $id) ); return new MessageType($this->response($messageType)); }
php
public function show($id) { $messageType = $this->client->get( sprintf('buckets/%d/categories/%d.json', $this->bucket, $id) ); return new MessageType($this->response($messageType)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "messageType", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/categories/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "MessageType", "(", "$", "this", "->", "response", "(", "$", "messageType", ")", ")", ";", "}" ]
Get a message type. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "message", "type", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/MessageTypes.php#L34-L41
226,976
CoopBelvedere/laravel-basecamp-api
src/Sections/MessageTypes.php
MessageTypes.store
public function store($data) { $message = $this->client->post( sprintf('buckets/%d/categories.json', $this->bucket), [ 'json' => $data, ] ); return new MessageType($this->response($message)); }
php
public function store($data) { $message = $this->client->post( sprintf('buckets/%d/categories.json', $this->bucket), [ 'json' => $data, ] ); return new MessageType($this->response($message)); }
[ "public", "function", "store", "(", "$", "data", ")", "{", "$", "message", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/categories.json'", ",", "$", "this", "->", "bucket", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "MessageType", "(", "$", "this", "->", "response", "(", "$", "message", ")", ")", ";", "}" ]
Store a message type. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "message", "type", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/MessageTypes.php#L49-L59
226,977
CoopBelvedere/laravel-basecamp-api
src/Sections/ClientApprovals.php
ClientApprovals.index
public function index($page = null) { $url = sprintf('buckets/%d/client/approvals.json', $this->bucket); $approvals = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($approvals, ClientApproval::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/client/approvals.json', $this->bucket); $approvals = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($approvals, ClientApproval::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/client/approvals.json'", ",", "$", "this", "->", "bucket", ")", ";", "$", "approvals", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "approvals", ",", "ClientApproval", "::", "class", ")", ";", "}" ]
Index all approvals. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "approvals", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ClientApprovals.php#L15-L26
226,978
CoopBelvedere/laravel-basecamp-api
src/Sections/ClientApprovals.php
ClientApprovals.show
public function show($id) { $approval = $this->client->get( sprintf('buckets/%d/client/approvals/%d.json', $this->bucket, $id) ); return new ClientApproval($this->response($approval)); }
php
public function show($id) { $approval = $this->client->get( sprintf('buckets/%d/client/approvals/%d.json', $this->bucket, $id) ); return new ClientApproval($this->response($approval)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "approval", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/client/approvals/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "ClientApproval", "(", "$", "this", "->", "response", "(", "$", "approval", ")", ")", ";", "}" ]
Get a client approval. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "client", "approval", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/ClientApprovals.php#L34-L41
226,979
nstapelbroek/culpa-laravel-5
src/Traits/CreatedBy.php
CreatedBy.creator
public function creator() { if (!method_exists($this, 'getFields')) { throw new BadMethodCallException('You are missing the Blameable Trait'); } $fields = $this->getFields(); $model = Config::get('culpa.users.classname', 'App\User'); return $this->belongsTo($model, $fields['created']); }
php
public function creator() { if (!method_exists($this, 'getFields')) { throw new BadMethodCallException('You are missing the Blameable Trait'); } $fields = $this->getFields(); $model = Config::get('culpa.users.classname', 'App\User'); return $this->belongsTo($model, $fields['created']); }
[ "public", "function", "creator", "(", ")", "{", "if", "(", "!", "method_exists", "(", "$", "this", ",", "'getFields'", ")", ")", "{", "throw", "new", "BadMethodCallException", "(", "'You are missing the Blameable Trait'", ")", ";", "}", "$", "fields", "=", "$", "this", "->", "getFields", "(", ")", ";", "$", "model", "=", "Config", "::", "get", "(", "'culpa.users.classname'", ",", "'App\\User'", ")", ";", "return", "$", "this", "->", "belongsTo", "(", "$", "model", ",", "$", "fields", "[", "'created'", "]", ")", ";", "}" ]
Get the user that created the model. @return \Illuminate\Database\Eloquent\Model User instance @throws BadMethodCallException
[ "Get", "the", "user", "that", "created", "the", "model", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Traits/CreatedBy.php#L28-L37
226,980
CoopBelvedere/laravel-basecamp-api
src/ClientMiddlewares.php
ClientMiddlewares.cache
public static function cache(Repository $cache = null) { if (! $cache) { $filestore = new FileStore(new Filesystem(), storage_path()); $cache = new Repository($filestore); } return new CacheMiddleware( new PrivateCacheStrategy( new LaravelCacheStorage($cache) ) ); }
php
public static function cache(Repository $cache = null) { if (! $cache) { $filestore = new FileStore(new Filesystem(), storage_path()); $cache = new Repository($filestore); } return new CacheMiddleware( new PrivateCacheStrategy( new LaravelCacheStorage($cache) ) ); }
[ "public", "static", "function", "cache", "(", "Repository", "$", "cache", "=", "null", ")", "{", "if", "(", "!", "$", "cache", ")", "{", "$", "filestore", "=", "new", "FileStore", "(", "new", "Filesystem", "(", ")", ",", "storage_path", "(", ")", ")", ";", "$", "cache", "=", "new", "Repository", "(", "$", "filestore", ")", ";", "}", "return", "new", "CacheMiddleware", "(", "new", "PrivateCacheStrategy", "(", "new", "LaravelCacheStorage", "(", "$", "cache", ")", ")", ")", ";", "}" ]
Cache middleware. Set the cache middleware for the guzzle requests. @param \Illuminate\Cache\Repository $cache @return \Kevinrob\GuzzleCache\CacheMiddleware
[ "Cache", "middleware", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/ClientMiddlewares.php#L26-L38
226,981
CoopBelvedere/laravel-basecamp-api
src/ClientMiddlewares.php
ClientMiddlewares.setBaseHeaders
public static function setBaseHeaders($token, $userAgent) { return Middleware::mapRequest( function (Request $request) use ($token, $userAgent) { return $request->withHeader('Accept', 'application/json') ->withHeader('Authorization', 'Bearer '.$token) ->withHeader('User-Agent', $userAgent); } ); }
php
public static function setBaseHeaders($token, $userAgent) { return Middleware::mapRequest( function (Request $request) use ($token, $userAgent) { return $request->withHeader('Accept', 'application/json') ->withHeader('Authorization', 'Bearer '.$token) ->withHeader('User-Agent', $userAgent); } ); }
[ "public", "static", "function", "setBaseHeaders", "(", "$", "token", ",", "$", "userAgent", ")", "{", "return", "Middleware", "::", "mapRequest", "(", "function", "(", "Request", "$", "request", ")", "use", "(", "$", "token", ",", "$", "userAgent", ")", "{", "return", "$", "request", "->", "withHeader", "(", "'Accept'", ",", "'application/json'", ")", "->", "withHeader", "(", "'Authorization'", ",", "'Bearer '", ".", "$", "token", ")", "->", "withHeader", "(", "'User-Agent'", ",", "$", "userAgent", ")", ";", "}", ")", ";", "}" ]
Set the base request headers. This is called in the handler stack instead of the Client instance in case the user's basecamp token is refreshed between requests. @param string $token @param string $userAgent @return \GuzzleHttp\Middleware
[ "Set", "the", "base", "request", "headers", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/ClientMiddlewares.php#L50-L59
226,982
CoopBelvedere/laravel-basecamp-api
src/ClientMiddlewares.php
ClientMiddlewares.retry
public static function retry(&$api, $config) { $retryRequest = function ( $retries, $request, $response, $error ) use ($api, $config) { // Refresh token middleware if ($response and $response->getStatusCode() == 401) { return self::refreshToken($api, $config, $retries); } // Don't retry on other requests. return false; }; return Middleware::retry($retryRequest); }
php
public static function retry(&$api, $config) { $retryRequest = function ( $retries, $request, $response, $error ) use ($api, $config) { // Refresh token middleware if ($response and $response->getStatusCode() == 401) { return self::refreshToken($api, $config, $retries); } // Don't retry on other requests. return false; }; return Middleware::retry($retryRequest); }
[ "public", "static", "function", "retry", "(", "&", "$", "api", ",", "$", "config", ")", "{", "$", "retryRequest", "=", "function", "(", "$", "retries", ",", "$", "request", ",", "$", "response", ",", "$", "error", ")", "use", "(", "$", "api", ",", "$", "config", ")", "{", "// Refresh token middleware", "if", "(", "$", "response", "and", "$", "response", "->", "getStatusCode", "(", ")", "==", "401", ")", "{", "return", "self", "::", "refreshToken", "(", "$", "api", ",", "$", "config", ",", "$", "retries", ")", ";", "}", "// Don't retry on other requests.", "return", "false", ";", "}", ";", "return", "Middleware", "::", "retry", "(", "$", "retryRequest", ")", ";", "}" ]
Retry middleware. Return a boolean if the request should be re-sent. @param array $config @return \GuzzleHttp\Middleware
[ "Retry", "middleware", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/ClientMiddlewares.php#L69-L84
226,983
CoopBelvedere/laravel-basecamp-api
src/ClientMiddlewares.php
ClientMiddlewares.refreshToken
protected static function refreshToken(&$api, $config, $retries = 0) { if ($retries >= 3) { return false; // Give up after 3 tries. } $response = (new Guzzle)->post(Client::AUTH_TOKEN, [ 'form_params' => [ 'type' => 'refresh', 'refresh_token' => $api['refresh_token'], 'client_id' => $config['services.37signals.client_id'], 'client_secret' => $config['services.37signals.client_secret'], 'redirect_uri' => $config['services.37signals.redirect'], ], ]); if (! $response or $response->getStatusCode() >= 400) { throw new \Exception('Error trying to connect.'); } $token = json_decode($response->getBody()); $api['token'] = $token->access_token; event('basecamp.refreshed_token', [$api['id'], $token]); // Now that we have a new access token, retry the original request. return true; }
php
protected static function refreshToken(&$api, $config, $retries = 0) { if ($retries >= 3) { return false; // Give up after 3 tries. } $response = (new Guzzle)->post(Client::AUTH_TOKEN, [ 'form_params' => [ 'type' => 'refresh', 'refresh_token' => $api['refresh_token'], 'client_id' => $config['services.37signals.client_id'], 'client_secret' => $config['services.37signals.client_secret'], 'redirect_uri' => $config['services.37signals.redirect'], ], ]); if (! $response or $response->getStatusCode() >= 400) { throw new \Exception('Error trying to connect.'); } $token = json_decode($response->getBody()); $api['token'] = $token->access_token; event('basecamp.refreshed_token', [$api['id'], $token]); // Now that we have a new access token, retry the original request. return true; }
[ "protected", "static", "function", "refreshToken", "(", "&", "$", "api", ",", "$", "config", ",", "$", "retries", "=", "0", ")", "{", "if", "(", "$", "retries", ">=", "3", ")", "{", "return", "false", ";", "// Give up after 3 tries.", "}", "$", "response", "=", "(", "new", "Guzzle", ")", "->", "post", "(", "Client", "::", "AUTH_TOKEN", ",", "[", "'form_params'", "=>", "[", "'type'", "=>", "'refresh'", ",", "'refresh_token'", "=>", "$", "api", "[", "'refresh_token'", "]", ",", "'client_id'", "=>", "$", "config", "[", "'services.37signals.client_id'", "]", ",", "'client_secret'", "=>", "$", "config", "[", "'services.37signals.client_secret'", "]", ",", "'redirect_uri'", "=>", "$", "config", "[", "'services.37signals.redirect'", "]", ",", "]", ",", "]", ")", ";", "if", "(", "!", "$", "response", "or", "$", "response", "->", "getStatusCode", "(", ")", ">=", "400", ")", "{", "throw", "new", "\\", "Exception", "(", "'Error trying to connect.'", ")", ";", "}", "$", "token", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "$", "api", "[", "'token'", "]", "=", "$", "token", "->", "access_token", ";", "event", "(", "'basecamp.refreshed_token'", ",", "[", "$", "api", "[", "'id'", "]", ",", "$", "token", "]", ")", ";", "// Now that we have a new access token, retry the original request.", "return", "true", ";", "}" ]
Refresh the user token. @param array $api @param array $config @param int $retries @return boolean
[ "Refresh", "the", "user", "token", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/ClientMiddlewares.php#L94-L122
226,984
javanile/moldable
src/Model/ClassApi.php
ClassApi.getClassName
protected static function getClassName() { $attribute = 'class-name'; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $point = strrpos($class, '\\'); $className = $point === false ? $class : substr($class, $point + 1); static::setClassAttribute($attribute, $className); } return static::getClassAttribute($attribute); }
php
protected static function getClassName() { $attribute = 'class-name'; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $point = strrpos($class, '\\'); $className = $point === false ? $class : substr($class, $point + 1); static::setClassAttribute($attribute, $className); } return static::getClassAttribute($attribute); }
[ "protected", "static", "function", "getClassName", "(", ")", "{", "$", "attribute", "=", "'class-name'", ";", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "class", "=", "static", "::", "getClass", "(", ")", ";", "$", "point", "=", "strrpos", "(", "$", "class", ",", "'\\\\'", ")", ";", "$", "className", "=", "$", "point", "===", "false", "?", "$", "class", ":", "substr", "(", "$", "class", ",", "$", "point", "+", "1", ")", ";", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "className", ")", ";", "}", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Retrieve static class name. @return type
[ "Retrieve", "static", "class", "name", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/ClassApi.php#L74-L87
226,985
javanile/moldable
src/Model/ClassApi.php
ClassApi.getClassConfigInherit
public static function getClassConfigInherit() { $attribute = 'class-config-inherit'; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $stack = []; $inherit = []; while ($class) { $stack[] = $class::getClassConfigArray(); $class = get_parent_class($class); } $stack = array_reverse($stack); foreach ($stack as $config) { $inherit = array_replace_recursive($inherit, $config); } static::setClassAttribute($attribute, $inherit); } return static::getClassAttribute($attribute); }
php
public static function getClassConfigInherit() { $attribute = 'class-config-inherit'; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $stack = []; $inherit = []; while ($class) { $stack[] = $class::getClassConfigArray(); $class = get_parent_class($class); } $stack = array_reverse($stack); foreach ($stack as $config) { $inherit = array_replace_recursive($inherit, $config); } static::setClassAttribute($attribute, $inherit); } return static::getClassAttribute($attribute); }
[ "public", "static", "function", "getClassConfigInherit", "(", ")", "{", "$", "attribute", "=", "'class-config-inherit'", ";", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "class", "=", "static", "::", "getClass", "(", ")", ";", "$", "stack", "=", "[", "]", ";", "$", "inherit", "=", "[", "]", ";", "while", "(", "$", "class", ")", "{", "$", "stack", "[", "]", "=", "$", "class", "::", "getClassConfigArray", "(", ")", ";", "$", "class", "=", "get_parent_class", "(", "$", "class", ")", ";", "}", "$", "stack", "=", "array_reverse", "(", "$", "stack", ")", ";", "foreach", "(", "$", "stack", "as", "$", "config", ")", "{", "$", "inherit", "=", "array_replace_recursive", "(", "$", "inherit", ",", "$", "config", ")", ";", "}", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "inherit", ")", ";", "}", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Get configuration array inherited.
[ "Get", "configuration", "array", "inherited", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/ClassApi.php#L222-L246
226,986
javanile/moldable
src/Model/ClassApi.php
ClassApi.getClassMethodsByPrefix
protected static function getClassMethodsByPrefix($prefix = null) { // $attribute = 'MethodsByPrefix:'.$prefix; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $allMethods = get_class_methods($class); $methods = []; if (count($allMethods) > 0) { foreach ($allMethods as $method) { if (preg_match('/^'.$prefix.'/i', $method)) { $methods[] = $method; } } } asort($methods); static::setClassAttribute($attribute, $methods); } // return static::getClassAttribute($attribute); }
php
protected static function getClassMethodsByPrefix($prefix = null) { // $attribute = 'MethodsByPrefix:'.$prefix; if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); $allMethods = get_class_methods($class); $methods = []; if (count($allMethods) > 0) { foreach ($allMethods as $method) { if (preg_match('/^'.$prefix.'/i', $method)) { $methods[] = $method; } } } asort($methods); static::setClassAttribute($attribute, $methods); } // return static::getClassAttribute($attribute); }
[ "protected", "static", "function", "getClassMethodsByPrefix", "(", "$", "prefix", "=", "null", ")", "{", "//", "$", "attribute", "=", "'MethodsByPrefix:'", ".", "$", "prefix", ";", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "class", "=", "static", "::", "getClass", "(", ")", ";", "$", "allMethods", "=", "get_class_methods", "(", "$", "class", ")", ";", "$", "methods", "=", "[", "]", ";", "if", "(", "count", "(", "$", "allMethods", ")", ">", "0", ")", "{", "foreach", "(", "$", "allMethods", "as", "$", "method", ")", "{", "if", "(", "preg_match", "(", "'/^'", ".", "$", "prefix", ".", "'/i'", ",", "$", "method", ")", ")", "{", "$", "methods", "[", "]", "=", "$", "method", ";", "}", "}", "}", "asort", "(", "$", "methods", ")", ";", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "methods", ")", ";", "}", "//", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Get methods names by prefix. @param type $prefix @return type
[ "Get", "methods", "names", "by", "prefix", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/ClassApi.php#L273-L297
226,987
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.processComment
public function processComment(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentText = $tokens[$stackPtr]['content']; // Multi-line block comment. if (substr($commentText, 0, 2) !== '/*' || substr($commentText, -2) !== '*/') { return; } // Not a type comment. if ($this->isTypeComment($commentText) === false) { return; } // The "/**@var ...*/" comment isn't parsed as DocBlock and is fixed here. $error = 'Type comment must be in "/** %s ClassName $variable_name */" format'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle', array(self::TYPE_TAG)); if ($fix === true) { $phpcsFile->fixer->replaceToken($stackPtr, '/** '.trim($commentText, ' /*').' */'); } }
php
public function processComment(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentText = $tokens[$stackPtr]['content']; // Multi-line block comment. if (substr($commentText, 0, 2) !== '/*' || substr($commentText, -2) !== '*/') { return; } // Not a type comment. if ($this->isTypeComment($commentText) === false) { return; } // The "/**@var ...*/" comment isn't parsed as DocBlock and is fixed here. $error = 'Type comment must be in "/** %s ClassName $variable_name */" format'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle', array(self::TYPE_TAG)); if ($fix === true) { $phpcsFile->fixer->replaceToken($stackPtr, '/** '.trim($commentText, ' /*').' */'); } }
[ "public", "function", "processComment", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ")", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "commentText", "=", "$", "tokens", "[", "$", "stackPtr", "]", "[", "'content'", "]", ";", "// Multi-line block comment.", "if", "(", "substr", "(", "$", "commentText", ",", "0", ",", "2", ")", "!==", "'/*'", "||", "substr", "(", "$", "commentText", ",", "-", "2", ")", "!==", "'*/'", ")", "{", "return", ";", "}", "// Not a type comment.", "if", "(", "$", "this", "->", "isTypeComment", "(", "$", "commentText", ")", "===", "false", ")", "{", "return", ";", "}", "// The \"/**@var ...*/\" comment isn't parsed as DocBlock and is fixed here.", "$", "error", "=", "'Type comment must be in \"/** %s ClassName $variable_name */\" format'", ";", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "$", "error", ",", "$", "stackPtr", ",", "'WrongStyle'", ",", "array", "(", "self", "::", "TYPE_TAG", ")", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "replaceToken", "(", "$", "stackPtr", ",", "'/** '", ".", "trim", "(", "$", "commentText", ",", "' /*'", ")", ".", "' */'", ")", ";", "}", "}" ]
Processes comment. @param File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @return void
[ "Processes", "comment", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L86-L107
226,988
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.processDocBlock
public function processDocBlock(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentStart = $stackPtr; $commentEnd = $tokens[$stackPtr]['comment_closer']; // Multi-line DocBlock. if ($tokens[$commentEnd]['line'] !== $tokens[$commentStart]['line']) { return; } $commentTags = $tokens[$stackPtr]['comment_tags']; // Single-line DocBlock without tags inside. if (empty($commentTags) === true) { return; } // First tag will always exist. $firstTagPtr = $commentTags[0]; // Not a type comment. if ($this->isTypeComment($tokens[$firstTagPtr]['content']) === false) { return; } $structure = new TypeCommentStructure($phpcsFile, $stackPtr); if ($structure->className === null) { $error = 'Type comment must be in "/** %s ClassName $variable_name */" format'; $leadingWhitespace = $tokens[$stackPtr + 1]['code'] === T_DOC_COMMENT_WHITESPACE; $trailingWhitespace = $tokens[$commentEnd - 1]['code'] === T_DOC_COMMENT_WHITESPACE; if ($leadingWhitespace === false || $trailingWhitespace === false) { $fix = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle', array(self::TYPE_TAG)); if ($fix === true) { if ($leadingWhitespace === false) { $phpcsFile->fixer->addContentBefore($stackPtr + 1, ' '); } if ($trailingWhitespace === false) { $phpcsFile->fixer->addContent($commentEnd - 1, ' '); } } } else { $phpcsFile->addError($error, $firstTagPtr, 'WrongStyle', array(self::TYPE_TAG)); } return; }//end if $this->processDocBlockContent($phpcsFile, $stackPtr, $structure); $this->processVariableAssociation($phpcsFile, $stackPtr, $structure); }
php
public function processDocBlock(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentStart = $stackPtr; $commentEnd = $tokens[$stackPtr]['comment_closer']; // Multi-line DocBlock. if ($tokens[$commentEnd]['line'] !== $tokens[$commentStart]['line']) { return; } $commentTags = $tokens[$stackPtr]['comment_tags']; // Single-line DocBlock without tags inside. if (empty($commentTags) === true) { return; } // First tag will always exist. $firstTagPtr = $commentTags[0]; // Not a type comment. if ($this->isTypeComment($tokens[$firstTagPtr]['content']) === false) { return; } $structure = new TypeCommentStructure($phpcsFile, $stackPtr); if ($structure->className === null) { $error = 'Type comment must be in "/** %s ClassName $variable_name */" format'; $leadingWhitespace = $tokens[$stackPtr + 1]['code'] === T_DOC_COMMENT_WHITESPACE; $trailingWhitespace = $tokens[$commentEnd - 1]['code'] === T_DOC_COMMENT_WHITESPACE; if ($leadingWhitespace === false || $trailingWhitespace === false) { $fix = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle', array(self::TYPE_TAG)); if ($fix === true) { if ($leadingWhitespace === false) { $phpcsFile->fixer->addContentBefore($stackPtr + 1, ' '); } if ($trailingWhitespace === false) { $phpcsFile->fixer->addContent($commentEnd - 1, ' '); } } } else { $phpcsFile->addError($error, $firstTagPtr, 'WrongStyle', array(self::TYPE_TAG)); } return; }//end if $this->processDocBlockContent($phpcsFile, $stackPtr, $structure); $this->processVariableAssociation($phpcsFile, $stackPtr, $structure); }
[ "public", "function", "processDocBlock", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ")", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "commentStart", "=", "$", "stackPtr", ";", "$", "commentEnd", "=", "$", "tokens", "[", "$", "stackPtr", "]", "[", "'comment_closer'", "]", ";", "// Multi-line DocBlock.", "if", "(", "$", "tokens", "[", "$", "commentEnd", "]", "[", "'line'", "]", "!==", "$", "tokens", "[", "$", "commentStart", "]", "[", "'line'", "]", ")", "{", "return", ";", "}", "$", "commentTags", "=", "$", "tokens", "[", "$", "stackPtr", "]", "[", "'comment_tags'", "]", ";", "// Single-line DocBlock without tags inside.", "if", "(", "empty", "(", "$", "commentTags", ")", "===", "true", ")", "{", "return", ";", "}", "// First tag will always exist.", "$", "firstTagPtr", "=", "$", "commentTags", "[", "0", "]", ";", "// Not a type comment.", "if", "(", "$", "this", "->", "isTypeComment", "(", "$", "tokens", "[", "$", "firstTagPtr", "]", "[", "'content'", "]", ")", "===", "false", ")", "{", "return", ";", "}", "$", "structure", "=", "new", "TypeCommentStructure", "(", "$", "phpcsFile", ",", "$", "stackPtr", ")", ";", "if", "(", "$", "structure", "->", "className", "===", "null", ")", "{", "$", "error", "=", "'Type comment must be in \"/** %s ClassName $variable_name */\" format'", ";", "$", "leadingWhitespace", "=", "$", "tokens", "[", "$", "stackPtr", "+", "1", "]", "[", "'code'", "]", "===", "T_DOC_COMMENT_WHITESPACE", ";", "$", "trailingWhitespace", "=", "$", "tokens", "[", "$", "commentEnd", "-", "1", "]", "[", "'code'", "]", "===", "T_DOC_COMMENT_WHITESPACE", ";", "if", "(", "$", "leadingWhitespace", "===", "false", "||", "$", "trailingWhitespace", "===", "false", ")", "{", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "$", "error", ",", "$", "stackPtr", ",", "'WrongStyle'", ",", "array", "(", "self", "::", "TYPE_TAG", ")", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "if", "(", "$", "leadingWhitespace", "===", "false", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "addContentBefore", "(", "$", "stackPtr", "+", "1", ",", "' '", ")", ";", "}", "if", "(", "$", "trailingWhitespace", "===", "false", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "addContent", "(", "$", "commentEnd", "-", "1", ",", "' '", ")", ";", "}", "}", "}", "else", "{", "$", "phpcsFile", "->", "addError", "(", "$", "error", ",", "$", "firstTagPtr", ",", "'WrongStyle'", ",", "array", "(", "self", "::", "TYPE_TAG", ")", ")", ";", "}", "return", ";", "}", "//end if", "$", "this", "->", "processDocBlockContent", "(", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "structure", ")", ";", "$", "this", "->", "processVariableAssociation", "(", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "structure", ")", ";", "}" ]
Processes DocBlock. @param File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @return void
[ "Processes", "DocBlock", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L119-L172
226,989
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.processVariableAssociation
public function processVariableAssociation( File $phpcsFile, $stackPtr, TypeCommentStructure $structure ) { // Variable association can't be determined. if ($structure->variableName === null || $structure->isVariable($structure->variableName) === false) { return; } $this->processVariableBeforeDocBlock($phpcsFile, $stackPtr, $structure); $this->processVariableAfterDocBlock($phpcsFile, $stackPtr, $structure); }
php
public function processVariableAssociation( File $phpcsFile, $stackPtr, TypeCommentStructure $structure ) { // Variable association can't be determined. if ($structure->variableName === null || $structure->isVariable($structure->variableName) === false) { return; } $this->processVariableBeforeDocBlock($phpcsFile, $stackPtr, $structure); $this->processVariableAfterDocBlock($phpcsFile, $stackPtr, $structure); }
[ "public", "function", "processVariableAssociation", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ",", "TypeCommentStructure", "$", "structure", ")", "{", "// Variable association can't be determined.", "if", "(", "$", "structure", "->", "variableName", "===", "null", "||", "$", "structure", "->", "isVariable", "(", "$", "structure", "->", "variableName", ")", "===", "false", ")", "{", "return", ";", "}", "$", "this", "->", "processVariableBeforeDocBlock", "(", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "structure", ")", ";", "$", "this", "->", "processVariableAfterDocBlock", "(", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "structure", ")", ";", "}" ]
Processes variable around DocBlock. @param File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param TypeCommentStructure $structure Type comment structure. @return void
[ "Processes", "variable", "around", "DocBlock", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L313-L325
226,990
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.isTypeComment
protected function isTypeComment($commentText) { return strpos($commentText, self::TYPE_TAG) !== false || strpos($commentText, '@type') !== false; }
php
protected function isTypeComment($commentText) { return strpos($commentText, self::TYPE_TAG) !== false || strpos($commentText, '@type') !== false; }
[ "protected", "function", "isTypeComment", "(", "$", "commentText", ")", "{", "return", "strpos", "(", "$", "commentText", ",", "self", "::", "TYPE_TAG", ")", "!==", "false", "||", "strpos", "(", "$", "commentText", ",", "'@type'", ")", "!==", "false", ";", "}" ]
Checks if comment is type comment. @param string $commentText Comment text. @return bool
[ "Checks", "if", "comment", "is", "type", "comment", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L492-L495
226,991
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.findFirstOnLine
public function findFirstOnLine(File $phpcsFile, $start) { $tokens = $phpcsFile->getTokens(); for ($i = $start; $i >= 0; $i--) { if ($tokens[$i]['line'] === $tokens[$start]['line']) { continue; } return ($i + 1); } return false; }
php
public function findFirstOnLine(File $phpcsFile, $start) { $tokens = $phpcsFile->getTokens(); for ($i = $start; $i >= 0; $i--) { if ($tokens[$i]['line'] === $tokens[$start]['line']) { continue; } return ($i + 1); } return false; }
[ "public", "function", "findFirstOnLine", "(", "File", "$", "phpcsFile", ",", "$", "start", ")", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "for", "(", "$", "i", "=", "$", "start", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "$", "tokens", "[", "$", "i", "]", "[", "'line'", "]", "===", "$", "tokens", "[", "$", "start", "]", "[", "'line'", "]", ")", "{", "continue", ";", "}", "return", "(", "$", "i", "+", "1", ")", ";", "}", "return", "false", ";", "}" ]
Finds first token on a line. @param File $phpcsFile All the tokens found in the document. @param int $start Start from token. @return int | bool
[ "Finds", "first", "token", "on", "a", "line", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L506-L519
226,992
aik099/CodingStandard
CodingStandard/Sniffs/Commenting/TypeCommentSniff.php
TypeCommentSniff.findLastOnLine
public function findLastOnLine(File $phpcsFile, $start) { $tokens = $phpcsFile->getTokens(); for ($i = $start; $i <= $phpcsFile->numTokens; $i++) { if ($tokens[$i]['line'] === $tokens[$start]['line']) { continue; } return ($i - 1); } return false; }
php
public function findLastOnLine(File $phpcsFile, $start) { $tokens = $phpcsFile->getTokens(); for ($i = $start; $i <= $phpcsFile->numTokens; $i++) { if ($tokens[$i]['line'] === $tokens[$start]['line']) { continue; } return ($i - 1); } return false; }
[ "public", "function", "findLastOnLine", "(", "File", "$", "phpcsFile", ",", "$", "start", ")", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "for", "(", "$", "i", "=", "$", "start", ";", "$", "i", "<=", "$", "phpcsFile", "->", "numTokens", ";", "$", "i", "++", ")", "{", "if", "(", "$", "tokens", "[", "$", "i", "]", "[", "'line'", "]", "===", "$", "tokens", "[", "$", "start", "]", "[", "'line'", "]", ")", "{", "continue", ";", "}", "return", "(", "$", "i", "-", "1", ")", ";", "}", "return", "false", ";", "}" ]
Finds last token on a line. @param File $phpcsFile All the tokens found in the document. @param int $start Start from token. @return int | bool
[ "Finds", "last", "token", "on", "a", "line", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Commenting/TypeCommentSniff.php#L530-L543
226,993
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Lookup.php
GoogleSafeBrowsing_Lookup.lookup
public function lookup($url) { $result = array(); // get url's to check $canon_url = GoogleSafeBrowsing_Lookup_URL::googleCanonicalize($url); if(is_null($canon_url)){ // unable to canonicalize, nothing we can do $this->debugLog('lookup('.$url.'): cannot canonicalize url, skipping'); return $result; } $lookup_urls = GoogleSafeBrowsing_Lookup_URL::googleGetLookupExpressions($canon_url); $lookup_hashes = array(); foreach($lookup_urls as $lookup_url){ $lookup_hashes[]=GoogleSafeBrowsing_Lookup_URL::hash($lookup_url); //$this->debugLog(bin2hex($lookup_hashes[count($lookup_hashes)-1])." $lookup_url"); } $found_hashes=$this->storage->hasPrefix($lookup_hashes); $matched_lists=array(); // full hash lookups foreach($found_hashes as $found_hash){ $this->debugLog('lookup('.$url.'): found hash prefix for '.bin2hex($found_hash)); $lookup_result=$this->storage->isListedInCache($found_hash); if(is_null($lookup_result)){ $lookup_result=array(); // not cached, query google $collection=$this->api->getHash(substr($found_hash,0,4),$this->storage->getLists()); if(count($collection->list_hashes)==0){ // no hashes found, can happen, so insert dummy record for this prefix // so we can use the cached result (empty) $this->storage->addHashInCache($found_hash,$lookup_result,null,(int)$collection->cache); }else{ // full length hashes found foreach($collection->list_hashes as $list_hash){ $this->debugLog('lookup('.$url.'): remote lookup found full length hashes in list '.$list_hash->list_name); foreach($list_hash->hashes as $hash){ $this->debugLog('lookup('.$url.'): hash '.bin2hex($hash->hash)); // cache in db $cache_seconds=(int)$collection->cache; if(isset($hash->cache) && $hash->cache){ $cache_seconds=(int)$hash->cache; } $this->storage->addHashInCache($hash->hash,array($list_hash->list_name),$hash->raw_meta,$cache_seconds); if($hash->hash==$found_hash){ // full length hash match if(!in_array($list_hash->list_name, $lookup_result)){ $lookup_result[]=$list_hash->list_name; } } } } } }// end cached if/else // $lookup_result is array of listnames (can be empty if not listed) foreach($lookup_result as $matched_list){ $matched_lists[$matched_list]=true; } } if(count($matched_lists)>0){ $this->debugLog('lookup('.$url.'): listed in '.implode(', ',array_keys($matched_lists))); } return array_keys($matched_lists); }
php
public function lookup($url) { $result = array(); // get url's to check $canon_url = GoogleSafeBrowsing_Lookup_URL::googleCanonicalize($url); if(is_null($canon_url)){ // unable to canonicalize, nothing we can do $this->debugLog('lookup('.$url.'): cannot canonicalize url, skipping'); return $result; } $lookup_urls = GoogleSafeBrowsing_Lookup_URL::googleGetLookupExpressions($canon_url); $lookup_hashes = array(); foreach($lookup_urls as $lookup_url){ $lookup_hashes[]=GoogleSafeBrowsing_Lookup_URL::hash($lookup_url); //$this->debugLog(bin2hex($lookup_hashes[count($lookup_hashes)-1])." $lookup_url"); } $found_hashes=$this->storage->hasPrefix($lookup_hashes); $matched_lists=array(); // full hash lookups foreach($found_hashes as $found_hash){ $this->debugLog('lookup('.$url.'): found hash prefix for '.bin2hex($found_hash)); $lookup_result=$this->storage->isListedInCache($found_hash); if(is_null($lookup_result)){ $lookup_result=array(); // not cached, query google $collection=$this->api->getHash(substr($found_hash,0,4),$this->storage->getLists()); if(count($collection->list_hashes)==0){ // no hashes found, can happen, so insert dummy record for this prefix // so we can use the cached result (empty) $this->storage->addHashInCache($found_hash,$lookup_result,null,(int)$collection->cache); }else{ // full length hashes found foreach($collection->list_hashes as $list_hash){ $this->debugLog('lookup('.$url.'): remote lookup found full length hashes in list '.$list_hash->list_name); foreach($list_hash->hashes as $hash){ $this->debugLog('lookup('.$url.'): hash '.bin2hex($hash->hash)); // cache in db $cache_seconds=(int)$collection->cache; if(isset($hash->cache) && $hash->cache){ $cache_seconds=(int)$hash->cache; } $this->storage->addHashInCache($hash->hash,array($list_hash->list_name),$hash->raw_meta,$cache_seconds); if($hash->hash==$found_hash){ // full length hash match if(!in_array($list_hash->list_name, $lookup_result)){ $lookup_result[]=$list_hash->list_name; } } } } } }// end cached if/else // $lookup_result is array of listnames (can be empty if not listed) foreach($lookup_result as $matched_list){ $matched_lists[$matched_list]=true; } } if(count($matched_lists)>0){ $this->debugLog('lookup('.$url.'): listed in '.implode(', ',array_keys($matched_lists))); } return array_keys($matched_lists); }
[ "public", "function", "lookup", "(", "$", "url", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// get url's to check", "$", "canon_url", "=", "GoogleSafeBrowsing_Lookup_URL", "::", "googleCanonicalize", "(", "$", "url", ")", ";", "if", "(", "is_null", "(", "$", "canon_url", ")", ")", "{", "// unable to canonicalize, nothing we can do", "$", "this", "->", "debugLog", "(", "'lookup('", ".", "$", "url", ".", "'): cannot canonicalize url, skipping'", ")", ";", "return", "$", "result", ";", "}", "$", "lookup_urls", "=", "GoogleSafeBrowsing_Lookup_URL", "::", "googleGetLookupExpressions", "(", "$", "canon_url", ")", ";", "$", "lookup_hashes", "=", "array", "(", ")", ";", "foreach", "(", "$", "lookup_urls", "as", "$", "lookup_url", ")", "{", "$", "lookup_hashes", "[", "]", "=", "GoogleSafeBrowsing_Lookup_URL", "::", "hash", "(", "$", "lookup_url", ")", ";", "//$this->debugLog(bin2hex($lookup_hashes[count($lookup_hashes)-1]).\" $lookup_url\");", "}", "$", "found_hashes", "=", "$", "this", "->", "storage", "->", "hasPrefix", "(", "$", "lookup_hashes", ")", ";", "$", "matched_lists", "=", "array", "(", ")", ";", "// full hash lookups", "foreach", "(", "$", "found_hashes", "as", "$", "found_hash", ")", "{", "$", "this", "->", "debugLog", "(", "'lookup('", ".", "$", "url", ".", "'): found hash prefix for '", ".", "bin2hex", "(", "$", "found_hash", ")", ")", ";", "$", "lookup_result", "=", "$", "this", "->", "storage", "->", "isListedInCache", "(", "$", "found_hash", ")", ";", "if", "(", "is_null", "(", "$", "lookup_result", ")", ")", "{", "$", "lookup_result", "=", "array", "(", ")", ";", "// not cached, query google", "$", "collection", "=", "$", "this", "->", "api", "->", "getHash", "(", "substr", "(", "$", "found_hash", ",", "0", ",", "4", ")", ",", "$", "this", "->", "storage", "->", "getLists", "(", ")", ")", ";", "if", "(", "count", "(", "$", "collection", "->", "list_hashes", ")", "==", "0", ")", "{", "// no hashes found, can happen, so insert dummy record for this prefix", "// so we can use the cached result (empty)", "$", "this", "->", "storage", "->", "addHashInCache", "(", "$", "found_hash", ",", "$", "lookup_result", ",", "null", ",", "(", "int", ")", "$", "collection", "->", "cache", ")", ";", "}", "else", "{", "// full length hashes found", "foreach", "(", "$", "collection", "->", "list_hashes", "as", "$", "list_hash", ")", "{", "$", "this", "->", "debugLog", "(", "'lookup('", ".", "$", "url", ".", "'): remote lookup found full length hashes in list '", ".", "$", "list_hash", "->", "list_name", ")", ";", "foreach", "(", "$", "list_hash", "->", "hashes", "as", "$", "hash", ")", "{", "$", "this", "->", "debugLog", "(", "'lookup('", ".", "$", "url", ".", "'): hash '", ".", "bin2hex", "(", "$", "hash", "->", "hash", ")", ")", ";", "// cache in db", "$", "cache_seconds", "=", "(", "int", ")", "$", "collection", "->", "cache", ";", "if", "(", "isset", "(", "$", "hash", "->", "cache", ")", "&&", "$", "hash", "->", "cache", ")", "{", "$", "cache_seconds", "=", "(", "int", ")", "$", "hash", "->", "cache", ";", "}", "$", "this", "->", "storage", "->", "addHashInCache", "(", "$", "hash", "->", "hash", ",", "array", "(", "$", "list_hash", "->", "list_name", ")", ",", "$", "hash", "->", "raw_meta", ",", "$", "cache_seconds", ")", ";", "if", "(", "$", "hash", "->", "hash", "==", "$", "found_hash", ")", "{", "// full length hash match", "if", "(", "!", "in_array", "(", "$", "list_hash", "->", "list_name", ",", "$", "lookup_result", ")", ")", "{", "$", "lookup_result", "[", "]", "=", "$", "list_hash", "->", "list_name", ";", "}", "}", "}", "}", "}", "}", "// end cached if/else", "// $lookup_result is array of listnames (can be empty if not listed)", "foreach", "(", "$", "lookup_result", "as", "$", "matched_list", ")", "{", "$", "matched_lists", "[", "$", "matched_list", "]", "=", "true", ";", "}", "}", "if", "(", "count", "(", "$", "matched_lists", ")", ">", "0", ")", "{", "$", "this", "->", "debugLog", "(", "'lookup('", ".", "$", "url", ".", "'): listed in '", ".", "implode", "(", "', '", ",", "array_keys", "(", "$", "matched_lists", ")", ")", ")", ";", "}", "return", "array_keys", "(", "$", "matched_lists", ")", ";", "}" ]
Lookup an url @param string $url @return string[]
[ "Lookup", "an", "url" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Lookup.php#L58-L122
226,994
rdehnhardt/lumen-maintenance-mode
src/MaintenanceModeService.php
MaintenanceModeService.setDownMode
public function setDownMode() { $file = $this->maintenanceFilePath(); if (!touch($file)) { $message = sprintf( 'Something went wrong on trying to create maintenance file %s.', $file ); throw new Exceptions\FileException($message); } return true; }
php
public function setDownMode() { $file = $this->maintenanceFilePath(); if (!touch($file)) { $message = sprintf( 'Something went wrong on trying to create maintenance file %s.', $file ); throw new Exceptions\FileException($message); } return true; }
[ "public", "function", "setDownMode", "(", ")", "{", "$", "file", "=", "$", "this", "->", "maintenanceFilePath", "(", ")", ";", "if", "(", "!", "touch", "(", "$", "file", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'Something went wrong on trying to create maintenance file %s.'", ",", "$", "file", ")", ";", "throw", "new", "Exceptions", "\\", "FileException", "(", "$", "message", ")", ";", "}", "return", "true", ";", "}" ]
Put the application in down mode. @throws Exceptions\FileException @return bool true if success and false if something fails.
[ "Put", "the", "application", "in", "down", "mode", "." ]
6d40cc5658345fecdf5b7571df902f339964f513
https://github.com/rdehnhardt/lumen-maintenance-mode/blob/6d40cc5658345fecdf5b7571df902f339964f513/src/MaintenanceModeService.php#L79-L93
226,995
rdehnhardt/lumen-maintenance-mode
src/MaintenanceModeService.php
MaintenanceModeService.setUpMode
public function setUpMode() { $file = $this->maintenanceFilePath(); if (file_exists($file) && !unlink($file)) { $message = sprintf( 'Something went wrong on trying to remove maintenance file %s.', $file ); throw new Exceptions\FileException($message); } return true; }
php
public function setUpMode() { $file = $this->maintenanceFilePath(); if (file_exists($file) && !unlink($file)) { $message = sprintf( 'Something went wrong on trying to remove maintenance file %s.', $file ); throw new Exceptions\FileException($message); } return true; }
[ "public", "function", "setUpMode", "(", ")", "{", "$", "file", "=", "$", "this", "->", "maintenanceFilePath", "(", ")", ";", "if", "(", "file_exists", "(", "$", "file", ")", "&&", "!", "unlink", "(", "$", "file", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'Something went wrong on trying to remove maintenance file %s.'", ",", "$", "file", ")", ";", "throw", "new", "Exceptions", "\\", "FileException", "(", "$", "message", ")", ";", "}", "return", "true", ";", "}" ]
Put application in up mode. @throws Exceptions\FileException @return bool true if success and false if something fails.
[ "Put", "application", "in", "up", "mode", "." ]
6d40cc5658345fecdf5b7571df902f339964f513
https://github.com/rdehnhardt/lumen-maintenance-mode/blob/6d40cc5658345fecdf5b7571df902f339964f513/src/MaintenanceModeService.php#L102-L116
226,996
matthewbdaly/laravel-repositories
src/Repositories/Base.php
Base.findOrFail
public function findOrFail(int $id) { $response = $this->model->with($this->with)->findOrFail($id); $this->with = []; return $response; }
php
public function findOrFail(int $id) { $response = $this->model->with($this->with)->findOrFail($id); $this->with = []; return $response; }
[ "public", "function", "findOrFail", "(", "int", "$", "id", ")", "{", "$", "response", "=", "$", "this", "->", "model", "->", "with", "(", "$", "this", "->", "with", ")", "->", "findOrFail", "(", "$", "id", ")", ";", "$", "this", "->", "with", "=", "[", "]", ";", "return", "$", "response", ";", "}" ]
Get single row, or throw a 404 @param integer $id The object ID. @return \Illuminate\Database\Eloquent\Model
[ "Get", "single", "row", "or", "throw", "a", "404" ]
af05180e3674fa3a9f5ba6f9ecccdda10b41135a
https://github.com/matthewbdaly/laravel-repositories/blob/af05180e3674fa3a9f5ba6f9ecccdda10b41135a/src/Repositories/Base.php#L58-L63
226,997
matthewbdaly/laravel-repositories
src/Repositories/Base.php
Base.findWhereOrFail
public function findWhereOrFail(int $id, array $parameters) { $response = $this->model->with($this->with)->where($parameters)->findOrFail($id); $this->with = []; return $response; }
php
public function findWhereOrFail(int $id, array $parameters) { $response = $this->model->with($this->with)->where($parameters)->findOrFail($id); $this->with = []; return $response; }
[ "public", "function", "findWhereOrFail", "(", "int", "$", "id", ",", "array", "$", "parameters", ")", "{", "$", "response", "=", "$", "this", "->", "model", "->", "with", "(", "$", "this", "->", "with", ")", "->", "where", "(", "$", "parameters", ")", "->", "findOrFail", "(", "$", "id", ")", ";", "$", "this", "->", "with", "=", "[", "]", ";", "return", "$", "response", ";", "}" ]
Get a single row matching parameters, or throw a 404 @param integer $id The object ID. @param array $parameters The parameters. @return \Illuminate\Database\Eloquent\Collection
[ "Get", "a", "single", "row", "matching", "parameters", "or", "throw", "a", "404" ]
af05180e3674fa3a9f5ba6f9ecccdda10b41135a
https://github.com/matthewbdaly/laravel-repositories/blob/af05180e3674fa3a9f5ba6f9ecccdda10b41135a/src/Repositories/Base.php#L139-L144
226,998
matthewbdaly/laravel-repositories
src/Repositories/Base.php
Base.detach
public function detach($model, string $relation, Model $value) { if (! $model instanceof Model) { $model = $this->find($model); } $model->$relation()->detach($value); }
php
public function detach($model, string $relation, Model $value) { if (! $model instanceof Model) { $model = $this->find($model); } $model->$relation()->detach($value); }
[ "public", "function", "detach", "(", "$", "model", ",", "string", "$", "relation", ",", "Model", "$", "value", ")", "{", "if", "(", "!", "$", "model", "instanceof", "Model", ")", "{", "$", "model", "=", "$", "this", "->", "find", "(", "$", "model", ")", ";", "}", "$", "model", "->", "$", "relation", "(", ")", "->", "detach", "(", "$", "value", ")", ";", "}" ]
Detach a model @param mixed $model The first model. @param string $relation The relationship on the first model. @param \Illuminate\Database\Eloquent\Model $value The model to attach. @return void
[ "Detach", "a", "model" ]
af05180e3674fa3a9f5ba6f9ecccdda10b41135a
https://github.com/matthewbdaly/laravel-repositories/blob/af05180e3674fa3a9f5ba6f9ecccdda10b41135a/src/Repositories/Base.php#L217-L224
226,999
whatwedo/TableBundle
Table/Table.php
Table.addColumn
public function addColumn($acronym, $type = null, array $options = []) { if (in_array($acronym, $this->reservedColumnAcronyms)) { throw new ReservedColumnAcronymException($acronym); } if ($type === null) { $type = Column::class; } $column = new $type($acronym, $options); // only DoctrineTable can sort nested properties. Therefore disable them for other tables. if (!$this instanceof DoctrineTable && $column instanceof SortableColumnInterface && $column->isSortable()) { if (strpos($column->getSortExpression(), '.') !== false) { $column->setSortable(false); } } if ($column instanceof TemplateableColumnInterface) { $column->setTemplating($this->templating); } if ($column instanceof SortableColumnInterface) { $column->setTableIdentifier($this->getIdentifier()); } if ($column instanceof FormattableColumnInterface) { $column->setFormatterManager($this->formatterManager); } $this->columns->set($acronym, $column); return $this; }
php
public function addColumn($acronym, $type = null, array $options = []) { if (in_array($acronym, $this->reservedColumnAcronyms)) { throw new ReservedColumnAcronymException($acronym); } if ($type === null) { $type = Column::class; } $column = new $type($acronym, $options); // only DoctrineTable can sort nested properties. Therefore disable them for other tables. if (!$this instanceof DoctrineTable && $column instanceof SortableColumnInterface && $column->isSortable()) { if (strpos($column->getSortExpression(), '.') !== false) { $column->setSortable(false); } } if ($column instanceof TemplateableColumnInterface) { $column->setTemplating($this->templating); } if ($column instanceof SortableColumnInterface) { $column->setTableIdentifier($this->getIdentifier()); } if ($column instanceof FormattableColumnInterface) { $column->setFormatterManager($this->formatterManager); } $this->columns->set($acronym, $column); return $this; }
[ "public", "function", "addColumn", "(", "$", "acronym", ",", "$", "type", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "in_array", "(", "$", "acronym", ",", "$", "this", "->", "reservedColumnAcronyms", ")", ")", "{", "throw", "new", "ReservedColumnAcronymException", "(", "$", "acronym", ")", ";", "}", "if", "(", "$", "type", "===", "null", ")", "{", "$", "type", "=", "Column", "::", "class", ";", "}", "$", "column", "=", "new", "$", "type", "(", "$", "acronym", ",", "$", "options", ")", ";", "// only DoctrineTable can sort nested properties. Therefore disable them for other tables.", "if", "(", "!", "$", "this", "instanceof", "DoctrineTable", "&&", "$", "column", "instanceof", "SortableColumnInterface", "&&", "$", "column", "->", "isSortable", "(", ")", ")", "{", "if", "(", "strpos", "(", "$", "column", "->", "getSortExpression", "(", ")", ",", "'.'", ")", "!==", "false", ")", "{", "$", "column", "->", "setSortable", "(", "false", ")", ";", "}", "}", "if", "(", "$", "column", "instanceof", "TemplateableColumnInterface", ")", "{", "$", "column", "->", "setTemplating", "(", "$", "this", "->", "templating", ")", ";", "}", "if", "(", "$", "column", "instanceof", "SortableColumnInterface", ")", "{", "$", "column", "->", "setTableIdentifier", "(", "$", "this", "->", "getIdentifier", "(", ")", ")", ";", "}", "if", "(", "$", "column", "instanceof", "FormattableColumnInterface", ")", "{", "$", "column", "->", "setFormatterManager", "(", "$", "this", "->", "formatterManager", ")", ";", "}", "$", "this", "->", "columns", "->", "set", "(", "$", "acronym", ",", "$", "column", ")", ";", "return", "$", "this", ";", "}" ]
adds a new column @param string $acronym @param null $type @param array $options @return $this
[ "adds", "a", "new", "column" ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Table/Table.php#L250-L284