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
19,400
onigoetz/imagecache
src/Manager.php
Manager.handleRequest
public function handleRequest($preset_key, $file) { //do it at the beginning for early validation $preset = $this->getPresetActions($preset_key, $file); $source_file = $this->getOriginalFilename($file); $original_file = $this->getOriginalFile($source_file); $final_file = $this->localUrl($preset_key, $file); $this->verifyDirectoryExistence($this->options['path_local'], dirname($final_file)); $final_file = $this->options['path_local'] . '/' . $final_file; if (file_exists($final_file)) { return $final_file; } $image = $this->loadImage($original_file); return $this->buildImage($preset, $image, $final_file)->source; }
php
public function handleRequest($preset_key, $file) { //do it at the beginning for early validation $preset = $this->getPresetActions($preset_key, $file); $source_file = $this->getOriginalFilename($file); $original_file = $this->getOriginalFile($source_file); $final_file = $this->localUrl($preset_key, $file); $this->verifyDirectoryExistence($this->options['path_local'], dirname($final_file)); $final_file = $this->options['path_local'] . '/' . $final_file; if (file_exists($final_file)) { return $final_file; } $image = $this->loadImage($original_file); return $this->buildImage($preset, $image, $final_file)->source; }
[ "public", "function", "handleRequest", "(", "$", "preset_key", ",", "$", "file", ")", "{", "//do it at the beginning for early validation", "$", "preset", "=", "$", "this", "->", "getPresetActions", "(", "$", "preset_key", ",", "$", "file", ")", ";", "$", "source_file", "=", "$", "this", "->", "getOriginalFilename", "(", "$", "file", ")", ";", "$", "original_file", "=", "$", "this", "->", "getOriginalFile", "(", "$", "source_file", ")", ";", "$", "final_file", "=", "$", "this", "->", "localUrl", "(", "$", "preset_key", ",", "$", "file", ")", ";", "$", "this", "->", "verifyDirectoryExistence", "(", "$", "this", "->", "options", "[", "'path_local'", "]", ",", "dirname", "(", "$", "final_file", ")", ")", ";", "$", "final_file", "=", "$", "this", "->", "options", "[", "'path_local'", "]", ".", "'/'", ".", "$", "final_file", ";", "if", "(", "file_exists", "(", "$", "final_file", ")", ")", "{", "return", "$", "final_file", ";", "}", "$", "image", "=", "$", "this", "->", "loadImage", "(", "$", "original_file", ")", ";", "return", "$", "this", "->", "buildImage", "(", "$", "preset", ",", "$", "image", ",", "$", "final_file", ")", "->", "source", ";", "}" ]
Take a preset and a file and return a transformed image @param $preset_key string @param $file string @throws Exceptions\InvalidPresetException @throws Exceptions\NotFoundException @throws \RuntimeException @return string
[ "Take", "a", "preset", "and", "a", "file", "and", "return", "a", "transformed", "image" ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Manager.php#L148-L170
19,401
onigoetz/imagecache
src/Manager.php
Manager.verifyDirectoryExistence
protected function verifyDirectoryExistence($base, $cacheDir) { if (is_dir("$base/$cacheDir")) { return; } $folder_path = explode('/', $cacheDir); foreach ($folder_path as $element) { $base .= '/' . $element; if (!is_dir($base)) { mkdir($base, 0755, true); chmod($base, 0755); } } }
php
protected function verifyDirectoryExistence($base, $cacheDir) { if (is_dir("$base/$cacheDir")) { return; } $folder_path = explode('/', $cacheDir); foreach ($folder_path as $element) { $base .= '/' . $element; if (!is_dir($base)) { mkdir($base, 0755, true); chmod($base, 0755); } } }
[ "protected", "function", "verifyDirectoryExistence", "(", "$", "base", ",", "$", "cacheDir", ")", "{", "if", "(", "is_dir", "(", "\"$base/$cacheDir\"", ")", ")", "{", "return", ";", "}", "$", "folder_path", "=", "explode", "(", "'/'", ",", "$", "cacheDir", ")", ";", "foreach", "(", "$", "folder_path", "as", "$", "element", ")", "{", "$", "base", ".=", "'/'", ".", "$", "element", ";", "if", "(", "!", "is_dir", "(", "$", "base", ")", ")", "{", "mkdir", "(", "$", "base", ",", "0755", ",", "true", ")", ";", "chmod", "(", "$", "base", ",", "0755", ")", ";", "}", "}", "}" ]
Create the folder containing the cached images if it doesn't exist @param $base @param $cacheDir
[ "Create", "the", "folder", "containing", "the", "cached", "images", "if", "it", "doesn", "t", "exist" ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Manager.php#L178-L192
19,402
onigoetz/imagecache
src/Manager.php
Manager.buildImage
protected function buildImage($actions, Image $image, $dst) { foreach ($actions as $action) { // Make sure the width and height are computed first so they can be used // in relative x/yoffsets like 'center' or 'bottom'. if (isset($action['width'])) { $action['width'] = $this->percent($action['width'], $image->getWidth()); } if (isset($action['height'])) { $action['height'] = $this->percent($action['height'], $image->getHeight()); } if (isset($action['xoffset'])) { $action['xoffset'] = $this->keywords($action['xoffset'], $image->getWidth(), $action['width']); } if (isset($action['yoffset'])) { $action['yoffset'] = $this->keywords($action['yoffset'], $image->getHeight(), $action['height']); } $this->getMethodCaller()->call($image, $action['action'], $action); } return $image->save($dst); }
php
protected function buildImage($actions, Image $image, $dst) { foreach ($actions as $action) { // Make sure the width and height are computed first so they can be used // in relative x/yoffsets like 'center' or 'bottom'. if (isset($action['width'])) { $action['width'] = $this->percent($action['width'], $image->getWidth()); } if (isset($action['height'])) { $action['height'] = $this->percent($action['height'], $image->getHeight()); } if (isset($action['xoffset'])) { $action['xoffset'] = $this->keywords($action['xoffset'], $image->getWidth(), $action['width']); } if (isset($action['yoffset'])) { $action['yoffset'] = $this->keywords($action['yoffset'], $image->getHeight(), $action['height']); } $this->getMethodCaller()->call($image, $action['action'], $action); } return $image->save($dst); }
[ "protected", "function", "buildImage", "(", "$", "actions", ",", "Image", "$", "image", ",", "$", "dst", ")", "{", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "// Make sure the width and height are computed first so they can be used", "// in relative x/yoffsets like 'center' or 'bottom'.", "if", "(", "isset", "(", "$", "action", "[", "'width'", "]", ")", ")", "{", "$", "action", "[", "'width'", "]", "=", "$", "this", "->", "percent", "(", "$", "action", "[", "'width'", "]", ",", "$", "image", "->", "getWidth", "(", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "action", "[", "'height'", "]", ")", ")", "{", "$", "action", "[", "'height'", "]", "=", "$", "this", "->", "percent", "(", "$", "action", "[", "'height'", "]", ",", "$", "image", "->", "getHeight", "(", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "action", "[", "'xoffset'", "]", ")", ")", "{", "$", "action", "[", "'xoffset'", "]", "=", "$", "this", "->", "keywords", "(", "$", "action", "[", "'xoffset'", "]", ",", "$", "image", "->", "getWidth", "(", ")", ",", "$", "action", "[", "'width'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "action", "[", "'yoffset'", "]", ")", ")", "{", "$", "action", "[", "'yoffset'", "]", "=", "$", "this", "->", "keywords", "(", "$", "action", "[", "'yoffset'", "]", ",", "$", "image", "->", "getHeight", "(", ")", ",", "$", "action", "[", "'height'", "]", ")", ";", "}", "$", "this", "->", "getMethodCaller", "(", ")", "->", "call", "(", "$", "image", ",", "$", "action", "[", "'action'", "]", ",", "$", "action", ")", ";", "}", "return", "$", "image", "->", "save", "(", "$", "dst", ")", ";", "}" ]
Create a new image based on an image preset. @param array $actions An image preset array. @param Image $image Path of the source file. @param string $dst Path of the destination file. @throws \RuntimeException @return Image
[ "Create", "a", "new", "image", "based", "on", "an", "image", "preset", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Manager.php#L208-L233
19,403
onigoetz/imagecache
src/Manager.php
Manager.percent
public function percent($value, $current_pixels) { if (strpos($value, '%') !== false) { $value = str_replace('%', '', $value) * 0.01 * $current_pixels; } return $value; }
php
public function percent($value, $current_pixels) { if (strpos($value, '%') !== false) { $value = str_replace('%', '', $value) * 0.01 * $current_pixels; } return $value; }
[ "public", "function", "percent", "(", "$", "value", ",", "$", "current_pixels", ")", "{", "if", "(", "strpos", "(", "$", "value", ",", "'%'", ")", "!==", "false", ")", "{", "$", "value", "=", "str_replace", "(", "'%'", ",", "''", ",", "$", "value", ")", "*", "0.01", "*", "$", "current_pixels", ";", "}", "return", "$", "value", ";", "}" ]
Accept a percentage and return it in pixels. @param string $value @param int $current_pixels @return mixed
[ "Accept", "a", "percentage", "and", "return", "it", "in", "pixels", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Manager.php#L242-L249
19,404
CakeCMS/Core
src/ORM/Behavior/ProcessBehavior.php
ProcessBehavior.process
public function process($name, array $ids = []) { $allowActions = $this->getConfig('actions'); if (!Arr::key($name, $allowActions)) { throw new \InvalidArgumentException(__d('core', 'Invalid action to perform')); } $action = $allowActions[$name]; if ($action === false) { throw new \InvalidArgumentException(__d('core', 'Action "{0}" is disabled', $name)); } if (Arr::in($action, get_class_methods($this->_table))) { return $this->_table->{$action}($ids); } return $this->{$action}($ids); }
php
public function process($name, array $ids = []) { $allowActions = $this->getConfig('actions'); if (!Arr::key($name, $allowActions)) { throw new \InvalidArgumentException(__d('core', 'Invalid action to perform')); } $action = $allowActions[$name]; if ($action === false) { throw new \InvalidArgumentException(__d('core', 'Action "{0}" is disabled', $name)); } if (Arr::in($action, get_class_methods($this->_table))) { return $this->_table->{$action}($ids); } return $this->{$action}($ids); }
[ "public", "function", "process", "(", "$", "name", ",", "array", "$", "ids", "=", "[", "]", ")", "{", "$", "allowActions", "=", "$", "this", "->", "getConfig", "(", "'actions'", ")", ";", "if", "(", "!", "Arr", "::", "key", "(", "$", "name", ",", "$", "allowActions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__d", "(", "'core'", ",", "'Invalid action to perform'", ")", ")", ";", "}", "$", "action", "=", "$", "allowActions", "[", "$", "name", "]", ";", "if", "(", "$", "action", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__d", "(", "'core'", ",", "'Action \"{0}\" is disabled'", ",", "$", "name", ")", ")", ";", "}", "if", "(", "Arr", "::", "in", "(", "$", "action", ",", "get_class_methods", "(", "$", "this", "->", "_table", ")", ")", ")", "{", "return", "$", "this", "->", "_table", "->", "{", "$", "action", "}", "(", "$", "ids", ")", ";", "}", "return", "$", "this", "->", "{", "$", "action", "}", "(", "$", "ids", ")", ";", "}" ]
Process table method. @param string $name @param array $ids @return mixed
[ "Process", "table", "method", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Behavior/ProcessBehavior.php#L49-L67
19,405
CakeCMS/Core
src/ORM/Behavior/ProcessBehavior.php
ProcessBehavior.processDelete
public function processDelete(array $ids) { return $this->_table->deleteAll([ $this->_table->getPrimaryKey() . ' IN (' . implode(',', $ids) . ')' ]); }
php
public function processDelete(array $ids) { return $this->_table->deleteAll([ $this->_table->getPrimaryKey() . ' IN (' . implode(',', $ids) . ')' ]); }
[ "public", "function", "processDelete", "(", "array", "$", "ids", ")", "{", "return", "$", "this", "->", "_table", "->", "deleteAll", "(", "[", "$", "this", "->", "_table", "->", "getPrimaryKey", "(", ")", ".", "' IN ('", ".", "implode", "(", "','", ",", "$", "ids", ")", ".", "')'", "]", ")", ";", "}" ]
Process delete method. @param array $ids @return int
[ "Process", "delete", "method", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Behavior/ProcessBehavior.php#L75-L80
19,406
CakeCMS/Core
src/ORM/Behavior/ProcessBehavior.php
ProcessBehavior._toggleField
protected function _toggleField(array $ids, $value = STATUS_UN_PUBLISH) { return $this->_table->updateAll([ $this->_configRead('field') => $value, ], [ $this->_table->getPrimaryKey() . ' IN (' . implode(',', $ids) . ')' ]); }
php
protected function _toggleField(array $ids, $value = STATUS_UN_PUBLISH) { return $this->_table->updateAll([ $this->_configRead('field') => $value, ], [ $this->_table->getPrimaryKey() . ' IN (' . implode(',', $ids) . ')' ]); }
[ "protected", "function", "_toggleField", "(", "array", "$", "ids", ",", "$", "value", "=", "STATUS_UN_PUBLISH", ")", "{", "return", "$", "this", "->", "_table", "->", "updateAll", "(", "[", "$", "this", "->", "_configRead", "(", "'field'", ")", "=>", "$", "value", ",", "]", ",", "[", "$", "this", "->", "_table", "->", "getPrimaryKey", "(", ")", ".", "' IN ('", ".", "implode", "(", "','", ",", "$", "ids", ")", ".", "')'", "]", ")", ";", "}" ]
Toggle table field. @param array $ids @param int $value @return int
[ "Toggle", "table", "field", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Behavior/ProcessBehavior.php#L111-L118
19,407
redaigbaria/oauth2
src/Entity/AbstractTokenEntity.php
AbstractTokenEntity.setId
public function setId($id = null) { $this->id = ($id !== null) ? $id : SecureKey::generate(); return $this; }
php
public function setId($id = null) { $this->id = ($id !== null) ? $id : SecureKey::generate(); return $this; }
[ "public", "function", "setId", "(", "$", "id", "=", "null", ")", "{", "$", "this", "->", "id", "=", "(", "$", "id", "!==", "null", ")", "?", "$", "id", ":", "SecureKey", "::", "generate", "(", ")", ";", "return", "$", "this", ";", "}" ]
Set token ID @param string $id Token ID @return self
[ "Set", "token", "ID" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/AbstractTokenEntity.php#L131-L136
19,408
redaigbaria/oauth2
src/Entity/AbstractTokenEntity.php
AbstractTokenEntity.setSessionId
public function setSessionId($session_id=null) { $this->session_id= ($session_id!== null) ? $session_id : null; return $this; }
php
public function setSessionId($session_id=null) { $this->session_id= ($session_id!== null) ? $session_id : null; return $this; }
[ "public", "function", "setSessionId", "(", "$", "session_id", "=", "null", ")", "{", "$", "this", "->", "session_id", "=", "(", "$", "session_id", "!==", "null", ")", "?", "$", "session_id", ":", "null", ";", "return", "$", "this", ";", "}" ]
Set the session id that this token is associated to .. @param string $session_id Session id
[ "Set", "the", "session", "id", "that", "this", "token", "is", "associated", "to", ".." ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/AbstractTokenEntity.php#L142-L147
19,409
userfriendly/SocialUserBundle
OAuth/UserProvider.php
UserProvider.getExistingIdentity
protected function getExistingIdentity( UserResponseInterface $response ) { $repo = $this->om->getRepository( $this->userIdentityClass ); // wrong class return $repo->findOneBy( array( 'identifier' => $response->getUsername(), 'type' => $response->getResourceOwner()->getName(), )); }
php
protected function getExistingIdentity( UserResponseInterface $response ) { $repo = $this->om->getRepository( $this->userIdentityClass ); // wrong class return $repo->findOneBy( array( 'identifier' => $response->getUsername(), 'type' => $response->getResourceOwner()->getName(), )); }
[ "protected", "function", "getExistingIdentity", "(", "UserResponseInterface", "$", "response", ")", "{", "$", "repo", "=", "$", "this", "->", "om", "->", "getRepository", "(", "$", "this", "->", "userIdentityClass", ")", ";", "// wrong class", "return", "$", "repo", "->", "findOneBy", "(", "array", "(", "'identifier'", "=>", "$", "response", "->", "getUsername", "(", ")", ",", "'type'", "=>", "$", "response", "->", "getResourceOwner", "(", ")", "->", "getName", "(", ")", ",", ")", ")", ";", "}" ]
Checks whether the authenticating Identity already exists @param \HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface $response @return \Userfriendly\Bundle\SocialUserBundle\Model\UserIdentity
[ "Checks", "whether", "the", "authenticating", "Identity", "already", "exists" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/OAuth/UserProvider.php#L98-L105
19,410
userfriendly/SocialUserBundle
OAuth/UserProvider.php
UserProvider.createUser
protected function createUser( UserResponseInterface $response ) { $user = $this->userManager->createUser(); $user->setUsername( $this->createUniqueUsername( $this->getRealName( $response ))); $user->setEmail( $this->getEmail( $response ) ); $user->setPassword( '' ); $user->setEnabled( true ); $this->userManager->updateUser( $user ); $this->createIdentity( $user, $response ); return $user; }
php
protected function createUser( UserResponseInterface $response ) { $user = $this->userManager->createUser(); $user->setUsername( $this->createUniqueUsername( $this->getRealName( $response ))); $user->setEmail( $this->getEmail( $response ) ); $user->setPassword( '' ); $user->setEnabled( true ); $this->userManager->updateUser( $user ); $this->createIdentity( $user, $response ); return $user; }
[ "protected", "function", "createUser", "(", "UserResponseInterface", "$", "response", ")", "{", "$", "user", "=", "$", "this", "->", "userManager", "->", "createUser", "(", ")", ";", "$", "user", "->", "setUsername", "(", "$", "this", "->", "createUniqueUsername", "(", "$", "this", "->", "getRealName", "(", "$", "response", ")", ")", ")", ";", "$", "user", "->", "setEmail", "(", "$", "this", "->", "getEmail", "(", "$", "response", ")", ")", ";", "$", "user", "->", "setPassword", "(", "''", ")", ";", "$", "user", "->", "setEnabled", "(", "true", ")", ";", "$", "this", "->", "userManager", "->", "updateUser", "(", "$", "user", ")", ";", "$", "this", "->", "createIdentity", "(", "$", "user", ",", "$", "response", ")", ";", "return", "$", "user", ";", "}" ]
Creates new User @param \HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface $response @return \Userfriendly\Bundle\SocialUserBundle\Model\User
[ "Creates", "new", "User" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/OAuth/UserProvider.php#L113-L123
19,411
userfriendly/SocialUserBundle
OAuth/UserProvider.php
UserProvider.createIdentity
protected function createIdentity( User $user, UserResponseInterface $response ) { $identity = new $this->userIdentityClass; $identity->setAccessToken( $this->getAccessToken( $response )); $identity->setIdentifier( $response->getUsername() ); $identity->setType( $response->getResourceOwner()->getName() ); $identity->setUser( $user ); $identity->setName( $this->getRealName( $response )); $identity->setEmail( $this->getEmail( $response )); $this->om->persist( $identity ); $this->om->flush(); return $identity; }
php
protected function createIdentity( User $user, UserResponseInterface $response ) { $identity = new $this->userIdentityClass; $identity->setAccessToken( $this->getAccessToken( $response )); $identity->setIdentifier( $response->getUsername() ); $identity->setType( $response->getResourceOwner()->getName() ); $identity->setUser( $user ); $identity->setName( $this->getRealName( $response )); $identity->setEmail( $this->getEmail( $response )); $this->om->persist( $identity ); $this->om->flush(); return $identity; }
[ "protected", "function", "createIdentity", "(", "User", "$", "user", ",", "UserResponseInterface", "$", "response", ")", "{", "$", "identity", "=", "new", "$", "this", "->", "userIdentityClass", ";", "$", "identity", "->", "setAccessToken", "(", "$", "this", "->", "getAccessToken", "(", "$", "response", ")", ")", ";", "$", "identity", "->", "setIdentifier", "(", "$", "response", "->", "getUsername", "(", ")", ")", ";", "$", "identity", "->", "setType", "(", "$", "response", "->", "getResourceOwner", "(", ")", "->", "getName", "(", ")", ")", ";", "$", "identity", "->", "setUser", "(", "$", "user", ")", ";", "$", "identity", "->", "setName", "(", "$", "this", "->", "getRealName", "(", "$", "response", ")", ")", ";", "$", "identity", "->", "setEmail", "(", "$", "this", "->", "getEmail", "(", "$", "response", ")", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "identity", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "return", "$", "identity", ";", "}" ]
Creates new Identity @param \HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface $response @param \Userfriendly\Bundle\SocialUserBundle\Model\User $user @return \Userfriendly\Bundle\SocialUserBundle\Model\UserIdentity
[ "Creates", "new", "Identity" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/OAuth/UserProvider.php#L132-L144
19,412
userfriendly/SocialUserBundle
OAuth/UserProvider.php
UserProvider.createUniqueUsername
protected function createUniqueUsername( $username ) { $originalName = $username; $existingUser = $this->userManager->findUserByUsername( $username ); $suffix = 0; while ( $existingUser ) { $suffix++; $username = $originalName . $suffix; $existingUser = $this->userManager->findUserByUsername( $username ); } return $username; }
php
protected function createUniqueUsername( $username ) { $originalName = $username; $existingUser = $this->userManager->findUserByUsername( $username ); $suffix = 0; while ( $existingUser ) { $suffix++; $username = $originalName . $suffix; $existingUser = $this->userManager->findUserByUsername( $username ); } return $username; }
[ "protected", "function", "createUniqueUsername", "(", "$", "username", ")", "{", "$", "originalName", "=", "$", "username", ";", "$", "existingUser", "=", "$", "this", "->", "userManager", "->", "findUserByUsername", "(", "$", "username", ")", ";", "$", "suffix", "=", "0", ";", "while", "(", "$", "existingUser", ")", "{", "$", "suffix", "++", ";", "$", "username", "=", "$", "originalName", ".", "$", "suffix", ";", "$", "existingUser", "=", "$", "this", "->", "userManager", "->", "findUserByUsername", "(", "$", "username", ")", ";", "}", "return", "$", "username", ";", "}" ]
Ensures uniqueness of username @param string $username @return string
[ "Ensures", "uniqueness", "of", "username" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/OAuth/UserProvider.php#L152-L164
19,413
yuncms/framework
src/web/Response.php
Response.setCacheHeaders
public function setCacheHeaders() { $cacheTime = 31536000; // 1 year $this->getHeaders() ->set('Expires', gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT') ->set('Pragma', 'cache') ->set('Cache-Control', 'max-age=' . $cacheTime); return $this; }
php
public function setCacheHeaders() { $cacheTime = 31536000; // 1 year $this->getHeaders() ->set('Expires', gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT') ->set('Pragma', 'cache') ->set('Cache-Control', 'max-age=' . $cacheTime); return $this; }
[ "public", "function", "setCacheHeaders", "(", ")", "{", "$", "cacheTime", "=", "31536000", ";", "// 1 year", "$", "this", "->", "getHeaders", "(", ")", "->", "set", "(", "'Expires'", ",", "gmdate", "(", "'D, d M Y H:i:s'", ",", "time", "(", ")", "+", "$", "cacheTime", ")", ".", "' GMT'", ")", "->", "set", "(", "'Pragma'", ",", "'cache'", ")", "->", "set", "(", "'Cache-Control'", ",", "'max-age='", ".", "$", "cacheTime", ")", ";", "return", "$", "this", ";", "}" ]
Sets headers that will instruct the client to cache this response. @return static self reference
[ "Sets", "headers", "that", "will", "instruct", "the", "client", "to", "cache", "this", "response", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/web/Response.php#L63-L72
19,414
yuncms/framework
src/web/Response.php
Response.setLastModifiedHeader
public function setLastModifiedHeader(string $path) { $modifiedTime = filemtime($path); if ($modifiedTime) { $this->getHeaders()->set('Last-Modified', gmdate('D, d M Y H:i:s', $modifiedTime) . ' GMT'); } return $this; }
php
public function setLastModifiedHeader(string $path) { $modifiedTime = filemtime($path); if ($modifiedTime) { $this->getHeaders()->set('Last-Modified', gmdate('D, d M Y H:i:s', $modifiedTime) . ' GMT'); } return $this; }
[ "public", "function", "setLastModifiedHeader", "(", "string", "$", "path", ")", "{", "$", "modifiedTime", "=", "filemtime", "(", "$", "path", ")", ";", "if", "(", "$", "modifiedTime", ")", "{", "$", "this", "->", "getHeaders", "(", ")", "->", "set", "(", "'Last-Modified'", ",", "gmdate", "(", "'D, d M Y H:i:s'", ",", "$", "modifiedTime", ")", ".", "' GMT'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a Last-Modified header based on a given file path. @param string $path The file to read the last modified date from. @return static self reference
[ "Sets", "a", "Last", "-", "Modified", "header", "based", "on", "a", "given", "file", "path", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/web/Response.php#L80-L89
19,415
php-rise/rise
src/Response.php
Response.sendFile
public function sendFile($file) { if ($this->sent) { return $this; } $this->setMode(self::MODE_FILE); $this->send($file); return $this; }
php
public function sendFile($file) { if ($this->sent) { return $this; } $this->setMode(self::MODE_FILE); $this->send($file); return $this; }
[ "public", "function", "sendFile", "(", "$", "file", ")", "{", "if", "(", "$", "this", "->", "sent", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "setMode", "(", "self", "::", "MODE_FILE", ")", ";", "$", "this", "->", "send", "(", "$", "file", ")", ";", "return", "$", "this", ";", "}" ]
Send a file. @param string $file @return self
[ "Send", "a", "file", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Response.php#L295-L304
19,416
php-rise/rise
src/Response.php
Response.redirect
public function redirect($url, $statusCode = 302) { $this->setStatusCode($statusCode) ->setHeader('Location', $url) ->setBody(sprintf('<!DOCTYPE html> <meta charset="UTF-8"> <meta http-equiv="refresh" content="1;url=%1$s"> <title>Redirecting to %1$s</title> Redirecting to <a href="%1$s">%1$s</a>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))); return $this; }
php
public function redirect($url, $statusCode = 302) { $this->setStatusCode($statusCode) ->setHeader('Location', $url) ->setBody(sprintf('<!DOCTYPE html> <meta charset="UTF-8"> <meta http-equiv="refresh" content="1;url=%1$s"> <title>Redirecting to %1$s</title> Redirecting to <a href="%1$s">%1$s</a>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))); return $this; }
[ "public", "function", "redirect", "(", "$", "url", ",", "$", "statusCode", "=", "302", ")", "{", "$", "this", "->", "setStatusCode", "(", "$", "statusCode", ")", "->", "setHeader", "(", "'Location'", ",", "$", "url", ")", "->", "setBody", "(", "sprintf", "(", "'<!DOCTYPE html>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"refresh\" content=\"1;url=%1$s\">\n<title>Redirecting to %1$s</title>\nRedirecting to <a href=\"%1$s\">%1$s</a>'", ",", "htmlspecialchars", "(", "$", "url", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Setup HTTP redirect. @param string $url @param int $statusCode Optional @return self
[ "Setup", "HTTP", "redirect", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Response.php#L313-L323
19,417
php-rise/rise
src/Response.php
Response.redirectRoute
public function redirectRoute($name, $params = [], $statusCode = 302) { $this->redirect($this->urlGenerator->generate($name, $params), $statusCode); return $this; }
php
public function redirectRoute($name, $params = [], $statusCode = 302) { $this->redirect($this->urlGenerator->generate($name, $params), $statusCode); return $this; }
[ "public", "function", "redirectRoute", "(", "$", "name", ",", "$", "params", "=", "[", "]", ",", "$", "statusCode", "=", "302", ")", "{", "$", "this", "->", "redirect", "(", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "name", ",", "$", "params", ")", ",", "$", "statusCode", ")", ";", "return", "$", "this", ";", "}" ]
HTTP redirect to a named route. @param string $routeName @param array $params @param int $statusCode Optional @return self
[ "HTTP", "redirect", "to", "a", "named", "route", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Response.php#L333-L336
19,418
php-rise/rise
src/Response.php
Response.closeOutputBuffers
public static function closeOutputBuffers($targetLevel, $flush) { $status = ob_get_status(true); $level = count($status); while ($level-- > $targetLevel && (!empty($status[$level]['del']) || (isset($status[$level]['flags']) && ($status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE) && ($status[$level]['flags'] & ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE)) ) ) ) { if ($flush) { ob_end_flush(); } else { ob_end_clean(); } } }
php
public static function closeOutputBuffers($targetLevel, $flush) { $status = ob_get_status(true); $level = count($status); while ($level-- > $targetLevel && (!empty($status[$level]['del']) || (isset($status[$level]['flags']) && ($status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE) && ($status[$level]['flags'] & ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE)) ) ) ) { if ($flush) { ob_end_flush(); } else { ob_end_clean(); } } }
[ "public", "static", "function", "closeOutputBuffers", "(", "$", "targetLevel", ",", "$", "flush", ")", "{", "$", "status", "=", "ob_get_status", "(", "true", ")", ";", "$", "level", "=", "count", "(", "$", "status", ")", ";", "while", "(", "$", "level", "--", ">", "$", "targetLevel", "&&", "(", "!", "empty", "(", "$", "status", "[", "$", "level", "]", "[", "'del'", "]", ")", "||", "(", "isset", "(", "$", "status", "[", "$", "level", "]", "[", "'flags'", "]", ")", "&&", "(", "$", "status", "[", "$", "level", "]", "[", "'flags'", "]", "&", "PHP_OUTPUT_HANDLER_REMOVABLE", ")", "&&", "(", "$", "status", "[", "$", "level", "]", "[", "'flags'", "]", "&", "(", "$", "flush", "?", "PHP_OUTPUT_HANDLER_FLUSHABLE", ":", "PHP_OUTPUT_HANDLER_CLEANABLE", ")", ")", ")", ")", ")", "{", "if", "(", "$", "flush", ")", "{", "ob_end_flush", "(", ")", ";", "}", "else", "{", "ob_end_clean", "(", ")", ";", "}", "}", "}" ]
Cleans or flushes output buffers up to target level. @NOTE Function from Symfony\Component\HttpFoundation\Response Resulting level can be greater than target level if a non-removable buffer has been encountered. @param int $targetLevel The target output buffering level @param bool $flush Whether to flush or clean the buffers
[ "Cleans", "or", "flushes", "output", "buffers", "up", "to", "target", "level", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Response.php#L561-L579
19,419
barebone-php/barebone-core
lib/LogTrait.php
LogTrait.log
public function log($text, $severity = 'info') { if ($severity === 'warn' || $severity === 'warning') { return Log::warning($text); } if ($severity === 'err' || $severity === 'error') { return Log::error($text); } return Log::info($text); }
php
public function log($text, $severity = 'info') { if ($severity === 'warn' || $severity === 'warning') { return Log::warning($text); } if ($severity === 'err' || $severity === 'error') { return Log::error($text); } return Log::info($text); }
[ "public", "function", "log", "(", "$", "text", ",", "$", "severity", "=", "'info'", ")", "{", "if", "(", "$", "severity", "===", "'warn'", "||", "$", "severity", "===", "'warning'", ")", "{", "return", "Log", "::", "warning", "(", "$", "text", ")", ";", "}", "if", "(", "$", "severity", "===", "'err'", "||", "$", "severity", "===", "'error'", ")", "{", "return", "Log", "::", "error", "(", "$", "text", ")", ";", "}", "return", "Log", "::", "info", "(", "$", "text", ")", ";", "}" ]
Write to application log @param string $text message @param string $severity Either 'info', 'warn' or 'error' @return Boolean Whether the record has been processed
[ "Write", "to", "application", "log" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/LogTrait.php#L38-L49
19,420
jfusion/org.jfusion.framework
src/User/Userinfo.php
Userinfo.getAnonymizeed
public function getAnonymizeed() { $userinfo = $this->toObject(); $userinfo->password_clear = '******'; if (isset($userinfo->password)) { $userinfo->password = substr($userinfo->password, 0, 6) . '********'; } if (isset($userinfo->password_salt)) { $userinfo->password_salt = substr($userinfo->password_salt, 0, 4) . '*****'; } return $userinfo; }
php
public function getAnonymizeed() { $userinfo = $this->toObject(); $userinfo->password_clear = '******'; if (isset($userinfo->password)) { $userinfo->password = substr($userinfo->password, 0, 6) . '********'; } if (isset($userinfo->password_salt)) { $userinfo->password_salt = substr($userinfo->password_salt, 0, 4) . '*****'; } return $userinfo; }
[ "public", "function", "getAnonymizeed", "(", ")", "{", "$", "userinfo", "=", "$", "this", "->", "toObject", "(", ")", ";", "$", "userinfo", "->", "password_clear", "=", "'******'", ";", "if", "(", "isset", "(", "$", "userinfo", "->", "password", ")", ")", "{", "$", "userinfo", "->", "password", "=", "substr", "(", "$", "userinfo", "->", "password", ",", "0", ",", "6", ")", ".", "'********'", ";", "}", "if", "(", "isset", "(", "$", "userinfo", "->", "password_salt", ")", ")", "{", "$", "userinfo", "->", "password_salt", "=", "substr", "(", "$", "userinfo", "->", "password_salt", ",", "0", ",", "4", ")", ".", "'*****'", ";", "}", "return", "$", "userinfo", ";", "}" ]
hides sensitive information @return stdClass parsed userinfo object
[ "hides", "sensitive", "information" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Userinfo.php#L210-L221
19,421
dburkart/scurvy
Scurvy.php
Scurvy.render
private function render() { $strings = implode($this->strings); // Render includes foreach ($this->incTemplates as $path => $include) { $incOutput = $include->render(); $path = preg_replace("/\//", "\/", $path); $strings = preg_replace("/\{include\s$path\}/", $incOutput, $strings); } // Render if-statements foreach ($this->ifTemplates as $key => $sub) { foreach ($sub as $iKey => $instance) { $str = ''; if ($this->expressions[$key]->evaluate($this->vars)) { $str = $instance->render(); } $pregKey = preg_quote($key, '/'); $strings = preg_replace("/\{if:$pregKey:$iKey\}/", $str, $strings); } } // Render foreach-loops foreach ($this->forTemplates as $key => $sub) { foreach ($sub as $iKey => $instance) { $tmplGen = ''; if (isset($this->vars[$key]) && is_array($this->vars[$key])) { foreach ($this->vars[$key] as $assocArray) { foreach ($assocArray as $k => $v) $instance->set($k, $v); $tmplGen .= $instance->render(); } } $pregKey = preg_quote($key, '/'); $strings = preg_replace("/\{for:$pregKey:$iKey\}/", $tmplGen, $strings); } } // Render plain old variables foreach ($this->vars as $key => $val) { if (!is_array($val)) $strings = preg_replace("/\{$key\}/", $val, $strings); } // Render expressions foreach ($this->expressions as $key => $expr) { $eval = $expr->evaluate($this->vars); // If we're an array, lets insert the number of items in the array. if ( is_array( $eval ) ) { $eval = count( $eval ); } $pregKey = preg_quote($key, '/'); $strings = preg_replace('/\{'.$pregKey.'\}/', $eval, $strings); } $strings = preg_replace("/\\\{/", '{', $strings); $strings = preg_replace("/\\\}/", '}', $strings); return $strings; }
php
private function render() { $strings = implode($this->strings); // Render includes foreach ($this->incTemplates as $path => $include) { $incOutput = $include->render(); $path = preg_replace("/\//", "\/", $path); $strings = preg_replace("/\{include\s$path\}/", $incOutput, $strings); } // Render if-statements foreach ($this->ifTemplates as $key => $sub) { foreach ($sub as $iKey => $instance) { $str = ''; if ($this->expressions[$key]->evaluate($this->vars)) { $str = $instance->render(); } $pregKey = preg_quote($key, '/'); $strings = preg_replace("/\{if:$pregKey:$iKey\}/", $str, $strings); } } // Render foreach-loops foreach ($this->forTemplates as $key => $sub) { foreach ($sub as $iKey => $instance) { $tmplGen = ''; if (isset($this->vars[$key]) && is_array($this->vars[$key])) { foreach ($this->vars[$key] as $assocArray) { foreach ($assocArray as $k => $v) $instance->set($k, $v); $tmplGen .= $instance->render(); } } $pregKey = preg_quote($key, '/'); $strings = preg_replace("/\{for:$pregKey:$iKey\}/", $tmplGen, $strings); } } // Render plain old variables foreach ($this->vars as $key => $val) { if (!is_array($val)) $strings = preg_replace("/\{$key\}/", $val, $strings); } // Render expressions foreach ($this->expressions as $key => $expr) { $eval = $expr->evaluate($this->vars); // If we're an array, lets insert the number of items in the array. if ( is_array( $eval ) ) { $eval = count( $eval ); } $pregKey = preg_quote($key, '/'); $strings = preg_replace('/\{'.$pregKey.'\}/', $eval, $strings); } $strings = preg_replace("/\\\{/", '{', $strings); $strings = preg_replace("/\\\}/", '}', $strings); return $strings; }
[ "private", "function", "render", "(", ")", "{", "$", "strings", "=", "implode", "(", "$", "this", "->", "strings", ")", ";", "// Render includes", "foreach", "(", "$", "this", "->", "incTemplates", "as", "$", "path", "=>", "$", "include", ")", "{", "$", "incOutput", "=", "$", "include", "->", "render", "(", ")", ";", "$", "path", "=", "preg_replace", "(", "\"/\\//\"", ",", "\"\\/\"", ",", "$", "path", ")", ";", "$", "strings", "=", "preg_replace", "(", "\"/\\{include\\s$path\\}/\"", ",", "$", "incOutput", ",", "$", "strings", ")", ";", "}", "// Render if-statements", "foreach", "(", "$", "this", "->", "ifTemplates", "as", "$", "key", "=>", "$", "sub", ")", "{", "foreach", "(", "$", "sub", "as", "$", "iKey", "=>", "$", "instance", ")", "{", "$", "str", "=", "''", ";", "if", "(", "$", "this", "->", "expressions", "[", "$", "key", "]", "->", "evaluate", "(", "$", "this", "->", "vars", ")", ")", "{", "$", "str", "=", "$", "instance", "->", "render", "(", ")", ";", "}", "$", "pregKey", "=", "preg_quote", "(", "$", "key", ",", "'/'", ")", ";", "$", "strings", "=", "preg_replace", "(", "\"/\\{if:$pregKey:$iKey\\}/\"", ",", "$", "str", ",", "$", "strings", ")", ";", "}", "}", "// Render foreach-loops", "foreach", "(", "$", "this", "->", "forTemplates", "as", "$", "key", "=>", "$", "sub", ")", "{", "foreach", "(", "$", "sub", "as", "$", "iKey", "=>", "$", "instance", ")", "{", "$", "tmplGen", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "vars", "[", "$", "key", "]", ")", "&&", "is_array", "(", "$", "this", "->", "vars", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "vars", "[", "$", "key", "]", "as", "$", "assocArray", ")", "{", "foreach", "(", "$", "assocArray", "as", "$", "k", "=>", "$", "v", ")", "$", "instance", "->", "set", "(", "$", "k", ",", "$", "v", ")", ";", "$", "tmplGen", ".=", "$", "instance", "->", "render", "(", ")", ";", "}", "}", "$", "pregKey", "=", "preg_quote", "(", "$", "key", ",", "'/'", ")", ";", "$", "strings", "=", "preg_replace", "(", "\"/\\{for:$pregKey:$iKey\\}/\"", ",", "$", "tmplGen", ",", "$", "strings", ")", ";", "}", "}", "// Render plain old variables", "foreach", "(", "$", "this", "->", "vars", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_array", "(", "$", "val", ")", ")", "$", "strings", "=", "preg_replace", "(", "\"/\\{$key\\}/\"", ",", "$", "val", ",", "$", "strings", ")", ";", "}", "// Render expressions", "foreach", "(", "$", "this", "->", "expressions", "as", "$", "key", "=>", "$", "expr", ")", "{", "$", "eval", "=", "$", "expr", "->", "evaluate", "(", "$", "this", "->", "vars", ")", ";", "// If we're an array, lets insert the number of items in the array.", "if", "(", "is_array", "(", "$", "eval", ")", ")", "{", "$", "eval", "=", "count", "(", "$", "eval", ")", ";", "}", "$", "pregKey", "=", "preg_quote", "(", "$", "key", ",", "'/'", ")", ";", "$", "strings", "=", "preg_replace", "(", "'/\\{'", ".", "$", "pregKey", ".", "'\\}/'", ",", "$", "eval", ",", "$", "strings", ")", ";", "}", "$", "strings", "=", "preg_replace", "(", "\"/\\\\\\{/\"", ",", "'{'", ",", "$", "strings", ")", ";", "$", "strings", "=", "preg_replace", "(", "\"/\\\\\\}/\"", ",", "'}'", ",", "$", "strings", ")", ";", "return", "$", "strings", ";", "}" ]
The render function goes through and renders the parsed document. @return string containing the rendered output.
[ "The", "render", "function", "goes", "through", "and", "renders", "the", "parsed", "document", "." ]
990a7c4f0517298de304438cf9cd95a303a231fb
https://github.com/dburkart/scurvy/blob/990a7c4f0517298de304438cf9cd95a303a231fb/Scurvy.php#L102-L168
19,422
dburkart/scurvy
Scurvy.php
Scurvy.set
private function set($var, $val) { $this->vars[$var] = $val; // We also need to set $var on each sub-template. So recursively do that foreach($this->forTemplates as $templateBunch) foreach($templateBunch as $sub) $sub->set($var, $val); foreach($this->ifTemplates as $templateBunch) foreach($templateBunch as $sub) $sub->set($var, $val); foreach($this->incTemplates as $sub) $sub->set($var, $val); }
php
private function set($var, $val) { $this->vars[$var] = $val; // We also need to set $var on each sub-template. So recursively do that foreach($this->forTemplates as $templateBunch) foreach($templateBunch as $sub) $sub->set($var, $val); foreach($this->ifTemplates as $templateBunch) foreach($templateBunch as $sub) $sub->set($var, $val); foreach($this->incTemplates as $sub) $sub->set($var, $val); }
[ "private", "function", "set", "(", "$", "var", ",", "$", "val", ")", "{", "$", "this", "->", "vars", "[", "$", "var", "]", "=", "$", "val", ";", "// We also need to set $var on each sub-template. So recursively do that", "foreach", "(", "$", "this", "->", "forTemplates", "as", "$", "templateBunch", ")", "foreach", "(", "$", "templateBunch", "as", "$", "sub", ")", "$", "sub", "->", "set", "(", "$", "var", ",", "$", "val", ")", ";", "foreach", "(", "$", "this", "->", "ifTemplates", "as", "$", "templateBunch", ")", "foreach", "(", "$", "templateBunch", "as", "$", "sub", ")", "$", "sub", "->", "set", "(", "$", "var", ",", "$", "val", ")", ";", "foreach", "(", "$", "this", "->", "incTemplates", "as", "$", "sub", ")", "$", "sub", "->", "set", "(", "$", "var", ",", "$", "val", ")", ";", "}" ]
Sets the value of a variable. @param string $var variable to set @param mixed $val value to set var to
[ "Sets", "the", "value", "of", "a", "variable", "." ]
990a7c4f0517298de304438cf9cd95a303a231fb
https://github.com/dburkart/scurvy/blob/990a7c4f0517298de304438cf9cd95a303a231fb/Scurvy.php#L176-L190
19,423
dburkart/scurvy
Scurvy.php
Scurvy.parseRecursive
private function parseRecursive($start, $regex, $subName = 'template') { $re_beg = $regex[0]; $re_end = $regex[1]; $numLines = count($this->strings); $i = $start; $n = 0; $line = 0; for ($i; $i < $numLines; $i++) { $match = preg_match($re_beg, $this->strings[$i]); if ($match) $n += 1; $match = preg_match($re_end, $this->strings[$i]); if ($match) { $n -= 1; if ($n == 0) break; } $line++; } if ($n > 0) { echo "Opening brace on line $line of {$subName} has no closing brace\n<br />"; } // Deal with edge-cases // // - {block}TEXT{/block} // - {block} // TEXT{/block} if ($start == $i) { $subTmpl = $this->strings[$start]; $beg = strpos($subTmpl, '}') + 1; $subTmpl = array( substr($subTmpl, $beg, strrpos($subTmpl, '{') - $beg) ); } else if ($i == ($start + 1)) { $subTmpl = $this->strings[$i]; $subTmpl = array( substr($subTmpl, 0, strrpos($subTmpl, '{'))); } else { $subTmpl = array_slice($this->strings, $start + 1, $i - ($start + 1)); } for ($j = $start; $j <= $i; $j++) { //-- Just set the string to empty. Don't worry about removing it //-- from the array $this->strings[$j] = ''; } if ($subName != 'comment') return new Scurvy($subTmpl, $this->template_dir, false, $subName); }
php
private function parseRecursive($start, $regex, $subName = 'template') { $re_beg = $regex[0]; $re_end = $regex[1]; $numLines = count($this->strings); $i = $start; $n = 0; $line = 0; for ($i; $i < $numLines; $i++) { $match = preg_match($re_beg, $this->strings[$i]); if ($match) $n += 1; $match = preg_match($re_end, $this->strings[$i]); if ($match) { $n -= 1; if ($n == 0) break; } $line++; } if ($n > 0) { echo "Opening brace on line $line of {$subName} has no closing brace\n<br />"; } // Deal with edge-cases // // - {block}TEXT{/block} // - {block} // TEXT{/block} if ($start == $i) { $subTmpl = $this->strings[$start]; $beg = strpos($subTmpl, '}') + 1; $subTmpl = array( substr($subTmpl, $beg, strrpos($subTmpl, '{') - $beg) ); } else if ($i == ($start + 1)) { $subTmpl = $this->strings[$i]; $subTmpl = array( substr($subTmpl, 0, strrpos($subTmpl, '{'))); } else { $subTmpl = array_slice($this->strings, $start + 1, $i - ($start + 1)); } for ($j = $start; $j <= $i; $j++) { //-- Just set the string to empty. Don't worry about removing it //-- from the array $this->strings[$j] = ''; } if ($subName != 'comment') return new Scurvy($subTmpl, $this->template_dir, false, $subName); }
[ "private", "function", "parseRecursive", "(", "$", "start", ",", "$", "regex", ",", "$", "subName", "=", "'template'", ")", "{", "$", "re_beg", "=", "$", "regex", "[", "0", "]", ";", "$", "re_end", "=", "$", "regex", "[", "1", "]", ";", "$", "numLines", "=", "count", "(", "$", "this", "->", "strings", ")", ";", "$", "i", "=", "$", "start", ";", "$", "n", "=", "0", ";", "$", "line", "=", "0", ";", "for", "(", "$", "i", ";", "$", "i", "<", "$", "numLines", ";", "$", "i", "++", ")", "{", "$", "match", "=", "preg_match", "(", "$", "re_beg", ",", "$", "this", "->", "strings", "[", "$", "i", "]", ")", ";", "if", "(", "$", "match", ")", "$", "n", "+=", "1", ";", "$", "match", "=", "preg_match", "(", "$", "re_end", ",", "$", "this", "->", "strings", "[", "$", "i", "]", ")", ";", "if", "(", "$", "match", ")", "{", "$", "n", "-=", "1", ";", "if", "(", "$", "n", "==", "0", ")", "break", ";", "}", "$", "line", "++", ";", "}", "if", "(", "$", "n", ">", "0", ")", "{", "echo", "\"Opening brace on line $line of {$subName} has no closing brace\\n<br />\"", ";", "}", "// Deal with edge-cases", "// ", "// - {block}TEXT{/block}", "// - {block}", "// TEXT{/block}", "if", "(", "$", "start", "==", "$", "i", ")", "{", "$", "subTmpl", "=", "$", "this", "->", "strings", "[", "$", "start", "]", ";", "$", "beg", "=", "strpos", "(", "$", "subTmpl", ",", "'}'", ")", "+", "1", ";", "$", "subTmpl", "=", "array", "(", "substr", "(", "$", "subTmpl", ",", "$", "beg", ",", "strrpos", "(", "$", "subTmpl", ",", "'{'", ")", "-", "$", "beg", ")", ")", ";", "}", "else", "if", "(", "$", "i", "==", "(", "$", "start", "+", "1", ")", ")", "{", "$", "subTmpl", "=", "$", "this", "->", "strings", "[", "$", "i", "]", ";", "$", "subTmpl", "=", "array", "(", "substr", "(", "$", "subTmpl", ",", "0", ",", "strrpos", "(", "$", "subTmpl", ",", "'{'", ")", ")", ")", ";", "}", "else", "{", "$", "subTmpl", "=", "array_slice", "(", "$", "this", "->", "strings", ",", "$", "start", "+", "1", ",", "$", "i", "-", "(", "$", "start", "+", "1", ")", ")", ";", "}", "for", "(", "$", "j", "=", "$", "start", ";", "$", "j", "<=", "$", "i", ";", "$", "j", "++", ")", "{", "//-- Just set the string to empty. Don't worry about removing it", "//-- from the array", "$", "this", "->", "strings", "[", "$", "j", "]", "=", "''", ";", "}", "if", "(", "$", "subName", "!=", "'comment'", ")", "return", "new", "Scurvy", "(", "$", "subTmpl", ",", "$", "this", "->", "template_dir", ",", "false", ",", "$", "subName", ")", ";", "}" ]
This function is used by the parse function to grab the contents of scurvy block statements. @param start the start index into $this->strings @param regex the regular expression for the block statement @param subName the name of the subTemplate (for debugging purposes) @return a new template with the contents of the block statement
[ "This", "function", "is", "used", "by", "the", "parse", "function", "to", "grab", "the", "contents", "of", "scurvy", "block", "statements", "." ]
990a7c4f0517298de304438cf9cd95a303a231fb
https://github.com/dburkart/scurvy/blob/990a7c4f0517298de304438cf9cd95a303a231fb/Scurvy.php#L339-L389
19,424
webforge-labs/psc-cms
lib/Psc/CMS/User.php
User.setPassword
public function setPassword($password) { if (is_array($password)) { if ($password['password'] == NULL) return $this; $this->hashPassword($password['password']); } else { if ($password == NULL) return $this; $this->password = $password; } return $this; }
php
public function setPassword($password) { if (is_array($password)) { if ($password['password'] == NULL) return $this; $this->hashPassword($password['password']); } else { if ($password == NULL) return $this; $this->password = $password; } return $this; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "if", "(", "is_array", "(", "$", "password", ")", ")", "{", "if", "(", "$", "password", "[", "'password'", "]", "==", "NULL", ")", "return", "$", "this", ";", "$", "this", "->", "hashPassword", "(", "$", "password", "[", "'password'", "]", ")", ";", "}", "else", "{", "if", "(", "$", "password", "==", "NULL", ")", "return", "$", "this", ";", "$", "this", "->", "password", "=", "$", "password", ";", "}", "return", "$", "this", ";", "}" ]
Das setzt das gehashte Passwort und sollte nur intern benutzt werden um das Passwort zu setzen hashPassword benutzen! diese Funktion wird intern vom AbstractEntityController benutzt der Parameter ist dann ein array mit confirmation und password wir könnten auch im validator mit postValidation() arbeiten, aber so ist es mehr convenient für das user objekt an sich @param string $password @chainable @access protected
[ "Das", "setzt", "das", "gehashte", "Passwort", "und", "sollte", "nur", "intern", "benutzt", "werden" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/User.php#L118-L127
19,425
Chill-project/Main
Controller/ExportController.php
ExportController.indexAction
public function indexAction(Request $request) { $exportManager = $this->get('chill.main.export_manager'); $exports = $exportManager->getExports(true); return $this->render('ChillMainBundle:Export:layout.html.twig', array( 'exports' => $exports )); }
php
public function indexAction(Request $request) { $exportManager = $this->get('chill.main.export_manager'); $exports = $exportManager->getExports(true); return $this->render('ChillMainBundle:Export:layout.html.twig', array( 'exports' => $exports )); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "exportManager", "=", "$", "this", "->", "get", "(", "'chill.main.export_manager'", ")", ";", "$", "exports", "=", "$", "exportManager", "->", "getExports", "(", "true", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:Export:layout.html.twig'", ",", "array", "(", "'exports'", "=>", "$", "exports", ")", ")", ";", "}" ]
Render the list of available exports @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "list", "of", "available", "exports" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ExportController.php#L46-L55
19,426
Chill-project/Main
Controller/ExportController.php
ExportController.newAction
public function newAction(Request $request, $alias) { // first check for ACL $exportManager = $this->get('chill.main.export_manager'); $export = $exportManager->getExport($alias); if ($exportManager->isGrantedForElement($export) === FALSE) { throw $this->createAccessDeniedException('The user does not have access to this export'); } $step = $request->query->getAlpha('step', 'centers'); switch ($step) { case 'centers': return $this->selectCentersStep($request, $alias); case 'export': return $this->exportFormStep($request, $alias); break; case 'formatter': return $this->formatterFormStep($request, $alias); break; case 'generate': return $this->forwardToGenerate($request, $alias); break; default: throw $this->createNotFoundException("The given step '$step' is invalid"); } }
php
public function newAction(Request $request, $alias) { // first check for ACL $exportManager = $this->get('chill.main.export_manager'); $export = $exportManager->getExport($alias); if ($exportManager->isGrantedForElement($export) === FALSE) { throw $this->createAccessDeniedException('The user does not have access to this export'); } $step = $request->query->getAlpha('step', 'centers'); switch ($step) { case 'centers': return $this->selectCentersStep($request, $alias); case 'export': return $this->exportFormStep($request, $alias); break; case 'formatter': return $this->formatterFormStep($request, $alias); break; case 'generate': return $this->forwardToGenerate($request, $alias); break; default: throw $this->createNotFoundException("The given step '$step' is invalid"); } }
[ "public", "function", "newAction", "(", "Request", "$", "request", ",", "$", "alias", ")", "{", "// first check for ACL", "$", "exportManager", "=", "$", "this", "->", "get", "(", "'chill.main.export_manager'", ")", ";", "$", "export", "=", "$", "exportManager", "->", "getExport", "(", "$", "alias", ")", ";", "if", "(", "$", "exportManager", "->", "isGrantedForElement", "(", "$", "export", ")", "===", "FALSE", ")", "{", "throw", "$", "this", "->", "createAccessDeniedException", "(", "'The user does not have access to this export'", ")", ";", "}", "$", "step", "=", "$", "request", "->", "query", "->", "getAlpha", "(", "'step'", ",", "'centers'", ")", ";", "switch", "(", "$", "step", ")", "{", "case", "'centers'", ":", "return", "$", "this", "->", "selectCentersStep", "(", "$", "request", ",", "$", "alias", ")", ";", "case", "'export'", ":", "return", "$", "this", "->", "exportFormStep", "(", "$", "request", ",", "$", "alias", ")", ";", "break", ";", "case", "'formatter'", ":", "return", "$", "this", "->", "formatterFormStep", "(", "$", "request", ",", "$", "alias", ")", ";", "break", ";", "case", "'generate'", ":", "return", "$", "this", "->", "forwardToGenerate", "(", "$", "request", ",", "$", "alias", ")", ";", "break", ";", "default", ":", "throw", "$", "this", "->", "createNotFoundException", "(", "\"The given step '$step' is invalid\"", ")", ";", "}", "}" ]
handle the step to build a query for an export This action has three steps : 1.'export', the export form. When the form is posted, the data is stored in the session (if valid), and then a redirection is done to next step. 2. 'formatter', the formatter form. When the form is posted, the data is stored in the session (if valid), and then a redirection is done to next step. 3. 'generate': gather data from session from the previous steps, and make a redirection to the "generate" action with data in query (HTTP GET) @param string $request @param Request $alias @return \Symfony\Component\HttpFoundation\Response
[ "handle", "the", "step", "to", "build", "a", "query", "for", "an", "export" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ExportController.php#L73-L100
19,427
Chill-project/Main
Controller/ExportController.php
ExportController.exportFormStep
protected function exportFormStep(Request $request, $alias) { $exportManager = $this->get('chill.main.export_manager'); // check we have data from the previous step (export step) $data = $this->get('session')->get('centers_step', null); if ($data === null) { return $this->redirectToRoute('chill_main_export_new', array( 'step' => $this->getNextStep('export', true), 'alias' => $alias )); } $export = $exportManager->getExport($alias); $form = $this->createCreateFormExport($alias, 'export', $data); if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isValid()) { $this->get('logger')->debug('form export is valid', array( 'location' => __METHOD__)); // store data for reusing in next steps $data = $form->getData(); $this->get('session')->set('export_step_raw', $request->request->all()); $this->get('session')->set('export_step', $data); //redirect to next step return $this->redirect( $this->generateUrl('chill_main_export_new', array( 'step' => $this->getNextStep('export'), 'alias' => $alias ))); } else { $this->get('logger')->debug('form export is invalid', array( 'location' => __METHOD__)); } } return $this->render('ChillMainBundle:Export:new.html.twig', array( 'form' => $form->createView(), 'export_alias' => $alias, 'export' => $export )); }
php
protected function exportFormStep(Request $request, $alias) { $exportManager = $this->get('chill.main.export_manager'); // check we have data from the previous step (export step) $data = $this->get('session')->get('centers_step', null); if ($data === null) { return $this->redirectToRoute('chill_main_export_new', array( 'step' => $this->getNextStep('export', true), 'alias' => $alias )); } $export = $exportManager->getExport($alias); $form = $this->createCreateFormExport($alias, 'export', $data); if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isValid()) { $this->get('logger')->debug('form export is valid', array( 'location' => __METHOD__)); // store data for reusing in next steps $data = $form->getData(); $this->get('session')->set('export_step_raw', $request->request->all()); $this->get('session')->set('export_step', $data); //redirect to next step return $this->redirect( $this->generateUrl('chill_main_export_new', array( 'step' => $this->getNextStep('export'), 'alias' => $alias ))); } else { $this->get('logger')->debug('form export is invalid', array( 'location' => __METHOD__)); } } return $this->render('ChillMainBundle:Export:new.html.twig', array( 'form' => $form->createView(), 'export_alias' => $alias, 'export' => $export )); }
[ "protected", "function", "exportFormStep", "(", "Request", "$", "request", ",", "$", "alias", ")", "{", "$", "exportManager", "=", "$", "this", "->", "get", "(", "'chill.main.export_manager'", ")", ";", "// check we have data from the previous step (export step)", "$", "data", "=", "$", "this", "->", "get", "(", "'session'", ")", "->", "get", "(", "'centers_step'", ",", "null", ")", ";", "if", "(", "$", "data", "===", "null", ")", "{", "return", "$", "this", "->", "redirectToRoute", "(", "'chill_main_export_new'", ",", "array", "(", "'step'", "=>", "$", "this", "->", "getNextStep", "(", "'export'", ",", "true", ")", ",", "'alias'", "=>", "$", "alias", ")", ")", ";", "}", "$", "export", "=", "$", "exportManager", "->", "getExport", "(", "$", "alias", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateFormExport", "(", "$", "alias", ",", "'export'", ",", "$", "data", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "===", "'POST'", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "get", "(", "'logger'", ")", "->", "debug", "(", "'form export is valid'", ",", "array", "(", "'location'", "=>", "__METHOD__", ")", ")", ";", "// store data for reusing in next steps", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "set", "(", "'export_step_raw'", ",", "$", "request", "->", "request", "->", "all", "(", ")", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "set", "(", "'export_step'", ",", "$", "data", ")", ";", "//redirect to next step", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'chill_main_export_new'", ",", "array", "(", "'step'", "=>", "$", "this", "->", "getNextStep", "(", "'export'", ")", ",", "'alias'", "=>", "$", "alias", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "get", "(", "'logger'", ")", "->", "debug", "(", "'form export is invalid'", ",", "array", "(", "'location'", "=>", "__METHOD__", ")", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:Export:new.html.twig'", ",", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'export_alias'", "=>", "$", "alias", ",", "'export'", "=>", "$", "export", ")", ")", ";", "}" ]
Render the export form When the method is POST, the form is stored if valid, and a redirection is done to next step. @param string $alias @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "export", "form" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ExportController.php#L154-L203
19,428
Chill-project/Main
Controller/ExportController.php
ExportController.createCreateFormExport
protected function createCreateFormExport($alias, $step, $data = array()) { /* @var $exportManager \Chill\MainBundle\Export\ExportManager */ $exportManager = $this->get('chill.main.export_manager'); $isGenerate = strpos($step, 'generate_') === 0; $builder = $this->get('form.factory') ->createNamedBuilder(null, FormType::class, array(), array( 'method' => $isGenerate ? 'GET' : 'POST', 'csrf_protection' => $isGenerate ? false : true, )); if ($step === 'centers' or $step === 'generate_centers') { $builder->add('centers', PickCenterType::class, array( 'export_alias' => $alias )); } if ($step === 'export' or $step === 'generate_export') { $builder->add('export', ExportType::class, array( 'export_alias' => $alias, 'picked_centers' => $exportManager->getPickedCenters($data['centers']) )); } if ($step === 'formatter' or $step === 'generate_formatter') { $builder->add('formatter', FormatterType::class, array( 'formatter_alias' => $exportManager ->getFormatterAlias($data['export']), 'export_alias' => $alias, 'aggregator_aliases' => $exportManager ->getUsedAggregatorsAliases($data['export']) )); } $builder->add('submit', 'submit', array( 'label' => 'Generate' )); return $builder->getForm(); }
php
protected function createCreateFormExport($alias, $step, $data = array()) { /* @var $exportManager \Chill\MainBundle\Export\ExportManager */ $exportManager = $this->get('chill.main.export_manager'); $isGenerate = strpos($step, 'generate_') === 0; $builder = $this->get('form.factory') ->createNamedBuilder(null, FormType::class, array(), array( 'method' => $isGenerate ? 'GET' : 'POST', 'csrf_protection' => $isGenerate ? false : true, )); if ($step === 'centers' or $step === 'generate_centers') { $builder->add('centers', PickCenterType::class, array( 'export_alias' => $alias )); } if ($step === 'export' or $step === 'generate_export') { $builder->add('export', ExportType::class, array( 'export_alias' => $alias, 'picked_centers' => $exportManager->getPickedCenters($data['centers']) )); } if ($step === 'formatter' or $step === 'generate_formatter') { $builder->add('formatter', FormatterType::class, array( 'formatter_alias' => $exportManager ->getFormatterAlias($data['export']), 'export_alias' => $alias, 'aggregator_aliases' => $exportManager ->getUsedAggregatorsAliases($data['export']) )); } $builder->add('submit', 'submit', array( 'label' => 'Generate' )); return $builder->getForm(); }
[ "protected", "function", "createCreateFormExport", "(", "$", "alias", ",", "$", "step", ",", "$", "data", "=", "array", "(", ")", ")", "{", "/* @var $exportManager \\Chill\\MainBundle\\Export\\ExportManager */", "$", "exportManager", "=", "$", "this", "->", "get", "(", "'chill.main.export_manager'", ")", ";", "$", "isGenerate", "=", "strpos", "(", "$", "step", ",", "'generate_'", ")", "===", "0", ";", "$", "builder", "=", "$", "this", "->", "get", "(", "'form.factory'", ")", "->", "createNamedBuilder", "(", "null", ",", "FormType", "::", "class", ",", "array", "(", ")", ",", "array", "(", "'method'", "=>", "$", "isGenerate", "?", "'GET'", ":", "'POST'", ",", "'csrf_protection'", "=>", "$", "isGenerate", "?", "false", ":", "true", ",", ")", ")", ";", "if", "(", "$", "step", "===", "'centers'", "or", "$", "step", "===", "'generate_centers'", ")", "{", "$", "builder", "->", "add", "(", "'centers'", ",", "PickCenterType", "::", "class", ",", "array", "(", "'export_alias'", "=>", "$", "alias", ")", ")", ";", "}", "if", "(", "$", "step", "===", "'export'", "or", "$", "step", "===", "'generate_export'", ")", "{", "$", "builder", "->", "add", "(", "'export'", ",", "ExportType", "::", "class", ",", "array", "(", "'export_alias'", "=>", "$", "alias", ",", "'picked_centers'", "=>", "$", "exportManager", "->", "getPickedCenters", "(", "$", "data", "[", "'centers'", "]", ")", ")", ")", ";", "}", "if", "(", "$", "step", "===", "'formatter'", "or", "$", "step", "===", "'generate_formatter'", ")", "{", "$", "builder", "->", "add", "(", "'formatter'", ",", "FormatterType", "::", "class", ",", "array", "(", "'formatter_alias'", "=>", "$", "exportManager", "->", "getFormatterAlias", "(", "$", "data", "[", "'export'", "]", ")", ",", "'export_alias'", "=>", "$", "alias", ",", "'aggregator_aliases'", "=>", "$", "exportManager", "->", "getUsedAggregatorsAliases", "(", "$", "data", "[", "'export'", "]", ")", ")", ")", ";", "}", "$", "builder", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Generate'", ")", ")", ";", "return", "$", "builder", "->", "getForm", "(", ")", ";", "}" ]
create a form to show on different steps. @param string $alias @param string $step, can either be 'export', 'formatter', 'generate_export' or 'generate_formatter' (last two are used by generate action) @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter' @return \Symfony\Component\Form\Form
[ "create", "a", "form", "to", "show", "on", "different", "steps", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ExportController.php#L213-L253
19,429
hendrikmaus/reynaldo
src/Parser/RefractParser.php
RefractParser.iterate
private function iterate(array $content, $parent = null) { foreach ($content as $element) { $this->process($element, $parent); } }
php
private function iterate(array $content, $parent = null) { foreach ($content as $element) { $this->process($element, $parent); } }
[ "private", "function", "iterate", "(", "array", "$", "content", ",", "$", "parent", "=", "null", ")", "{", "foreach", "(", "$", "content", "as", "$", "element", ")", "{", "$", "this", "->", "process", "(", "$", "element", ",", "$", "parent", ")", ";", "}", "}" ]
Iterate given content array and call `process` for every element inside @param array $content @param null|BaseElement $parent
[ "Iterate", "given", "content", "array", "and", "call", "process", "for", "every", "element", "inside" ]
be100f56e8f39d86d16ce9222838d20f462e8678
https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Parser/RefractParser.php#L60-L65
19,430
hendrikmaus/reynaldo
src/Parser/RefractParser.php
RefractParser.process
private function process(array $element, $parent = null) { $apiElement = $element['element']; if (isset($this->elementMap[$apiElement])) { $this->processElement( $element, $this->elementMap[$apiElement], $parent ); } if ($element['element'] === 'category') { // todo extend the element map to check for classes, then merge processCategory into processElement $this->processCategory($element, $parent); } }
php
private function process(array $element, $parent = null) { $apiElement = $element['element']; if (isset($this->elementMap[$apiElement])) { $this->processElement( $element, $this->elementMap[$apiElement], $parent ); } if ($element['element'] === 'category') { // todo extend the element map to check for classes, then merge processCategory into processElement $this->processCategory($element, $parent); } }
[ "private", "function", "process", "(", "array", "$", "element", ",", "$", "parent", "=", "null", ")", "{", "$", "apiElement", "=", "$", "element", "[", "'element'", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "elementMap", "[", "$", "apiElement", "]", ")", ")", "{", "$", "this", "->", "processElement", "(", "$", "element", ",", "$", "this", "->", "elementMap", "[", "$", "apiElement", "]", ",", "$", "parent", ")", ";", "}", "if", "(", "$", "element", "[", "'element'", "]", "===", "'category'", ")", "{", "// todo extend the element map to check for classes, then merge processCategory into processElement", "$", "this", "->", "processCategory", "(", "$", "element", ",", "$", "parent", ")", ";", "}", "}" ]
Create php classes using raw element data; called recursively @param array $element @param null|BaseElement $parent
[ "Create", "php", "classes", "using", "raw", "element", "data", ";", "called", "recursively" ]
be100f56e8f39d86d16ce9222838d20f462e8678
https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Parser/RefractParser.php#L73-L89
19,431
hendrikmaus/reynaldo
src/Parser/RefractParser.php
RefractParser.processElement
private function processElement(array $element, $class, BaseElement $parent, $replaceAttribute = null) { $apiElement = new $class($element); if (!$replaceAttribute) { $parent->addContentElement($apiElement); } else { $parent->replaceAttributeWithElement($replaceAttribute, $apiElement); } if (isset($element['attributes'])) { foreach ($element['attributes'] as $attributeName => $attributeValue) { if (!isset($this->elementMap[$attributeName])) { continue; } $this->processElement( $attributeValue, $this->elementMap[$attributeName], $apiElement, $attributeName ); } } if (!isset($element['content'])) { return; } if (!is_array($element['content'])) { return; } $this->iterate($element['content'], $apiElement); }
php
private function processElement(array $element, $class, BaseElement $parent, $replaceAttribute = null) { $apiElement = new $class($element); if (!$replaceAttribute) { $parent->addContentElement($apiElement); } else { $parent->replaceAttributeWithElement($replaceAttribute, $apiElement); } if (isset($element['attributes'])) { foreach ($element['attributes'] as $attributeName => $attributeValue) { if (!isset($this->elementMap[$attributeName])) { continue; } $this->processElement( $attributeValue, $this->elementMap[$attributeName], $apiElement, $attributeName ); } } if (!isset($element['content'])) { return; } if (!is_array($element['content'])) { return; } $this->iterate($element['content'], $apiElement); }
[ "private", "function", "processElement", "(", "array", "$", "element", ",", "$", "class", ",", "BaseElement", "$", "parent", ",", "$", "replaceAttribute", "=", "null", ")", "{", "$", "apiElement", "=", "new", "$", "class", "(", "$", "element", ")", ";", "if", "(", "!", "$", "replaceAttribute", ")", "{", "$", "parent", "->", "addContentElement", "(", "$", "apiElement", ")", ";", "}", "else", "{", "$", "parent", "->", "replaceAttributeWithElement", "(", "$", "replaceAttribute", ",", "$", "apiElement", ")", ";", "}", "if", "(", "isset", "(", "$", "element", "[", "'attributes'", "]", ")", ")", "{", "foreach", "(", "$", "element", "[", "'attributes'", "]", "as", "$", "attributeName", "=>", "$", "attributeValue", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "elementMap", "[", "$", "attributeName", "]", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "processElement", "(", "$", "attributeValue", ",", "$", "this", "->", "elementMap", "[", "$", "attributeName", "]", ",", "$", "apiElement", ",", "$", "attributeName", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "element", "[", "'content'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "!", "is_array", "(", "$", "element", "[", "'content'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "iterate", "(", "$", "element", "[", "'content'", "]", ",", "$", "apiElement", ")", ";", "}" ]
Create new element from raw data and add it to its parent @param array $element Raw element data @param string $class FQCN to use for creating an element @param BaseElement $parent parent element to add the newly created one to @param null|string $replaceAttribute usually, the new element will be added to the content of the given parent. There are some cases, hrefVariables for example, where the attributes actually contain elements as well. To add the new element to the attributes, pass the name of the key inside of attributes that should be replaced
[ "Create", "new", "element", "from", "raw", "data", "and", "add", "it", "to", "its", "parent" ]
be100f56e8f39d86d16ce9222838d20f462e8678
https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Parser/RefractParser.php#L103-L137
19,432
hendrikmaus/reynaldo
src/Parser/RefractParser.php
RefractParser.processCategory
private function processCategory(array $element, $parent = null) { if ($this->isMasterCategory($element)) { $this->createCategory($element, MasterCategoryElement::class, $this->parseResult); } if ($this->isResourceGroup($element)) { $this->createCategory($element, ResourceGroupElement::class, $parent); } if ($this->isDataStructureCategory($element)) { $this->createCategory($element, DataStructureCategoryElement::class, $parent); } }
php
private function processCategory(array $element, $parent = null) { if ($this->isMasterCategory($element)) { $this->createCategory($element, MasterCategoryElement::class, $this->parseResult); } if ($this->isResourceGroup($element)) { $this->createCategory($element, ResourceGroupElement::class, $parent); } if ($this->isDataStructureCategory($element)) { $this->createCategory($element, DataStructureCategoryElement::class, $parent); } }
[ "private", "function", "processCategory", "(", "array", "$", "element", ",", "$", "parent", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isMasterCategory", "(", "$", "element", ")", ")", "{", "$", "this", "->", "createCategory", "(", "$", "element", ",", "MasterCategoryElement", "::", "class", ",", "$", "this", "->", "parseResult", ")", ";", "}", "if", "(", "$", "this", "->", "isResourceGroup", "(", "$", "element", ")", ")", "{", "$", "this", "->", "createCategory", "(", "$", "element", ",", "ResourceGroupElement", "::", "class", ",", "$", "parent", ")", ";", "}", "if", "(", "$", "this", "->", "isDataStructureCategory", "(", "$", "element", ")", ")", "{", "$", "this", "->", "createCategory", "(", "$", "element", ",", "DataStructureCategoryElement", "::", "class", ",", "$", "parent", ")", ";", "}", "}" ]
Helper to create different php classes from element `category` which carries its actual meaning in its classes @param array $element @param null|BaseElement $parent
[ "Helper", "to", "create", "different", "php", "classes", "from", "element", "category", "which", "carries", "its", "actual", "meaning", "in", "its", "classes" ]
be100f56e8f39d86d16ce9222838d20f462e8678
https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Parser/RefractParser.php#L145-L158
19,433
hendrikmaus/reynaldo
src/Parser/RefractParser.php
RefractParser.createCategory
private function createCategory(array $element, $className, BaseElement $parent) { $newElement = new $className($element); $parent->addContentElement($newElement); $this->iterate($element['content'], $newElement); }
php
private function createCategory(array $element, $className, BaseElement $parent) { $newElement = new $className($element); $parent->addContentElement($newElement); $this->iterate($element['content'], $newElement); }
[ "private", "function", "createCategory", "(", "array", "$", "element", ",", "$", "className", ",", "BaseElement", "$", "parent", ")", "{", "$", "newElement", "=", "new", "$", "className", "(", "$", "element", ")", ";", "$", "parent", "->", "addContentElement", "(", "$", "newElement", ")", ";", "$", "this", "->", "iterate", "(", "$", "element", "[", "'content'", "]", ",", "$", "newElement", ")", ";", "}" ]
Sub-helper for `processCategory` @param array $element @param string $className @param BaseElement $parent
[ "Sub", "-", "helper", "for", "processCategory" ]
be100f56e8f39d86d16ce9222838d20f462e8678
https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Parser/RefractParser.php#L190-L195
19,434
simple-php-mvc/simple-php-mvc
src/MVC/Controller/Controller.php
Controller.call
final public function call(MVC $mvc, $method, $fileView = null) { if (!method_exists($this, $method)) { throw new \LogicException(sprintf('Method "s" don\'t exists.', $method)); } # Replace the view object $this->view = $mvc->view(); # Arguments of method $arguments = array(); # Create a reflection method $reflectionMethod = new \ReflectionMethod(get_class($this), $method); $reflectionParams = $reflectionMethod->getParameters(); foreach ($reflectionParams as $param) { if ($paramClass = $param->getClass()) { $className = $paramClass->name; if ($className === 'MVC\\MVC' || $className === '\\MVC\\MVC') { $arguments[] = $mvc; } elseif ($className === 'MVC\\Server\\HttpRequest' || $className === '\\MVC\\Server\\HttpRequest') { $arguments[] = $mvc->request(); } } else { foreach ($mvc->request()->params as $keyReqParam => $valueReqParam) { if ($param->name === $keyReqParam) { $arguments[] = $valueReqParam; break; } } } } $response = call_user_func_array($reflectionMethod->getClosure($this), $arguments); if (empty($response)) { throw new \LogicException('Response null returned.'); } if (is_string($response)) { $this->response['body'] = $response; } elseif ($mvc->request()->isAjax()) { $this->response['body'] = $this->renderJson($response); } elseif(is_array($response)) { if (!$fileView) { throw new \LogicException('File view is null.'); } $class = explode("\\", get_called_class()); $classname = end($class); // Class without Controller $classname = str_replace('Controller', '', $classname); $file = $classname . "/{$fileView}"; $this->response['body'] = $this->renderHtml($file, $response); } return $this->response; }
php
final public function call(MVC $mvc, $method, $fileView = null) { if (!method_exists($this, $method)) { throw new \LogicException(sprintf('Method "s" don\'t exists.', $method)); } # Replace the view object $this->view = $mvc->view(); # Arguments of method $arguments = array(); # Create a reflection method $reflectionMethod = new \ReflectionMethod(get_class($this), $method); $reflectionParams = $reflectionMethod->getParameters(); foreach ($reflectionParams as $param) { if ($paramClass = $param->getClass()) { $className = $paramClass->name; if ($className === 'MVC\\MVC' || $className === '\\MVC\\MVC') { $arguments[] = $mvc; } elseif ($className === 'MVC\\Server\\HttpRequest' || $className === '\\MVC\\Server\\HttpRequest') { $arguments[] = $mvc->request(); } } else { foreach ($mvc->request()->params as $keyReqParam => $valueReqParam) { if ($param->name === $keyReqParam) { $arguments[] = $valueReqParam; break; } } } } $response = call_user_func_array($reflectionMethod->getClosure($this), $arguments); if (empty($response)) { throw new \LogicException('Response null returned.'); } if (is_string($response)) { $this->response['body'] = $response; } elseif ($mvc->request()->isAjax()) { $this->response['body'] = $this->renderJson($response); } elseif(is_array($response)) { if (!$fileView) { throw new \LogicException('File view is null.'); } $class = explode("\\", get_called_class()); $classname = end($class); // Class without Controller $classname = str_replace('Controller', '', $classname); $file = $classname . "/{$fileView}"; $this->response['body'] = $this->renderHtml($file, $response); } return $this->response; }
[ "final", "public", "function", "call", "(", "MVC", "$", "mvc", ",", "$", "method", ",", "$", "fileView", "=", "null", ")", "{", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Method \"s\" don\\'t exists.'", ",", "$", "method", ")", ")", ";", "}", "# Replace the view object", "$", "this", "->", "view", "=", "$", "mvc", "->", "view", "(", ")", ";", "# Arguments of method", "$", "arguments", "=", "array", "(", ")", ";", "# Create a reflection method", "$", "reflectionMethod", "=", "new", "\\", "ReflectionMethod", "(", "get_class", "(", "$", "this", ")", ",", "$", "method", ")", ";", "$", "reflectionParams", "=", "$", "reflectionMethod", "->", "getParameters", "(", ")", ";", "foreach", "(", "$", "reflectionParams", "as", "$", "param", ")", "{", "if", "(", "$", "paramClass", "=", "$", "param", "->", "getClass", "(", ")", ")", "{", "$", "className", "=", "$", "paramClass", "->", "name", ";", "if", "(", "$", "className", "===", "'MVC\\\\MVC'", "||", "$", "className", "===", "'\\\\MVC\\\\MVC'", ")", "{", "$", "arguments", "[", "]", "=", "$", "mvc", ";", "}", "elseif", "(", "$", "className", "===", "'MVC\\\\Server\\\\HttpRequest'", "||", "$", "className", "===", "'\\\\MVC\\\\Server\\\\HttpRequest'", ")", "{", "$", "arguments", "[", "]", "=", "$", "mvc", "->", "request", "(", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "mvc", "->", "request", "(", ")", "->", "params", "as", "$", "keyReqParam", "=>", "$", "valueReqParam", ")", "{", "if", "(", "$", "param", "->", "name", "===", "$", "keyReqParam", ")", "{", "$", "arguments", "[", "]", "=", "$", "valueReqParam", ";", "break", ";", "}", "}", "}", "}", "$", "response", "=", "call_user_func_array", "(", "$", "reflectionMethod", "->", "getClosure", "(", "$", "this", ")", ",", "$", "arguments", ")", ";", "if", "(", "empty", "(", "$", "response", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Response null returned.'", ")", ";", "}", "if", "(", "is_string", "(", "$", "response", ")", ")", "{", "$", "this", "->", "response", "[", "'body'", "]", "=", "$", "response", ";", "}", "elseif", "(", "$", "mvc", "->", "request", "(", ")", "->", "isAjax", "(", ")", ")", "{", "$", "this", "->", "response", "[", "'body'", "]", "=", "$", "this", "->", "renderJson", "(", "$", "response", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "response", ")", ")", "{", "if", "(", "!", "$", "fileView", ")", "{", "throw", "new", "\\", "LogicException", "(", "'File view is null.'", ")", ";", "}", "$", "class", "=", "explode", "(", "\"\\\\\"", ",", "get_called_class", "(", ")", ")", ";", "$", "classname", "=", "end", "(", "$", "class", ")", ";", "// Class without Controller", "$", "classname", "=", "str_replace", "(", "'Controller'", ",", "''", ",", "$", "classname", ")", ";", "$", "file", "=", "$", "classname", ".", "\"/{$fileView}\"", ";", "$", "this", "->", "response", "[", "'body'", "]", "=", "$", "this", "->", "renderHtml", "(", "$", "file", ",", "$", "response", ")", ";", "}", "return", "$", "this", "->", "response", ";", "}" ]
Call a action of controller @access public @param MVC $mvc MVC Application object @param string $method Method or Function of the Class Controller @param string $fileView String of the view file @return array Response array @throws \LogicException
[ "Call", "a", "action", "of", "controller" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Controller/Controller.php#L56-L110
19,435
simple-php-mvc/simple-php-mvc
src/MVC/Controller/Controller.php
Controller.renderJson
public function renderJson($value) { $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP; return json_encode($value, $options); }
php
public function renderJson($value) { $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP; return json_encode($value, $options); }
[ "public", "function", "renderJson", "(", "$", "value", ")", "{", "$", "options", "=", "JSON_HEX_TAG", "|", "JSON_HEX_APOS", "|", "JSON_HEX_QUOT", "|", "JSON_HEX_AMP", ";", "return", "json_encode", "(", "$", "value", ",", "$", "options", ")", ";", "}" ]
Converts the supplied value to JSON. @access public @param mixed $value The value to encode. @return string
[ "Converts", "the", "supplied", "value", "to", "JSON", "." ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Controller/Controller.php#L128-L132
19,436
Craftsware/scissor
src/Lib/Time.php
Time.offset
public function offset($timezone) { $timeOffset = (new \DateTimeZone($timezone))->getOffset(new \DateTime('now', new \DateTimeZone('UTC'))); if($timeOffset < 0) { return 'UTC -'. gmdate('H:i', -$timeOffset); } else { return 'UTC +'. gmdate('H:i', $timeOffset); } }
php
public function offset($timezone) { $timeOffset = (new \DateTimeZone($timezone))->getOffset(new \DateTime('now', new \DateTimeZone('UTC'))); if($timeOffset < 0) { return 'UTC -'. gmdate('H:i', -$timeOffset); } else { return 'UTC +'. gmdate('H:i', $timeOffset); } }
[ "public", "function", "offset", "(", "$", "timezone", ")", "{", "$", "timeOffset", "=", "(", "new", "\\", "DateTimeZone", "(", "$", "timezone", ")", ")", "->", "getOffset", "(", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ")", ";", "if", "(", "$", "timeOffset", "<", "0", ")", "{", "return", "'UTC -'", ".", "gmdate", "(", "'H:i'", ",", "-", "$", "timeOffset", ")", ";", "}", "else", "{", "return", "'UTC +'", ".", "gmdate", "(", "'H:i'", ",", "$", "timeOffset", ")", ";", "}", "}" ]
Get Time Offset
[ "Get", "Time", "Offset" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Lib/Time.php#L52-L64
19,437
Craftsware/scissor
src/Lib/Time.php
Time.datetime
public function datetime($datetime, $timezone = null, $format = 'M/d/Y - h:i:s A') { $datetime = new \DateTime($datetime); if($timezone) { $datetime->setTimezone(new \DateTimeZone($timezone)); } return $datetime->format($format); }
php
public function datetime($datetime, $timezone = null, $format = 'M/d/Y - h:i:s A') { $datetime = new \DateTime($datetime); if($timezone) { $datetime->setTimezone(new \DateTimeZone($timezone)); } return $datetime->format($format); }
[ "public", "function", "datetime", "(", "$", "datetime", ",", "$", "timezone", "=", "null", ",", "$", "format", "=", "'M/d/Y - h:i:s A'", ")", "{", "$", "datetime", "=", "new", "\\", "DateTime", "(", "$", "datetime", ")", ";", "if", "(", "$", "timezone", ")", "{", "$", "datetime", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "$", "timezone", ")", ")", ";", "}", "return", "$", "datetime", "->", "format", "(", "$", "format", ")", ";", "}" ]
Set Date and Time
[ "Set", "Date", "and", "Time" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Lib/Time.php#L70-L80
19,438
webforge-labs/psc-cms
lib/Psc/System/Deploy/Deployer.php
Deployer.createTask
public function createTask($name) { $this->init(); $class = Code::expandNamespace(\Webforge\Common\String::expand($name, 'Task'), 'Psc\System\Deploy'); $gClass = GClass::factory($class); $params = array(); if ($gClass->hasMethod('__construct')) { $constructor = $gClass->getMethod('__construct'); foreach ($constructor->getParameters() as $parameter) { $params[] = $this->resolveTaskDependency($parameter, $gClass); } } return $gClass->newInstance($params); }
php
public function createTask($name) { $this->init(); $class = Code::expandNamespace(\Webforge\Common\String::expand($name, 'Task'), 'Psc\System\Deploy'); $gClass = GClass::factory($class); $params = array(); if ($gClass->hasMethod('__construct')) { $constructor = $gClass->getMethod('__construct'); foreach ($constructor->getParameters() as $parameter) { $params[] = $this->resolveTaskDependency($parameter, $gClass); } } return $gClass->newInstance($params); }
[ "public", "function", "createTask", "(", "$", "name", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "class", "=", "Code", "::", "expandNamespace", "(", "\\", "Webforge", "\\", "Common", "\\", "String", "::", "expand", "(", "$", "name", ",", "'Task'", ")", ",", "'Psc\\System\\Deploy'", ")", ";", "$", "gClass", "=", "GClass", "::", "factory", "(", "$", "class", ")", ";", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "gClass", "->", "hasMethod", "(", "'__construct'", ")", ")", "{", "$", "constructor", "=", "$", "gClass", "->", "getMethod", "(", "'__construct'", ")", ";", "foreach", "(", "$", "constructor", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "resolveTaskDependency", "(", "$", "parameter", ",", "$", "gClass", ")", ";", "}", "}", "return", "$", "gClass", "->", "newInstance", "(", "$", "params", ")", ";", "}" ]
wird automatisch mit dependencies erstellt @param string $name der Name des Tasks ohne Namespace und "Task" dahinter
[ "wird", "automatisch", "mit", "dependencies", "erstellt" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/Deploy/Deployer.php#L130-L144
19,439
timiki/rpc-common
src/JsonRequest.php
JsonRequest.setResponse
public function setResponse(JsonResponse $response) { $this->response = $response; if (!$response->getRequest()) { $response->setRequest($this); } return $this; }
php
public function setResponse(JsonResponse $response) { $this->response = $response; if (!$response->getRequest()) { $response->setRequest($this); } return $this; }
[ "public", "function", "setResponse", "(", "JsonResponse", "$", "response", ")", "{", "$", "this", "->", "response", "=", "$", "response", ";", "if", "(", "!", "$", "response", "->", "getRequest", "(", ")", ")", "{", "$", "response", "->", "setRequest", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set response. @param JsonResponse $response @return $this
[ "Set", "response", "." ]
a20e8bc92b16aa3686c4405bf5182123a5cfc750
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L116-L125
19,440
timiki/rpc-common
src/JsonRequest.php
JsonRequest.isValid
public function isValid() { if (empty($this->jsonrpc)) { return false; } if (empty($this->method) || !is_string($this->method)) { return false; } if (!empty($this->params) && !is_array($this->params)) { return false; } return true; }
php
public function isValid() { if (empty($this->jsonrpc)) { return false; } if (empty($this->method) || !is_string($this->method)) { return false; } if (!empty($this->params) && !is_array($this->params)) { return false; } return true; }
[ "public", "function", "isValid", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "jsonrpc", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "method", ")", "||", "!", "is_string", "(", "$", "this", "->", "method", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "params", ")", "&&", "!", "is_array", "(", "$", "this", "->", "params", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is valid. @return boolean
[ "Is", "valid", "." ]
a20e8bc92b16aa3686c4405bf5182123a5cfc750
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L132-L147
19,441
timiki/rpc-common
src/JsonRequest.php
JsonRequest.toArray
public function toArray() { $json = []; $json['jsonrpc'] = $this->jsonrpc; if ($this->method) { $json['method'] = $this->method; } $json['method'] = $this->method; if ($this->params) { $json['params'] = $this->params; } if ($this->id) { $json['id'] = $this->id; } return $json; }
php
public function toArray() { $json = []; $json['jsonrpc'] = $this->jsonrpc; if ($this->method) { $json['method'] = $this->method; } $json['method'] = $this->method; if ($this->params) { $json['params'] = $this->params; } if ($this->id) { $json['id'] = $this->id; } return $json; }
[ "public", "function", "toArray", "(", ")", "{", "$", "json", "=", "[", "]", ";", "$", "json", "[", "'jsonrpc'", "]", "=", "$", "this", "->", "jsonrpc", ";", "if", "(", "$", "this", "->", "method", ")", "{", "$", "json", "[", "'method'", "]", "=", "$", "this", "->", "method", ";", "}", "$", "json", "[", "'method'", "]", "=", "$", "this", "->", "method", ";", "if", "(", "$", "this", "->", "params", ")", "{", "$", "json", "[", "'params'", "]", "=", "$", "this", "->", "params", ";", "}", "if", "(", "$", "this", "->", "id", ")", "{", "$", "json", "[", "'id'", "]", "=", "$", "this", "->", "id", ";", "}", "return", "$", "json", ";", "}" ]
Convert JsonRequest to json string. @return array
[ "Convert", "JsonRequest", "to", "json", "string", "." ]
a20e8bc92b16aa3686c4405bf5182123a5cfc750
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L166-L186
19,442
ARCANEDEV/Sanitizer
src/Filters/EmailFilter.php
EmailFilter.filter
public function filter($value, array $options = []) { return is_string($value) ? filter_var(Str::lower(trim($value)), FILTER_SANITIZE_EMAIL) : $value; }
php
public function filter($value, array $options = []) { return is_string($value) ? filter_var(Str::lower(trim($value)), FILTER_SANITIZE_EMAIL) : $value; }
[ "public", "function", "filter", "(", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "is_string", "(", "$", "value", ")", "?", "filter_var", "(", "Str", "::", "lower", "(", "trim", "(", "$", "value", ")", ")", ",", "FILTER_SANITIZE_EMAIL", ")", ":", "$", "value", ";", "}" ]
Sanitize email of the given string. @param mixed $value @param array $options @return string|mixed
[ "Sanitize", "email", "of", "the", "given", "string", "." ]
e21990ce6d881366d52a7f4e5040b07cc3ecca96
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Filters/EmailFilter.php#L26-L31
19,443
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.createMessage
public function createMessage(TicketInterface $ticket = null) { /* @var TicketMessageInterface $message */ $message = new $this->ticketMessageClass(); if ($ticket) { $message->setPriority($ticket->getPriority()); $message->setStatus($ticket->getStatus()); $message->setTicket($ticket); } else { $message->setStatus(TicketMessage::STATUS_OPEN); } return $message; }
php
public function createMessage(TicketInterface $ticket = null) { /* @var TicketMessageInterface $message */ $message = new $this->ticketMessageClass(); if ($ticket) { $message->setPriority($ticket->getPriority()); $message->setStatus($ticket->getStatus()); $message->setTicket($ticket); } else { $message->setStatus(TicketMessage::STATUS_OPEN); } return $message; }
[ "public", "function", "createMessage", "(", "TicketInterface", "$", "ticket", "=", "null", ")", "{", "/* @var TicketMessageInterface $message */", "$", "message", "=", "new", "$", "this", "->", "ticketMessageClass", "(", ")", ";", "if", "(", "$", "ticket", ")", "{", "$", "message", "->", "setPriority", "(", "$", "ticket", "->", "getPriority", "(", ")", ")", ";", "$", "message", "->", "setStatus", "(", "$", "ticket", "->", "getStatus", "(", ")", ")", ";", "$", "message", "->", "setTicket", "(", "$", "ticket", ")", ";", "}", "else", "{", "$", "message", "->", "setStatus", "(", "TicketMessage", "::", "STATUS_OPEN", ")", ";", "}", "return", "$", "message", ";", "}" ]
Create a new instance of TicketMessage Entity. @param TicketInterface $ticket @return TicketMessageInterface
[ "Create", "a", "new", "instance", "of", "TicketMessage", "Entity", "." ]
043950aa95f322cfaae145ce3c7781a4b0618a18
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L124-L138
19,444
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.isPreviouslyDeployed
public function isPreviouslyDeployed(Asset $asset) { // Is there any previous deployed version? $outputBasename = $this->computeOutputBasename($asset); $file = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; if (is_file($file)) { $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); return true; } return false; }
php
public function isPreviouslyDeployed(Asset $asset) { // Is there any previous deployed version? $outputBasename = $this->computeOutputBasename($asset); $file = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; if (is_file($file)) { $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); return true; } return false; }
[ "public", "function", "isPreviouslyDeployed", "(", "Asset", "$", "asset", ")", "{", "// Is there any previous deployed version?", "$", "outputBasename", "=", "$", "this", "->", "computeOutputBasename", "(", "$", "asset", ")", ";", "$", "file", "=", "$", "this", "->", "destinationPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "outputBasename", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "$", "objectUrl", "=", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "outputBasename", ";", "$", "asset", "->", "setOutputUrl", "(", "$", "objectUrl", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Attempt to retrieve a previously deployed asset; if it does exist, then update the Asset instance's outputUrl property, without performing any further filters' actions. fullPath and outputExtension are set at this point in the Asset instance. @param Asset $asset @return bool Whether the Asset was previously deployed or not; If yes, then Asset's outputUrl property will be updated.
[ "Attempt", "to", "retrieve", "a", "previously", "deployed", "asset", ";", "if", "it", "does", "exist", "then", "update", "the", "Asset", "instance", "s", "outputUrl", "property", "without", "performing", "any", "further", "filters", "actions", ".", "fullPath", "and", "outputExtension", "are", "set", "at", "this", "point", "in", "the", "Asset", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L59-L73
19,445
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.deploy
public function deploy(Asset $asset) { $outputBasename = $this->computeOutputBasename($asset); $fullPath = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; $saving = file_put_contents($fullPath, $asset->getContents()); if($saving === false) { throw new PhassetsInternalException( 'file_put_contents() could not write to ' . $fullPath . '. It is writable?' ); } $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); }
php
public function deploy(Asset $asset) { $outputBasename = $this->computeOutputBasename($asset); $fullPath = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; $saving = file_put_contents($fullPath, $asset->getContents()); if($saving === false) { throw new PhassetsInternalException( 'file_put_contents() could not write to ' . $fullPath . '. It is writable?' ); } $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); }
[ "public", "function", "deploy", "(", "Asset", "$", "asset", ")", "{", "$", "outputBasename", "=", "$", "this", "->", "computeOutputBasename", "(", "$", "asset", ")", ";", "$", "fullPath", "=", "$", "this", "->", "destinationPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "outputBasename", ";", "$", "saving", "=", "file_put_contents", "(", "$", "fullPath", ",", "$", "asset", "->", "getContents", "(", ")", ")", ";", "if", "(", "$", "saving", "===", "false", ")", "{", "throw", "new", "PhassetsInternalException", "(", "'file_put_contents() could not write to '", ".", "$", "fullPath", ".", "'. It is writable?'", ")", ";", "}", "$", "objectUrl", "=", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "outputBasename", ";", "$", "asset", "->", "setOutputUrl", "(", "$", "objectUrl", ")", ";", "}" ]
Given an Asset instance, try to deploy is using internal rules of this deployer and update Asset's property outputUrl. @param Asset $asset Asset instance whose outputUrl property will be modified @throws PhassetsInternalException If the deployment process fails
[ "Given", "an", "Asset", "instance", "try", "to", "deploy", "is", "using", "internal", "rules", "of", "this", "deployer", "and", "update", "Asset", "s", "property", "outputUrl", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L82-L99
19,446
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.isSupported
public function isSupported() { $this->destinationPath = $this->configurator->getConfig('filesystem_deployer', 'destination_path'); $this->baseUrl = $this->configurator->getConfig('filesystem_deployer', 'base_url'); $this->trigger = $this->configurator->getConfig('filesystem_deployer', 'changes_trigger'); if ($this->destinationPath === null) { throw new PhassetsInternalException(__CLASS__ . ': no "destination_path" setting found'); } if (!is_dir($this->destinationPath) || !is_writable($this->destinationPath)) { throw new PhassetsInternalException(__CLASS__ . ": 'destination_path' ({$this->destinationPath}) is " . 'either not a valid dir, nor writable.' ); } }
php
public function isSupported() { $this->destinationPath = $this->configurator->getConfig('filesystem_deployer', 'destination_path'); $this->baseUrl = $this->configurator->getConfig('filesystem_deployer', 'base_url'); $this->trigger = $this->configurator->getConfig('filesystem_deployer', 'changes_trigger'); if ($this->destinationPath === null) { throw new PhassetsInternalException(__CLASS__ . ': no "destination_path" setting found'); } if (!is_dir($this->destinationPath) || !is_writable($this->destinationPath)) { throw new PhassetsInternalException(__CLASS__ . ": 'destination_path' ({$this->destinationPath}) is " . 'either not a valid dir, nor writable.' ); } }
[ "public", "function", "isSupported", "(", ")", "{", "$", "this", "->", "destinationPath", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'destination_path'", ")", ";", "$", "this", "->", "baseUrl", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'base_url'", ")", ";", "$", "this", "->", "trigger", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'changes_trigger'", ")", ";", "if", "(", "$", "this", "->", "destinationPath", "===", "null", ")", "{", "throw", "new", "PhassetsInternalException", "(", "__CLASS__", ".", "': no \"destination_path\" setting found'", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "this", "->", "destinationPath", ")", "||", "!", "is_writable", "(", "$", "this", "->", "destinationPath", ")", ")", "{", "throw", "new", "PhassetsInternalException", "(", "__CLASS__", ".", "\": 'destination_path' ({$this->destinationPath}) is \"", ".", "'either not a valid dir, nor writable.'", ")", ";", "}", "}" ]
This must throw a PhassetsInternalException if the current configuration doesn't allow this deployer to deploy processed assets. @throws PhassetsInternalException If at this time Phassets can't use this deployer to deploy and serve deployed assets
[ "This", "must", "throw", "a", "PhassetsInternalException", "if", "the", "current", "configuration", "doesn", "t", "allow", "this", "deployer", "to", "deploy", "processed", "assets", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L108-L123
19,447
CakeCMS/Core
src/Less/Less.php
Less.compile
public function compile($lessFile, $basePath = null) { try { $basePath = $this->_prepareBasepath($basePath, dirname($lessFile)); $cache = new Cache($this->_options); $cache->setFile($lessFile, $basePath); $isExpired = $cache->isExpired(); $isForce = $this->_options->get('force', false, 'bool'); if ($isForce || $cache->isExpired()) { $result = $this->_driver->compile($lessFile, $basePath); $cache->save($result); } $isExpired = ($isForce) ? true : $isExpired; $return = [FS::clean($cache->getFile(), '/'), $isExpired]; } catch (\Exception $e) { $message = 'Less error: ' . $e->getMessage(); throw new Exception($message); } return $return; }
php
public function compile($lessFile, $basePath = null) { try { $basePath = $this->_prepareBasepath($basePath, dirname($lessFile)); $cache = new Cache($this->_options); $cache->setFile($lessFile, $basePath); $isExpired = $cache->isExpired(); $isForce = $this->_options->get('force', false, 'bool'); if ($isForce || $cache->isExpired()) { $result = $this->_driver->compile($lessFile, $basePath); $cache->save($result); } $isExpired = ($isForce) ? true : $isExpired; $return = [FS::clean($cache->getFile(), '/'), $isExpired]; } catch (\Exception $e) { $message = 'Less error: ' . $e->getMessage(); throw new Exception($message); } return $return; }
[ "public", "function", "compile", "(", "$", "lessFile", ",", "$", "basePath", "=", "null", ")", "{", "try", "{", "$", "basePath", "=", "$", "this", "->", "_prepareBasepath", "(", "$", "basePath", ",", "dirname", "(", "$", "lessFile", ")", ")", ";", "$", "cache", "=", "new", "Cache", "(", "$", "this", "->", "_options", ")", ";", "$", "cache", "->", "setFile", "(", "$", "lessFile", ",", "$", "basePath", ")", ";", "$", "isExpired", "=", "$", "cache", "->", "isExpired", "(", ")", ";", "$", "isForce", "=", "$", "this", "->", "_options", "->", "get", "(", "'force'", ",", "false", ",", "'bool'", ")", ";", "if", "(", "$", "isForce", "||", "$", "cache", "->", "isExpired", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "_driver", "->", "compile", "(", "$", "lessFile", ",", "$", "basePath", ")", ";", "$", "cache", "->", "save", "(", "$", "result", ")", ";", "}", "$", "isExpired", "=", "(", "$", "isForce", ")", "?", "true", ":", "$", "isExpired", ";", "$", "return", "=", "[", "FS", "::", "clean", "(", "$", "cache", "->", "getFile", "(", ")", ",", "'/'", ")", ",", "$", "isExpired", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "message", "=", "'Less error: '", ".", "$", "e", "->", "getMessage", "(", ")", ";", "throw", "new", "Exception", "(", "$", "message", ")", ";", "}", "return", "$", "return", ";", "}" ]
Compile less file. @param string $lessFile @param null|string $basePath @return array @throws Exception
[ "Compile", "less", "file", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Less/Less.php#L38-L63
19,448
fubhy/graphql-php
src/Executor/Values.php
Values.getVariableValues
public static function getVariableValues(Schema $schema, array $asts, array $inputs) { $values = []; foreach ($asts as $ast) { $variable = $ast->get('variable')->get('name')->get('value'); $values[$variable] = self::getvariableValue($schema, $ast, isset($inputs[$variable]) ? $inputs[$variable] : NULL); } return $values; }
php
public static function getVariableValues(Schema $schema, array $asts, array $inputs) { $values = []; foreach ($asts as $ast) { $variable = $ast->get('variable')->get('name')->get('value'); $values[$variable] = self::getvariableValue($schema, $ast, isset($inputs[$variable]) ? $inputs[$variable] : NULL); } return $values; }
[ "public", "static", "function", "getVariableValues", "(", "Schema", "$", "schema", ",", "array", "$", "asts", ",", "array", "$", "inputs", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "asts", "as", "$", "ast", ")", "{", "$", "variable", "=", "$", "ast", "->", "get", "(", "'variable'", ")", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "$", "values", "[", "$", "variable", "]", "=", "self", "::", "getvariableValue", "(", "$", "schema", ",", "$", "ast", ",", "isset", "(", "$", "inputs", "[", "$", "variable", "]", ")", "?", "$", "inputs", "[", "$", "variable", "]", ":", "NULL", ")", ";", "}", "return", "$", "values", ";", "}" ]
Prepares an object map of variables of the correct type based on the provided variable definitions and arbitrary input. If the input cannot be coerced to match the variable definitions, a Error will be thrown. @param Schema $schema @param array $asts @param array $inputs @return array @throws \Exception
[ "Prepares", "an", "object", "map", "of", "variables", "of", "the", "correct", "type", "based", "on", "the", "provided", "variable", "definitions", "and", "arbitrary", "input", ".", "If", "the", "input", "cannot", "be", "coerced", "to", "match", "the", "variable", "definitions", "a", "Error", "will", "be", "thrown", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L33-L41
19,449
fubhy/graphql-php
src/Executor/Values.php
Values.getVariableValue
protected static function getVariableValue(Schema $schema, VariableDefinition $definition, $input) { $type = TypeInfo::typeFromAST($schema, $definition->get('type')); if (!$type) { return NULL; } if (self::isValidValue($type, $input)) { if (!isset($input)) { $default = $definition->get('defaultValue'); if ($default) { return self::coerceValueAST($type, $default); } } return self::coerceValue($type, $input); } // @todo Fix exception message once printer is ported. throw new \Exception(sprintf('Variable $%s expected value of different type.', $definition->get('variable')->get('name')->get('value'))); }
php
protected static function getVariableValue(Schema $schema, VariableDefinition $definition, $input) { $type = TypeInfo::typeFromAST($schema, $definition->get('type')); if (!$type) { return NULL; } if (self::isValidValue($type, $input)) { if (!isset($input)) { $default = $definition->get('defaultValue'); if ($default) { return self::coerceValueAST($type, $default); } } return self::coerceValue($type, $input); } // @todo Fix exception message once printer is ported. throw new \Exception(sprintf('Variable $%s expected value of different type.', $definition->get('variable')->get('name')->get('value'))); }
[ "protected", "static", "function", "getVariableValue", "(", "Schema", "$", "schema", ",", "VariableDefinition", "$", "definition", ",", "$", "input", ")", "{", "$", "type", "=", "TypeInfo", "::", "typeFromAST", "(", "$", "schema", ",", "$", "definition", "->", "get", "(", "'type'", ")", ")", ";", "if", "(", "!", "$", "type", ")", "{", "return", "NULL", ";", "}", "if", "(", "self", "::", "isValidValue", "(", "$", "type", ",", "$", "input", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "input", ")", ")", "{", "$", "default", "=", "$", "definition", "->", "get", "(", "'defaultValue'", ")", ";", "if", "(", "$", "default", ")", "{", "return", "self", "::", "coerceValueAST", "(", "$", "type", ",", "$", "default", ")", ";", "}", "}", "return", "self", "::", "coerceValue", "(", "$", "type", ",", "$", "input", ")", ";", "}", "// @todo Fix exception message once printer is ported.", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Variable $%s expected value of different type.'", ",", "$", "definition", "->", "get", "(", "'variable'", ")", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ")", ")", ";", "}" ]
Given a variable definition, and any value of input, return a value which adheres to the variable definition, or throw an error. @param Schema $schema @param VariableDefinition $definition @param $input @return array|mixed|null|string @throws \Exception
[ "Given", "a", "variable", "definition", "and", "any", "value", "of", "input", "return", "a", "value", "which", "adheres", "to", "the", "variable", "definition", "or", "throw", "an", "error", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L112-L133
19,450
fubhy/graphql-php
src/Executor/Values.php
Values.isValidValue
protected static function isValidValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { if (NULL === $value) { return FALSE; } return self::isValidValue($type->getWrappedType(), $value); } if ($value === NULL) { return TRUE; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { foreach ($value as $item) { if (!self::isValidValue($itemType, $item)) { return FALSE; } } return TRUE; } else { return self::isValidValue($itemType, $value); } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); foreach ($fields as $fieldName => $field) { if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) { return FALSE; } } return TRUE; } if ($type instanceof ScalarType || $type instanceof EnumType) { return NULL !== $type->coerce($value); } return FALSE; }
php
protected static function isValidValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { if (NULL === $value) { return FALSE; } return self::isValidValue($type->getWrappedType(), $value); } if ($value === NULL) { return TRUE; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { foreach ($value as $item) { if (!self::isValidValue($itemType, $item)) { return FALSE; } } return TRUE; } else { return self::isValidValue($itemType, $value); } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); foreach ($fields as $fieldName => $field) { if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) { return FALSE; } } return TRUE; } if ($type instanceof ScalarType || $type instanceof EnumType) { return NULL !== $type->coerce($value); } return FALSE; }
[ "protected", "static", "function", "isValidValue", "(", "TypeInterface", "$", "type", ",", "$", "value", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "if", "(", "NULL", "===", "$", "value", ")", "{", "return", "FALSE", ";", "}", "return", "self", "::", "isValidValue", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "value", ")", ";", "}", "if", "(", "$", "value", "===", "NULL", ")", "{", "return", "TRUE", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "item", ")", "{", "if", "(", "!", "self", "::", "isValidValue", "(", "$", "itemType", ",", "$", "item", ")", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}", "else", "{", "return", "self", "::", "isValidValue", "(", "$", "itemType", ",", "$", "value", ")", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "if", "(", "!", "self", "::", "isValidValue", "(", "$", "field", "->", "getType", "(", ")", ",", "isset", "(", "$", "value", "[", "$", "fieldName", "]", ")", "?", "$", "value", "[", "$", "fieldName", "]", ":", "NULL", ")", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "return", "NULL", "!==", "$", "type", "->", "coerce", "(", "$", "value", ")", ";", "}", "return", "FALSE", ";", "}" ]
Given a type and any value, return true if that value is valid. @param TypeInterface $type @param $value @return bool
[ "Given", "a", "type", "and", "any", "value", "return", "true", "if", "that", "value", "is", "valid", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L143-L188
19,451
fubhy/graphql-php
src/Executor/Values.php
Values.coerceValue
protected static function coerceValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValue is non-null. // We only call this function after calling isValidValue. return self::coerceValue($type->getWrappedType(), $value); } if (!isset($value)) { return NULL; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { return array_map(function ($item) use ($itemType) { return Values::coerceValue($itemType, $item); }, $value); } else { return [self::coerceValue($itemType, $value)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); $object = []; foreach ($fields as $fieldName => $field) { $fieldValue = self::coerceValue($field->getType(), $value[$fieldName]); $object[$fieldName] = $fieldValue === NULL ? $field->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerce($value); if (NULL !== $coerced) { return $coerced; } } return NULL; }
php
protected static function coerceValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValue is non-null. // We only call this function after calling isValidValue. return self::coerceValue($type->getWrappedType(), $value); } if (!isset($value)) { return NULL; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { return array_map(function ($item) use ($itemType) { return Values::coerceValue($itemType, $item); }, $value); } else { return [self::coerceValue($itemType, $value)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); $object = []; foreach ($fields as $fieldName => $field) { $fieldValue = self::coerceValue($field->getType(), $value[$fieldName]); $object[$fieldName] = $fieldValue === NULL ? $field->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerce($value); if (NULL !== $coerced) { return $coerced; } } return NULL; }
[ "protected", "static", "function", "coerceValue", "(", "TypeInterface", "$", "type", ",", "$", "value", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "// Note: we're not checking that the result of coerceValue is non-null.", "// We only call this function after calling isValidValue.", "return", "self", "::", "coerceValue", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "value", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "return", "NULL", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "itemType", ")", "{", "return", "Values", "::", "coerceValue", "(", "$", "itemType", ",", "$", "item", ")", ";", "}", ",", "$", "value", ")", ";", "}", "else", "{", "return", "[", "self", "::", "coerceValue", "(", "$", "itemType", ",", "$", "value", ")", "]", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "$", "object", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "$", "fieldValue", "=", "self", "::", "coerceValue", "(", "$", "field", "->", "getType", "(", ")", ",", "$", "value", "[", "$", "fieldName", "]", ")", ";", "$", "object", "[", "$", "fieldName", "]", "=", "$", "fieldValue", "===", "NULL", "?", "$", "field", "->", "getDefaultValue", "(", ")", ":", "$", "fieldValue", ";", "}", "return", "$", "object", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "$", "coerced", "=", "$", "type", "->", "coerce", "(", "$", "value", ")", ";", "if", "(", "NULL", "!==", "$", "coerced", ")", "{", "return", "$", "coerced", ";", "}", "}", "return", "NULL", ";", "}" ]
Given a type and any value, return a runtime value coerced to match the type. @param TypeInterface $type @param $value @return array|mixed|null|string
[ "Given", "a", "type", "and", "any", "value", "return", "a", "runtime", "value", "coerced", "to", "match", "the", "type", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L199-L241
19,452
fubhy/graphql-php
src/Executor/Values.php
Values.coerceValueAST
protected static function coerceValueAST(TypeInterface $type, $ast, $variables = NULL) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValueAST is non-null. // We're assuming that this query has been validated and the value used // here is of the correct type. return self::coerceValueAST($type->getWrappedType(), $ast, $variables); } if (!$ast) { return NULL; } if ($ast::KIND === Node::KIND_VARIABLE) { $variableName = $ast->get('name')->get('value'); if (!isset($variables, $variables[$variableName])) { return NULL; } // Note: we're not doing any checking that this variable is correct. We're // assuming that this query has been validated and the variable usage here // is of the correct type. return $variables[$variableName]; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if ($ast::KIND === Node::KIND_ARRAY_VALUE) { $tmp = []; foreach ($ast->get('values') as $itemAST) { $tmp[] = self::coerceValueAST($itemType, $itemAST, $variables); } return $tmp; } else { return [self::coerceValueAST($itemType, $ast, $variables)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); if ($ast::KIND !== Node::KIND_OBJECT_VALUE) { return NULL; } $asts = array_reduce($ast->get('fields'), function ($carry, $field) { $carry[$field->get('name')->get('value')] = $field; return $carry; }, []); $object = []; foreach ($fields as $name => $item) { $field = $asts[$name]; $fieldValue = self::coerceValueAST($item->getType(), $field ? $field->get('value') : NULL, $variables); $object[$name] = $fieldValue === NULL ? $item->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerceLiteral($ast); if (isset($coerced)) { return $coerced; } } return NULL; }
php
protected static function coerceValueAST(TypeInterface $type, $ast, $variables = NULL) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValueAST is non-null. // We're assuming that this query has been validated and the value used // here is of the correct type. return self::coerceValueAST($type->getWrappedType(), $ast, $variables); } if (!$ast) { return NULL; } if ($ast::KIND === Node::KIND_VARIABLE) { $variableName = $ast->get('name')->get('value'); if (!isset($variables, $variables[$variableName])) { return NULL; } // Note: we're not doing any checking that this variable is correct. We're // assuming that this query has been validated and the variable usage here // is of the correct type. return $variables[$variableName]; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if ($ast::KIND === Node::KIND_ARRAY_VALUE) { $tmp = []; foreach ($ast->get('values') as $itemAST) { $tmp[] = self::coerceValueAST($itemType, $itemAST, $variables); } return $tmp; } else { return [self::coerceValueAST($itemType, $ast, $variables)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); if ($ast::KIND !== Node::KIND_OBJECT_VALUE) { return NULL; } $asts = array_reduce($ast->get('fields'), function ($carry, $field) { $carry[$field->get('name')->get('value')] = $field; return $carry; }, []); $object = []; foreach ($fields as $name => $item) { $field = $asts[$name]; $fieldValue = self::coerceValueAST($item->getType(), $field ? $field->get('value') : NULL, $variables); $object[$name] = $fieldValue === NULL ? $item->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerceLiteral($ast); if (isset($coerced)) { return $coerced; } } return NULL; }
[ "protected", "static", "function", "coerceValueAST", "(", "TypeInterface", "$", "type", ",", "$", "ast", ",", "$", "variables", "=", "NULL", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "// Note: we're not checking that the result of coerceValueAST is non-null.", "// We're assuming that this query has been validated and the value used", "// here is of the correct type.", "return", "self", "::", "coerceValueAST", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "ast", ",", "$", "variables", ")", ";", "}", "if", "(", "!", "$", "ast", ")", "{", "return", "NULL", ";", "}", "if", "(", "$", "ast", "::", "KIND", "===", "Node", "::", "KIND_VARIABLE", ")", "{", "$", "variableName", "=", "$", "ast", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "if", "(", "!", "isset", "(", "$", "variables", ",", "$", "variables", "[", "$", "variableName", "]", ")", ")", "{", "return", "NULL", ";", "}", "// Note: we're not doing any checking that this variable is correct. We're", "// assuming that this query has been validated and the variable usage here", "// is of the correct type.", "return", "$", "variables", "[", "$", "variableName", "]", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "$", "ast", "::", "KIND", "===", "Node", "::", "KIND_ARRAY_VALUE", ")", "{", "$", "tmp", "=", "[", "]", ";", "foreach", "(", "$", "ast", "->", "get", "(", "'values'", ")", "as", "$", "itemAST", ")", "{", "$", "tmp", "[", "]", "=", "self", "::", "coerceValueAST", "(", "$", "itemType", ",", "$", "itemAST", ",", "$", "variables", ")", ";", "}", "return", "$", "tmp", ";", "}", "else", "{", "return", "[", "self", "::", "coerceValueAST", "(", "$", "itemType", ",", "$", "ast", ",", "$", "variables", ")", "]", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "if", "(", "$", "ast", "::", "KIND", "!==", "Node", "::", "KIND_OBJECT_VALUE", ")", "{", "return", "NULL", ";", "}", "$", "asts", "=", "array_reduce", "(", "$", "ast", "->", "get", "(", "'fields'", ")", ",", "function", "(", "$", "carry", ",", "$", "field", ")", "{", "$", "carry", "[", "$", "field", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "]", "=", "$", "field", ";", "return", "$", "carry", ";", "}", ",", "[", "]", ")", ";", "$", "object", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "name", "=>", "$", "item", ")", "{", "$", "field", "=", "$", "asts", "[", "$", "name", "]", ";", "$", "fieldValue", "=", "self", "::", "coerceValueAST", "(", "$", "item", "->", "getType", "(", ")", ",", "$", "field", "?", "$", "field", "->", "get", "(", "'value'", ")", ":", "NULL", ",", "$", "variables", ")", ";", "$", "object", "[", "$", "name", "]", "=", "$", "fieldValue", "===", "NULL", "?", "$", "item", "->", "getDefaultValue", "(", ")", ":", "$", "fieldValue", ";", "}", "return", "$", "object", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "$", "coerced", "=", "$", "type", "->", "coerceLiteral", "(", "$", "ast", ")", ";", "if", "(", "isset", "(", "$", "coerced", ")", ")", "{", "return", "$", "coerced", ";", "}", "}", "return", "NULL", ";", "}" ]
Given a type and a value AST node known to match this type, build a runtime value. @param TypeInterface $type @param $ast @param null $variables @return array|mixed|null|string
[ "Given", "a", "type", "and", "a", "value", "AST", "node", "known", "to", "match", "this", "type", "build", "a", "runtime", "value", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L253-L325
19,453
lootils/archiver
src/Lootils/Archiver/ZipArchive.php
ZipArchive.close
public function close() { if (isset($this->zip)) { $this->zip->close(); $this->zip = null; } }
php
public function close() { if (isset($this->zip)) { $this->zip->close(); $this->zip = null; } }
[ "public", "function", "close", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "zip", ")", ")", "{", "$", "this", "->", "zip", "->", "close", "(", ")", ";", "$", "this", "->", "zip", "=", "null", ";", "}", "}" ]
Release the zip resource.
[ "Release", "the", "zip", "resource", "." ]
5b801bddfe15f7378a118c4094f04b37abb5a53e
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/ZipArchive.php#L105-L111
19,454
teneleven/GeolocatorBundle
DependencyInjection/TenelevenGeolocatorExtension.php
TenelevenGeolocatorExtension.prepend
public function prepend(ContainerBuilder $container) { $configs = array( 'bazinga_geocoder' => array( 'providers' => array('google_maps' => null) ), // 'ivory_google_map' => array( // 'map' => array('width' => "100%", 'height' => "600px"), // 'info_window' => array('auto_close' => true) // ), 'doctrine' => array( 'orm' => array( 'dql' => array( 'numeric_functions' => array( 'GEO_DISTANCE' => 'Craue\GeoBundle\Doctrine\Query\Mysql\GeoDistance' ) ) ) ) ); foreach ($configs as $name => $config) { $container->prependExtensionConfig($name, $config); } }
php
public function prepend(ContainerBuilder $container) { $configs = array( 'bazinga_geocoder' => array( 'providers' => array('google_maps' => null) ), // 'ivory_google_map' => array( // 'map' => array('width' => "100%", 'height' => "600px"), // 'info_window' => array('auto_close' => true) // ), 'doctrine' => array( 'orm' => array( 'dql' => array( 'numeric_functions' => array( 'GEO_DISTANCE' => 'Craue\GeoBundle\Doctrine\Query\Mysql\GeoDistance' ) ) ) ) ); foreach ($configs as $name => $config) { $container->prependExtensionConfig($name, $config); } }
[ "public", "function", "prepend", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "configs", "=", "array", "(", "'bazinga_geocoder'", "=>", "array", "(", "'providers'", "=>", "array", "(", "'google_maps'", "=>", "null", ")", ")", ",", "// 'ivory_google_map' => array(", "// 'map' => array('width' => \"100%\", 'height' => \"600px\"),", "// 'info_window' => array('auto_close' => true)", "// ),", "'doctrine'", "=>", "array", "(", "'orm'", "=>", "array", "(", "'dql'", "=>", "array", "(", "'numeric_functions'", "=>", "array", "(", "'GEO_DISTANCE'", "=>", "'Craue\\GeoBundle\\Doctrine\\Query\\Mysql\\GeoDistance'", ")", ")", ")", ")", ")", ";", "foreach", "(", "$", "configs", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "container", "->", "prependExtensionConfig", "(", "$", "name", ",", "$", "config", ")", ";", "}", "}" ]
Configure sensitive defaults for other bundles @param ContainerBuilder $container
[ "Configure", "sensitive", "defaults", "for", "other", "bundles" ]
4ead8e783a91577f2a67aa302b79641d4b9e99ad
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/DependencyInjection/TenelevenGeolocatorExtension.php#L80-L104
19,455
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ApiLogQuery) { return $criteria; } $query = new ApiLogQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ApiLogQuery) { return $criteria; } $query = new ApiLogQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "ApiLogQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "ApiLogQuery", "(", "null", ",", "null", ",", "$", "modelAlias", ")", ";", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new ApiLogQuery object. @param string $modelAlias The alias of a model in the query @param ApiLogQuery|Criteria $criteria Optional Criteria to build the query from @return ApiLogQuery
[ "Returns", "a", "new", "ApiLogQuery", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L83-L95
19,456
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.filterByDtCall
public function filterByDtCall($dtCall = null, $comparison = null) { if (is_array($dtCall)) { $useMinMax = false; if (isset($dtCall['min'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dtCall['max'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall, $comparison); }
php
public function filterByDtCall($dtCall = null, $comparison = null) { if (is_array($dtCall)) { $useMinMax = false; if (isset($dtCall['min'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dtCall['max'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall, $comparison); }
[ "public", "function", "filterByDtCall", "(", "$", "dtCall", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "dtCall", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "dtCall", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "dtCall", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the dt_call column Example usage: <code> $query->filterByDtCall('2011-03-14'); // WHERE dt_call = '2011-03-14' $query->filterByDtCall('now'); // WHERE dt_call = '2011-03-14' $query->filterByDtCall(array('max' => 'yesterday')); // WHERE dt_call < '2011-03-13' </code> @param mixed $dtCall The value to use as filter. Values can be integers (unix timestamps), DateTime objects, or strings. Empty strings are treated as NULL. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ApiLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "dt_call", "column" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L310-L331
19,457
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.filterByLastResponse
public function filterByLastResponse($lastResponse = null, $comparison = null) { return $this->addUsingAlias(ApiLogPeer::LAST_RESPONSE, $lastResponse, $comparison); }
php
public function filterByLastResponse($lastResponse = null, $comparison = null) { return $this->addUsingAlias(ApiLogPeer::LAST_RESPONSE, $lastResponse, $comparison); }
[ "public", "function", "filterByLastResponse", "(", "$", "lastResponse", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ",", "$", "lastResponse", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the last_response column @param mixed $lastResponse The value to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ApiLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "last_response", "column" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L427-L431
19,458
Double-Opt-in/php-client-api
src/Security/Crypter.php
Crypter.encrypt
public function encrypt($plaintext, $key) { // Set up encryption parameters. $inputData = cryptoHelpers::convertStringToByteArray($plaintext); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $iv = cryptoHelpers::generateSharedKey(16); $encrypted = AES::encrypt( $inputData, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); $retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($encrypted['cipher']); return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal; }
php
public function encrypt($plaintext, $key) { // Set up encryption parameters. $inputData = cryptoHelpers::convertStringToByteArray($plaintext); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $iv = cryptoHelpers::generateSharedKey(16); $encrypted = AES::encrypt( $inputData, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); $retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($encrypted['cipher']); return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal; }
[ "public", "function", "encrypt", "(", "$", "plaintext", ",", "$", "key", ")", "{", "// Set up encryption parameters.", "$", "inputData", "=", "cryptoHelpers", "::", "convertStringToByteArray", "(", "$", "plaintext", ")", ";", "$", "keyAsNumbers", "=", "cryptoHelpers", "::", "toNumbers", "(", "bin2hex", "(", "$", "key", ")", ")", ";", "$", "keyLength", "=", "count", "(", "$", "keyAsNumbers", ")", ";", "$", "iv", "=", "cryptoHelpers", "::", "generateSharedKey", "(", "16", ")", ";", "$", "encrypted", "=", "AES", "::", "encrypt", "(", "$", "inputData", ",", "AES", "::", "modeOfOperation_CBC", ",", "$", "keyAsNumbers", ",", "$", "keyLength", ",", "$", "iv", ")", ";", "$", "retVal", "=", "$", "encrypted", "[", "'originalsize'", "]", ".", "self", "::", "SEPARATOR_CRYPTO_PARTS", ".", "cryptoHelpers", "::", "toHex", "(", "$", "iv", ")", ".", "self", "::", "SEPARATOR_CRYPTO_PARTS", ".", "cryptoHelpers", "::", "toHex", "(", "$", "encrypted", "[", "'cipher'", "]", ")", ";", "return", "self", "::", "IDENTIFIER", ".", "self", "::", "SEPARATOR_ALGORITHM", ".", "$", "retVal", ";", "}" ]
encrypts the given plain text with a key @param string $plaintext @param string $key @return string
[ "encrypts", "the", "given", "plain", "text", "with", "a", "key" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/Crypter.php#L28-L49
19,459
Double-Opt-in/php-client-api
src/Security/Crypter.php
Crypter.decrypt
public function decrypt($encrypted, $key) { if (empty($encrypted)) return null; list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2); if ($identifier !== self::IDENTIFIER) throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier); // Split the input into its parts $cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input); $originalSize = intval($cipherSplit[0]); $iv = cryptoHelpers::toNumbers($cipherSplit[1]); $cipherText = $cipherSplit[2]; // Set up encryption parameters $cipherIn = cryptoHelpers::toNumbers($cipherText); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $decrypted = AES::decrypt( $cipherIn, $originalSize, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); // Byte-array to text. $hexDecrypted = cryptoHelpers::toHex($decrypted); $retVal = pack("H*", $hexDecrypted); return $retVal; }
php
public function decrypt($encrypted, $key) { if (empty($encrypted)) return null; list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2); if ($identifier !== self::IDENTIFIER) throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier); // Split the input into its parts $cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input); $originalSize = intval($cipherSplit[0]); $iv = cryptoHelpers::toNumbers($cipherSplit[1]); $cipherText = $cipherSplit[2]; // Set up encryption parameters $cipherIn = cryptoHelpers::toNumbers($cipherText); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $decrypted = AES::decrypt( $cipherIn, $originalSize, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); // Byte-array to text. $hexDecrypted = cryptoHelpers::toHex($decrypted); $retVal = pack("H*", $hexDecrypted); return $retVal; }
[ "public", "function", "decrypt", "(", "$", "encrypted", ",", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "encrypted", ")", ")", "return", "null", ";", "list", "(", "$", "identifier", ",", "$", "input", ")", "=", "explode", "(", "self", "::", "SEPARATOR_ALGORITHM", ",", "$", "encrypted", ",", "2", ")", ";", "if", "(", "$", "identifier", "!==", "self", "::", "IDENTIFIER", ")", "throw", "new", "Exception", "(", "'Encryption can not be decrypted. Unsupported identifier: '", ".", "$", "identifier", ")", ";", "// Split the input into its parts", "$", "cipherSplit", "=", "explode", "(", "self", "::", "SEPARATOR_CRYPTO_PARTS", ",", "$", "input", ")", ";", "$", "originalSize", "=", "intval", "(", "$", "cipherSplit", "[", "0", "]", ")", ";", "$", "iv", "=", "cryptoHelpers", "::", "toNumbers", "(", "$", "cipherSplit", "[", "1", "]", ")", ";", "$", "cipherText", "=", "$", "cipherSplit", "[", "2", "]", ";", "// Set up encryption parameters", "$", "cipherIn", "=", "cryptoHelpers", "::", "toNumbers", "(", "$", "cipherText", ")", ";", "$", "keyAsNumbers", "=", "cryptoHelpers", "::", "toNumbers", "(", "bin2hex", "(", "$", "key", ")", ")", ";", "$", "keyLength", "=", "count", "(", "$", "keyAsNumbers", ")", ";", "$", "decrypted", "=", "AES", "::", "decrypt", "(", "$", "cipherIn", ",", "$", "originalSize", ",", "AES", "::", "modeOfOperation_CBC", ",", "$", "keyAsNumbers", ",", "$", "keyLength", ",", "$", "iv", ")", ";", "// Byte-array to text.", "$", "hexDecrypted", "=", "cryptoHelpers", "::", "toHex", "(", "$", "decrypted", ")", ";", "$", "retVal", "=", "pack", "(", "\"H*\"", ",", "$", "hexDecrypted", ")", ";", "return", "$", "retVal", ";", "}" ]
decrypts a message @param string $encrypted @param string $key @return string @throws Exception
[ "decrypts", "a", "message" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/Crypter.php#L60-L95
19,460
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.edebug
protected function edebug($str) { if (!$this->SMTPDebug) { return; } switch ($this->Debugoutput) { case 'error_log': error_log($str); break; case 'html': //Cleans up output a bit for a better looking display that's HTML-safe echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n"; break; case 'echo': default: echo $str."\n"; } }
php
protected function edebug($str) { if (!$this->SMTPDebug) { return; } switch ($this->Debugoutput) { case 'error_log': error_log($str); break; case 'html': //Cleans up output a bit for a better looking display that's HTML-safe echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n"; break; case 'echo': default: echo $str."\n"; } }
[ "protected", "function", "edebug", "(", "$", "str", ")", "{", "if", "(", "!", "$", "this", "->", "SMTPDebug", ")", "{", "return", ";", "}", "switch", "(", "$", "this", "->", "Debugoutput", ")", "{", "case", "'error_log'", ":", "error_log", "(", "$", "str", ")", ";", "break", ";", "case", "'html'", ":", "//Cleans up output a bit for a better looking display that's HTML-safe", "echo", "htmlentities", "(", "preg_replace", "(", "'/[\\r\\n]+/'", ",", "''", ",", "$", "str", ")", ",", "ENT_QUOTES", ",", "$", "this", "->", "CharSet", ")", ".", "\"<br>\\n\"", ";", "break", ";", "case", "'echo'", ":", "default", ":", "echo", "$", "str", ".", "\"\\n\"", ";", "}", "}" ]
Output debugging info via user-defined method. Only if debug output is enabled. @see PHPMailer::$Debugoutput @see PHPMailer::$SMTPDebug @param string $str
[ "Output", "debugging", "info", "via", "user", "-", "defined", "method", ".", "Only", "if", "debug", "output", "is", "enabled", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L629-L646
19,461
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.addAttachment
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') { try { if (!@is_file($path)) { throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); } // If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } $filename = basename($path); if ($name == '') { $name = $filename; } $this->attachment[] = array( 0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => $disposition, 7 => 0 ); } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; }
php
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') { try { if (!@is_file($path)) { throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); } // If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } $filename = basename($path); if ($name == '') { $name = $filename; } $this->attachment[] = array( 0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => $disposition, 7 => 0 ); } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; }
[ "public", "function", "addAttachment", "(", "$", "path", ",", "$", "name", "=", "''", ",", "$", "encoding", "=", "'base64'", ",", "$", "type", "=", "''", ",", "$", "disposition", "=", "'attachment'", ")", "{", "try", "{", "if", "(", "!", "@", "is_file", "(", "$", "path", ")", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'file_access'", ")", ".", "$", "path", ",", "self", "::", "STOP_CONTINUE", ")", ";", "}", "// If a MIME type is not specified, try to work it out from the file name", "if", "(", "$", "type", "==", "''", ")", "{", "$", "type", "=", "self", "::", "filenameToType", "(", "$", "path", ")", ";", "}", "$", "filename", "=", "basename", "(", "$", "path", ")", ";", "if", "(", "$", "name", "==", "''", ")", "{", "$", "name", "=", "$", "filename", ";", "}", "$", "this", "->", "attachment", "[", "]", "=", "array", "(", "0", "=>", "$", "path", ",", "1", "=>", "$", "filename", ",", "2", "=>", "$", "name", ",", "3", "=>", "$", "encoding", ",", "4", "=>", "$", "type", ",", "5", "=>", "false", ",", "// isStringAttachment", "6", "=>", "$", "disposition", ",", "7", "=>", "0", ")", ";", "}", "catch", "(", "phpmailerException", "$", "exc", ")", "{", "$", "this", "->", "setError", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "edebug", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exceptions", ")", "{", "throw", "$", "exc", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Add an attachment from a path on the filesystem. Returns false if the file could not be found or read. @param string $path Path to the attachment. @param string $name Overrides the attachment name. @param string $encoding File encoding (see $Encoding). @param string $type File extension (MIME) type. @param string $disposition Disposition to use @throws phpmailerException @return boolean
[ "Add", "an", "attachment", "from", "a", "path", "on", "the", "filesystem", ".", "Returns", "false", "if", "the", "file", "could", "not", "be", "found", "or", "read", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2050-L2087
19,462
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.encodeQ
public function encodeQ($str, $position = 'text') { // There should not be any EOL in the string $pattern = ''; $encoded = str_replace(array("\r", "\n"), '', $str); switch (strtolower($position)) { case 'phrase': // RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; /** @noinspection PhpMissingBreakStatementInspection */ case 'comment': // RFC 2047 section 5.2 $pattern = '\(\)"'; // intentional fall-through // for this reason we build the $pattern without including delimiters and [] case 'text': default: // RFC 2047 section 5.1 // Replace every high ascii, control, =, ? and _ characters $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { // If the string contains an '=', make sure it's the first thing we replace // so as to avoid double-encoding $eqkey = array_search('=', $matches[0]); if ($eqkey !== false) { unset($matches[0][$eqkey]); array_unshift($matches[0], '='); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); } } // Replace every spaces to _ (more readable than =20) return str_replace(' ', '_', $encoded); }
php
public function encodeQ($str, $position = 'text') { // There should not be any EOL in the string $pattern = ''; $encoded = str_replace(array("\r", "\n"), '', $str); switch (strtolower($position)) { case 'phrase': // RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; /** @noinspection PhpMissingBreakStatementInspection */ case 'comment': // RFC 2047 section 5.2 $pattern = '\(\)"'; // intentional fall-through // for this reason we build the $pattern without including delimiters and [] case 'text': default: // RFC 2047 section 5.1 // Replace every high ascii, control, =, ? and _ characters $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { // If the string contains an '=', make sure it's the first thing we replace // so as to avoid double-encoding $eqkey = array_search('=', $matches[0]); if ($eqkey !== false) { unset($matches[0][$eqkey]); array_unshift($matches[0], '='); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); } } // Replace every spaces to _ (more readable than =20) return str_replace(' ', '_', $encoded); }
[ "public", "function", "encodeQ", "(", "$", "str", ",", "$", "position", "=", "'text'", ")", "{", "// There should not be any EOL in the string", "$", "pattern", "=", "''", ";", "$", "encoded", "=", "str_replace", "(", "array", "(", "\"\\r\"", ",", "\"\\n\"", ")", ",", "''", ",", "$", "str", ")", ";", "switch", "(", "strtolower", "(", "$", "position", ")", ")", "{", "case", "'phrase'", ":", "// RFC 2047 section 5.3", "$", "pattern", "=", "'^A-Za-z0-9!*+\\/ -'", ";", "break", ";", "/** @noinspection PhpMissingBreakStatementInspection */", "case", "'comment'", ":", "// RFC 2047 section 5.2", "$", "pattern", "=", "'\\(\\)\"'", ";", "// intentional fall-through", "// for this reason we build the $pattern without including delimiters and []", "case", "'text'", ":", "default", ":", "// RFC 2047 section 5.1", "// Replace every high ascii, control, =, ? and _ characters", "$", "pattern", "=", "'\\000-\\011\\013\\014\\016-\\037\\075\\077\\137\\177-\\377'", ".", "$", "pattern", ";", "break", ";", "}", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match_all", "(", "\"/[{$pattern}]/\"", ",", "$", "encoded", ",", "$", "matches", ")", ")", "{", "// If the string contains an '=', make sure it's the first thing we replace", "// so as to avoid double-encoding", "$", "eqkey", "=", "array_search", "(", "'='", ",", "$", "matches", "[", "0", "]", ")", ";", "if", "(", "$", "eqkey", "!==", "false", ")", "{", "unset", "(", "$", "matches", "[", "0", "]", "[", "$", "eqkey", "]", ")", ";", "array_unshift", "(", "$", "matches", "[", "0", "]", ",", "'='", ")", ";", "}", "foreach", "(", "array_unique", "(", "$", "matches", "[", "0", "]", ")", "as", "$", "char", ")", "{", "$", "encoded", "=", "str_replace", "(", "$", "char", ",", "'='", ".", "sprintf", "(", "'%02X'", ",", "ord", "(", "$", "char", ")", ")", ",", "$", "encoded", ")", ";", "}", "}", "// Replace every spaces to _ (more readable than =20)", "return", "str_replace", "(", "' '", ",", "'_'", ",", "$", "encoded", ")", ";", "}" ]
Encode a string using Q encoding. @link http://tools.ietf.org/html/rfc2047 @param string $str the text to encode @param string $position Where the text is going to be used, see the RFC for what that means @access public @return string
[ "Encode", "a", "string", "using", "Q", "encoding", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2466-L2504
19,463
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.html2text
public function html2text($html, $advanced = false) { if ($advanced) { require_once 'extras/class.html2text.php'; $htmlconverter = new html2text($html); return $htmlconverter->get_text(); } return html_entity_decode( trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet ); }
php
public function html2text($html, $advanced = false) { if ($advanced) { require_once 'extras/class.html2text.php'; $htmlconverter = new html2text($html); return $htmlconverter->get_text(); } return html_entity_decode( trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet ); }
[ "public", "function", "html2text", "(", "$", "html", ",", "$", "advanced", "=", "false", ")", "{", "if", "(", "$", "advanced", ")", "{", "require_once", "'extras/class.html2text.php'", ";", "$", "htmlconverter", "=", "new", "html2text", "(", "$", "html", ")", ";", "return", "$", "htmlconverter", "->", "get_text", "(", ")", ";", "}", "return", "html_entity_decode", "(", "trim", "(", "strip_tags", "(", "preg_replace", "(", "'/<(head|title|style|script)[^>]*>.*?<\\/\\\\1>/si'", ",", "''", ",", "$", "html", ")", ")", ")", ",", "ENT_QUOTES", ",", "$", "this", "->", "CharSet", ")", ";", "}" ]
Convert an HTML string into plain text. @param string $html The HTML text to convert @param boolean $advanced Should this use the more complex html2text converter or just a simple one? @return string
[ "Convert", "an", "HTML", "string", "into", "plain", "text", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2926-L2938
19,464
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer._mime_types
public static function _mime_types($ext = '') { $mimes = array( 'xl' => 'application/excel', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'bin' => 'application/macbinary', 'doc' => 'application/msword', 'word' => 'application/msword', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'eml' => 'message/rfc822', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'log' => 'text/plain', 'text' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'rv' => 'video/vnd.rn-realvideo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie' ); return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream'); }
php
public static function _mime_types($ext = '') { $mimes = array( 'xl' => 'application/excel', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'bin' => 'application/macbinary', 'doc' => 'application/msword', 'word' => 'application/msword', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'eml' => 'message/rfc822', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'log' => 'text/plain', 'text' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'rv' => 'video/vnd.rn-realvideo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie' ); return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream'); }
[ "public", "static", "function", "_mime_types", "(", "$", "ext", "=", "''", ")", "{", "$", "mimes", "=", "array", "(", "'xl'", "=>", "'application/excel'", ",", "'hqx'", "=>", "'application/mac-binhex40'", ",", "'cpt'", "=>", "'application/mac-compactpro'", ",", "'bin'", "=>", "'application/macbinary'", ",", "'doc'", "=>", "'application/msword'", ",", "'word'", "=>", "'application/msword'", ",", "'class'", "=>", "'application/octet-stream'", ",", "'dll'", "=>", "'application/octet-stream'", ",", "'dms'", "=>", "'application/octet-stream'", ",", "'exe'", "=>", "'application/octet-stream'", ",", "'lha'", "=>", "'application/octet-stream'", ",", "'lzh'", "=>", "'application/octet-stream'", ",", "'psd'", "=>", "'application/octet-stream'", ",", "'sea'", "=>", "'application/octet-stream'", ",", "'so'", "=>", "'application/octet-stream'", ",", "'oda'", "=>", "'application/oda'", ",", "'pdf'", "=>", "'application/pdf'", ",", "'ai'", "=>", "'application/postscript'", ",", "'eps'", "=>", "'application/postscript'", ",", "'ps'", "=>", "'application/postscript'", ",", "'smi'", "=>", "'application/smil'", ",", "'smil'", "=>", "'application/smil'", ",", "'mif'", "=>", "'application/vnd.mif'", ",", "'xls'", "=>", "'application/vnd.ms-excel'", ",", "'ppt'", "=>", "'application/vnd.ms-powerpoint'", ",", "'wbxml'", "=>", "'application/vnd.wap.wbxml'", ",", "'wmlc'", "=>", "'application/vnd.wap.wmlc'", ",", "'dcr'", "=>", "'application/x-director'", ",", "'dir'", "=>", "'application/x-director'", ",", "'dxr'", "=>", "'application/x-director'", ",", "'dvi'", "=>", "'application/x-dvi'", ",", "'gtar'", "=>", "'application/x-gtar'", ",", "'php3'", "=>", "'application/x-httpd-php'", ",", "'php4'", "=>", "'application/x-httpd-php'", ",", "'php'", "=>", "'application/x-httpd-php'", ",", "'phtml'", "=>", "'application/x-httpd-php'", ",", "'phps'", "=>", "'application/x-httpd-php-source'", ",", "'js'", "=>", "'application/x-javascript'", ",", "'swf'", "=>", "'application/x-shockwave-flash'", ",", "'sit'", "=>", "'application/x-stuffit'", ",", "'tar'", "=>", "'application/x-tar'", ",", "'tgz'", "=>", "'application/x-tar'", ",", "'xht'", "=>", "'application/xhtml+xml'", ",", "'xhtml'", "=>", "'application/xhtml+xml'", ",", "'zip'", "=>", "'application/zip'", ",", "'mid'", "=>", "'audio/midi'", ",", "'midi'", "=>", "'audio/midi'", ",", "'mp2'", "=>", "'audio/mpeg'", ",", "'mp3'", "=>", "'audio/mpeg'", ",", "'mpga'", "=>", "'audio/mpeg'", ",", "'aif'", "=>", "'audio/x-aiff'", ",", "'aifc'", "=>", "'audio/x-aiff'", ",", "'aiff'", "=>", "'audio/x-aiff'", ",", "'ram'", "=>", "'audio/x-pn-realaudio'", ",", "'rm'", "=>", "'audio/x-pn-realaudio'", ",", "'rpm'", "=>", "'audio/x-pn-realaudio-plugin'", ",", "'ra'", "=>", "'audio/x-realaudio'", ",", "'wav'", "=>", "'audio/x-wav'", ",", "'bmp'", "=>", "'image/bmp'", ",", "'gif'", "=>", "'image/gif'", ",", "'jpeg'", "=>", "'image/jpeg'", ",", "'jpe'", "=>", "'image/jpeg'", ",", "'jpg'", "=>", "'image/jpeg'", ",", "'png'", "=>", "'image/png'", ",", "'tiff'", "=>", "'image/tiff'", ",", "'tif'", "=>", "'image/tiff'", ",", "'eml'", "=>", "'message/rfc822'", ",", "'css'", "=>", "'text/css'", ",", "'html'", "=>", "'text/html'", ",", "'htm'", "=>", "'text/html'", ",", "'shtml'", "=>", "'text/html'", ",", "'log'", "=>", "'text/plain'", ",", "'text'", "=>", "'text/plain'", ",", "'txt'", "=>", "'text/plain'", ",", "'rtx'", "=>", "'text/richtext'", ",", "'rtf'", "=>", "'text/rtf'", ",", "'vcf'", "=>", "'text/vcard'", ",", "'vcard'", "=>", "'text/vcard'", ",", "'xml'", "=>", "'text/xml'", ",", "'xsl'", "=>", "'text/xml'", ",", "'mpeg'", "=>", "'video/mpeg'", ",", "'mpe'", "=>", "'video/mpeg'", ",", "'mpg'", "=>", "'video/mpeg'", ",", "'mov'", "=>", "'video/quicktime'", ",", "'qt'", "=>", "'video/quicktime'", ",", "'rv'", "=>", "'video/vnd.rn-realvideo'", ",", "'avi'", "=>", "'video/x-msvideo'", ",", "'movie'", "=>", "'video/x-sgi-movie'", ")", ";", "return", "(", "array_key_exists", "(", "strtolower", "(", "$", "ext", ")", ",", "$", "mimes", ")", "?", "$", "mimes", "[", "strtolower", "(", "$", "ext", ")", "]", ":", "'application/octet-stream'", ")", ";", "}" ]
Get the MIME type for a file extension. @param string $ext File extension @access public @return string MIME type of file. @static
[ "Get", "the", "MIME", "type", "for", "a", "file", "extension", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2947-L3040
19,465
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.set
public function set($name, $value = '') { try { if (isset($this->$name)) { $this->$name = $value; } else { throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL); } } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($exc->getCode() == self::STOP_CRITICAL) { return false; } } return true; }
php
public function set($name, $value = '') { try { if (isset($this->$name)) { $this->$name = $value; } else { throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL); } } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($exc->getCode() == self::STOP_CRITICAL) { return false; } } return true; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", "=", "''", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "this", "->", "$", "name", ")", ")", "{", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'variable_set'", ")", ".", "$", "name", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "}", "catch", "(", "Exception", "$", "exc", ")", "{", "$", "this", "->", "setError", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "exc", "->", "getCode", "(", ")", "==", "self", "::", "STOP_CRITICAL", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Set or reset instance properties. Usage Example: $page->set('X-Priority', '3'); @access public @param string $name @param mixed $value NOTE: will not work with arrays, there are no arrays to set/reset @throws phpmailerException @return boolean @TODO Should this not be using __set() magic function?
[ "Set", "or", "reset", "instance", "properties", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L3121-L3136
19,466
ClanCats/Core
src/classes/ClanCats.php
ClanCats.runtime
public static function runtime( $fnc = null, $params = array() ) { if ( is_null( $fnc ) ) { return static::$runtime_class; } return call_user_func_array( array( static::$runtime_class, $fnc ), $params ); }
php
public static function runtime( $fnc = null, $params = array() ) { if ( is_null( $fnc ) ) { return static::$runtime_class; } return call_user_func_array( array( static::$runtime_class, $fnc ), $params ); }
[ "public", "static", "function", "runtime", "(", "$", "fnc", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "fnc", ")", ")", "{", "return", "static", "::", "$", "runtime_class", ";", "}", "return", "call_user_func_array", "(", "array", "(", "static", "::", "$", "runtime_class", ",", "$", "fnc", ")", ",", "$", "params", ")", ";", "}" ]
get the current runtime class name or execute an function on the runtime class @return string
[ "get", "the", "current", "runtime", "class", "name", "or", "execute", "an", "function", "on", "the", "runtime", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L111-L119
19,467
ClanCats/Core
src/classes/ClanCats.php
ClanCats.paths
public static function paths( $paths = null, $define = true ) { if ( is_null( $paths ) ) { return static::$paths; } foreach( $paths as $key => $path ) { static::$paths[$key] = $path; if ( $define === true ) { define( strtoupper( $key ).'PATH', $path ); } } }
php
public static function paths( $paths = null, $define = true ) { if ( is_null( $paths ) ) { return static::$paths; } foreach( $paths as $key => $path ) { static::$paths[$key] = $path; if ( $define === true ) { define( strtoupper( $key ).'PATH', $path ); } } }
[ "public", "static", "function", "paths", "(", "$", "paths", "=", "null", ",", "$", "define", "=", "true", ")", "{", "if", "(", "is_null", "(", "$", "paths", ")", ")", "{", "return", "static", "::", "$", "paths", ";", "}", "foreach", "(", "$", "paths", "as", "$", "key", "=>", "$", "path", ")", "{", "static", "::", "$", "paths", "[", "$", "key", "]", "=", "$", "path", ";", "if", "(", "$", "define", "===", "true", ")", "{", "define", "(", "strtoupper", "(", "$", "key", ")", ".", "'PATH'", ",", "$", "path", ")", ";", "}", "}", "}" ]
paths getter and setter when paths empty: return all registerd paths when paths an array: adds paths to the index and optional create a define. @param array $paths @param bool $define @return array|void
[ "paths", "getter", "and", "setter" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L162-L178
19,468
ClanCats/Core
src/classes/ClanCats.php
ClanCats.directories
public static function directories( $dirs = null, $define = true ) { if ( is_null( $dirs ) ) { return static::$directories; } foreach( $dirs as $key => $dir ) { static::$directories[$key] = $dir; if ( $define === true ) { define( 'CCDIR_'.strtoupper( $key ), $dir ); } } }
php
public static function directories( $dirs = null, $define = true ) { if ( is_null( $dirs ) ) { return static::$directories; } foreach( $dirs as $key => $dir ) { static::$directories[$key] = $dir; if ( $define === true ) { define( 'CCDIR_'.strtoupper( $key ), $dir ); } } }
[ "public", "static", "function", "directories", "(", "$", "dirs", "=", "null", ",", "$", "define", "=", "true", ")", "{", "if", "(", "is_null", "(", "$", "dirs", ")", ")", "{", "return", "static", "::", "$", "directories", ";", "}", "foreach", "(", "$", "dirs", "as", "$", "key", "=>", "$", "dir", ")", "{", "static", "::", "$", "directories", "[", "$", "key", "]", "=", "$", "dir", ";", "if", "(", "$", "define", "===", "true", ")", "{", "define", "(", "'CCDIR_'", ".", "strtoupper", "(", "$", "key", ")", ",", "$", "dir", ")", ";", "}", "}", "}" ]
directories getter and setter when dirs empty: return all registerd directories when dirs an array: adds directories to the index and optional create a define. @param array $paths @param bool $define @return array|void
[ "directories", "getter", "and", "setter" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L193-L209
19,469
ClanCats/Core
src/classes/ClanCats.php
ClanCats.wake
public static function wake( $environment ) { if ( !is_null( static::$environment ) ) { throw new CCException( "ClanCats::wake - you cannot wake the application twice." ); } // set environment static::$environment = $environment; // load the main configuration static::$config = CCConfig::create( 'main' ); // setup the application error tables CCError_Inspector::info_callback( 'ClanCatsFramework', function() { return array( 'Runtime Class' => \ClanCats::runtime(), 'CCF Version' => \ClanCats::version(), 'CCF Environment' => \ClanCats::environment(), 'Development env' => var_export( \ClanCats::in_development(), true ), 'File extention' => EXT, 'Core namespace' => CCCORE_NAMESPACE, ); }); CCError_Inspector::info_callback( 'CCF Paths', array( 'ClanCats', 'paths' ) ); CCError_Inspector::info_callback( 'CCF Directories', array( 'ClanCats', 'directories' ) ); CCError_Inspector::info_callback( 'Namespaces', function() { return \CCFinder::$namespaces; }); }
php
public static function wake( $environment ) { if ( !is_null( static::$environment ) ) { throw new CCException( "ClanCats::wake - you cannot wake the application twice." ); } // set environment static::$environment = $environment; // load the main configuration static::$config = CCConfig::create( 'main' ); // setup the application error tables CCError_Inspector::info_callback( 'ClanCatsFramework', function() { return array( 'Runtime Class' => \ClanCats::runtime(), 'CCF Version' => \ClanCats::version(), 'CCF Environment' => \ClanCats::environment(), 'Development env' => var_export( \ClanCats::in_development(), true ), 'File extention' => EXT, 'Core namespace' => CCCORE_NAMESPACE, ); }); CCError_Inspector::info_callback( 'CCF Paths', array( 'ClanCats', 'paths' ) ); CCError_Inspector::info_callback( 'CCF Directories', array( 'ClanCats', 'directories' ) ); CCError_Inspector::info_callback( 'Namespaces', function() { return \CCFinder::$namespaces; }); }
[ "public", "static", "function", "wake", "(", "$", "environment", ")", "{", "if", "(", "!", "is_null", "(", "static", "::", "$", "environment", ")", ")", "{", "throw", "new", "CCException", "(", "\"ClanCats::wake - you cannot wake the application twice.\"", ")", ";", "}", "// set environment", "static", "::", "$", "environment", "=", "$", "environment", ";", "// load the main configuration", "static", "::", "$", "config", "=", "CCConfig", "::", "create", "(", "'main'", ")", ";", "// setup the application error tables", "CCError_Inspector", "::", "info_callback", "(", "'ClanCatsFramework'", ",", "function", "(", ")", "{", "return", "array", "(", "'Runtime Class'", "=>", "\\", "ClanCats", "::", "runtime", "(", ")", ",", "'CCF Version'", "=>", "\\", "ClanCats", "::", "version", "(", ")", ",", "'CCF Environment'", "=>", "\\", "ClanCats", "::", "environment", "(", ")", ",", "'Development env'", "=>", "var_export", "(", "\\", "ClanCats", "::", "in_development", "(", ")", ",", "true", ")", ",", "'File extention'", "=>", "EXT", ",", "'Core namespace'", "=>", "CCCORE_NAMESPACE", ",", ")", ";", "}", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'CCF Paths'", ",", "array", "(", "'ClanCats'", ",", "'paths'", ")", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'CCF Directories'", ",", "array", "(", "'ClanCats'", ",", "'directories'", ")", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'Namespaces'", ",", "function", "(", ")", "{", "return", "\\", "CCFinder", "::", "$", "namespaces", ";", "}", ")", ";", "}" ]
start the ccf lifecycle this method sets the current environment, loads the configuration and wakes the application @param string $environment @return void
[ "start", "the", "ccf", "lifecycle" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L292-L322
19,470
ClanCats/Core
src/classes/ClanCats.php
ClanCats.wake_app
public static function wake_app( $app ) { static::$runtime_class = $app; \CCFinder::bind( $app, static::$paths['app'].$app.EXT ); // run the application wake $response = $app::wake(); // when the application wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } $response = null; // run the environment wake if ( method_exists( $app, 'wake_'.static::$environment ) ) { $response = call_user_func( $app.'::wake_'.static::$environment ); // when the application env wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } } // add routes from the app CCRouter::on( $app::routes() ); }
php
public static function wake_app( $app ) { static::$runtime_class = $app; \CCFinder::bind( $app, static::$paths['app'].$app.EXT ); // run the application wake $response = $app::wake(); // when the application wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } $response = null; // run the environment wake if ( method_exists( $app, 'wake_'.static::$environment ) ) { $response = call_user_func( $app.'::wake_'.static::$environment ); // when the application env wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } } // add routes from the app CCRouter::on( $app::routes() ); }
[ "public", "static", "function", "wake_app", "(", "$", "app", ")", "{", "static", "::", "$", "runtime_class", "=", "$", "app", ";", "\\", "CCFinder", "::", "bind", "(", "$", "app", ",", "static", "::", "$", "paths", "[", "'app'", "]", ".", "$", "app", ".", "EXT", ")", ";", "// run the application wake", "$", "response", "=", "$", "app", "::", "wake", "(", ")", ";", "// when the application wake returns an response we display it", "if", "(", "$", "response", "instanceof", "CCResponse", ")", "{", "if", "(", "static", "::", "$", "config", "->", "send_app_wake_response", ")", "{", "$", "response", "->", "send", "(", "true", ")", ";", "die", ";", "}", "}", "$", "response", "=", "null", ";", "// run the environment wake", "if", "(", "method_exists", "(", "$", "app", ",", "'wake_'", ".", "static", "::", "$", "environment", ")", ")", "{", "$", "response", "=", "call_user_func", "(", "$", "app", ".", "'::wake_'", ".", "static", "::", "$", "environment", ")", ";", "// when the application env wake returns an response we display it", "if", "(", "$", "response", "instanceof", "CCResponse", ")", "{", "if", "(", "static", "::", "$", "config", "->", "send_app_wake_response", ")", "{", "$", "response", "->", "send", "(", "true", ")", ";", "die", ";", "}", "}", "}", "// add routes from the app", "CCRouter", "::", "on", "(", "$", "app", "::", "routes", "(", ")", ")", ";", "}" ]
start the ccf app lifecycle This method registers the App class and runs the wake events. @param string $app The used app class = APPATH/<$app>.php @return void
[ "start", "the", "ccf", "app", "lifecycle" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L332-L364
19,471
qcubed/orm
src/Query/Node/Column.php
Column.join
public function join( Builder $objBuilder, $blnExpandSelection = false, iCondition $objJoinCondition = null, Clause\Select $objSelect = null ) { $objParentNode = $this->objParentNode; if (!$objParentNode) { throw new Caller('A column node must have a parent node.'); } else { // Here we pass the join condition on to the parent object $objParentNode->join($objBuilder, $blnExpandSelection, $objJoinCondition, $objSelect); } }
php
public function join( Builder $objBuilder, $blnExpandSelection = false, iCondition $objJoinCondition = null, Clause\Select $objSelect = null ) { $objParentNode = $this->objParentNode; if (!$objParentNode) { throw new Caller('A column node must have a parent node.'); } else { // Here we pass the join condition on to the parent object $objParentNode->join($objBuilder, $blnExpandSelection, $objJoinCondition, $objSelect); } }
[ "public", "function", "join", "(", "Builder", "$", "objBuilder", ",", "$", "blnExpandSelection", "=", "false", ",", "iCondition", "$", "objJoinCondition", "=", "null", ",", "Clause", "\\", "Select", "$", "objSelect", "=", "null", ")", "{", "$", "objParentNode", "=", "$", "this", "->", "objParentNode", ";", "if", "(", "!", "$", "objParentNode", ")", "{", "throw", "new", "Caller", "(", "'A column node must have a parent node.'", ")", ";", "}", "else", "{", "// Here we pass the join condition on to the parent object", "$", "objParentNode", "->", "join", "(", "$", "objBuilder", ",", "$", "blnExpandSelection", ",", "$", "objJoinCondition", ",", "$", "objSelect", ")", ";", "}", "}" ]
Join the node to the given query. Since this is a leaf node, we pass on the join to the parent. @param Builder $objBuilder @param bool $blnExpandSelection @param iCondition|null $objJoinCondition @param Clause\Select|null $objSelect @throws Caller
[ "Join", "the", "node", "to", "the", "given", "query", ".", "Since", "this", "is", "a", "leaf", "node", "we", "pass", "on", "the", "join", "to", "the", "parent", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/Column.php#L96-L109
19,472
qcubed/orm
src/Query/Node/Column.php
Column.getAsManualSqlColumn
public function getAsManualSqlColumn() { if ($this->strTableName) { return $this->strTableName . '.' . $this->strName; } else { if (($this->objParentNode) && ($this->objParentNode->strTableName)) { return $this->objParentNode->strTableName . '.' . $this->strName; } else { return $this->strName; } } }
php
public function getAsManualSqlColumn() { if ($this->strTableName) { return $this->strTableName . '.' . $this->strName; } else { if (($this->objParentNode) && ($this->objParentNode->strTableName)) { return $this->objParentNode->strTableName . '.' . $this->strName; } else { return $this->strName; } } }
[ "public", "function", "getAsManualSqlColumn", "(", ")", "{", "if", "(", "$", "this", "->", "strTableName", ")", "{", "return", "$", "this", "->", "strTableName", ".", "'.'", ".", "$", "this", "->", "strName", ";", "}", "else", "{", "if", "(", "(", "$", "this", "->", "objParentNode", ")", "&&", "(", "$", "this", "->", "objParentNode", "->", "strTableName", ")", ")", "{", "return", "$", "this", "->", "objParentNode", "->", "strTableName", ".", "'.'", ".", "$", "this", "->", "strName", ";", "}", "else", "{", "return", "$", "this", "->", "strName", ";", "}", "}", "}" ]
Get the unaliased column name. For special situations, like order by, since you can't order by aliases. @return string
[ "Get", "the", "unaliased", "column", "name", ".", "For", "special", "situations", "like", "order", "by", "since", "you", "can", "t", "order", "by", "aliases", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/Column.php#L115-L126
19,473
meccado/acl-admin-control-panel
src/Http/Controllers/Admin/AdminController.php
AdminController.getUserRolePermissions
public function getUserRolePermissions() { $roles = Role::select('id', 'name', 'label')->get(); $permissions = Permission::select('id', 'name', 'label')->get(); return \View::make('admin.permissions.role-assign-permissions', [ 'roles' => $roles, 'permissions' => $permissions, 'title' => 'assign', ]); }
php
public function getUserRolePermissions() { $roles = Role::select('id', 'name', 'label')->get(); $permissions = Permission::select('id', 'name', 'label')->get(); return \View::make('admin.permissions.role-assign-permissions', [ 'roles' => $roles, 'permissions' => $permissions, 'title' => 'assign', ]); }
[ "public", "function", "getUserRolePermissions", "(", ")", "{", "$", "roles", "=", "Role", "::", "select", "(", "'id'", ",", "'name'", ",", "'label'", ")", "->", "get", "(", ")", ";", "$", "permissions", "=", "Permission", "::", "select", "(", "'id'", ",", "'name'", ",", "'label'", ")", "->", "get", "(", ")", ";", "return", "\\", "View", "::", "make", "(", "'admin.permissions.role-assign-permissions'", ",", "[", "'roles'", "=>", "$", "roles", ",", "'permissions'", "=>", "$", "permissions", ",", "'title'", "=>", "'assign'", ",", "]", ")", ";", "}" ]
Display given permissions to role. @return void
[ "Display", "given", "permissions", "to", "role", "." ]
50ac4c0dbf8bd49944ecad6a70708a70411b7378
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/AdminController.php#L45-L54
19,474
meccado/acl-admin-control-panel
src/Http/Controllers/Admin/AdminController.php
AdminController.postUserRolePermissions
public function postUserRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->assign($permission); } \Session::flash('flash_message', 'Permission granted!'); return \Redirect::route('admin.assign-role-permissions',[ ]); }
php
public function postUserRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->assign($permission); } \Session::flash('flash_message', 'Permission granted!'); return \Redirect::route('admin.assign-role-permissions',[ ]); }
[ "public", "function", "postUserRolePermissions", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'role'", "=>", "'required'", ",", "'permissions'", "=>", "'required'", "]", ")", ";", "$", "role", "=", "Role", "::", "with", "(", "'permissions'", ")", "->", "whereName", "(", "$", "request", "->", "role", ")", "->", "first", "(", ")", ";", "$", "role", "->", "permissions", "(", ")", "->", "detach", "(", ")", ";", "foreach", "(", "$", "request", "->", "permissions", "as", "$", "permission_name", ")", "{", "$", "permission", "=", "Permission", "::", "whereName", "(", "$", "permission_name", ")", "->", "first", "(", ")", ";", "$", "role", "->", "assign", "(", "$", "permission", ")", ";", "}", "\\", "Session", "::", "flash", "(", "'flash_message'", ",", "'Permission granted!'", ")", ";", "return", "\\", "Redirect", "::", "route", "(", "'admin.assign-role-permissions'", ",", "[", "]", ")", ";", "}" ]
Store given permissions to role. @param \Illuminate\Http\Request $request @return void
[ "Store", "given", "permissions", "to", "role", "." ]
50ac4c0dbf8bd49944ecad6a70708a70411b7378
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/AdminController.php#L64-L76
19,475
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.create
public static function create($paths, $cache = null, $debug = false) { $wise = new self($debug); if ($cache) { $wise->setCacheDir($cache); } $locator = new FileLocator($paths); $resolver = new LoaderResolver( array( new Loader\IniFileLoader($locator), new Loader\JsonFileLoader($locator), new Loader\PhpFileLoader($locator), new Loader\XmlFileLoader($locator), new Loader\YamlFileLoader($locator), ) ); $wise->setCollector(new Resource\ResourceCollector()); $wise->setLoader(new DelegatingLoader($resolver)); $resolver->setResourceCollector($wise->getCollector()); $resolver->setWise($wise); return $wise; }
php
public static function create($paths, $cache = null, $debug = false) { $wise = new self($debug); if ($cache) { $wise->setCacheDir($cache); } $locator = new FileLocator($paths); $resolver = new LoaderResolver( array( new Loader\IniFileLoader($locator), new Loader\JsonFileLoader($locator), new Loader\PhpFileLoader($locator), new Loader\XmlFileLoader($locator), new Loader\YamlFileLoader($locator), ) ); $wise->setCollector(new Resource\ResourceCollector()); $wise->setLoader(new DelegatingLoader($resolver)); $resolver->setResourceCollector($wise->getCollector()); $resolver->setWise($wise); return $wise; }
[ "public", "static", "function", "create", "(", "$", "paths", ",", "$", "cache", "=", "null", ",", "$", "debug", "=", "false", ")", "{", "$", "wise", "=", "new", "self", "(", "$", "debug", ")", ";", "if", "(", "$", "cache", ")", "{", "$", "wise", "->", "setCacheDir", "(", "$", "cache", ")", ";", "}", "$", "locator", "=", "new", "FileLocator", "(", "$", "paths", ")", ";", "$", "resolver", "=", "new", "LoaderResolver", "(", "array", "(", "new", "Loader", "\\", "IniFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "JsonFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "PhpFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "YamlFileLoader", "(", "$", "locator", ")", ",", ")", ")", ";", "$", "wise", "->", "setCollector", "(", "new", "Resource", "\\", "ResourceCollector", "(", ")", ")", ";", "$", "wise", "->", "setLoader", "(", "new", "DelegatingLoader", "(", "$", "resolver", ")", ")", ";", "$", "resolver", "->", "setResourceCollector", "(", "$", "wise", "->", "getCollector", "(", ")", ")", ";", "$", "resolver", "->", "setWise", "(", "$", "wise", ")", ";", "return", "$", "wise", ";", "}" ]
Creates a pre-configured instance of Wise. @param array|string $paths The configuration directory path(s). @param string $cache The cache directory path. @param boolean $debug Enable debugging? @return Wise The instance.
[ "Creates", "a", "pre", "-", "configured", "instance", "of", "Wise", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L90-L116
19,476
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.load
public function load($resource, $type = null, $require = false) { if (null === $this->loader) { throw new LogicException('No loader has been configured.'); } if (false === $this->loader->supports($resource, $type)) { throw LoaderException::format( 'The resource "%s"%s is not supported by the loader.', is_scalar($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } if ($this->cacheDir && $this->collector && is_string($resource) && (false === strpos("\n", $resource)) && (false === strpos("\r", $resource))) { $cache = new ConfigCache( $this->cacheDir . DIRECTORY_SEPARATOR . basename($resource) . '.cache', $this->debug ); if ($cache->isFresh()) { /** @noinspection PhpIncludeInspection */ return require $cache; } } if ($this->collector) { $this->collector->clearResources(); } $data = $this->process( $this->loader->load($resource, $type), $resource, $type, $require ); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', $this->collector->getResources() ); } return $data; }
php
public function load($resource, $type = null, $require = false) { if (null === $this->loader) { throw new LogicException('No loader has been configured.'); } if (false === $this->loader->supports($resource, $type)) { throw LoaderException::format( 'The resource "%s"%s is not supported by the loader.', is_scalar($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } if ($this->cacheDir && $this->collector && is_string($resource) && (false === strpos("\n", $resource)) && (false === strpos("\r", $resource))) { $cache = new ConfigCache( $this->cacheDir . DIRECTORY_SEPARATOR . basename($resource) . '.cache', $this->debug ); if ($cache->isFresh()) { /** @noinspection PhpIncludeInspection */ return require $cache; } } if ($this->collector) { $this->collector->clearResources(); } $data = $this->process( $this->loader->load($resource, $type), $resource, $type, $require ); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', $this->collector->getResources() ); } return $data; }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ",", "$", "require", "=", "false", ")", "{", "if", "(", "null", "===", "$", "this", "->", "loader", ")", "{", "throw", "new", "LogicException", "(", "'No loader has been configured.'", ")", ";", "}", "if", "(", "false", "===", "$", "this", "->", "loader", "->", "supports", "(", "$", "resource", ",", "$", "type", ")", ")", "{", "throw", "LoaderException", "::", "format", "(", "'The resource \"%s\"%s is not supported by the loader.'", ",", "is_scalar", "(", "$", "resource", ")", "?", "$", "resource", ":", "gettype", "(", "$", "resource", ")", ",", "$", "type", "?", "\" ($type)\"", ":", "''", ")", ";", "}", "if", "(", "$", "this", "->", "cacheDir", "&&", "$", "this", "->", "collector", "&&", "is_string", "(", "$", "resource", ")", "&&", "(", "false", "===", "strpos", "(", "\"\\n\"", ",", "$", "resource", ")", ")", "&&", "(", "false", "===", "strpos", "(", "\"\\r\"", ",", "$", "resource", ")", ")", ")", "{", "$", "cache", "=", "new", "ConfigCache", "(", "$", "this", "->", "cacheDir", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "resource", ")", ".", "'.cache'", ",", "$", "this", "->", "debug", ")", ";", "if", "(", "$", "cache", "->", "isFresh", "(", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "return", "require", "$", "cache", ";", "}", "}", "if", "(", "$", "this", "->", "collector", ")", "{", "$", "this", "->", "collector", "->", "clearResources", "(", ")", ";", "}", "$", "data", "=", "$", "this", "->", "process", "(", "$", "this", "->", "loader", "->", "load", "(", "$", "resource", ",", "$", "type", ")", ",", "$", "resource", ",", "$", "type", ",", "$", "require", ")", ";", "if", "(", "isset", "(", "$", "cache", ")", ")", "{", "$", "cache", "->", "write", "(", "'<?php return '", ".", "var_export", "(", "$", "data", ",", "true", ")", ".", "';'", ",", "$", "this", "->", "collector", "->", "getResources", "(", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Loads the configuration data from a resource. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The data. @throws LoaderException If the loader could not be used. @throws LogicException If no loader has been configured.
[ "Loads", "the", "configuration", "data", "from", "a", "resource", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L190-L239
19,477
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.loadFlat
public function loadFlat($resource, $type = null, $require = false) { return ArrayUtil::flatten($this->load($resource, $type, $require)); }
php
public function loadFlat($resource, $type = null, $require = false) { return ArrayUtil::flatten($this->load($resource, $type, $require)); }
[ "public", "function", "loadFlat", "(", "$", "resource", ",", "$", "type", "=", "null", ",", "$", "require", "=", "false", ")", "{", "return", "ArrayUtil", "::", "flatten", "(", "$", "this", "->", "load", "(", "$", "resource", ",", "$", "type", ",", "$", "require", ")", ")", ";", "}" ]
Loads the configuration data from a resource and returns it flattened. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The data.
[ "Loads", "the", "configuration", "data", "from", "a", "resource", "and", "returns", "it", "flattened", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L250-L253
19,478
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setCollector
public function setCollector(ResourceCollectorInterface $collector) { $this->collector = $collector; if ($this->loader) { if ($this->loader instanceof ResourceAwareInterface) { $this->loader->setResourceCollector($collector); } if ($this->loader instanceof DelegatingLoader) { $resolver = $this->loader->getResolver(); if ($resolver instanceof ResourceAwareInterface) { $resolver->setResourceCollector($collector); } } } }
php
public function setCollector(ResourceCollectorInterface $collector) { $this->collector = $collector; if ($this->loader) { if ($this->loader instanceof ResourceAwareInterface) { $this->loader->setResourceCollector($collector); } if ($this->loader instanceof DelegatingLoader) { $resolver = $this->loader->getResolver(); if ($resolver instanceof ResourceAwareInterface) { $resolver->setResourceCollector($collector); } } } }
[ "public", "function", "setCollector", "(", "ResourceCollectorInterface", "$", "collector", ")", "{", "$", "this", "->", "collector", "=", "$", "collector", ";", "if", "(", "$", "this", "->", "loader", ")", "{", "if", "(", "$", "this", "->", "loader", "instanceof", "ResourceAwareInterface", ")", "{", "$", "this", "->", "loader", "->", "setResourceCollector", "(", "$", "collector", ")", ";", "}", "if", "(", "$", "this", "->", "loader", "instanceof", "DelegatingLoader", ")", "{", "$", "resolver", "=", "$", "this", "->", "loader", "->", "getResolver", "(", ")", ";", "if", "(", "$", "resolver", "instanceof", "ResourceAwareInterface", ")", "{", "$", "resolver", "->", "setResourceCollector", "(", "$", "collector", ")", ";", "}", "}", "}", "}" ]
Sets the resource collector. @param ResourceCollectorInterface $collector The collector.
[ "Sets", "the", "resource", "collector", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L270-L287
19,479
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setGlobalParameters
public function setGlobalParameters($parameters) { if (!is_array($parameters) && !($parameters instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The $parameters argument must be an array or array accessible object.' ); } $this->parameters = $parameters; }
php
public function setGlobalParameters($parameters) { if (!is_array($parameters) && !($parameters instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The $parameters argument must be an array or array accessible object.' ); } $this->parameters = $parameters; }
[ "public", "function", "setGlobalParameters", "(", "$", "parameters", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameters", ")", "&&", "!", "(", "$", "parameters", "instanceof", "ArrayAccess", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The $parameters argument must be an array or array accessible object.'", ")", ";", "}", "$", "this", "->", "parameters", "=", "$", "parameters", ";", "}" ]
Sets a list of global parameters. @param array|ArrayAccess $parameters The parameters. @throws InvalidArgumentException If $parameters is invalid.
[ "Sets", "a", "list", "of", "global", "parameters", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L296-L305
19,480
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setLoader
public function setLoader(LoaderInterface $loader) { $this->loader = $loader; if ($this->collector && ($loader instanceof ResourceAwareInterface)) { $loader->setResourceCollector($this->collector); } if ($loader instanceof WiseAwareInterface) { $loader->setWise($this); } if ($loader instanceof DelegatingLoader) { $resolver = $loader->getResolver(); if ($this->collector && ($resolver instanceof ResourceAwareInterface)) { $resolver->setResourceCollector($this->collector); } if ($resolver instanceof WiseAwareInterface) { $resolver->setWise($this); } } }
php
public function setLoader(LoaderInterface $loader) { $this->loader = $loader; if ($this->collector && ($loader instanceof ResourceAwareInterface)) { $loader->setResourceCollector($this->collector); } if ($loader instanceof WiseAwareInterface) { $loader->setWise($this); } if ($loader instanceof DelegatingLoader) { $resolver = $loader->getResolver(); if ($this->collector && ($resolver instanceof ResourceAwareInterface)) { $resolver->setResourceCollector($this->collector); } if ($resolver instanceof WiseAwareInterface) { $resolver->setWise($this); } } }
[ "public", "function", "setLoader", "(", "LoaderInterface", "$", "loader", ")", "{", "$", "this", "->", "loader", "=", "$", "loader", ";", "if", "(", "$", "this", "->", "collector", "&&", "(", "$", "loader", "instanceof", "ResourceAwareInterface", ")", ")", "{", "$", "loader", "->", "setResourceCollector", "(", "$", "this", "->", "collector", ")", ";", "}", "if", "(", "$", "loader", "instanceof", "WiseAwareInterface", ")", "{", "$", "loader", "->", "setWise", "(", "$", "this", ")", ";", "}", "if", "(", "$", "loader", "instanceof", "DelegatingLoader", ")", "{", "$", "resolver", "=", "$", "loader", "->", "getResolver", "(", ")", ";", "if", "(", "$", "this", "->", "collector", "&&", "(", "$", "resolver", "instanceof", "ResourceAwareInterface", ")", ")", "{", "$", "resolver", "->", "setResourceCollector", "(", "$", "this", "->", "collector", ")", ";", "}", "if", "(", "$", "resolver", "instanceof", "WiseAwareInterface", ")", "{", "$", "resolver", "->", "setWise", "(", "$", "this", ")", ";", "}", "}", "}" ]
Sets a configuration loader. @param LoaderInterface $loader A loader.
[ "Sets", "a", "configuration", "loader", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L312-L336
19,481
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.process
private function process(array $data, $resource, $type, $require) { if ($this->processor) { if ($this->processor instanceof ProcessorInterface) { if ($this->processor->supports($resource, $type)) { $data = $this->processor->process($data); } elseif ($require) { throw ProcessorException::format( 'The resource "%s"%s is not supported by the processor.', is_string($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } } else { $processor = new Processor(); $data = $processor->processConfiguration( $this->processor, $data ); } } elseif ($require) { throw ProcessorException::format( 'No processor registered to handle any resource.' ); } return $data; }
php
private function process(array $data, $resource, $type, $require) { if ($this->processor) { if ($this->processor instanceof ProcessorInterface) { if ($this->processor->supports($resource, $type)) { $data = $this->processor->process($data); } elseif ($require) { throw ProcessorException::format( 'The resource "%s"%s is not supported by the processor.', is_string($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } } else { $processor = new Processor(); $data = $processor->processConfiguration( $this->processor, $data ); } } elseif ($require) { throw ProcessorException::format( 'No processor registered to handle any resource.' ); } return $data; }
[ "private", "function", "process", "(", "array", "$", "data", ",", "$", "resource", ",", "$", "type", ",", "$", "require", ")", "{", "if", "(", "$", "this", "->", "processor", ")", "{", "if", "(", "$", "this", "->", "processor", "instanceof", "ProcessorInterface", ")", "{", "if", "(", "$", "this", "->", "processor", "->", "supports", "(", "$", "resource", ",", "$", "type", ")", ")", "{", "$", "data", "=", "$", "this", "->", "processor", "->", "process", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "require", ")", "{", "throw", "ProcessorException", "::", "format", "(", "'The resource \"%s\"%s is not supported by the processor.'", ",", "is_string", "(", "$", "resource", ")", "?", "$", "resource", ":", "gettype", "(", "$", "resource", ")", ",", "$", "type", "?", "\" ($type)\"", ":", "''", ")", ";", "}", "}", "else", "{", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "data", "=", "$", "processor", "->", "processConfiguration", "(", "$", "this", "->", "processor", ",", "$", "data", ")", ";", "}", "}", "elseif", "(", "$", "require", ")", "{", "throw", "ProcessorException", "::", "format", "(", "'No processor registered to handle any resource.'", ")", ";", "}", "return", "$", "data", ";", "}" ]
Processes the configuration definition. @param array $data The configuration data. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The processed configuration data. @throws ProcessorException If the processor could not be used and it is require that one be used.
[ "Processes", "the", "configuration", "definition", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L361-L388
19,482
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.create
public static function create( $path ) { if ( is_null( $path ) ) { return new static(); } // use the orbit path if we are relative if ( substr( $path, 0, 1 ) != '/' ) { $path = ORBITPATH.$path; } // check the path if ( substr( $path, -1 ) != '/' ) { $path .= '/'; } $blueprint = $path.'blueprint.json'; if ( !file_exists( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}." ); } if ( !$blueprint_data = CCJson::read( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - invalid blueprint at {$blueprint}." ); } return static::blueprint( $blueprint_data, $path ); }
php
public static function create( $path ) { if ( is_null( $path ) ) { return new static(); } // use the orbit path if we are relative if ( substr( $path, 0, 1 ) != '/' ) { $path = ORBITPATH.$path; } // check the path if ( substr( $path, -1 ) != '/' ) { $path .= '/'; } $blueprint = $path.'blueprint.json'; if ( !file_exists( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}." ); } if ( !$blueprint_data = CCJson::read( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - invalid blueprint at {$blueprint}." ); } return static::blueprint( $blueprint_data, $path ); }
[ "public", "static", "function", "create", "(", "$", "path", ")", "{", "if", "(", "is_null", "(", "$", "path", ")", ")", "{", "return", "new", "static", "(", ")", ";", "}", "// use the orbit path if we are relative", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "!=", "'/'", ")", "{", "$", "path", "=", "ORBITPATH", ".", "$", "path", ";", "}", "// check the path", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "path", ".=", "'/'", ";", "}", "$", "blueprint", "=", "$", "path", ".", "'blueprint.json'", ";", "if", "(", "!", "file_exists", "(", "$", "blueprint", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}.\"", ")", ";", "}", "if", "(", "!", "$", "blueprint_data", "=", "CCJson", "::", "read", "(", "$", "blueprint", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCOrbit_Ship::create - invalid blueprint at {$blueprint}.\"", ")", ";", "}", "return", "static", "::", "blueprint", "(", "$", "blueprint_data", ",", "$", "path", ")", ";", "}" ]
create an new ship object from path @param string $path @return CCOrbit_Ship
[ "create", "an", "new", "ship", "object", "from", "path" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L21-L53
19,483
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.blueprint
public static function blueprint( $data, $path ) { if ( !is_array( $data ) ) { throw new \InvalidArgumentException( "CCOrbit_Ship::blueprint - first argument has to be an array." ); } $ship = new static(); $name = $data['name']; $namespace = $data['namespace']; // check if we have a name if not use dir name if ( is_null( $name ) ) { $name = basename( $path ); } // get ship namespace if ( $namespace === true ) { $namespace = $name; } // try to load other ship class if ( is_string( $namespace ) ) { // register the namespace \CCFinder::bundle( $namespace, $path ); $class = $namespace.'\\Ship'; if ( class_exists( $class ) ) { $ship = new $class(); } } // set the path $ship->name = $name; $ship->path = $path; $ship->namespace = $namespace; // assign the data foreach( $data as $key => $item ) { if ( property_exists( $ship, $key ) ) { $ship->$key = $item; } } // check the namespace if ( $ship->namespace === false ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'shipyard/wake'.EXT; } if ( is_null( $ship->install ) ) { $ship->install = 'shipyard/install'.EXT; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'shipyard/uninstall'.EXT; } } elseif ( is_string( $ship->namespace ) ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'Ship::wake'; } if ( is_null( $ship->install ) ) { $ship->install = 'Ship::install'; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'Ship::uninstall'; } } return $ship; }
php
public static function blueprint( $data, $path ) { if ( !is_array( $data ) ) { throw new \InvalidArgumentException( "CCOrbit_Ship::blueprint - first argument has to be an array." ); } $ship = new static(); $name = $data['name']; $namespace = $data['namespace']; // check if we have a name if not use dir name if ( is_null( $name ) ) { $name = basename( $path ); } // get ship namespace if ( $namespace === true ) { $namespace = $name; } // try to load other ship class if ( is_string( $namespace ) ) { // register the namespace \CCFinder::bundle( $namespace, $path ); $class = $namespace.'\\Ship'; if ( class_exists( $class ) ) { $ship = new $class(); } } // set the path $ship->name = $name; $ship->path = $path; $ship->namespace = $namespace; // assign the data foreach( $data as $key => $item ) { if ( property_exists( $ship, $key ) ) { $ship->$key = $item; } } // check the namespace if ( $ship->namespace === false ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'shipyard/wake'.EXT; } if ( is_null( $ship->install ) ) { $ship->install = 'shipyard/install'.EXT; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'shipyard/uninstall'.EXT; } } elseif ( is_string( $ship->namespace ) ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'Ship::wake'; } if ( is_null( $ship->install ) ) { $ship->install = 'Ship::install'; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'Ship::uninstall'; } } return $ship; }
[ "public", "static", "function", "blueprint", "(", "$", "data", ",", "$", "path", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCOrbit_Ship::blueprint - first argument has to be an array.\"", ")", ";", "}", "$", "ship", "=", "new", "static", "(", ")", ";", "$", "name", "=", "$", "data", "[", "'name'", "]", ";", "$", "namespace", "=", "$", "data", "[", "'namespace'", "]", ";", "// check if we have a name if not use dir name", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "basename", "(", "$", "path", ")", ";", "}", "// get ship namespace", "if", "(", "$", "namespace", "===", "true", ")", "{", "$", "namespace", "=", "$", "name", ";", "}", "// try to load other ship class", "if", "(", "is_string", "(", "$", "namespace", ")", ")", "{", "// register the namespace", "\\", "CCFinder", "::", "bundle", "(", "$", "namespace", ",", "$", "path", ")", ";", "$", "class", "=", "$", "namespace", ".", "'\\\\Ship'", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "ship", "=", "new", "$", "class", "(", ")", ";", "}", "}", "// set the path", "$", "ship", "->", "name", "=", "$", "name", ";", "$", "ship", "->", "path", "=", "$", "path", ";", "$", "ship", "->", "namespace", "=", "$", "namespace", ";", "// assign the data", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "property_exists", "(", "$", "ship", ",", "$", "key", ")", ")", "{", "$", "ship", "->", "$", "key", "=", "$", "item", ";", "}", "}", "// check the namespace", "if", "(", "$", "ship", "->", "namespace", "===", "false", ")", "{", "if", "(", "is_null", "(", "$", "ship", "->", "wake", ")", ")", "{", "$", "ship", "->", "wake", "=", "'shipyard/wake'", ".", "EXT", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "install", ")", ")", "{", "$", "ship", "->", "install", "=", "'shipyard/install'", ".", "EXT", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "uninstall", ")", ")", "{", "$", "ship", "->", "uninstall", "=", "'shipyard/uninstall'", ".", "EXT", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "ship", "->", "namespace", ")", ")", "{", "if", "(", "is_null", "(", "$", "ship", "->", "wake", ")", ")", "{", "$", "ship", "->", "wake", "=", "'Ship::wake'", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "install", ")", ")", "{", "$", "ship", "->", "install", "=", "'Ship::install'", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "uninstall", ")", ")", "{", "$", "ship", "->", "uninstall", "=", "'Ship::uninstall'", ";", "}", "}", "return", "$", "ship", ";", "}" ]
create new ship with given data @param array $data @return CCOrbit_Ship
[ "create", "new", "ship", "with", "given", "data" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L61-L146
19,484
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.event
public function event( $event ) { // call the wake event if ( is_string( $this->namespace ) ) { if ( strpos( $event, '::' ) !== false ) { $callback = explode( '::', $event ); $class = $this->namespace."\\".$callback[0]; if ( class_exists( $class ) ) { call_user_func( array( $this, $callback[1] ) ); } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } }
php
public function event( $event ) { // call the wake event if ( is_string( $this->namespace ) ) { if ( strpos( $event, '::' ) !== false ) { $callback = explode( '::', $event ); $class = $this->namespace."\\".$callback[0]; if ( class_exists( $class ) ) { call_user_func( array( $this, $callback[1] ) ); } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } }
[ "public", "function", "event", "(", "$", "event", ")", "{", "// call the wake event", "if", "(", "is_string", "(", "$", "this", "->", "namespace", ")", ")", "{", "if", "(", "strpos", "(", "$", "event", ",", "'::'", ")", "!==", "false", ")", "{", "$", "callback", "=", "explode", "(", "'::'", ",", "$", "event", ")", ";", "$", "class", "=", "$", "this", "->", "namespace", ".", "\"\\\\\"", ".", "$", "callback", "[", "0", "]", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "callback", "[", "1", "]", ")", ")", ";", "}", "}", "else", "{", "if", "(", "is_file", "(", "$", "this", "->", "path", ".", "$", "event", ")", ")", "{", "require", "$", "this", "->", "path", ".", "$", "event", ";", "}", "}", "}", "else", "{", "if", "(", "is_file", "(", "$", "this", "->", "path", ".", "$", "event", ")", ")", "{", "require", "$", "this", "->", "path", ".", "$", "event", ";", "}", "}", "}" ]
run an event on this object
[ "run", "an", "event", "on", "this", "object" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L202-L232
19,485
Kylob/Bootstrap
src/Form.php
Form.align
public function align($direction = 'horizontal', $collapse = 'sm', $indent = 2) { if ($direction == 'collapse') { $this->align = ''; } elseif ($direction == 'inline') { $this->align = 'form-inline'; } else { $this->align = 'form-horizontal'; $this->collapse = (in_array($collapse, array('xs', 'sm', 'md', 'lg'))) ? $collapse : 'sm'; $this->indent = (is_numeric($indent) && $indent > 0 && $indent < 12) ? $indent : 2; } }
php
public function align($direction = 'horizontal', $collapse = 'sm', $indent = 2) { if ($direction == 'collapse') { $this->align = ''; } elseif ($direction == 'inline') { $this->align = 'form-inline'; } else { $this->align = 'form-horizontal'; $this->collapse = (in_array($collapse, array('xs', 'sm', 'md', 'lg'))) ? $collapse : 'sm'; $this->indent = (is_numeric($indent) && $indent > 0 && $indent < 12) ? $indent : 2; } }
[ "public", "function", "align", "(", "$", "direction", "=", "'horizontal'", ",", "$", "collapse", "=", "'sm'", ",", "$", "indent", "=", "2", ")", "{", "if", "(", "$", "direction", "==", "'collapse'", ")", "{", "$", "this", "->", "align", "=", "''", ";", "}", "elseif", "(", "$", "direction", "==", "'inline'", ")", "{", "$", "this", "->", "align", "=", "'form-inline'", ";", "}", "else", "{", "$", "this", "->", "align", "=", "'form-horizontal'", ";", "$", "this", "->", "collapse", "=", "(", "in_array", "(", "$", "collapse", ",", "array", "(", "'xs'", ",", "'sm'", ",", "'md'", ",", "'lg'", ")", ")", ")", "?", "$", "collapse", ":", "'sm'", ";", "$", "this", "->", "indent", "=", "(", "is_numeric", "(", "$", "indent", ")", "&&", "$", "indent", ">", "0", "&&", "$", "indent", "<", "12", ")", "?", "$", "indent", ":", "2", ";", "}", "}" ]
Utilize any Bootstrap form style. @param string $direction The options are: - '**collapse**' - This will display the form prompt immediately above the field. - '**inline**' - All of the fields will be inline with each other, and the form prompts will be removed. - '**horizontal**' - Vertically aligns all of the fields with the prompt immediately preceding, and right aligned. @param string $collapse Either '**xs**', '**sm**', '**md**', or '**lg**'. This is the breaking point so to speak for a '**horizontal**' form. It is the device size on which the form will '**collapse**'. @param int $indent The number of columns (up to 12) that you would like to indent the field in a '**horizontal**' form. @example ```php $form->align('collapse'); ```
[ "Utilize", "any", "Bootstrap", "form", "style", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L118-L129
19,486
Kylob/Bootstrap
src/Form.php
Form.prompt
public function prompt($place, $html, $required = false) { switch ($place) { case 'info': case 'append': $this->prompt[$place] = $html; break; case 'prepend': $this->prompt['prepend'] = array('html' => $html, 'required' => (bool) $required); break; } }
php
public function prompt($place, $html, $required = false) { switch ($place) { case 'info': case 'append': $this->prompt[$place] = $html; break; case 'prepend': $this->prompt['prepend'] = array('html' => $html, 'required' => (bool) $required); break; } }
[ "public", "function", "prompt", "(", "$", "place", ",", "$", "html", ",", "$", "required", "=", "false", ")", "{", "switch", "(", "$", "place", ")", "{", "case", "'info'", ":", "case", "'append'", ":", "$", "this", "->", "prompt", "[", "$", "place", "]", "=", "$", "html", ";", "break", ";", "case", "'prepend'", ":", "$", "this", "->", "prompt", "[", "'prepend'", "]", "=", "array", "(", "'html'", "=>", "$", "html", ",", "'required'", "=>", "(", "bool", ")", "$", "required", ")", ";", "break", ";", "}", "}" ]
This is to add html tags, or semicolons, or asterisks, or whatever you would like to all of the form's prompts. @param string $place Either '**info**', '**append**', or '**prepend**' to the prompt. You only have one shot at each. @param string $html Whatever you would like to add. For '**info**', this will be the icon class you want to use. @param mixed $required If ``$place == 'prepend'`` and this is anything but (bool) false, then the **$html** will only be prepended if the ``$form->validator->required('field')``. @example ```php $form->prompt('prepend', '<font color="red">*</font> ', 'required'); // If the field is required it will add a red asterisk to the front. $form->prompt('append', ':'); // Adds a semicolon to all of the prompts. ```
[ "This", "is", "to", "add", "html", "tags", "or", "semicolons", "or", "asterisks", "or", "whatever", "you", "would", "like", "to", "all", "of", "the", "form", "s", "prompts", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L146-L157
19,487
Kylob/Bootstrap
src/Form.php
Form.submit
public function submit($submit = 'Submit', $reset = '') { // never use name="submit" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form $buttons = func_get_args(); if (substr($submit, 0, 1) != '<') { $buttons[0] = $this->page->tag('button', array( 'type' => 'submit', 'class' => array('btn', 'btn-primary', str_replace('input', 'btn', $this->input)), 'data-loading-text' => 'Submitting...', ), $submit); } if (isset($buttons[1]) && substr($reset, 0, 1) != '<') { $buttons[1] = $this->page->tag('button', array( 'type' => 'reset', 'class' => array('btn', 'btn-default', str_replace('input', 'btn', $this->input)), ), $reset); } return $this->field('', implode(' ', $buttons)); }
php
public function submit($submit = 'Submit', $reset = '') { // never use name="submit" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form $buttons = func_get_args(); if (substr($submit, 0, 1) != '<') { $buttons[0] = $this->page->tag('button', array( 'type' => 'submit', 'class' => array('btn', 'btn-primary', str_replace('input', 'btn', $this->input)), 'data-loading-text' => 'Submitting...', ), $submit); } if (isset($buttons[1]) && substr($reset, 0, 1) != '<') { $buttons[1] = $this->page->tag('button', array( 'type' => 'reset', 'class' => array('btn', 'btn-default', str_replace('input', 'btn', $this->input)), ), $reset); } return $this->field('', implode(' ', $buttons)); }
[ "public", "function", "submit", "(", "$", "submit", "=", "'Submit'", ",", "$", "reset", "=", "''", ")", "{", "// never use name=\"submit\" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form", "$", "buttons", "=", "func_get_args", "(", ")", ";", "if", "(", "substr", "(", "$", "submit", ",", "0", ",", "1", ")", "!=", "'<'", ")", "{", "$", "buttons", "[", "0", "]", "=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "array", "(", "'type'", "=>", "'submit'", ",", "'class'", "=>", "array", "(", "'btn'", ",", "'btn-primary'", ",", "str_replace", "(", "'input'", ",", "'btn'", ",", "$", "this", "->", "input", ")", ")", ",", "'data-loading-text'", "=>", "'Submitting...'", ",", ")", ",", "$", "submit", ")", ";", "}", "if", "(", "isset", "(", "$", "buttons", "[", "1", "]", ")", "&&", "substr", "(", "$", "reset", ",", "0", ",", "1", ")", "!=", "'<'", ")", "{", "$", "buttons", "[", "1", "]", "=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "array", "(", "'type'", "=>", "'reset'", ",", "'class'", "=>", "array", "(", "'btn'", ",", "'btn-default'", ",", "str_replace", "(", "'input'", ",", "'btn'", ",", "$", "this", "->", "input", ")", ")", ",", ")", ",", "$", "reset", ")", ";", "}", "return", "$", "this", "->", "field", "(", "''", ",", "implode", "(", "' '", ",", "$", "buttons", ")", ")", ";", "}" ]
Quickly adds a submit button to your form. @param string $submit What you would like the submit button to say. If it starts with a '**<**', then we assume you have spelled it all out for us. @param string $reset This will add a reset button if you give it a value, and if it starts with a '**<**' then it can be whatever you want it to be. You can keep adding args until you run out of ideas for buttons to include. @return string A ``<div class="form-group">...</div>`` html string with buttons. @example ```php echo $form->submit(); ```
[ "Quickly", "adds", "a", "submit", "button", "to", "your", "form", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L372-L391
19,488
Double-Opt-in/php-client-api
src/Client/Commands/Responses/DecryptedCommandResponse.php
DecryptedCommandResponse.assignCryptographyEngine
public function assignCryptographyEngine(CryptographyEngine $cryptographyEngine, $email) { $this->cryptographyEngine = $cryptographyEngine; $this->email = $email; }
php
public function assignCryptographyEngine(CryptographyEngine $cryptographyEngine, $email) { $this->cryptographyEngine = $cryptographyEngine; $this->email = $email; }
[ "public", "function", "assignCryptographyEngine", "(", "CryptographyEngine", "$", "cryptographyEngine", ",", "$", "email", ")", "{", "$", "this", "->", "cryptographyEngine", "=", "$", "cryptographyEngine", ";", "$", "this", "->", "email", "=", "$", "email", ";", "}" ]
assigns the cryptography engine @param \DoubleOptIn\ClientApi\Security\CryptographyEngine $cryptographyEngine @param string $email @return void
[ "assigns", "the", "cryptography", "engine" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/DecryptedCommandResponse.php#L38-L42
19,489
Double-Opt-in/php-client-api
src/Client/Commands/Responses/DecryptedCommandResponse.php
DecryptedCommandResponse.resolveActionFromStdClass
protected function resolveActionFromStdClass(stdClass $stdClass) { if (isset($stdClass->data)) $stdClass->data = $this->cryptographyEngine->decrypt($stdClass->data, $this->email); return Action::createFromStdClass($stdClass); }
php
protected function resolveActionFromStdClass(stdClass $stdClass) { if (isset($stdClass->data)) $stdClass->data = $this->cryptographyEngine->decrypt($stdClass->data, $this->email); return Action::createFromStdClass($stdClass); }
[ "protected", "function", "resolveActionFromStdClass", "(", "stdClass", "$", "stdClass", ")", "{", "if", "(", "isset", "(", "$", "stdClass", "->", "data", ")", ")", "$", "stdClass", "->", "data", "=", "$", "this", "->", "cryptographyEngine", "->", "decrypt", "(", "$", "stdClass", "->", "data", ",", "$", "this", "->", "email", ")", ";", "return", "Action", "::", "createFromStdClass", "(", "$", "stdClass", ")", ";", "}" ]
resolves an action from a stdClass @param \stdClass $stdClass @return Action
[ "resolves", "an", "action", "from", "a", "stdClass" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/DecryptedCommandResponse.php#L51-L57
19,490
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedGDBackend.php
ExtendedGDBackend.merge
public function merge(GDBackend $image){ imagealphablending($this->owner->getImageResource(), false); imagesavealpha($this->owner->getImageResource(), true); imagealphablending($image->getImageResource(), false); imagesavealpha($image->getImageResource(), true); $srcX = 0; $srcY = 0; $srcW = $image->getWidth(); $srcH = $image->getHeight(); $dstX = round(($this->owner->getWidth() - $srcW)/2); $dstY = round(($this->owner->getHeight() - $srcH)/2); $dstW = $image->getWidth(); $dstH = $image->getHeight(); imagecopyresampled($this->owner->getImageResource(), $image->getImageResource(), $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); $output = clone $this->owner; $output->setImageResource($this->owner->getImageResource()); return $output; }
php
public function merge(GDBackend $image){ imagealphablending($this->owner->getImageResource(), false); imagesavealpha($this->owner->getImageResource(), true); imagealphablending($image->getImageResource(), false); imagesavealpha($image->getImageResource(), true); $srcX = 0; $srcY = 0; $srcW = $image->getWidth(); $srcH = $image->getHeight(); $dstX = round(($this->owner->getWidth() - $srcW)/2); $dstY = round(($this->owner->getHeight() - $srcH)/2); $dstW = $image->getWidth(); $dstH = $image->getHeight(); imagecopyresampled($this->owner->getImageResource(), $image->getImageResource(), $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); $output = clone $this->owner; $output->setImageResource($this->owner->getImageResource()); return $output; }
[ "public", "function", "merge", "(", "GDBackend", "$", "image", ")", "{", "imagealphablending", "(", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ",", "false", ")", ";", "imagesavealpha", "(", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ",", "true", ")", ";", "imagealphablending", "(", "$", "image", "->", "getImageResource", "(", ")", ",", "false", ")", ";", "imagesavealpha", "(", "$", "image", "->", "getImageResource", "(", ")", ",", "true", ")", ";", "$", "srcX", "=", "0", ";", "$", "srcY", "=", "0", ";", "$", "srcW", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "srcH", "=", "$", "image", "->", "getHeight", "(", ")", ";", "$", "dstX", "=", "round", "(", "(", "$", "this", "->", "owner", "->", "getWidth", "(", ")", "-", "$", "srcW", ")", "/", "2", ")", ";", "$", "dstY", "=", "round", "(", "(", "$", "this", "->", "owner", "->", "getHeight", "(", ")", "-", "$", "srcH", ")", "/", "2", ")", ";", "$", "dstW", "=", "$", "image", "->", "getWidth", "(", ")", ";", "$", "dstH", "=", "$", "image", "->", "getHeight", "(", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ",", "$", "image", "->", "getImageResource", "(", ")", ",", "$", "dstX", ",", "$", "dstY", ",", "$", "srcX", ",", "$", "srcY", ",", "$", "dstW", ",", "$", "dstH", ",", "$", "srcW", ",", "$", "srcH", ")", ";", "$", "output", "=", "clone", "$", "this", "->", "owner", ";", "$", "output", "->", "setImageResource", "(", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ")", ";", "return", "$", "output", ";", "}" ]
Merge two Images together
[ "Merge", "two", "Images", "together" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedGDBackend.php#L15-L37
19,491
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedGDBackend.php
ExtendedGDBackend.blur
public function blur($intensity) { $image = $this->owner->getImageResource(); switch($intensity){ case 'light': for ($x=1; $x<=10; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; case 'strong': for ($x=1; $x<=40; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; case 'normal': default: for ($x=1; $x<=25; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } $output = clone $this->owner; $output->setImageResource($image); return $output; }
php
public function blur($intensity) { $image = $this->owner->getImageResource(); switch($intensity){ case 'light': for ($x=1; $x<=10; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; case 'strong': for ($x=1; $x<=40; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; case 'normal': default: for ($x=1; $x<=25; $x++) imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } $output = clone $this->owner; $output->setImageResource($image); return $output; }
[ "public", "function", "blur", "(", "$", "intensity", ")", "{", "$", "image", "=", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ";", "switch", "(", "$", "intensity", ")", "{", "case", "'light'", ":", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<=", "10", ";", "$", "x", "++", ")", "imagefilter", "(", "$", "image", ",", "IMG_FILTER_GAUSSIAN_BLUR", ")", ";", "break", ";", "case", "'strong'", ":", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<=", "40", ";", "$", "x", "++", ")", "imagefilter", "(", "$", "image", ",", "IMG_FILTER_GAUSSIAN_BLUR", ")", ";", "break", ";", "case", "'normal'", ":", "default", ":", "for", "(", "$", "x", "=", "1", ";", "$", "x", "<=", "25", ";", "$", "x", "++", ")", "imagefilter", "(", "$", "image", ",", "IMG_FILTER_GAUSSIAN_BLUR", ")", ";", "break", ";", "}", "$", "output", "=", "clone", "$", "this", "->", "owner", ";", "$", "output", "->", "setImageResource", "(", "$", "image", ")", ";", "return", "$", "output", ";", "}" ]
blur the image
[ "blur", "the", "image" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedGDBackend.php#L42-L66
19,492
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedGDBackend.php
ExtendedGDBackend.toJpeg
public function toJpeg($backgroundColor, $type) { $image = $this->owner->getImageResource(); switch($type){ case IMAGETYPE_GIF: case IMAGETYPE_PNG: $newGD = imagecreatetruecolor($this->owner->getWidth(), $this->owner->getHeight()); $bg = GDBackend::color_web2gd($newGD, $backgroundColor); imagefill($newGD, 0, 0, $bg); imagealphablending($newGD, TRUE); imagecopy($newGD, $image, 0, 0, 0, 0, $this->owner->getWidth(), $this->owner->getHeight()); break; case IMAGETYPE_JPEG: $newGD = $image; break; } $output = clone $this->owner; $output->setImageResource($newGD); return $output; }
php
public function toJpeg($backgroundColor, $type) { $image = $this->owner->getImageResource(); switch($type){ case IMAGETYPE_GIF: case IMAGETYPE_PNG: $newGD = imagecreatetruecolor($this->owner->getWidth(), $this->owner->getHeight()); $bg = GDBackend::color_web2gd($newGD, $backgroundColor); imagefill($newGD, 0, 0, $bg); imagealphablending($newGD, TRUE); imagecopy($newGD, $image, 0, 0, 0, 0, $this->owner->getWidth(), $this->owner->getHeight()); break; case IMAGETYPE_JPEG: $newGD = $image; break; } $output = clone $this->owner; $output->setImageResource($newGD); return $output; }
[ "public", "function", "toJpeg", "(", "$", "backgroundColor", ",", "$", "type", ")", "{", "$", "image", "=", "$", "this", "->", "owner", "->", "getImageResource", "(", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "IMAGETYPE_GIF", ":", "case", "IMAGETYPE_PNG", ":", "$", "newGD", "=", "imagecreatetruecolor", "(", "$", "this", "->", "owner", "->", "getWidth", "(", ")", ",", "$", "this", "->", "owner", "->", "getHeight", "(", ")", ")", ";", "$", "bg", "=", "GDBackend", "::", "color_web2gd", "(", "$", "newGD", ",", "$", "backgroundColor", ")", ";", "imagefill", "(", "$", "newGD", ",", "0", ",", "0", ",", "$", "bg", ")", ";", "imagealphablending", "(", "$", "newGD", ",", "TRUE", ")", ";", "imagecopy", "(", "$", "newGD", ",", "$", "image", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "owner", "->", "getWidth", "(", ")", ",", "$", "this", "->", "owner", "->", "getHeight", "(", ")", ")", ";", "break", ";", "case", "IMAGETYPE_JPEG", ":", "$", "newGD", "=", "$", "image", ";", "break", ";", "}", "$", "output", "=", "clone", "$", "this", "->", "owner", ";", "$", "output", "->", "setImageResource", "(", "$", "newGD", ")", ";", "return", "$", "output", ";", "}" ]
convert to jpeg
[ "convert", "to", "jpeg" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedGDBackend.php#L144-L165
19,493
javiacei/IdeupSimplePaginatorBundle
Paginator/Adapter/AdapterFactory.php
AdapterFactory.createAdapter
public function createAdapter($collection) { if (\is_array($collection)) { $className = 'Array'; } else { try { $r = new \ReflectionClass($collection); $className = $r->getName(); } catch (\ReflectionException $exc) { throw new AdapterNotSupportedException($collection); } } $adapterName = __NAMESPACE__ . "\\" . $className . 'Adapter' ; return new $adapterName($collection); }
php
public function createAdapter($collection) { if (\is_array($collection)) { $className = 'Array'; } else { try { $r = new \ReflectionClass($collection); $className = $r->getName(); } catch (\ReflectionException $exc) { throw new AdapterNotSupportedException($collection); } } $adapterName = __NAMESPACE__ . "\\" . $className . 'Adapter' ; return new $adapterName($collection); }
[ "public", "function", "createAdapter", "(", "$", "collection", ")", "{", "if", "(", "\\", "is_array", "(", "$", "collection", ")", ")", "{", "$", "className", "=", "'Array'", ";", "}", "else", "{", "try", "{", "$", "r", "=", "new", "\\", "ReflectionClass", "(", "$", "collection", ")", ";", "$", "className", "=", "$", "r", "->", "getName", "(", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "exc", ")", "{", "throw", "new", "AdapterNotSupportedException", "(", "$", "collection", ")", ";", "}", "}", "$", "adapterName", "=", "__NAMESPACE__", ".", "\"\\\\\"", ".", "$", "className", ".", "'Adapter'", ";", "return", "new", "$", "adapterName", "(", "$", "collection", ")", ";", "}" ]
This method recieve a data collection and returns the corresponding adapter. @param mixed $collection @return AdapterInterface @throws Ideup\SimplePaginatorBundle\Paginator\Exception\AdapterNotSupportedException
[ "This", "method", "recieve", "a", "data", "collection", "and", "returns", "the", "corresponding", "adapter", "." ]
12639a9c75bc403649fc2b2881e190a017d8c5b2
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Paginator/Adapter/AdapterFactory.php#L24-L42
19,494
zicht/z-plugin-git
git/Plugin.php
Plugin.appendConfiguration
public function appendConfiguration(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('vcs') ->children() ->scalarNode('url')->end() ->arrayNode('export') ->children() ->scalarNode('revfile')->isRequired()->end() ->end() ->end() ->end() ->end() ->end() ; }
php
public function appendConfiguration(ArrayNodeDefinition $rootNode) { $rootNode ->children() ->arrayNode('vcs') ->children() ->scalarNode('url')->end() ->arrayNode('export') ->children() ->scalarNode('revfile')->isRequired()->end() ->end() ->end() ->end() ->end() ->end() ; }
[ "public", "function", "appendConfiguration", "(", "ArrayNodeDefinition", "$", "rootNode", ")", "{", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'vcs'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'url'", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'export'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'revfile'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Appends Git configuration options @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode @return mixed|void
[ "Appends", "Git", "configuration", "options" ]
0ed336b19a20225f96111e30db1ae59fabdea0e7
https://github.com/zicht/z-plugin-git/blob/0ed336b19a20225f96111e30db1ae59fabdea0e7/git/Plugin.php#L27-L43
19,495
phossa2/config
src/Config/Traits/DelegatorWritableTrait.php
DelegatorWritableTrait.setRegistryWritableFalse
protected function setRegistryWritableFalse()/*# : bool */ { foreach ($this->lookup_pool as $reg) { if ($reg instanceof WritableInterface && !$reg->setWritable(false)) { return false; } } return true; }
php
protected function setRegistryWritableFalse()/*# : bool */ { foreach ($this->lookup_pool as $reg) { if ($reg instanceof WritableInterface && !$reg->setWritable(false)) { return false; } } return true; }
[ "protected", "function", "setRegistryWritableFalse", "(", ")", "/*# : bool */", "{", "foreach", "(", "$", "this", "->", "lookup_pool", "as", "$", "reg", ")", "{", "if", "(", "$", "reg", "instanceof", "WritableInterface", "&&", "!", "$", "reg", "->", "setWritable", "(", "false", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Set writable to FALSE in all registries @return bool @access protected
[ "Set", "writable", "to", "FALSE", "in", "all", "registries" ]
7c046fd2c97633b69545b4745d8bffe28e19b1df
https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Traits/DelegatorWritableTrait.php#L79-L88
19,496
steeffeen/FancyManiaLinks
FML/Script/Features/CheckBoxFeature.php
CheckBoxFeature.setQuad
public function setQuad(Quad $quad) { $quad->checkId(); $quad->setScriptEvents(true); $this->quad = $quad; return $this; }
php
public function setQuad(Quad $quad) { $quad->checkId(); $quad->setScriptEvents(true); $this->quad = $quad; return $this; }
[ "public", "function", "setQuad", "(", "Quad", "$", "quad", ")", "{", "$", "quad", "->", "checkId", "(", ")", ";", "$", "quad", "->", "setScriptEvents", "(", "true", ")", ";", "$", "this", "->", "quad", "=", "$", "quad", ";", "return", "$", "this", ";", "}" ]
Set the CheckBox Quad @api @param Quad $quad CheckBox Quad @return static
[ "Set", "the", "CheckBox", "Quad" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/CheckBoxFeature.php#L97-L103
19,497
ClanCats/Core
src/classes/CCFile.php
CCFile.write
public static function write( $path, $content ) { static::mkdir( $path ); // if writing the file fails if ( file_put_contents( $path, $content, LOCK_EX ) === false ) { if ( static::_can_print() ) { CCCli::line( CCCli::color( 'failure', 'red' ).' creating '.$path ); } return false; } // everything went good if ( static::_can_print() ) { CCCli::line( CCCli::color( 'created', 'green' ).' '.$path ); } return true; }
php
public static function write( $path, $content ) { static::mkdir( $path ); // if writing the file fails if ( file_put_contents( $path, $content, LOCK_EX ) === false ) { if ( static::_can_print() ) { CCCli::line( CCCli::color( 'failure', 'red' ).' creating '.$path ); } return false; } // everything went good if ( static::_can_print() ) { CCCli::line( CCCli::color( 'created', 'green' ).' '.$path ); } return true; }
[ "public", "static", "function", "write", "(", "$", "path", ",", "$", "content", ")", "{", "static", "::", "mkdir", "(", "$", "path", ")", ";", "// if writing the file fails", "if", "(", "file_put_contents", "(", "$", "path", ",", "$", "content", ",", "LOCK_EX", ")", "===", "false", ")", "{", "if", "(", "static", "::", "_can_print", "(", ")", ")", "{", "CCCli", "::", "line", "(", "CCCli", "::", "color", "(", "'failure'", ",", "'red'", ")", ".", "' creating '", ".", "$", "path", ")", ";", "}", "return", "false", ";", "}", "// everything went good", "if", "(", "static", "::", "_can_print", "(", ")", ")", "{", "CCCli", "::", "line", "(", "CCCli", "::", "color", "(", "'created'", ",", "'green'", ")", ".", "' '", ".", "$", "path", ")", ";", "}", "return", "true", ";", "}" ]
save a file @param string $path @param string $content @return bool
[ "save", "a", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFile.php#L90-L113
19,498
ClanCats/Core
src/classes/CCFile.php
CCFile.append
public static function append( $path, $content ) { if ( !is_dir( dirname( $path ) ) ) { if ( !mkdir( dirname( $path ), 0755, true ) ) { throw new CCException( "CCFile - could not create directory: ".dirname( $path ) ); } } return file_put_contents( $path, $content, LOCK_EX | FILE_APPEND ); }
php
public static function append( $path, $content ) { if ( !is_dir( dirname( $path ) ) ) { if ( !mkdir( dirname( $path ), 0755, true ) ) { throw new CCException( "CCFile - could not create directory: ".dirname( $path ) ); } } return file_put_contents( $path, $content, LOCK_EX | FILE_APPEND ); }
[ "public", "static", "function", "append", "(", "$", "path", ",", "$", "content", ")", "{", "if", "(", "!", "is_dir", "(", "dirname", "(", "$", "path", ")", ")", ")", "{", "if", "(", "!", "mkdir", "(", "dirname", "(", "$", "path", ")", ",", "0755", ",", "true", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCFile - could not create directory: \"", ".", "dirname", "(", "$", "path", ")", ")", ";", "}", "}", "return", "file_put_contents", "(", "$", "path", ",", "$", "content", ",", "LOCK_EX", "|", "FILE_APPEND", ")", ";", "}" ]
append to a file @param string $path @param string $content @return bool
[ "append", "to", "a", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFile.php#L122-L132
19,499
ClanCats/Core
src/classes/CCFile.php
CCFile.delete
public static function delete( $path ) { $success = false; if ( file_exists( $path ) ) { $success = unlink( $path ); } if ( static::_can_print() ) { if ( $success ) { CCCli::line( CCCli::color( 'removed', 'green' ).' '.$path ); } else { CCCli::line( CCCli::color( 'removing failure', 'red' ).' '.$path ); } } return $success; }
php
public static function delete( $path ) { $success = false; if ( file_exists( $path ) ) { $success = unlink( $path ); } if ( static::_can_print() ) { if ( $success ) { CCCli::line( CCCli::color( 'removed', 'green' ).' '.$path ); } else { CCCli::line( CCCli::color( 'removing failure', 'red' ).' '.$path ); } } return $success; }
[ "public", "static", "function", "delete", "(", "$", "path", ")", "{", "$", "success", "=", "false", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "success", "=", "unlink", "(", "$", "path", ")", ";", "}", "if", "(", "static", "::", "_can_print", "(", ")", ")", "{", "if", "(", "$", "success", ")", "{", "CCCli", "::", "line", "(", "CCCli", "::", "color", "(", "'removed'", ",", "'green'", ")", ".", "' '", ".", "$", "path", ")", ";", "}", "else", "{", "CCCli", "::", "line", "(", "CCCli", "::", "color", "(", "'removing failure'", ",", "'red'", ")", ".", "' '", ".", "$", "path", ")", ";", "}", "}", "return", "$", "success", ";", "}" ]
Delete a file This function is going to remove a file from your filesystem @param string $path @return bool
[ "Delete", "a", "file", "This", "function", "is", "going", "to", "remove", "a", "file", "from", "your", "filesystem" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFile.php#L141-L163