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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
2,900
nonetallt/jinitialize-core
src/JinitializeContainer.php
JinitializeContainer.getData
public function getData(string $plugin = null) { /* Only get data for single plugin */ if(! is_null($plugin)) { return $this->getPlugin($plugin)->getContainer()->getData(); } /* Get data for all plugins */ $data = []; foreach($this->plugins as $plugin) { $data[$plugin->getName()] = $plugin->getContainer()->getData(); } return $data; }
php
public function getData(string $plugin = null) { /* Only get data for single plugin */ if(! is_null($plugin)) { return $this->getPlugin($plugin)->getContainer()->getData(); } /* Get data for all plugins */ $data = []; foreach($this->plugins as $plugin) { $data[$plugin->getName()] = $plugin->getContainer()->getData(); } return $data; }
[ "public", "function", "getData", "(", "string", "$", "plugin", "=", "null", ")", "{", "/* Only get data for single plugin */", "if", "(", "!", "is_null", "(", "$", "plugin", ")", ")", "{", "return", "$", "this", "->", "getPlugin", "(", "$", "plugin", ")", "->", "getContainer", "(", ")", "->", "getData", "(", ")", ";", "}", "/* Get data for all plugins */", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "$", "data", "[", "$", "plugin", "->", "getName", "(", ")", "]", "=", "$", "plugin", "->", "getContainer", "(", ")", "->", "getData", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Get data in the container. @param string|null $plugin plugin scope to get only data for a specific plugin.
[ "Get", "data", "in", "the", "container", "." ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeContainer.php#L64-L77
2,901
setrun/setrun-component-user
src/commands/UserController.php
UserController.actionCreate
public function actionCreate() { $user = new User(); $this->readValue($user, 'username'); $this->readValue($user, 'email'); $user->setPassword($this->prompt('Password:', [ 'required' => true, 'pattern' => '#^.{6,255}$#i', 'error' => 'More than 6 symbols', ])); $user->generateAuthKey(); $user->status = User::STATUS_ACTIVE; $this->log($this->repository->save($user)); }
php
public function actionCreate() { $user = new User(); $this->readValue($user, 'username'); $this->readValue($user, 'email'); $user->setPassword($this->prompt('Password:', [ 'required' => true, 'pattern' => '#^.{6,255}$#i', 'error' => 'More than 6 symbols', ])); $user->generateAuthKey(); $user->status = User::STATUS_ACTIVE; $this->log($this->repository->save($user)); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "this", "->", "readValue", "(", "$", "user", ",", "'username'", ")", ";", "$", "this", "->", "readValue", "(", "$", "user", ",", "'email'", ")", ";", "$", "user", "->", "setPassword", "(", "$", "this", "->", "prompt", "(", "'Password:'", ",", "[", "'required'", "=>", "true", ",", "'pattern'", "=>", "'#^.{6,255}$#i'", ",", "'error'", "=>", "'More than 6 symbols'", ",", "]", ")", ")", ";", "$", "user", "->", "generateAuthKey", "(", ")", ";", "$", "user", "->", "status", "=", "User", "::", "STATUS_ACTIVE", ";", "$", "this", "->", "log", "(", "$", "this", "->", "repository", "->", "save", "(", "$", "user", ")", ")", ";", "}" ]
Creates new user.
[ "Creates", "new", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/commands/UserController.php#L20-L33
2,902
setrun/setrun-component-user
src/commands/UserController.php
UserController.actionRemove
public function actionRemove() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $this->log($this->repository->remove($user)); }
php
public function actionRemove() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $this->log($this->repository->remove($user)); }
[ "public", "function", "actionRemove", "(", ")", "{", "$", "username", "=", "$", "this", "->", "prompt", "(", "'Username:'", ",", "[", "'required'", "=>", "true", "]", ")", ";", "$", "user", "=", "$", "this", "->", "findModel", "(", "$", "username", ")", ";", "$", "this", "->", "log", "(", "$", "this", "->", "repository", "->", "remove", "(", "$", "user", ")", ")", ";", "}" ]
Removes user by username.
[ "Removes", "user", "by", "username", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/commands/UserController.php#L38-L43
2,903
setrun/setrun-component-user
src/commands/UserController.php
UserController.actionActivate
public function actionActivate() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->status = User::STATUS_ACTIVE; $this->log($this->repository->save($user)); }
php
public function actionActivate() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->status = User::STATUS_ACTIVE; $this->log($this->repository->save($user)); }
[ "public", "function", "actionActivate", "(", ")", "{", "$", "username", "=", "$", "this", "->", "prompt", "(", "'Username:'", ",", "[", "'required'", "=>", "true", "]", ")", ";", "$", "user", "=", "$", "this", "->", "findModel", "(", "$", "username", ")", ";", "$", "user", "->", "status", "=", "User", "::", "STATUS_ACTIVE", ";", "$", "this", "->", "log", "(", "$", "this", "->", "repository", "->", "save", "(", "$", "user", ")", ")", ";", "}" ]
Activates user.
[ "Activates", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/commands/UserController.php#L48-L54
2,904
setrun/setrun-component-user
src/commands/UserController.php
UserController.actionBlocked
public function actionBlocked() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->status = User::STATUS_BLOCKED; $this->log($this->repository->save($user)); }
php
public function actionBlocked() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->status = User::STATUS_BLOCKED; $this->log($this->repository->save($user)); }
[ "public", "function", "actionBlocked", "(", ")", "{", "$", "username", "=", "$", "this", "->", "prompt", "(", "'Username:'", ",", "[", "'required'", "=>", "true", "]", ")", ";", "$", "user", "=", "$", "this", "->", "findModel", "(", "$", "username", ")", ";", "$", "user", "->", "status", "=", "User", "::", "STATUS_BLOCKED", ";", "$", "this", "->", "log", "(", "$", "this", "->", "repository", "->", "save", "(", "$", "user", ")", ")", ";", "}" ]
Blocked user.
[ "Blocked", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/commands/UserController.php#L59-L65
2,905
setrun/setrun-component-user
src/commands/UserController.php
UserController.actionChangePassword
public function actionChangePassword() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->setPassword($this->prompt('New password:', [ 'required' => true, 'pattern' => '#^.{6,255}$#i', 'error' => 'More than 6 symbols', ])); $this->log($this->repository->save($user)); }
php
public function actionChangePassword() { $username = $this->prompt('Username:', ['required' => true]); $user = $this->findModel($username); $user->setPassword($this->prompt('New password:', [ 'required' => true, 'pattern' => '#^.{6,255}$#i', 'error' => 'More than 6 symbols', ])); $this->log($this->repository->save($user)); }
[ "public", "function", "actionChangePassword", "(", ")", "{", "$", "username", "=", "$", "this", "->", "prompt", "(", "'Username:'", ",", "[", "'required'", "=>", "true", "]", ")", ";", "$", "user", "=", "$", "this", "->", "findModel", "(", "$", "username", ")", ";", "$", "user", "->", "setPassword", "(", "$", "this", "->", "prompt", "(", "'New password:'", ",", "[", "'required'", "=>", "true", ",", "'pattern'", "=>", "'#^.{6,255}$#i'", ",", "'error'", "=>", "'More than 6 symbols'", ",", "]", ")", ")", ";", "$", "this", "->", "log", "(", "$", "this", "->", "repository", "->", "save", "(", "$", "user", ")", ")", ";", "}" ]
Changes user password.
[ "Changes", "user", "password", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/commands/UserController.php#L70-L80
2,906
CodeCollab/Form
src/Field/Generic.php
Generic.isRequired
public function isRequired(): bool { foreach ($this->validationRules as $rule) { if ($rule instanceof Required) { return true; } } return false; }
php
public function isRequired(): bool { foreach ($this->validationRules as $rule) { if ($rule instanceof Required) { return true; } } return false; }
[ "public", "function", "isRequired", "(", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "validationRules", "as", "$", "rule", ")", "{", "if", "(", "$", "rule", "instanceof", "Required", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks whether the field is required @return bool True when the field is required
[ "Checks", "whether", "the", "field", "is", "required" ]
4ccb8d4effd3a53d6676ec862e080a127ed0056c
https://github.com/CodeCollab/Form/blob/4ccb8d4effd3a53d6676ec862e080a127ed0056c/src/Field/Generic.php#L115-L124
2,907
CodeCollab/Form
src/Field/Generic.php
Generic.getValue
public function getValue(): string { if (!$this->validated && $this->defaultValue !== null) { return $this->defaultValue; } if ($this->value === null) { return ''; } return $this->value; }
php
public function getValue(): string { if (!$this->validated && $this->defaultValue !== null) { return $this->defaultValue; } if ($this->value === null) { return ''; } return $this->value; }
[ "public", "function", "getValue", "(", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "validated", "&&", "$", "this", "->", "defaultValue", "!==", "null", ")", "{", "return", "$", "this", "->", "defaultValue", ";", "}", "if", "(", "$", "this", "->", "value", "===", "null", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "value", ";", "}" ]
Gets the field's value @return string The value
[ "Gets", "the", "field", "s", "value" ]
4ccb8d4effd3a53d6676ec862e080a127ed0056c
https://github.com/CodeCollab/Form/blob/4ccb8d4effd3a53d6676ec862e080a127ed0056c/src/Field/Generic.php#L141-L152
2,908
CodeCollab/Form
src/Field/Generic.php
Generic.validate
public function validate() { foreach ($this->validationRules as $rule) { $rule->validate($this->getValue()); if (!$rule->isValid()) { $this->errors += $rule->getError(); } } $this->validated = true; }
php
public function validate() { foreach ($this->validationRules as $rule) { $rule->validate($this->getValue()); if (!$rule->isValid()) { $this->errors += $rule->getError(); } } $this->validated = true; }
[ "public", "function", "validate", "(", ")", "{", "foreach", "(", "$", "this", "->", "validationRules", "as", "$", "rule", ")", "{", "$", "rule", "->", "validate", "(", "$", "this", "->", "getValue", "(", ")", ")", ";", "if", "(", "!", "$", "rule", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "errors", "+=", "$", "rule", "->", "getError", "(", ")", ";", "}", "}", "$", "this", "->", "validated", "=", "true", ";", "}" ]
Validates the field
[ "Validates", "the", "field" ]
4ccb8d4effd3a53d6676ec862e080a127ed0056c
https://github.com/CodeCollab/Form/blob/4ccb8d4effd3a53d6676ec862e080a127ed0056c/src/Field/Generic.php#L157-L168
2,909
e-commerce-passaro/compra
src/Compra/Repository.php
Repository.findAllByAutenticacaoId
public function findAllByAutenticacaoId($autenticacaoId) { $sql = new Sql($this->dbAdapter); $select = $sql->select($this->tableName)->where(array('autenticacao_id' => $autenticacaoId)); $stmt = $sql->prepareStatementForSqlObject($select); $result = $stmt->execute(); if ($result instanceof ResultInterface && $result->isQueryResult()) { $resultSet = new HydratingResultSet($this->hydrator, $this->prototipo); return $resultSet->initialize($result); } return array(); }
php
public function findAllByAutenticacaoId($autenticacaoId) { $sql = new Sql($this->dbAdapter); $select = $sql->select($this->tableName)->where(array('autenticacao_id' => $autenticacaoId)); $stmt = $sql->prepareStatementForSqlObject($select); $result = $stmt->execute(); if ($result instanceof ResultInterface && $result->isQueryResult()) { $resultSet = new HydratingResultSet($this->hydrator, $this->prototipo); return $resultSet->initialize($result); } return array(); }
[ "public", "function", "findAllByAutenticacaoId", "(", "$", "autenticacaoId", ")", "{", "$", "sql", "=", "new", "Sql", "(", "$", "this", "->", "dbAdapter", ")", ";", "$", "select", "=", "$", "sql", "->", "select", "(", "$", "this", "->", "tableName", ")", "->", "where", "(", "array", "(", "'autenticacao_id'", "=>", "$", "autenticacaoId", ")", ")", ";", "$", "stmt", "=", "$", "sql", "->", "prepareStatementForSqlObject", "(", "$", "select", ")", ";", "$", "result", "=", "$", "stmt", "->", "execute", "(", ")", ";", "if", "(", "$", "result", "instanceof", "ResultInterface", "&&", "$", "result", "->", "isQueryResult", "(", ")", ")", "{", "$", "resultSet", "=", "new", "HydratingResultSet", "(", "$", "this", "->", "hydrator", ",", "$", "this", "->", "prototipo", ")", ";", "return", "$", "resultSet", "->", "initialize", "(", "$", "result", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Encontra um iterador com todos as compras relacionadas a uma autenticacao no BD @param int $autenticacaoId @return Iterator
[ "Encontra", "um", "iterador", "com", "todos", "as", "compras", "relacionadas", "a", "uma", "autenticacao", "no", "BD" ]
8acf4ec2dbcb32305b7855bf6d936c8b95ddd105
https://github.com/e-commerce-passaro/compra/blob/8acf4ec2dbcb32305b7855bf6d936c8b95ddd105/src/Compra/Repository.php#L98-L112
2,910
sellerlabs/nucleus
src/SellerLabs/Nucleus/Meditation/TypedSpec.php
TypedSpec.getInternalFieldConstraints
protected function getInternalFieldConstraints($fieldName) { return parent::getInternalFieldConstraints($fieldName) ->append(ArrayList::of([$this->getFieldType($fieldName)])); }
php
protected function getInternalFieldConstraints($fieldName) { return parent::getInternalFieldConstraints($fieldName) ->append(ArrayList::of([$this->getFieldType($fieldName)])); }
[ "protected", "function", "getInternalFieldConstraints", "(", "$", "fieldName", ")", "{", "return", "parent", "::", "getInternalFieldConstraints", "(", "$", "fieldName", ")", "->", "append", "(", "ArrayList", "::", "of", "(", "[", "$", "this", "->", "getFieldType", "(", "$", "fieldName", ")", "]", ")", ")", ";", "}" ]
Get all the constraints for a field. @param string $fieldName @return IterableType
[ "Get", "all", "the", "constraints", "for", "a", "field", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Meditation/TypedSpec.php#L55-L59
2,911
sellerlabs/nucleus
src/SellerLabs/Nucleus/Meditation/TypedSpec.php
TypedSpec.getFieldType
public function getFieldType($fieldName) { return Maybe::fromMaybe( Boa::any(), $this->getFieldAnnotation($fieldName, static::ANNOTATION_TYPE) ); }
php
public function getFieldType($fieldName) { return Maybe::fromMaybe( Boa::any(), $this->getFieldAnnotation($fieldName, static::ANNOTATION_TYPE) ); }
[ "public", "function", "getFieldType", "(", "$", "fieldName", ")", "{", "return", "Maybe", "::", "fromMaybe", "(", "Boa", "::", "any", "(", ")", ",", "$", "this", "->", "getFieldAnnotation", "(", "$", "fieldName", ",", "static", "::", "ANNOTATION_TYPE", ")", ")", ";", "}" ]
Get the type annotation for a field. @param string $fieldName @return AbstractTypeConstraint
[ "Get", "the", "type", "annotation", "for", "a", "field", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Meditation/TypedSpec.php#L68-L74
2,912
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.getResource
public function getResource($identifier) { /** @var UserEntity $user */ $user = $this->userManager->findUserByUsername($identifier); if (!$user) { throw new NotFoundHttpException( $this->translator->trans('error.user_not_found', array('%id%' => $identifier)) ); } return $this->createResourceFromUser($user); }
php
public function getResource($identifier) { /** @var UserEntity $user */ $user = $this->userManager->findUserByUsername($identifier); if (!$user) { throw new NotFoundHttpException( $this->translator->trans('error.user_not_found', array('%id%' => $identifier)) ); } return $this->createResourceFromUser($user); }
[ "public", "function", "getResource", "(", "$", "identifier", ")", "{", "/** @var UserEntity $user */", "$", "user", "=", "$", "this", "->", "userManager", "->", "findUserByUsername", "(", "$", "identifier", ")", ";", "if", "(", "!", "$", "user", ")", "{", "throw", "new", "NotFoundHttpException", "(", "$", "this", "->", "translator", "->", "trans", "(", "'error.user_not_found'", ",", "array", "(", "'%id%'", "=>", "$", "identifier", ")", ")", ")", ";", "}", "return", "$", "this", "->", "createResourceFromUser", "(", "$", "user", ")", ";", "}" ]
Returns a resource representation of the user with the given username. @param string $identifier The username of the resource to retrieve. @throws NotFoundHttpException if the user could not be found. @return Resource
[ "Returns", "a", "resource", "representation", "of", "the", "user", "with", "the", "given", "username", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L59-L70
2,913
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.getCollection
public function getCollection(array $options = array()) { /** @var UserEntity[] $collection */ $collection = $this->userManager->findUsers(); $resource = new Resource($this->generateBrowseUrl(), array('count' => count($collection))); foreach ($collection as $element) { $resource->setEmbedded('user', $this->createResourceFromUser($element)); } return $resource; }
php
public function getCollection(array $options = array()) { /** @var UserEntity[] $collection */ $collection = $this->userManager->findUsers(); $resource = new Resource($this->generateBrowseUrl(), array('count' => count($collection))); foreach ($collection as $element) { $resource->setEmbedded('user', $this->createResourceFromUser($element)); } return $resource; }
[ "public", "function", "getCollection", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "/** @var UserEntity[] $collection */", "$", "collection", "=", "$", "this", "->", "userManager", "->", "findUsers", "(", ")", ";", "$", "resource", "=", "new", "Resource", "(", "$", "this", "->", "generateBrowseUrl", "(", ")", ",", "array", "(", "'count'", "=>", "count", "(", "$", "collection", ")", ")", ")", ";", "foreach", "(", "$", "collection", "as", "$", "element", ")", "{", "$", "resource", "->", "setEmbedded", "(", "'user'", ",", "$", "this", "->", "createResourceFromUser", "(", "$", "element", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Returns all users in a single collection resource. @param string[] $options @return Resource
[ "Returns", "all", "users", "in", "a", "single", "collection", "resource", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L79-L90
2,914
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.populateResourceWithForm
public function populateResourceWithForm(Resource $resource, FormInterface $form) { $formData = $form->getData(); $resource->setData( array( 'username' => $formData['username'], 'email' => $formData['email'] ) ); }
php
public function populateResourceWithForm(Resource $resource, FormInterface $form) { $formData = $form->getData(); $resource->setData( array( 'username' => $formData['username'], 'email' => $formData['email'] ) ); }
[ "public", "function", "populateResourceWithForm", "(", "Resource", "$", "resource", ",", "FormInterface", "$", "form", ")", "{", "$", "formData", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "resource", "->", "setData", "(", "array", "(", "'username'", "=>", "$", "formData", "[", "'username'", "]", ",", "'email'", "=>", "$", "formData", "[", "'email'", "]", ")", ")", ";", "}" ]
Populates the given resource with the values in the form; overwriting any existing items. @param \Hal\Resource $resource @param FormInterface $form @return void
[ "Populates", "the", "given", "resource", "with", "the", "values", "in", "the", "form", ";", "overwriting", "any", "existing", "items", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L148-L158
2,915
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.delete
public function delete(Resource $resource) { $data = $resource->toArray(); $user = $this->userManager->findUserByUsername($data['username']); if (!$user) { $errorMessage = $this->translator->trans('error.user_not_found', array('%username%' => $data['username'])); throw new NotFoundHttpException($errorMessage); } $this->userManager->deleteUser($user); }
php
public function delete(Resource $resource) { $data = $resource->toArray(); $user = $this->userManager->findUserByUsername($data['username']); if (!$user) { $errorMessage = $this->translator->trans('error.user_not_found', array('%username%' => $data['username'])); throw new NotFoundHttpException($errorMessage); } $this->userManager->deleteUser($user); }
[ "public", "function", "delete", "(", "Resource", "$", "resource", ")", "{", "$", "data", "=", "$", "resource", "->", "toArray", "(", ")", ";", "$", "user", "=", "$", "this", "->", "userManager", "->", "findUserByUsername", "(", "$", "data", "[", "'username'", "]", ")", ";", "if", "(", "!", "$", "user", ")", "{", "$", "errorMessage", "=", "$", "this", "->", "translator", "->", "trans", "(", "'error.user_not_found'", ",", "array", "(", "'%username%'", "=>", "$", "data", "[", "'username'", "]", ")", ")", ";", "throw", "new", "NotFoundHttpException", "(", "$", "errorMessage", ")", ";", "}", "$", "this", "->", "userManager", "->", "deleteUser", "(", "$", "user", ")", ";", "}" ]
Removes the User from the database. @param \Hal\Resource $resource @throws NotFoundHttpException if no user with the given id could be found. @return void
[ "Removes", "the", "User", "from", "the", "database", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L169-L180
2,916
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.generateReadUrl
public function generateReadUrl($resourceOrIdentifier) { if ($resourceOrIdentifier instanceof Resource) { $data = $resourceOrIdentifier->toArray(); $id = $data['username']; } else { $id = $resourceOrIdentifier; } $route = $this->router->generate( 'ingewikkeld_rest_user_user_read', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_PATH ); return $route; }
php
public function generateReadUrl($resourceOrIdentifier) { if ($resourceOrIdentifier instanceof Resource) { $data = $resourceOrIdentifier->toArray(); $id = $data['username']; } else { $id = $resourceOrIdentifier; } $route = $this->router->generate( 'ingewikkeld_rest_user_user_read', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_PATH ); return $route; }
[ "public", "function", "generateReadUrl", "(", "$", "resourceOrIdentifier", ")", "{", "if", "(", "$", "resourceOrIdentifier", "instanceof", "Resource", ")", "{", "$", "data", "=", "$", "resourceOrIdentifier", "->", "toArray", "(", ")", ";", "$", "id", "=", "$", "data", "[", "'username'", "]", ";", "}", "else", "{", "$", "id", "=", "$", "resourceOrIdentifier", ";", "}", "$", "route", "=", "$", "this", "->", "router", "->", "generate", "(", "'ingewikkeld_rest_user_user_read'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ",", "UrlGeneratorInterface", "::", "ABSOLUTE_PATH", ")", ";", "return", "$", "route", ";", "}" ]
Generate the URL for the read page for the given resource. @param Resource|int|string $resourceOrIdentifier @return string
[ "Generate", "the", "URL", "for", "the", "read", "page", "for", "the", "given", "resource", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L203-L219
2,917
Ingewikkeld/rest-user-bundle
src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php
User.createResourceFromUser
protected function createResourceFromUser(UserEntity $user) { $resource = new Resource( $this->generateReadUrl($user->getUsernameCanonical()), array( 'username' => $user->getUsernameCanonical(), 'email' => $user->getEmail(), 'last_login' => $user->getLastLogin() ? $user->getLastLogin()->format('c') : null, ) ); return $resource; }
php
protected function createResourceFromUser(UserEntity $user) { $resource = new Resource( $this->generateReadUrl($user->getUsernameCanonical()), array( 'username' => $user->getUsernameCanonical(), 'email' => $user->getEmail(), 'last_login' => $user->getLastLogin() ? $user->getLastLogin()->format('c') : null, ) ); return $resource; }
[ "protected", "function", "createResourceFromUser", "(", "UserEntity", "$", "user", ")", "{", "$", "resource", "=", "new", "Resource", "(", "$", "this", "->", "generateReadUrl", "(", "$", "user", "->", "getUsernameCanonical", "(", ")", ")", ",", "array", "(", "'username'", "=>", "$", "user", "->", "getUsernameCanonical", "(", ")", ",", "'email'", "=>", "$", "user", "->", "getEmail", "(", ")", ",", "'last_login'", "=>", "$", "user", "->", "getLastLogin", "(", ")", "?", "$", "user", "->", "getLastLogin", "(", ")", "->", "format", "(", "'c'", ")", ":", "null", ",", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Creates a resource object from the User entity. @param UserEntity $user @return Resource
[ "Creates", "a", "resource", "object", "from", "the", "User", "entity", "." ]
73acdeadc6098bea7256a7969536d7ba9c5afa5a
https://github.com/Ingewikkeld/rest-user-bundle/blob/73acdeadc6098bea7256a7969536d7ba9c5afa5a/src/Ingewikkeld/Rest/UserBundle/ResourceMapper/User.php#L228-L240
2,918
cityware/city-utility
src/Export/Pdf.php
Pdf.defineStyles
private function defineStyles(array $options = array()) { $this->_style = new ZfPdf\Style(); $this->_style->setFillColor(new ZfPdf\Color\Html($options['colors']['lines'])); $this->_topo = new ZfPdf\Style(); $this->_topo->setFillColor(new ZfPdf\Color\Html($options['colors']['header'])); $this->td = new ZfPdf\Style(); $this->td->setFillColor(new ZfPdf\Color\Html($options['colors']['row2'])); $this->td2 = new ZfPdf\Style(); $this->td2->setFillColor(new ZfPdf\Color\Html($options['colors']['row1'])); $this->_styleText = new ZfPdf\Style(); $this->_styleText->setFillColor(new ZfPdf\Color\Html($options['colors']['text'])); return $this; }
php
private function defineStyles(array $options = array()) { $this->_style = new ZfPdf\Style(); $this->_style->setFillColor(new ZfPdf\Color\Html($options['colors']['lines'])); $this->_topo = new ZfPdf\Style(); $this->_topo->setFillColor(new ZfPdf\Color\Html($options['colors']['header'])); $this->td = new ZfPdf\Style(); $this->td->setFillColor(new ZfPdf\Color\Html($options['colors']['row2'])); $this->td2 = new ZfPdf\Style(); $this->td2->setFillColor(new ZfPdf\Color\Html($options['colors']['row1'])); $this->_styleText = new ZfPdf\Style(); $this->_styleText->setFillColor(new ZfPdf\Color\Html($options['colors']['text'])); return $this; }
[ "private", "function", "defineStyles", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_style", "=", "new", "ZfPdf", "\\", "Style", "(", ")", ";", "$", "this", "->", "_style", "->", "setFillColor", "(", "new", "ZfPdf", "\\", "Color", "\\", "Html", "(", "$", "options", "[", "'colors'", "]", "[", "'lines'", "]", ")", ")", ";", "$", "this", "->", "_topo", "=", "new", "ZfPdf", "\\", "Style", "(", ")", ";", "$", "this", "->", "_topo", "->", "setFillColor", "(", "new", "ZfPdf", "\\", "Color", "\\", "Html", "(", "$", "options", "[", "'colors'", "]", "[", "'header'", "]", ")", ")", ";", "$", "this", "->", "td", "=", "new", "ZfPdf", "\\", "Style", "(", ")", ";", "$", "this", "->", "td", "->", "setFillColor", "(", "new", "ZfPdf", "\\", "Color", "\\", "Html", "(", "$", "options", "[", "'colors'", "]", "[", "'row2'", "]", ")", ")", ";", "$", "this", "->", "td2", "=", "new", "ZfPdf", "\\", "Style", "(", ")", ";", "$", "this", "->", "td2", "->", "setFillColor", "(", "new", "ZfPdf", "\\", "Color", "\\", "Html", "(", "$", "options", "[", "'colors'", "]", "[", "'row1'", "]", ")", ")", ";", "$", "this", "->", "_styleText", "=", "new", "ZfPdf", "\\", "Style", "(", ")", ";", "$", "this", "->", "_styleText", "->", "setFillColor", "(", "new", "ZfPdf", "\\", "Color", "\\", "Html", "(", "$", "options", "[", "'colors'", "]", "[", "'text'", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Define os estilos do documento @param array $options @return \Cityware\Datagrid\Export\Pdf
[ "Define", "os", "estilos", "do", "documento" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Export/Pdf.php#L346-L364
2,919
cityware/city-utility
src/Export/Pdf.php
Pdf.drawFieldName
private function drawFieldName() { $iTitulos = 0; $this->_page->setFont($this->_font, $this->_cellFontSize + 1); foreach ($this->_arrayForm['gridfieldsconfig'] as $field => $value) { if ((int) $this->_la == 0) { $this->_largura1 = 40; } else { $this->_largura1 = $this->_cell[$iTitulos - 1] + $this->_largura1; } $this->_page->setStyle($this->_topo); $this->_page->drawRectangle($this->_largura1, $this->_altura - 4, $this->_largura1 + $this->_cell[$iTitulos] + 1, $this->_altura + 12); $this->_page->setStyle($this->_styleText); $fieldName = $this->_arrayLocale->translate($field); $this->_page->drawText($fieldName, $this->_largura1 + 2, $this->_altura, 'UTF-8'); $this->_la = $this->_largura1; $iTitulos++; } $this->_page->setFont($this->_font, $this->_cellFontSize); return $this; }
php
private function drawFieldName() { $iTitulos = 0; $this->_page->setFont($this->_font, $this->_cellFontSize + 1); foreach ($this->_arrayForm['gridfieldsconfig'] as $field => $value) { if ((int) $this->_la == 0) { $this->_largura1 = 40; } else { $this->_largura1 = $this->_cell[$iTitulos - 1] + $this->_largura1; } $this->_page->setStyle($this->_topo); $this->_page->drawRectangle($this->_largura1, $this->_altura - 4, $this->_largura1 + $this->_cell[$iTitulos] + 1, $this->_altura + 12); $this->_page->setStyle($this->_styleText); $fieldName = $this->_arrayLocale->translate($field); $this->_page->drawText($fieldName, $this->_largura1 + 2, $this->_altura, 'UTF-8'); $this->_la = $this->_largura1; $iTitulos++; } $this->_page->setFont($this->_font, $this->_cellFontSize); return $this; }
[ "private", "function", "drawFieldName", "(", ")", "{", "$", "iTitulos", "=", "0", ";", "$", "this", "->", "_page", "->", "setFont", "(", "$", "this", "->", "_font", ",", "$", "this", "->", "_cellFontSize", "+", "1", ")", ";", "foreach", "(", "$", "this", "->", "_arrayForm", "[", "'gridfieldsconfig'", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "(", "int", ")", "$", "this", "->", "_la", "==", "0", ")", "{", "$", "this", "->", "_largura1", "=", "40", ";", "}", "else", "{", "$", "this", "->", "_largura1", "=", "$", "this", "->", "_cell", "[", "$", "iTitulos", "-", "1", "]", "+", "$", "this", "->", "_largura1", ";", "}", "$", "this", "->", "_page", "->", "setStyle", "(", "$", "this", "->", "_topo", ")", ";", "$", "this", "->", "_page", "->", "drawRectangle", "(", "$", "this", "->", "_largura1", ",", "$", "this", "->", "_altura", "-", "4", ",", "$", "this", "->", "_largura1", "+", "$", "this", "->", "_cell", "[", "$", "iTitulos", "]", "+", "1", ",", "$", "this", "->", "_altura", "+", "12", ")", ";", "$", "this", "->", "_page", "->", "setStyle", "(", "$", "this", "->", "_styleText", ")", ";", "$", "fieldName", "=", "$", "this", "->", "_arrayLocale", "->", "translate", "(", "$", "field", ")", ";", "$", "this", "->", "_page", "->", "drawText", "(", "$", "fieldName", ",", "$", "this", "->", "_largura1", "+", "2", ",", "$", "this", "->", "_altura", ",", "'UTF-8'", ")", ";", "$", "this", "->", "_la", "=", "$", "this", "->", "_largura1", ";", "$", "iTitulos", "++", ";", "}", "$", "this", "->", "_page", "->", "setFont", "(", "$", "this", "->", "_font", ",", "$", "this", "->", "_cellFontSize", ")", ";", "return", "$", "this", ";", "}" ]
Desenha os campos em formato tabela @param type $this->_topo @param type $this->_styleText @return \Cityware\Datagrid\Export\Pdf
[ "Desenha", "os", "campos", "em", "formato", "tabela" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Export/Pdf.php#L427-L452
2,920
flowcode/ceibo
src/flowcode/ceibo/support/DaoSupport.php
DaoSupport.updateRelations
public function updateRelations($entity) { $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity)); foreach ($mapper->getRelations() as $relation) { if ($relation->getCardinality() == Relation::$manyToMany) { // delete previous relations $queryDeletePrevious = $this->buildDeleteRelationQuery($relation, $entity); $this->conn->executeNonQuery($queryDeletePrevious); // insert new relations $queryRel = $this->buildRelationQuery($entity); foreach (explode(";", $queryRel) as $q) { if (strlen($q) > 5) $this->conn->executeInsert($q); } } if ($relation->getCardinality() == Relation::$oneToMany) { $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity()); $m = "get" . $relation->getName(); $setid = "set" . $relMapper->getNameForColumn($relation->getForeignColumn()); // save actual relations foreach ($entity->$m() as $relEntity) { $relEntity->$setid($entity->getId()); $this->save($relEntity); } // delete old relations. // TODO: delete old relations } } }
php
public function updateRelations($entity) { $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity)); foreach ($mapper->getRelations() as $relation) { if ($relation->getCardinality() == Relation::$manyToMany) { // delete previous relations $queryDeletePrevious = $this->buildDeleteRelationQuery($relation, $entity); $this->conn->executeNonQuery($queryDeletePrevious); // insert new relations $queryRel = $this->buildRelationQuery($entity); foreach (explode(";", $queryRel) as $q) { if (strlen($q) > 5) $this->conn->executeInsert($q); } } if ($relation->getCardinality() == Relation::$oneToMany) { $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity()); $m = "get" . $relation->getName(); $setid = "set" . $relMapper->getNameForColumn($relation->getForeignColumn()); // save actual relations foreach ($entity->$m() as $relEntity) { $relEntity->$setid($entity->getId()); $this->save($relEntity); } // delete old relations. // TODO: delete old relations } } }
[ "public", "function", "updateRelations", "(", "$", "entity", ")", "{", "$", "mapper", "=", "MapperBuilder", "::", "buildFromMapping", "(", "$", "this", "->", "mapping", ",", "get_class", "(", "$", "entity", ")", ")", ";", "foreach", "(", "$", "mapper", "->", "getRelations", "(", ")", "as", "$", "relation", ")", "{", "if", "(", "$", "relation", "->", "getCardinality", "(", ")", "==", "Relation", "::", "$", "manyToMany", ")", "{", "// delete previous relations", "$", "queryDeletePrevious", "=", "$", "this", "->", "buildDeleteRelationQuery", "(", "$", "relation", ",", "$", "entity", ")", ";", "$", "this", "->", "conn", "->", "executeNonQuery", "(", "$", "queryDeletePrevious", ")", ";", "// insert new relations", "$", "queryRel", "=", "$", "this", "->", "buildRelationQuery", "(", "$", "entity", ")", ";", "foreach", "(", "explode", "(", "\";\"", ",", "$", "queryRel", ")", "as", "$", "q", ")", "{", "if", "(", "strlen", "(", "$", "q", ")", ">", "5", ")", "$", "this", "->", "conn", "->", "executeInsert", "(", "$", "q", ")", ";", "}", "}", "if", "(", "$", "relation", "->", "getCardinality", "(", ")", "==", "Relation", "::", "$", "oneToMany", ")", "{", "$", "relMapper", "=", "MapperBuilder", "::", "buildFromName", "(", "$", "this", "->", "mapping", ",", "$", "relation", "->", "getEntity", "(", ")", ")", ";", "$", "m", "=", "\"get\"", ".", "$", "relation", "->", "getName", "(", ")", ";", "$", "setid", "=", "\"set\"", ".", "$", "relMapper", "->", "getNameForColumn", "(", "$", "relation", "->", "getForeignColumn", "(", ")", ")", ";", "// save actual relations", "foreach", "(", "$", "entity", "->", "$", "m", "(", ")", "as", "$", "relEntity", ")", "{", "$", "relEntity", "->", "$", "setid", "(", "$", "entity", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "save", "(", "$", "relEntity", ")", ";", "}", "// delete old relations.", "// TODO: delete old relations", "}", "}", "}" ]
Update the entity relations. OneToOne o ManyToMany. @param type $entity
[ "Update", "the", "entity", "relations", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/support/DaoSupport.php#L60-L90
2,921
flowcode/ceibo
src/flowcode/ceibo/support/DaoSupport.php
DaoSupport.buildDeleteQuery
public function buildDeleteQuery($entity) { $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity)); $query = ""; foreach ($mapper->getRelations() as $relation) { $query .= $this->buildDeleteRelationQuery($relation, $entity); } $query .= "DELETE FROM " . $mapper->getTable() . " "; $query .= "WHERE id = '" . $entity->getId() . "';"; return $query; }
php
public function buildDeleteQuery($entity) { $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity)); $query = ""; foreach ($mapper->getRelations() as $relation) { $query .= $this->buildDeleteRelationQuery($relation, $entity); } $query .= "DELETE FROM " . $mapper->getTable() . " "; $query .= "WHERE id = '" . $entity->getId() . "';"; return $query; }
[ "public", "function", "buildDeleteQuery", "(", "$", "entity", ")", "{", "$", "mapper", "=", "MapperBuilder", "::", "buildFromMapping", "(", "$", "this", "->", "mapping", ",", "get_class", "(", "$", "entity", ")", ")", ";", "$", "query", "=", "\"\"", ";", "foreach", "(", "$", "mapper", "->", "getRelations", "(", ")", "as", "$", "relation", ")", "{", "$", "query", ".=", "$", "this", "->", "buildDeleteRelationQuery", "(", "$", "relation", ",", "$", "entity", ")", ";", "}", "$", "query", ".=", "\"DELETE FROM \"", ".", "$", "mapper", "->", "getTable", "(", ")", ".", "\" \"", ";", "$", "query", ".=", "\"WHERE id = '\"", ".", "$", "entity", "->", "getId", "(", ")", ".", "\"';\"", ";", "return", "$", "query", ";", "}" ]
Build a delete query for an entity. @param type $entity @return string
[ "Build", "a", "delete", "query", "for", "an", "entity", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/support/DaoSupport.php#L97-L108
2,922
flowcode/ceibo
src/flowcode/ceibo/support/DaoSupport.php
DaoSupport.buildDeleteRelationQuery
public function buildDeleteRelationQuery($relation, $entity) { $query = "DELETE FROM " . $relation->getTable() . " "; $query .= "WHERE " . $relation->getForeignColumn() . " = '" . $entity->getId() . "';"; return $query; }
php
public function buildDeleteRelationQuery($relation, $entity) { $query = "DELETE FROM " . $relation->getTable() . " "; $query .= "WHERE " . $relation->getForeignColumn() . " = '" . $entity->getId() . "';"; return $query; }
[ "public", "function", "buildDeleteRelationQuery", "(", "$", "relation", ",", "$", "entity", ")", "{", "$", "query", "=", "\"DELETE FROM \"", ".", "$", "relation", "->", "getTable", "(", ")", ".", "\" \"", ";", "$", "query", ".=", "\"WHERE \"", ".", "$", "relation", "->", "getForeignColumn", "(", ")", ".", "\" = '\"", ".", "$", "entity", "->", "getId", "(", ")", ".", "\"';\"", ";", "return", "$", "query", ";", "}" ]
Build a delete query for an entity an its relation. @param type $relation @param type $entity @return string
[ "Build", "a", "delete", "query", "for", "an", "entity", "an", "its", "relation", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/support/DaoSupport.php#L116-L120
2,923
nirix/radium
src/Database/Model/Filterable.php
Filterable.runFilters
protected function runFilters($when, $action) { $when = "_{$when}"; $filters = static::${$when}; // Anything to do? if (array_key_exists($action, $filters)) { foreach ($filters[$action] as $method) { $this->{$method}(); } } }
php
protected function runFilters($when, $action) { $when = "_{$when}"; $filters = static::${$when}; // Anything to do? if (array_key_exists($action, $filters)) { foreach ($filters[$action] as $method) { $this->{$method}(); } } }
[ "protected", "function", "runFilters", "(", "$", "when", ",", "$", "action", ")", "{", "$", "when", "=", "\"_{$when}\"", ";", "$", "filters", "=", "static", "::", "$", "{", "$", "when", "}", ";", "// Anything to do?", "if", "(", "array_key_exists", "(", "$", "action", ",", "$", "filters", ")", ")", "{", "foreach", "(", "$", "filters", "[", "$", "action", "]", "as", "$", "method", ")", "{", "$", "this", "->", "{", "$", "method", "}", "(", ")", ";", "}", "}", "}" ]
Runs the filters for the specified action. @param string $action
[ "Runs", "the", "filters", "for", "the", "specified", "action", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Filterable.php#L59-L70
2,924
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.callEvents
public static function callEvents(MocaBonita $mocaBonita, $dispatch, $complement = null) { foreach ($mocaBonita->getMbEvents($dispatch) as $event) { call_user_func_array( [$event, $dispatch], [$mocaBonita->getMbRequest(), $mocaBonita->getMbResponse(), $complement] ); } }
php
public static function callEvents(MocaBonita $mocaBonita, $dispatch, $complement = null) { foreach ($mocaBonita->getMbEvents($dispatch) as $event) { call_user_func_array( [$event, $dispatch], [$mocaBonita->getMbRequest(), $mocaBonita->getMbResponse(), $complement] ); } }
[ "public", "static", "function", "callEvents", "(", "MocaBonita", "$", "mocaBonita", ",", "$", "dispatch", ",", "$", "complement", "=", "null", ")", "{", "foreach", "(", "$", "mocaBonita", "->", "getMbEvents", "(", "$", "dispatch", ")", "as", "$", "event", ")", "{", "call_user_func_array", "(", "[", "$", "event", ",", "$", "dispatch", "]", ",", "[", "$", "mocaBonita", "->", "getMbRequest", "(", ")", ",", "$", "mocaBonita", "->", "getMbResponse", "(", ")", ",", "$", "complement", "]", ")", ";", "}", "}" ]
Call page events @param MocaBonita $mocaBonita @param string $dispatch @param object $complement @return void
[ "Call", "page", "events" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L91-L99
2,925
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.startWpDispatcher
public function startWpDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MocaBonita $mocaBonita) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function startWpDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MocaBonita $mocaBonita) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "startWpDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "MocaBonita", "$", "mocaBonita", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start after wordpress initialize @param MbRequest $mbRequest @param MbResponse $mbResponse @param MocaBonita $mocaBonita @throws MbException
[ "Event", "that", "will", "start", "after", "wordpress", "initialize" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L110-L115
2,926
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.beforePageDispatcher
public function beforePageDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbPage $mbPage) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function beforePageDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbPage $mbPage) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "beforePageDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "MbPage", "$", "mbPage", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start before running the page @param MbRequest $mbRequest @param MbResponse $mbResponse @param MbPage $mbPage @throws MbException
[ "Event", "that", "will", "start", "before", "running", "the", "page" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L142-L147
2,927
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.afterShortcodeDispatcher
public function afterShortcodeDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbShortCode $mbShortCode) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function afterShortcodeDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbShortCode $mbShortCode) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "afterShortcodeDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "MbShortCode", "$", "mbShortCode", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start after running the shortcode @param MbRequest $mbRequest @param MbResponse $mbResponse @param MbShortCode $mbShortCode @throws MbException
[ "Event", "that", "will", "start", "after", "running", "the", "shortcode" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L222-L227
2,928
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.beforeActionDispatcher
public function beforeActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbAction $mbAction) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function beforeActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbAction $mbAction) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "beforeActionDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "MbAction", "$", "mbAction", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start before running the action @param MbRequest $mbRequest @param MbResponse $mbResponse @param MbAction $mbAction @throws MbException
[ "Event", "that", "will", "start", "before", "running", "the", "action" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L238-L243
2,929
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.afterActionDispatcher
public function afterActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbAction $acaombAction) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function afterActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, MbAction $acaombAction) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "afterActionDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "MbAction", "$", "acaombAction", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start after running the action @param MbRequest $mbRequest @param MbResponse $mbResponse @param MbAction $acaombAction @throws MbException
[ "Event", "that", "will", "start", "after", "running", "the", "action" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L254-L259
2,930
jhorlima/wp-mocabonita
src/tools/MbEvent.php
MbEvent.exceptionActionDispatcher
public function exceptionActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, \Exception $exception) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
php
public function exceptionActionDispatcher(MbRequest $mbRequest, MbResponse $mbResponse, \Exception $exception) { $className = static::class; $methodName = __METHOD__; throw new MbException("{$methodName} not allowed in! {$className}."); }
[ "public", "function", "exceptionActionDispatcher", "(", "MbRequest", "$", "mbRequest", ",", "MbResponse", "$", "mbResponse", ",", "\\", "Exception", "$", "exception", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "methodName", "=", "__METHOD__", ";", "throw", "new", "MbException", "(", "\"{$methodName} not allowed in! {$className}.\"", ")", ";", "}" ]
Event that will start after the action launches an exception @param MbRequest $mbRequest @param MbResponse $mbResponse @param \Exception $exception @throws MbException
[ "Event", "that", "will", "start", "after", "the", "action", "launches", "an", "exception" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbEvent.php#L287-L292
2,931
kherge-abandoned/lib-compact
src/lib/Phine/Compact/Exception/XmlException.php
XmlException.createUsingLastXmlError
public function createUsingLastXmlError() { $errors = array(); $count = 0; /** @var \libXMLError $error */ foreach (libxml_get_errors() as $error) { $errors[] = sprintf( '#%d.) "%s" in %s line %d column %d.', ++$count, trim($error->message), $error->file, $error->line, $error->column ); } $this->finish(); if (empty($errors)) { $errors[] = '(unknown error)'; } return new self(join("\n", $errors)); }
php
public function createUsingLastXmlError() { $errors = array(); $count = 0; /** @var \libXMLError $error */ foreach (libxml_get_errors() as $error) { $errors[] = sprintf( '#%d.) "%s" in %s line %d column %d.', ++$count, trim($error->message), $error->file, $error->line, $error->column ); } $this->finish(); if (empty($errors)) { $errors[] = '(unknown error)'; } return new self(join("\n", $errors)); }
[ "public", "function", "createUsingLastXmlError", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "$", "count", "=", "0", ";", "/** @var \\libXMLError $error */", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "{", "$", "errors", "[", "]", "=", "sprintf", "(", "'#%d.) \"%s\" in %s line %d column %d.'", ",", "++", "$", "count", ",", "trim", "(", "$", "error", "->", "message", ")", ",", "$", "error", "->", "file", ",", "$", "error", "->", "line", ",", "$", "error", "->", "column", ")", ";", "}", "$", "this", "->", "finish", "(", ")", ";", "if", "(", "empty", "(", "$", "errors", ")", ")", "{", "$", "errors", "[", "]", "=", "'(unknown error)'", ";", "}", "return", "new", "self", "(", "join", "(", "\"\\n\"", ",", "$", "errors", ")", ")", ";", "}" ]
Creates a new exception using the most recent libxml errors. This method will create a new exception using all of th error messages in the libxml error buffer. The message will contain each error message, along with the affected file name, line number, and column number. throw XmlException::createUsingLastXmlError(); @return XmlException The new exception.
[ "Creates", "a", "new", "exception", "using", "the", "most", "recent", "libxml", "errors", "." ]
76bdbed6949c6de1928ec16a06639809a2e89a25
https://github.com/kherge-abandoned/lib-compact/blob/76bdbed6949c6de1928ec16a06639809a2e89a25/src/lib/Phine/Compact/Exception/XmlException.php#L37-L61
2,932
WellCommerce/Form
Elements/Fieldset/LanguageFieldset.php
LanguageFieldset.getValue
public function getValue() { $values = []; $this->getChildren()->forAll(function (ElementInterface $child) use (&$values) { foreach ($this->locales as $locale) { $values[$locale['code']][$child->getName()] = $this->getChildValue($child, $locale['code']); } }); return $values; }
php
public function getValue() { $values = []; $this->getChildren()->forAll(function (ElementInterface $child) use (&$values) { foreach ($this->locales as $locale) { $values[$locale['code']][$child->getName()] = $this->getChildValue($child, $locale['code']); } }); return $values; }
[ "public", "function", "getValue", "(", ")", "{", "$", "values", "=", "[", "]", ";", "$", "this", "->", "getChildren", "(", ")", "->", "forAll", "(", "function", "(", "ElementInterface", "$", "child", ")", "use", "(", "&", "$", "values", ")", "{", "foreach", "(", "$", "this", "->", "locales", "as", "$", "locale", ")", "{", "$", "values", "[", "$", "locale", "[", "'code'", "]", "]", "[", "$", "child", "->", "getName", "(", ")", "]", "=", "$", "this", "->", "getChildValue", "(", "$", "child", ",", "$", "locale", "[", "'code'", "]", ")", ";", "}", "}", ")", ";", "return", "$", "values", ";", "}" ]
Returns fieldset values @return array|mixed
[ "Returns", "fieldset", "values" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Fieldset/LanguageFieldset.php#L93-L104
2,933
WellCommerce/Form
Elements/Fieldset/LanguageFieldset.php
LanguageFieldset.prepareLanguages
protected function prepareLanguages() { $options = []; foreach ($this->options['languages'] as $language) { $options[] = $this->prepareLanguage($language); } return $options; }
php
protected function prepareLanguages() { $options = []; foreach ($this->options['languages'] as $language) { $options[] = $this->prepareLanguage($language); } return $options; }
[ "protected", "function", "prepareLanguages", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "options", "[", "'languages'", "]", "as", "$", "language", ")", "{", "$", "options", "[", "]", "=", "$", "this", "->", "prepareLanguage", "(", "$", "language", ")", ";", "}", "return", "$", "options", ";", "}" ]
Prepares the languages @return array
[ "Prepares", "the", "languages" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Fieldset/LanguageFieldset.php#L126-L134
2,934
WellCommerce/Form
Elements/Fieldset/LanguageFieldset.php
LanguageFieldset.prepareLanguage
protected function prepareLanguage($language) { $value = addslashes($language['code']); $label = addslashes($language['code']); $flag = addslashes(sprintf('%s.png', substr($label, 0, 2))); return [ 'sValue' => $value, 'sLabel' => $label, 'sFlag' => $flag, ]; }
php
protected function prepareLanguage($language) { $value = addslashes($language['code']); $label = addslashes($language['code']); $flag = addslashes(sprintf('%s.png', substr($label, 0, 2))); return [ 'sValue' => $value, 'sLabel' => $label, 'sFlag' => $flag, ]; }
[ "protected", "function", "prepareLanguage", "(", "$", "language", ")", "{", "$", "value", "=", "addslashes", "(", "$", "language", "[", "'code'", "]", ")", ";", "$", "label", "=", "addslashes", "(", "$", "language", "[", "'code'", "]", ")", ";", "$", "flag", "=", "addslashes", "(", "sprintf", "(", "'%s.png'", ",", "substr", "(", "$", "label", ",", "0", ",", "2", ")", ")", ")", ";", "return", "[", "'sValue'", "=>", "$", "value", ",", "'sLabel'", "=>", "$", "label", ",", "'sFlag'", "=>", "$", "flag", ",", "]", ";", "}" ]
Prepares language to use it as element attribute @param $language @return array
[ "Prepares", "language", "to", "use", "it", "as", "element", "attribute" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Fieldset/LanguageFieldset.php#L143-L154
2,935
WellCommerce/Form
Elements/Fieldset/LanguageFieldset.php
LanguageFieldset.convertRepetitionsData
protected function convertRepetitionsData($data) { $values = []; foreach ($data as $locale => $translation) { foreach ($translation as $fieldName => $fieldValue) { $values[$fieldName][$locale] = $fieldValue; } } return $values; }
php
protected function convertRepetitionsData($data) { $values = []; foreach ($data as $locale => $translation) { foreach ($translation as $fieldName => $fieldValue) { $values[$fieldName][$locale] = $fieldValue; } } return $values; }
[ "protected", "function", "convertRepetitionsData", "(", "$", "data", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "locale", "=>", "$", "translation", ")", "{", "foreach", "(", "$", "translation", "as", "$", "fieldName", "=>", "$", "fieldValue", ")", "{", "$", "values", "[", "$", "fieldName", "]", "[", "$", "locale", "]", "=", "$", "fieldValue", ";", "}", "}", "return", "$", "values", ";", "}" ]
Flips language repetitions @param array $data @return array
[ "Flips", "language", "repetitions" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Fieldset/LanguageFieldset.php#L163-L173
2,936
WellCommerce/Form
Elements/Fieldset/LanguageFieldset.php
LanguageFieldset.getChildValue
protected function getChildValue(ElementInterface $child, $locale) { $accessor = $this->getPropertyAccessor(); $value = $child->getValue(); if (is_array($value)) { return $accessor->getValue($value, "[{$locale}]"); } return null; }
php
protected function getChildValue(ElementInterface $child, $locale) { $accessor = $this->getPropertyAccessor(); $value = $child->getValue(); if (is_array($value)) { return $accessor->getValue($value, "[{$locale}]"); } return null; }
[ "protected", "function", "getChildValue", "(", "ElementInterface", "$", "child", ",", "$", "locale", ")", "{", "$", "accessor", "=", "$", "this", "->", "getPropertyAccessor", "(", ")", ";", "$", "value", "=", "$", "child", "->", "getValue", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "accessor", "->", "getValue", "(", "$", "value", ",", "\"[{$locale}]\"", ")", ";", "}", "return", "null", ";", "}" ]
Returns child values @param ElementInterface $child @param string $locale @return mixed|null
[ "Returns", "child", "values" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Fieldset/LanguageFieldset.php#L183-L193
2,937
bkdotcom/Toolbox
src/Net.php
Net.getHeaderValue
public static function getHeaderValue($key = 'Content-Type', $headers = array()) { $value = null; if (empty($headers)) { // no headers passed... determine from sent if (function_exists('headers_list')) { $headers = headers_list(); } elseif (function_exists('apache_response_headers')) { // apache_response_headers is somewhat worthless.... must flush the output first via ob_end_flush $headers = apache_response_headers(); if (!headers_sent()) { // $this->debug->warn('headers not yet sent.. unable to determine complete list'); // $this->debug->log('headers', $headers); } } else { // $this->debug->warn('unable to determine sent headers'); } } if ($headers) { if (is_string($headers)) { $headers = explode("\n", $headers); } $arrayUtil = new ArrayUtil(); if ($arrayUtil->isHash($headers)) { if (isset($headers[$key])) { $value = $headers[$key]; } } else { foreach ($headers as $header) { if (preg_match('/^'.$key.':\s*([^;]*)/i', $header, $matches)) { $value = $matches[1]; break; } } } } if (is_null($value) && $key == 'Content-Type') { $value = ini_get('default_mimetype'); } // $this->debug->log('value', $value); // $this->debug->groupEnd(); return $value; }
php
public static function getHeaderValue($key = 'Content-Type', $headers = array()) { $value = null; if (empty($headers)) { // no headers passed... determine from sent if (function_exists('headers_list')) { $headers = headers_list(); } elseif (function_exists('apache_response_headers')) { // apache_response_headers is somewhat worthless.... must flush the output first via ob_end_flush $headers = apache_response_headers(); if (!headers_sent()) { // $this->debug->warn('headers not yet sent.. unable to determine complete list'); // $this->debug->log('headers', $headers); } } else { // $this->debug->warn('unable to determine sent headers'); } } if ($headers) { if (is_string($headers)) { $headers = explode("\n", $headers); } $arrayUtil = new ArrayUtil(); if ($arrayUtil->isHash($headers)) { if (isset($headers[$key])) { $value = $headers[$key]; } } else { foreach ($headers as $header) { if (preg_match('/^'.$key.':\s*([^;]*)/i', $header, $matches)) { $value = $matches[1]; break; } } } } if (is_null($value) && $key == 'Content-Type') { $value = ini_get('default_mimetype'); } // $this->debug->log('value', $value); // $this->debug->groupEnd(); return $value; }
[ "public", "static", "function", "getHeaderValue", "(", "$", "key", "=", "'Content-Type'", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "value", "=", "null", ";", "if", "(", "empty", "(", "$", "headers", ")", ")", "{", "// no headers passed... determine from sent", "if", "(", "function_exists", "(", "'headers_list'", ")", ")", "{", "$", "headers", "=", "headers_list", "(", ")", ";", "}", "elseif", "(", "function_exists", "(", "'apache_response_headers'", ")", ")", "{", "// apache_response_headers is somewhat worthless.... must flush the output first via ob_end_flush", "$", "headers", "=", "apache_response_headers", "(", ")", ";", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "// $this->debug->warn('headers not yet sent.. unable to determine complete list');", "// $this->debug->log('headers', $headers);", "}", "}", "else", "{", "// $this->debug->warn('unable to determine sent headers');", "}", "}", "if", "(", "$", "headers", ")", "{", "if", "(", "is_string", "(", "$", "headers", ")", ")", "{", "$", "headers", "=", "explode", "(", "\"\\n\"", ",", "$", "headers", ")", ";", "}", "$", "arrayUtil", "=", "new", "ArrayUtil", "(", ")", ";", "if", "(", "$", "arrayUtil", "->", "isHash", "(", "$", "headers", ")", ")", "{", "if", "(", "isset", "(", "$", "headers", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "headers", "[", "$", "key", "]", ";", "}", "}", "else", "{", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "if", "(", "preg_match", "(", "'/^'", ".", "$", "key", ".", "':\\s*([^;]*)/i'", ",", "$", "header", ",", "$", "matches", ")", ")", "{", "$", "value", "=", "$", "matches", "[", "1", "]", ";", "break", ";", "}", "}", "}", "}", "if", "(", "is_null", "(", "$", "value", ")", "&&", "$", "key", "==", "'Content-Type'", ")", "{", "$", "value", "=", "ini_get", "(", "'default_mimetype'", ")", ";", "}", "// $this->debug->log('value', $value);", "// $this->debug->groupEnd();", "return", "$", "value", ";", "}" ]
Get header value @param string $key Defaults to 'Content-Type' @param array|string $headers =array() Defaults to sent headers, can be string, numeric array, or key/value array @return string
[ "Get", "header", "value" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Net.php#L300-L342
2,938
bkdotcom/Toolbox
src/Net.php
Net.isIpIn
public static function isIpIn($ipAddr, $net, $mask) { // doesn't check for the return value of ip2long $ipAddr = ip2long($ipAddr); $rede = ip2long($net); $mask = ip2long($mask); $res = $ipAddr & $mask; // AND return ($res == $rede); }
php
public static function isIpIn($ipAddr, $net, $mask) { // doesn't check for the return value of ip2long $ipAddr = ip2long($ipAddr); $rede = ip2long($net); $mask = ip2long($mask); $res = $ipAddr & $mask; // AND return ($res == $rede); }
[ "public", "static", "function", "isIpIn", "(", "$", "ipAddr", ",", "$", "net", ",", "$", "mask", ")", "{", "// doesn't check for the return value of ip2long", "$", "ipAddr", "=", "ip2long", "(", "$", "ipAddr", ")", ";", "$", "rede", "=", "ip2long", "(", "$", "net", ")", ";", "$", "mask", "=", "ip2long", "(", "$", "mask", ")", ";", "$", "res", "=", "$", "ipAddr", "&", "$", "mask", ";", "// AND", "return", "(", "$", "res", "==", "$", "rede", ")", ";", "}" ]
is IP address in given subnet? @param string $ipAddr IP address @param string $net network @param string $mask netmask @return boolean
[ "is", "IP", "address", "in", "given", "subnet?" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Net.php#L353-L361
2,939
bkdotcom/Toolbox
src/Net.php
Net.isIpLocal
public static function isIpLocal($ipAddr) { // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $ip); $return = false; if ($ipAddr == '::1') { $ipAddr = '127.0.0.1'; } $net_n_masks = array( array('127.0.0.0', '255.0.0.0'), array('10.0.0.0', '255.0.0.0'), array('192.168.0.0', '255.255.0.0'), array('172.16.0.0', '255.240.0.0'), array('169.254.0.0', '255.255.0.0'), ); foreach ($net_n_masks as $nma) { if (self::isIpIn($ipAddr, $nma[0], $nma[1])) { $return = true; break; } } // $this->debug->groupEnd(); return $return; }
php
public static function isIpLocal($ipAddr) { // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $ip); $return = false; if ($ipAddr == '::1') { $ipAddr = '127.0.0.1'; } $net_n_masks = array( array('127.0.0.0', '255.0.0.0'), array('10.0.0.0', '255.0.0.0'), array('192.168.0.0', '255.255.0.0'), array('172.16.0.0', '255.240.0.0'), array('169.254.0.0', '255.255.0.0'), ); foreach ($net_n_masks as $nma) { if (self::isIpIn($ipAddr, $nma[0], $nma[1])) { $return = true; break; } } // $this->debug->groupEnd(); return $return; }
[ "public", "static", "function", "isIpLocal", "(", "$", "ipAddr", ")", "{", "// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $ip);", "$", "return", "=", "false", ";", "if", "(", "$", "ipAddr", "==", "'::1'", ")", "{", "$", "ipAddr", "=", "'127.0.0.1'", ";", "}", "$", "net_n_masks", "=", "array", "(", "array", "(", "'127.0.0.0'", ",", "'255.0.0.0'", ")", ",", "array", "(", "'10.0.0.0'", ",", "'255.0.0.0'", ")", ",", "array", "(", "'192.168.0.0'", ",", "'255.255.0.0'", ")", ",", "array", "(", "'172.16.0.0'", ",", "'255.240.0.0'", ")", ",", "array", "(", "'169.254.0.0'", ",", "'255.255.0.0'", ")", ",", ")", ";", "foreach", "(", "$", "net_n_masks", "as", "$", "nma", ")", "{", "if", "(", "self", "::", "isIpIn", "(", "$", "ipAddr", ",", "$", "nma", "[", "0", "]", ",", "$", "nma", "[", "1", "]", ")", ")", "{", "$", "return", "=", "true", ";", "break", ";", "}", "}", "// $this->debug->groupEnd();", "return", "$", "return", ";", "}" ]
Returns whether or not IP address is on a local network @param string $ipAddr IP address @return boolean
[ "Returns", "whether", "or", "not", "IP", "address", "is", "on", "a", "local", "network" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Net.php#L370-L392
2,940
bkdotcom/Toolbox
src/Net.php
Net.parseHeaders
public static function parseHeaders($headerString) { $headers = explode("\n", $headerString); $keys = array_keys($headers); $regexReturnCode = '/^\S+\s+(\d+)\s?(.*)/'; $regexHeader = '/^(.*?):\s*(.*)$/'; $headers['Return-Code'] = preg_match($regexReturnCode, $headerString, $matches) ? $matches[1] : 200; foreach ($keys as $k) { $v = trim($headers[$k]); unset($headers[$k]); if (preg_match($regexHeader, $v, $matches)) { $k = $matches[1]; $k = preg_replace_callback('/(^|-)(.?)/', function ($matches) { return $matches[1].strtoupper($matches[2]); }, $k); $v = trim($matches[2]); if (isset($headers[$k])) { if (!is_array($headers[$k])) { $headers[$k] = array($headers[$k]); } $headers[$k][] = $v; } else { $headers[$k] = $v; } } elseif (preg_match($regexReturnCode, $v, $matches)) { $headers['Return-Code'] = $matches[1]; } } return $headers; }
php
public static function parseHeaders($headerString) { $headers = explode("\n", $headerString); $keys = array_keys($headers); $regexReturnCode = '/^\S+\s+(\d+)\s?(.*)/'; $regexHeader = '/^(.*?):\s*(.*)$/'; $headers['Return-Code'] = preg_match($regexReturnCode, $headerString, $matches) ? $matches[1] : 200; foreach ($keys as $k) { $v = trim($headers[$k]); unset($headers[$k]); if (preg_match($regexHeader, $v, $matches)) { $k = $matches[1]; $k = preg_replace_callback('/(^|-)(.?)/', function ($matches) { return $matches[1].strtoupper($matches[2]); }, $k); $v = trim($matches[2]); if (isset($headers[$k])) { if (!is_array($headers[$k])) { $headers[$k] = array($headers[$k]); } $headers[$k][] = $v; } else { $headers[$k] = $v; } } elseif (preg_match($regexReturnCode, $v, $matches)) { $headers['Return-Code'] = $matches[1]; } } return $headers; }
[ "public", "static", "function", "parseHeaders", "(", "$", "headerString", ")", "{", "$", "headers", "=", "explode", "(", "\"\\n\"", ",", "$", "headerString", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "headers", ")", ";", "$", "regexReturnCode", "=", "'/^\\S+\\s+(\\d+)\\s?(.*)/'", ";", "$", "regexHeader", "=", "'/^(.*?):\\s*(.*)$/'", ";", "$", "headers", "[", "'Return-Code'", "]", "=", "preg_match", "(", "$", "regexReturnCode", ",", "$", "headerString", ",", "$", "matches", ")", "?", "$", "matches", "[", "1", "]", ":", "200", ";", "foreach", "(", "$", "keys", "as", "$", "k", ")", "{", "$", "v", "=", "trim", "(", "$", "headers", "[", "$", "k", "]", ")", ";", "unset", "(", "$", "headers", "[", "$", "k", "]", ")", ";", "if", "(", "preg_match", "(", "$", "regexHeader", ",", "$", "v", ",", "$", "matches", ")", ")", "{", "$", "k", "=", "$", "matches", "[", "1", "]", ";", "$", "k", "=", "preg_replace_callback", "(", "'/(^|-)(.?)/'", ",", "function", "(", "$", "matches", ")", "{", "return", "$", "matches", "[", "1", "]", ".", "strtoupper", "(", "$", "matches", "[", "2", "]", ")", ";", "}", ",", "$", "k", ")", ";", "$", "v", "=", "trim", "(", "$", "matches", "[", "2", "]", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "$", "k", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "headers", "[", "$", "k", "]", ")", ")", "{", "$", "headers", "[", "$", "k", "]", "=", "array", "(", "$", "headers", "[", "$", "k", "]", ")", ";", "}", "$", "headers", "[", "$", "k", "]", "[", "]", "=", "$", "v", ";", "}", "else", "{", "$", "headers", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "elseif", "(", "preg_match", "(", "$", "regexReturnCode", ",", "$", "v", ",", "$", "matches", ")", ")", "{", "$", "headers", "[", "'Return-Code'", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Parse header string @param string $headerString header block @return array
[ "Parse", "header", "string" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Net.php#L475-L506
2,941
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.createCursorRecordSet
public function createCursorRecordSet(EntityMetadata $metadata, Cursor $cursor, Store $store) { return new CursorRecordSet($metadata, $cursor, $store, $this); }
php
public function createCursorRecordSet(EntityMetadata $metadata, Cursor $cursor, Store $store) { return new CursorRecordSet($metadata, $cursor, $store, $this); }
[ "public", "function", "createCursorRecordSet", "(", "EntityMetadata", "$", "metadata", ",", "Cursor", "$", "cursor", ",", "Store", "$", "store", ")", "{", "return", "new", "CursorRecordSet", "(", "$", "metadata", ",", "$", "cursor", ",", "$", "store", ",", "$", "this", ")", ";", "}" ]
Creates a cursor record set object from a MongoDB cursor. @param EntityMetadata $metadata @param Cursor $cursor @param Store $store @return CursorRecordSet
[ "Creates", "a", "cursor", "record", "set", "object", "from", "a", "MongoDB", "cursor", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L26-L29
2,942
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.extractType
public function extractType(EntityMetadata $metadata, array $record) { if (false === $metadata->isPolymorphic()) { return $metadata->type; } return $this->extractField(Persister::POLYMORPHIC_KEY, $record); }
php
public function extractType(EntityMetadata $metadata, array $record) { if (false === $metadata->isPolymorphic()) { return $metadata->type; } return $this->extractField(Persister::POLYMORPHIC_KEY, $record); }
[ "public", "function", "extractType", "(", "EntityMetadata", "$", "metadata", ",", "array", "$", "record", ")", "{", "if", "(", "false", "===", "$", "metadata", "->", "isPolymorphic", "(", ")", ")", "{", "return", "$", "metadata", "->", "type", ";", "}", "return", "$", "this", "->", "extractField", "(", "Persister", "::", "POLYMORPHIC_KEY", ",", "$", "record", ")", ";", "}" ]
Extracts the model type from a raw MongoDB record. @param EntityMetadata $metadata @param array $record @return string @throws PersisterException
[ "Extracts", "the", "model", "type", "from", "a", "raw", "MongoDB", "record", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L39-L45
2,943
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.convertRelationships
private function convertRelationships(EntityMetadata $metadata, array $data) { foreach ($metadata->getRelationships() as $key => $relMeta) { if (!isset($data[$key])) { continue; } if (true === $relMeta->isMany() && !is_array($data[$key])) { throw PersisterException::badRequest(sprintf('Relationship key "%s" is a reference many. Expected record data type of array, "%s" found on model "%s" for identifier "%s"', $key, gettype($data[$key]), $type, $identifier)); } $references = $relMeta->isOne() ? [$data[$key]] : $data[$key]; $extracted = []; foreach ($references as $reference) { $extracted[] = $this->extractRelationship($relMeta, $reference); } $data[$key] = $relMeta->isOne() ? reset($extracted) : $extracted; } return $data; }
php
private function convertRelationships(EntityMetadata $metadata, array $data) { foreach ($metadata->getRelationships() as $key => $relMeta) { if (!isset($data[$key])) { continue; } if (true === $relMeta->isMany() && !is_array($data[$key])) { throw PersisterException::badRequest(sprintf('Relationship key "%s" is a reference many. Expected record data type of array, "%s" found on model "%s" for identifier "%s"', $key, gettype($data[$key]), $type, $identifier)); } $references = $relMeta->isOne() ? [$data[$key]] : $data[$key]; $extracted = []; foreach ($references as $reference) { $extracted[] = $this->extractRelationship($relMeta, $reference); } $data[$key] = $relMeta->isOne() ? reset($extracted) : $extracted; } return $data; }
[ "private", "function", "convertRelationships", "(", "EntityMetadata", "$", "metadata", ",", "array", "$", "data", ")", "{", "foreach", "(", "$", "metadata", "->", "getRelationships", "(", ")", "as", "$", "key", "=>", "$", "relMeta", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "true", "===", "$", "relMeta", "->", "isMany", "(", ")", "&&", "!", "is_array", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "throw", "PersisterException", "::", "badRequest", "(", "sprintf", "(", "'Relationship key \"%s\" is a reference many. Expected record data type of array, \"%s\" found on model \"%s\" for identifier \"%s\"'", ",", "$", "key", ",", "gettype", "(", "$", "data", "[", "$", "key", "]", ")", ",", "$", "type", ",", "$", "identifier", ")", ")", ";", "}", "$", "references", "=", "$", "relMeta", "->", "isOne", "(", ")", "?", "[", "$", "data", "[", "$", "key", "]", "]", ":", "$", "data", "[", "$", "key", "]", ";", "$", "extracted", "=", "[", "]", ";", "foreach", "(", "$", "references", "as", "$", "reference", ")", "{", "$", "extracted", "[", "]", "=", "$", "this", "->", "extractRelationship", "(", "$", "relMeta", ",", "$", "reference", ")", ";", "}", "$", "data", "[", "$", "key", "]", "=", "$", "relMeta", "->", "isOne", "(", ")", "?", "reset", "(", "$", "extracted", ")", ":", "$", "extracted", ";", "}", "return", "$", "data", ";", "}" ]
Converts the relationships on a raw result to the proper format. @param EntityMetadata $metadata @param array &$data @return array
[ "Converts", "the", "relationships", "on", "a", "raw", "result", "to", "the", "proper", "format", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L80-L98
2,944
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.extractField
private function extractField($key, array $data) { if (!isset($data[$key])) { throw PersisterException::badRequest(sprintf('Unable to extract a field value. The "%s" key was not found.', $key)); } return $data[$key]; }
php
private function extractField($key, array $data) { if (!isset($data[$key])) { throw PersisterException::badRequest(sprintf('Unable to extract a field value. The "%s" key was not found.', $key)); } return $data[$key]; }
[ "private", "function", "extractField", "(", "$", "key", ",", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "throw", "PersisterException", "::", "badRequest", "(", "sprintf", "(", "'Unable to extract a field value. The \"%s\" key was not found.'", ",", "$", "key", ")", ")", ";", "}", "return", "$", "data", "[", "$", "key", "]", ";", "}" ]
Extracts a root field from a raw MongoDB result. @param string $key @param array $data @return mixed @throws PersisterException
[ "Extracts", "a", "root", "field", "from", "a", "raw", "MongoDB", "result", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L108-L114
2,945
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.extractIdAndType
private function extractIdAndType(EntityMetadata $metadata, array &$data) { $identifier = $this->extractField(Persister::IDENTIFIER_KEY, $data); unset($data[Persister::IDENTIFIER_KEY]); $key = Persister::POLYMORPHIC_KEY; $type = $this->extractType($metadata, $data); if (isset($data[$key])) { unset($data[$key]); } return [$identifier, $type]; }
php
private function extractIdAndType(EntityMetadata $metadata, array &$data) { $identifier = $this->extractField(Persister::IDENTIFIER_KEY, $data); unset($data[Persister::IDENTIFIER_KEY]); $key = Persister::POLYMORPHIC_KEY; $type = $this->extractType($metadata, $data); if (isset($data[$key])) { unset($data[$key]); } return [$identifier, $type]; }
[ "private", "function", "extractIdAndType", "(", "EntityMetadata", "$", "metadata", ",", "array", "&", "$", "data", ")", "{", "$", "identifier", "=", "$", "this", "->", "extractField", "(", "Persister", "::", "IDENTIFIER_KEY", ",", "$", "data", ")", ";", "unset", "(", "$", "data", "[", "Persister", "::", "IDENTIFIER_KEY", "]", ")", ";", "$", "key", "=", "Persister", "::", "POLYMORPHIC_KEY", ";", "$", "type", "=", "$", "this", "->", "extractType", "(", "$", "metadata", ",", "$", "data", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "return", "[", "$", "identifier", ",", "$", "type", "]", ";", "}" ]
Extracts the identifier and model type from a raw result and removes them from the source data. Returns as a tuple. @param EntityMetadata $metadata @param array &$data @return array @throws PersisterException
[ "Extracts", "the", "identifier", "and", "model", "type", "from", "a", "raw", "result", "and", "removes", "them", "from", "the", "source", "data", ".", "Returns", "as", "a", "tuple", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L125-L136
2,946
as3io/modlr-persister-mongodb
src/Hydrator.php
Hydrator.extractRelationship
private function extractRelationship(RelationshipMetadata $relMeta, $reference) { $simple = false === $relMeta->isPolymorphic(); $idKey = Persister::IDENTIFIER_KEY; $typeKey = Persister::POLYMORPHIC_KEY; if (true === $simple && is_array($reference) && isset($reference[$idKey])) { return [ 'id' => $reference[$idKey], 'type' => $relMeta->getEntityType(), ]; } if (true === $simple && !is_array($reference)) { return [ 'id' => $reference, 'type' => $relMeta->getEntityType(), ]; } if (false === $simple && is_array($reference) && isset($reference[$idKey]) && isset($reference[$typeKey])) { return [ 'id' => $reference[$idKey], 'type' => $reference[$typeKey], ]; } throw PersisterException::badRequest('Unable to extract a reference id.'); }
php
private function extractRelationship(RelationshipMetadata $relMeta, $reference) { $simple = false === $relMeta->isPolymorphic(); $idKey = Persister::IDENTIFIER_KEY; $typeKey = Persister::POLYMORPHIC_KEY; if (true === $simple && is_array($reference) && isset($reference[$idKey])) { return [ 'id' => $reference[$idKey], 'type' => $relMeta->getEntityType(), ]; } if (true === $simple && !is_array($reference)) { return [ 'id' => $reference, 'type' => $relMeta->getEntityType(), ]; } if (false === $simple && is_array($reference) && isset($reference[$idKey]) && isset($reference[$typeKey])) { return [ 'id' => $reference[$idKey], 'type' => $reference[$typeKey], ]; } throw PersisterException::badRequest('Unable to extract a reference id.'); }
[ "private", "function", "extractRelationship", "(", "RelationshipMetadata", "$", "relMeta", ",", "$", "reference", ")", "{", "$", "simple", "=", "false", "===", "$", "relMeta", "->", "isPolymorphic", "(", ")", ";", "$", "idKey", "=", "Persister", "::", "IDENTIFIER_KEY", ";", "$", "typeKey", "=", "Persister", "::", "POLYMORPHIC_KEY", ";", "if", "(", "true", "===", "$", "simple", "&&", "is_array", "(", "$", "reference", ")", "&&", "isset", "(", "$", "reference", "[", "$", "idKey", "]", ")", ")", "{", "return", "[", "'id'", "=>", "$", "reference", "[", "$", "idKey", "]", ",", "'type'", "=>", "$", "relMeta", "->", "getEntityType", "(", ")", ",", "]", ";", "}", "if", "(", "true", "===", "$", "simple", "&&", "!", "is_array", "(", "$", "reference", ")", ")", "{", "return", "[", "'id'", "=>", "$", "reference", ",", "'type'", "=>", "$", "relMeta", "->", "getEntityType", "(", ")", ",", "]", ";", "}", "if", "(", "false", "===", "$", "simple", "&&", "is_array", "(", "$", "reference", ")", "&&", "isset", "(", "$", "reference", "[", "$", "idKey", "]", ")", "&&", "isset", "(", "$", "reference", "[", "$", "typeKey", "]", ")", ")", "{", "return", "[", "'id'", "=>", "$", "reference", "[", "$", "idKey", "]", ",", "'type'", "=>", "$", "reference", "[", "$", "typeKey", "]", ",", "]", ";", "}", "throw", "PersisterException", "::", "badRequest", "(", "'Unable to extract a reference id.'", ")", ";", "}" ]
Extracts a standard relationship array that the store expects from a raw MongoDB reference value. @param RelationshipMetadata $relMeta @param mixed $reference @return array @throws RuntimeException If the relationship could not be extracted.
[ "Extracts", "a", "standard", "relationship", "array", "that", "the", "store", "expects", "from", "a", "raw", "MongoDB", "reference", "value", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Hydrator.php#L146-L173
2,947
nirix/radium
src/Database/Model/Base.php
Base.setUpdatedAt
protected function setUpdatedAt() { // Convert created_at back to GMT for saving if (isset($this->created_at)) { $this->created_at = Time::localToGmt($this->created_at); } // Set updated at if (!isset($this->updated_at) or $this->updated_at === null) { $this->updated_at = 'NOW()'; } }
php
protected function setUpdatedAt() { // Convert created_at back to GMT for saving if (isset($this->created_at)) { $this->created_at = Time::localToGmt($this->created_at); } // Set updated at if (!isset($this->updated_at) or $this->updated_at === null) { $this->updated_at = 'NOW()'; } }
[ "protected", "function", "setUpdatedAt", "(", ")", "{", "// Convert created_at back to GMT for saving", "if", "(", "isset", "(", "$", "this", "->", "created_at", ")", ")", "{", "$", "this", "->", "created_at", "=", "Time", "::", "localToGmt", "(", "$", "this", "->", "created_at", ")", ";", "}", "// Set updated at", "if", "(", "!", "isset", "(", "$", "this", "->", "updated_at", ")", "or", "$", "this", "->", "updated_at", "===", "null", ")", "{", "$", "this", "->", "updated_at", "=", "'NOW()'", ";", "}", "}" ]
Set the updated_at value.
[ "Set", "the", "updated_at", "value", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Base.php#L178-L189
2,948
litert/delay-initializer
lib/TItemContainer.php
TItemContainer.getItem
public function getItem(string $name) { if (isset($this->__delayItems[$name])) { return $this->__delayItems[$name]; } if (!is_callable($this->__delayCtors[$name] ?? false)) { throw new Exception( "Item {$name} not found.", Exception::ITEM_NOT_FOUND ); } return $this->__delayItems[$name] = $this->__delayCtors[$name]( ...$this->__delayCtorArgs ); }
php
public function getItem(string $name) { if (isset($this->__delayItems[$name])) { return $this->__delayItems[$name]; } if (!is_callable($this->__delayCtors[$name] ?? false)) { throw new Exception( "Item {$name} not found.", Exception::ITEM_NOT_FOUND ); } return $this->__delayItems[$name] = $this->__delayCtors[$name]( ...$this->__delayCtorArgs ); }
[ "public", "function", "getItem", "(", "string", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "__delayItems", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "__delayItems", "[", "$", "name", "]", ";", "}", "if", "(", "!", "is_callable", "(", "$", "this", "->", "__delayCtors", "[", "$", "name", "]", "??", "false", ")", ")", "{", "throw", "new", "Exception", "(", "\"Item {$name} not found.\"", ",", "Exception", "::", "ITEM_NOT_FOUND", ")", ";", "}", "return", "$", "this", "->", "__delayItems", "[", "$", "name", "]", "=", "$", "this", "->", "__delayCtors", "[", "$", "name", "]", "(", "...", "$", "this", "->", "__delayCtorArgs", ")", ";", "}" ]
Get a delay-initialized item by name. @param string $name name of item @return mixed @throws Exception
[ "Get", "a", "delay", "-", "initialized", "item", "by", "name", "." ]
073d03bdee435d13eece459ca1a88b2b955809c8
https://github.com/litert/delay-initializer/blob/073d03bdee435d13eece459ca1a88b2b955809c8/lib/TItemContainer.php#L60-L78
2,949
Thuata/FrameworkBundle
Repository/Registry/RegistryFactory.php
RegistryFactory.injectDependencies
private function injectDependencies(RegistryInterface $registry, $entityName = null, EntityManager $entityManager = null) { if (!($entityManager instanceof EntityManager)) { /** @var EntityManager $entityManager */ $entityManager = $this->container->get('doctrine.orm.entity_manager'); } if ($registry instanceof EntityManagerAwareInterface) { $registry->setEntityManager($entityManager); } if ($registry instanceof EntityRegistry) { if ($entityName === null) { throw new \Exception('Can\'t load an entity registry without entity name'); } $registry->setEntityRepository($entityManager->getRepository($entityName)); } if ($registry instanceof MongoDBAwareInterface) { if ($entityName === null) { throw new \Exception('Can\'t load a mongodb registry without entity name'); } $collection = ConnectionFactory::getInstance()->getConnection()->getMongoDatabase()->selectCollection($entityName); $registry->setMongoDBCollection($collection); } if ($registry instanceof ClassAwareInterface) { $shortcutParser = new ShortcutNotationParser($entityName); $bundle = $this->container->get('kernel')->getBundle($shortcutParser->getBundleName()); $stackConfiguration = new EntityStackConfiguration($bundle, $shortcutParser->getEntityName()); if ($registry instanceof MongoDBAwareInterface) { $registry->setEntityClass($stackConfiguration->getDocumentClass()); } else { $registry->setEntityClass($stackConfiguration->getEntityClass()); } } }
php
private function injectDependencies(RegistryInterface $registry, $entityName = null, EntityManager $entityManager = null) { if (!($entityManager instanceof EntityManager)) { /** @var EntityManager $entityManager */ $entityManager = $this->container->get('doctrine.orm.entity_manager'); } if ($registry instanceof EntityManagerAwareInterface) { $registry->setEntityManager($entityManager); } if ($registry instanceof EntityRegistry) { if ($entityName === null) { throw new \Exception('Can\'t load an entity registry without entity name'); } $registry->setEntityRepository($entityManager->getRepository($entityName)); } if ($registry instanceof MongoDBAwareInterface) { if ($entityName === null) { throw new \Exception('Can\'t load a mongodb registry without entity name'); } $collection = ConnectionFactory::getInstance()->getConnection()->getMongoDatabase()->selectCollection($entityName); $registry->setMongoDBCollection($collection); } if ($registry instanceof ClassAwareInterface) { $shortcutParser = new ShortcutNotationParser($entityName); $bundle = $this->container->get('kernel')->getBundle($shortcutParser->getBundleName()); $stackConfiguration = new EntityStackConfiguration($bundle, $shortcutParser->getEntityName()); if ($registry instanceof MongoDBAwareInterface) { $registry->setEntityClass($stackConfiguration->getDocumentClass()); } else { $registry->setEntityClass($stackConfiguration->getEntityClass()); } } }
[ "private", "function", "injectDependencies", "(", "RegistryInterface", "$", "registry", ",", "$", "entityName", "=", "null", ",", "EntityManager", "$", "entityManager", "=", "null", ")", "{", "if", "(", "!", "(", "$", "entityManager", "instanceof", "EntityManager", ")", ")", "{", "/** @var EntityManager $entityManager */", "$", "entityManager", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", ";", "}", "if", "(", "$", "registry", "instanceof", "EntityManagerAwareInterface", ")", "{", "$", "registry", "->", "setEntityManager", "(", "$", "entityManager", ")", ";", "}", "if", "(", "$", "registry", "instanceof", "EntityRegistry", ")", "{", "if", "(", "$", "entityName", "===", "null", ")", "{", "throw", "new", "\\", "Exception", "(", "'Can\\'t load an entity registry without entity name'", ")", ";", "}", "$", "registry", "->", "setEntityRepository", "(", "$", "entityManager", "->", "getRepository", "(", "$", "entityName", ")", ")", ";", "}", "if", "(", "$", "registry", "instanceof", "MongoDBAwareInterface", ")", "{", "if", "(", "$", "entityName", "===", "null", ")", "{", "throw", "new", "\\", "Exception", "(", "'Can\\'t load a mongodb registry without entity name'", ")", ";", "}", "$", "collection", "=", "ConnectionFactory", "::", "getInstance", "(", ")", "->", "getConnection", "(", ")", "->", "getMongoDatabase", "(", ")", "->", "selectCollection", "(", "$", "entityName", ")", ";", "$", "registry", "->", "setMongoDBCollection", "(", "$", "collection", ")", ";", "}", "if", "(", "$", "registry", "instanceof", "ClassAwareInterface", ")", "{", "$", "shortcutParser", "=", "new", "ShortcutNotationParser", "(", "$", "entityName", ")", ";", "$", "bundle", "=", "$", "this", "->", "container", "->", "get", "(", "'kernel'", ")", "->", "getBundle", "(", "$", "shortcutParser", "->", "getBundleName", "(", ")", ")", ";", "$", "stackConfiguration", "=", "new", "EntityStackConfiguration", "(", "$", "bundle", ",", "$", "shortcutParser", "->", "getEntityName", "(", ")", ")", ";", "if", "(", "$", "registry", "instanceof", "MongoDBAwareInterface", ")", "{", "$", "registry", "->", "setEntityClass", "(", "$", "stackConfiguration", "->", "getDocumentClass", "(", ")", ")", ";", "}", "else", "{", "$", "registry", "->", "setEntityClass", "(", "$", "stackConfiguration", "->", "getEntityClass", "(", ")", ")", ";", "}", "}", "}" ]
Inject dependencies using implemented interfaces to registry @param \Thuata\ComponentBundle\Registry\RegistryInterface $registry @param string|null $entityName @param EntityManager $entityManager @throws \Exception
[ "Inject", "dependencies", "using", "implemented", "interfaces", "to", "registry" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/RegistryFactory.php#L103-L143
2,950
Thuata/FrameworkBundle
Repository/Registry/RegistryFactory.php
RegistryFactory.getRegistry
public function getRegistry(string $registryName, $entityClass = null, EntityManager $entityManager = null) { if (!array_key_exists($registryName, self::$registries)) { throw new InvalidRegistryName($registryName); } $reflectionClass = new \ReflectionClass(self::$registries[$registryName]); /** @var RegistryInterface $instance */ $instance = $reflectionClass->newInstance(); $this->injectDependencies($instance, $entityClass, $entityManager); return $instance; }
php
public function getRegistry(string $registryName, $entityClass = null, EntityManager $entityManager = null) { if (!array_key_exists($registryName, self::$registries)) { throw new InvalidRegistryName($registryName); } $reflectionClass = new \ReflectionClass(self::$registries[$registryName]); /** @var RegistryInterface $instance */ $instance = $reflectionClass->newInstance(); $this->injectDependencies($instance, $entityClass, $entityManager); return $instance; }
[ "public", "function", "getRegistry", "(", "string", "$", "registryName", ",", "$", "entityClass", "=", "null", ",", "EntityManager", "$", "entityManager", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "registryName", ",", "self", "::", "$", "registries", ")", ")", "{", "throw", "new", "InvalidRegistryName", "(", "$", "registryName", ")", ";", "}", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "self", "::", "$", "registries", "[", "$", "registryName", "]", ")", ";", "/** @var RegistryInterface $instance */", "$", "instance", "=", "$", "reflectionClass", "->", "newInstance", "(", ")", ";", "$", "this", "->", "injectDependencies", "(", "$", "instance", ",", "$", "entityClass", ",", "$", "entityManager", ")", ";", "return", "$", "instance", ";", "}" ]
Gets a registry from its name @param string $registryName @param string $entityClass @param EntityManager $entityManager @return RegistryInterface
[ "Gets", "a", "registry", "from", "its", "name" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/RegistryFactory.php#L154-L168
2,951
vincenttouzet/BaseBundle
Manager/BaseManager.php
BaseManager.persist
public function persist($object, $flush = true) { if ($object->getId()) { $this->update($object, $flush); } else { $this->create($object, $flush); } }
php
public function persist($object, $flush = true) { if ($object->getId()) { $this->update($object, $flush); } else { $this->create($object, $flush); } }
[ "public", "function", "persist", "(", "$", "object", ",", "$", "flush", "=", "true", ")", "{", "if", "(", "$", "object", "->", "getId", "(", ")", ")", "{", "$", "this", "->", "update", "(", "$", "object", ",", "$", "flush", ")", ";", "}", "else", "{", "$", "this", "->", "create", "(", "$", "object", ",", "$", "flush", ")", ";", "}", "}" ]
Persist an object into database. @param Object $object Object @param bool $flush Flush entity manager
[ "Persist", "an", "object", "into", "database", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Manager/BaseManager.php#L65-L72
2,952
vincenttouzet/BaseBundle
Manager/BaseManager.php
BaseManager.create
public function create($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preCreate($object); $entityManager->persist($object); if ($flush) { $entityManager->flush(); } $this->postCreate($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
php
public function create($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preCreate($object); $entityManager->persist($object); if ($flush) { $entityManager->flush(); } $this->postCreate($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
[ "public", "function", "create", "(", "$", "object", ",", "$", "flush", "=", "true", ")", "{", "try", "{", "$", "entityManager", "=", "$", "this", "->", "getEntityManager", "(", "$", "object", ")", ";", "$", "this", "->", "preCreate", "(", "$", "object", ")", ";", "$", "entityManager", "->", "persist", "(", "$", "object", ")", ";", "if", "(", "$", "flush", ")", "{", "$", "entityManager", "->", "flush", "(", ")", ";", "}", "$", "this", "->", "postCreate", "(", "$", "object", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "ModelManagerException", "(", "''", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
create new entity in database. @param Object $object Object @param Boolean $flush Flush entity manager @see Sonata\DoctrineORMAdminBundle\Model\ModelManager::create()
[ "create", "new", "entity", "in", "database", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Manager/BaseManager.php#L82-L95
2,953
vincenttouzet/BaseBundle
Manager/BaseManager.php
BaseManager.update
public function update($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preUpdate($object); $entityManager->persist($object); if ($flush) { $entityManager->flush(); } $this->postUpdate($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
php
public function update($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preUpdate($object); $entityManager->persist($object); if ($flush) { $entityManager->flush(); } $this->postUpdate($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
[ "public", "function", "update", "(", "$", "object", ",", "$", "flush", "=", "true", ")", "{", "try", "{", "$", "entityManager", "=", "$", "this", "->", "getEntityManager", "(", "$", "object", ")", ";", "$", "this", "->", "preUpdate", "(", "$", "object", ")", ";", "$", "entityManager", "->", "persist", "(", "$", "object", ")", ";", "if", "(", "$", "flush", ")", "{", "$", "entityManager", "->", "flush", "(", ")", ";", "}", "$", "this", "->", "postUpdate", "(", "$", "object", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "ModelManagerException", "(", "''", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
update an object into database. @param Object $object Object @param Boolean $flush Flush entity manager @see Sonata\DoctrineORMAdminBundle\Model\ModelManager::update()
[ "update", "an", "object", "into", "database", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Manager/BaseManager.php#L123-L136
2,954
vincenttouzet/BaseBundle
Manager/BaseManager.php
BaseManager.delete
public function delete($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preDelete($object); $entityManager->remove($object); if ($flush) { $entityManager->flush(); } $this->postDelete($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
php
public function delete($object, $flush = true) { try { $entityManager = $this->getEntityManager($object); $this->preDelete($object); $entityManager->remove($object); if ($flush) { $entityManager->flush(); } $this->postDelete($object); } catch (\PDOException $e) { throw new ModelManagerException('', 0, $e); } }
[ "public", "function", "delete", "(", "$", "object", ",", "$", "flush", "=", "true", ")", "{", "try", "{", "$", "entityManager", "=", "$", "this", "->", "getEntityManager", "(", "$", "object", ")", ";", "$", "this", "->", "preDelete", "(", "$", "object", ")", ";", "$", "entityManager", "->", "remove", "(", "$", "object", ")", ";", "if", "(", "$", "flush", ")", "{", "$", "entityManager", "->", "flush", "(", ")", ";", "}", "$", "this", "->", "postDelete", "(", "$", "object", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "ModelManagerException", "(", "''", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
delete an object from database. @param Object $object Object @param Boolean $flush Flush entity manager @see Sonata\DoctrineORMAdminBundle\Model\ModelManager::delete()
[ "delete", "an", "object", "from", "database", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Manager/BaseManager.php#L164-L177
2,955
vincenttouzet/BaseBundle
Manager/BaseManager.php
BaseManager.getBatchObjects
public function getBatchObjects($class, ProxyQueryInterface $queryProxy) { $queryProxy->select('DISTINCT '.$queryProxy->getRootAlias()); return $queryProxy->getQuery()->execute(); }
php
public function getBatchObjects($class, ProxyQueryInterface $queryProxy) { $queryProxy->select('DISTINCT '.$queryProxy->getRootAlias()); return $queryProxy->getQuery()->execute(); }
[ "public", "function", "getBatchObjects", "(", "$", "class", ",", "ProxyQueryInterface", "$", "queryProxy", ")", "{", "$", "queryProxy", "->", "select", "(", "'DISTINCT '", ".", "$", "queryProxy", "->", "getRootAlias", "(", ")", ")", ";", "return", "$", "queryProxy", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Retrieve objects from a batch request. @param string $class Class name @param ProxyQueryInterface $queryProxy ProxyQueryInterface instance @throws \Exception
[ "Retrieve", "objects", "from", "a", "batch", "request", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Manager/BaseManager.php#L205-L210
2,956
mvccore/ext-view-helper-writebyjs
src/MvcCore/Ext/Views/Helpers/WriteByJsHelper.php
WriteByJsHelper.WriteByJs
public function WriteByJs ($string) { $resultStringArr = []; for ($i = 0, $l = strlen($string); $i < $l; $i++) { $char = mb_substr($string, $i, 1, 'UTF-8'); if (mb_check_encoding($char, 'UTF-8')) { $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8'); $resultStringArr[] = hexdec(bin2hex($ret)); } } $utf8Indexes = implode(',', $resultStringArr); $utf8Indexes = trim($utf8Indexes, ','); while (substr($utf8Indexes, strlen($utf8Indexes) - 2, 2) == ',0') { $utf8Indexes = substr($utf8Indexes, 0, strlen($utf8Indexes) - 2); } return '<script>document.write(String.fromCharCode(' . $utf8Indexes . '));</script>'; }
php
public function WriteByJs ($string) { $resultStringArr = []; for ($i = 0, $l = strlen($string); $i < $l; $i++) { $char = mb_substr($string, $i, 1, 'UTF-8'); if (mb_check_encoding($char, 'UTF-8')) { $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8'); $resultStringArr[] = hexdec(bin2hex($ret)); } } $utf8Indexes = implode(',', $resultStringArr); $utf8Indexes = trim($utf8Indexes, ','); while (substr($utf8Indexes, strlen($utf8Indexes) - 2, 2) == ',0') { $utf8Indexes = substr($utf8Indexes, 0, strlen($utf8Indexes) - 2); } return '<script>document.write(String.fromCharCode(' . $utf8Indexes . '));</script>'; }
[ "public", "function", "WriteByJs", "(", "$", "string", ")", "{", "$", "resultStringArr", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ",", "$", "l", "=", "strlen", "(", "$", "string", ")", ";", "$", "i", "<", "$", "l", ";", "$", "i", "++", ")", "{", "$", "char", "=", "mb_substr", "(", "$", "string", ",", "$", "i", ",", "1", ",", "'UTF-8'", ")", ";", "if", "(", "mb_check_encoding", "(", "$", "char", ",", "'UTF-8'", ")", ")", "{", "$", "ret", "=", "mb_convert_encoding", "(", "$", "char", ",", "'UTF-32BE'", ",", "'UTF-8'", ")", ";", "$", "resultStringArr", "[", "]", "=", "hexdec", "(", "bin2hex", "(", "$", "ret", ")", ")", ";", "}", "}", "$", "utf8Indexes", "=", "implode", "(", "','", ",", "$", "resultStringArr", ")", ";", "$", "utf8Indexes", "=", "trim", "(", "$", "utf8Indexes", ",", "','", ")", ";", "while", "(", "substr", "(", "$", "utf8Indexes", ",", "strlen", "(", "$", "utf8Indexes", ")", "-", "2", ",", "2", ")", "==", "',0'", ")", "{", "$", "utf8Indexes", "=", "substr", "(", "$", "utf8Indexes", ",", "0", ",", "strlen", "(", "$", "utf8Indexes", ")", "-", "2", ")", ";", "}", "return", "'<script>document.write(String.fromCharCode('", ".", "$", "utf8Indexes", ".", "'));</script>'", ";", "}" ]
Any plaint text or any html content. @param string $string @return string
[ "Any", "plaint", "text", "or", "any", "html", "content", "." ]
53f33dbeb752f21989780fe36ea34418293e9df5
https://github.com/mvccore/ext-view-helper-writebyjs/blob/53f33dbeb752f21989780fe36ea34418293e9df5/src/MvcCore/Ext/Views/Helpers/WriteByJsHelper.php#L38-L53
2,957
GustavSoftware/Utils
src/Miscellaneous.php
Miscellaneous.cloneArray
public static function cloneArray(array $array): array { $newArray = []; foreach($array as $key => $value) { if(\is_object($value)) { $newArray[$key] = clone $value; } elseif(\is_array($value)) { $newArray[$key] = self::cloneArray($value); } else { $newArray[$key] = $value; } } return $newArray; }
php
public static function cloneArray(array $array): array { $newArray = []; foreach($array as $key => $value) { if(\is_object($value)) { $newArray[$key] = clone $value; } elseif(\is_array($value)) { $newArray[$key] = self::cloneArray($value); } else { $newArray[$key] = $value; } } return $newArray; }
[ "public", "static", "function", "cloneArray", "(", "array", "$", "array", ")", ":", "array", "{", "$", "newArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "is_object", "(", "$", "value", ")", ")", "{", "$", "newArray", "[", "$", "key", "]", "=", "clone", "$", "value", ";", "}", "elseif", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "$", "newArray", "[", "$", "key", "]", "=", "self", "::", "cloneArray", "(", "$", "value", ")", ";", "}", "else", "{", "$", "newArray", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "newArray", ";", "}" ]
This method clones an array recursively. So all objects contained in this array will be cloned correctly. @param array $array The array to clone @return array The cloned array
[ "This", "method", "clones", "an", "array", "recursively", ".", "So", "all", "objects", "contained", "in", "this", "array", "will", "be", "cloned", "correctly", "." ]
370131e9baf3477863123ca31972cbbfaaf2f39b
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/Miscellaneous.php#L212-L225
2,958
phpservicebus/core
src/Serialization/Json/ObjectNormalizer.php
ObjectNormalizer.extractObjectProperties
private function extractObjectProperties($object) { $propertyToValue = []; if (method_exists($object, '__sleep')) { $properties = $object->__sleep(); foreach ($properties as $property) { $propertyToValue[$property] = $object->$property; } return $propertyToValue; } $reflectedProperties = []; $ref = new \ReflectionClass($object); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $propertyToValue[$property->getName()] = $property->getValue($object); $reflectedProperties[] = $property->getName(); } $dynamicProperties = array_diff(array_keys(get_object_vars($object)), $reflectedProperties); foreach ($dynamicProperties as $property) { $propertyToValue[$property] = $object->$property; } return $propertyToValue; }
php
private function extractObjectProperties($object) { $propertyToValue = []; if (method_exists($object, '__sleep')) { $properties = $object->__sleep(); foreach ($properties as $property) { $propertyToValue[$property] = $object->$property; } return $propertyToValue; } $reflectedProperties = []; $ref = new \ReflectionClass($object); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $propertyToValue[$property->getName()] = $property->getValue($object); $reflectedProperties[] = $property->getName(); } $dynamicProperties = array_diff(array_keys(get_object_vars($object)), $reflectedProperties); foreach ($dynamicProperties as $property) { $propertyToValue[$property] = $object->$property; } return $propertyToValue; }
[ "private", "function", "extractObjectProperties", "(", "$", "object", ")", "{", "$", "propertyToValue", "=", "[", "]", ";", "if", "(", "method_exists", "(", "$", "object", ",", "'__sleep'", ")", ")", "{", "$", "properties", "=", "$", "object", "->", "__sleep", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "propertyToValue", "[", "$", "property", "]", "=", "$", "object", "->", "$", "property", ";", "}", "return", "$", "propertyToValue", ";", "}", "$", "reflectedProperties", "=", "[", "]", ";", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "foreach", "(", "$", "ref", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "propertyToValue", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "$", "reflectedProperties", "[", "]", "=", "$", "property", "->", "getName", "(", ")", ";", "}", "$", "dynamicProperties", "=", "array_diff", "(", "array_keys", "(", "get_object_vars", "(", "$", "object", ")", ")", ",", "$", "reflectedProperties", ")", ";", "foreach", "(", "$", "dynamicProperties", "as", "$", "property", ")", "{", "$", "propertyToValue", "[", "$", "property", "]", "=", "$", "object", "->", "$", "property", ";", "}", "return", "$", "propertyToValue", ";", "}" ]
Returns an array containing the object's properties to values @param object $object @return array
[ "Returns", "an", "array", "containing", "the", "object", "s", "properties", "to", "values" ]
adbcf94be1e022120ede0c5aafa8a4f7900b0a6c
https://github.com/phpservicebus/core/blob/adbcf94be1e022120ede0c5aafa8a4f7900b0a6c/src/Serialization/Json/ObjectNormalizer.php#L133-L162
2,959
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.getDefaultAssociationsFilter
protected function getDefaultAssociationsFilter() { $filter = new AssociationsFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
php
protected function getDefaultAssociationsFilter() { $filter = new AssociationsFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
[ "protected", "function", "getDefaultAssociationsFilter", "(", ")", "{", "$", "filter", "=", "new", "AssociationsFilter", "(", ")", ";", "$", "filter", "->", "setInsideAssociationID", "(", "$", "this", "->", "arguments", "[", "self", "::", "ARGUMENT_INSIDEASSOCIATIONID", "]", ")", ";", "return", "$", "filter", ";", "}" ]
Get the default associations filter. @return AssociationsFilter
[ "Get", "the", "default", "associations", "filter", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L58-L64
2,960
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.getDefaultAssociationFilter
protected function getDefaultAssociationFilter() { $filter = new AssociationFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
php
protected function getDefaultAssociationFilter() { $filter = new AssociationFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
[ "protected", "function", "getDefaultAssociationFilter", "(", ")", "{", "$", "filter", "=", "new", "AssociationFilter", "(", ")", ";", "$", "filter", "->", "setInsideAssociationID", "(", "$", "this", "->", "arguments", "[", "self", "::", "ARGUMENT_INSIDEASSOCIATIONID", "]", ")", ";", "return", "$", "filter", ";", "}" ]
Get the default association filter. @return AssociationFilter
[ "Get", "the", "default", "association", "filter", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L71-L77
2,961
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.getDefaultEventFilter
protected function getDefaultEventFilter() { $filter = new EventFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
php
protected function getDefaultEventFilter() { $filter = new EventFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
[ "protected", "function", "getDefaultEventFilter", "(", ")", "{", "$", "filter", "=", "new", "EventFilter", "(", ")", ";", "$", "filter", "->", "setInsideAssociationID", "(", "$", "this", "->", "arguments", "[", "self", "::", "ARGUMENT_INSIDEASSOCIATIONID", "]", ")", ";", "return", "$", "filter", ";", "}" ]
Get the default event filter. @return EventFilter
[ "Get", "the", "default", "event", "filter", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L84-L90
2,962
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.getDefaultAnnouncementFilter
protected function getDefaultAnnouncementFilter() { $filter = new AnnouncementFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
php
protected function getDefaultAnnouncementFilter() { $filter = new AnnouncementFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
[ "protected", "function", "getDefaultAnnouncementFilter", "(", ")", "{", "$", "filter", "=", "new", "AnnouncementFilter", "(", ")", ";", "$", "filter", "->", "setInsideAssociationID", "(", "$", "this", "->", "arguments", "[", "self", "::", "ARGUMENT_INSIDEASSOCIATIONID", "]", ")", ";", "return", "$", "filter", ";", "}" ]
Get the default announcement filter. @return AnnouncementFilter
[ "Get", "the", "default", "announcement", "filter", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L110-L116
2,963
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.getDefaultFunctionaryFilter
protected function getDefaultFunctionaryFilter() { $filter = new FunctionaryFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
php
protected function getDefaultFunctionaryFilter() { $filter = new FunctionaryFilter(); $filter->setInsideAssociationID($this->arguments[self::ARGUMENT_INSIDEASSOCIATIONID]); return $filter; }
[ "protected", "function", "getDefaultFunctionaryFilter", "(", ")", "{", "$", "filter", "=", "new", "FunctionaryFilter", "(", ")", ";", "$", "filter", "->", "setInsideAssociationID", "(", "$", "this", "->", "arguments", "[", "self", "::", "ARGUMENT_INSIDEASSOCIATIONID", "]", ")", ";", "return", "$", "filter", ";", "}" ]
Get the default functionary filter. @return FunctionaryFilter
[ "Get", "the", "default", "functionary", "filter", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L136-L142
2,964
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.removeNullValuesFromArray
protected function removeNullValuesFromArray($array) { $result = []; foreach ($array as $key => $value) { if (isset($value)) { if (($value instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage && count($value) > 0) || !($value instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage)) { $result[$key] = $value; } } } return $result; }
php
protected function removeNullValuesFromArray($array) { $result = []; foreach ($array as $key => $value) { if (isset($value)) { if (($value instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage && count($value) > 0) || !($value instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage)) { $result[$key] = $value; } } } return $result; }
[ "protected", "function", "removeNullValuesFromArray", "(", "$", "array", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", ")", ")", "{", "if", "(", "(", "$", "value", "instanceof", "\\", "TYPO3", "\\", "CMS", "\\", "Extbase", "\\", "Persistence", "\\", "ObjectStorage", "&&", "count", "(", "$", "value", ")", ">", "0", ")", "||", "!", "(", "$", "value", "instanceof", "\\", "TYPO3", "\\", "CMS", "\\", "Extbase", "\\", "Persistence", "\\", "ObjectStorage", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
remove all null values from the array @param array $array @return array
[ "remove", "all", "null", "values", "from", "the", "array" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L163-L176
2,965
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.checkDateTime
protected function checkDateTime($value, $base = null) { if (is_null($value)) { return $value; } if (!$value instanceof \DateTimeInterface) { return $this->buildDateTimebyString($value, $base); } else { return $value; } }
php
protected function checkDateTime($value, $base = null) { if (is_null($value)) { return $value; } if (!$value instanceof \DateTimeInterface) { return $this->buildDateTimebyString($value, $base); } else { return $value; } }
[ "protected", "function", "checkDateTime", "(", "$", "value", ",", "$", "base", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "!", "$", "value", "instanceof", "\\", "DateTimeInterface", ")", "{", "return", "$", "this", "->", "buildDateTimebyString", "(", "$", "value", ",", "$", "base", ")", ";", "}", "else", "{", "return", "$", "value", ";", "}", "}" ]
check a dateTime value @param mixed $value @param mixed $base @return \DateTimeInterface @throws Exception
[ "check", "a", "dateTime", "value" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L206-L217
2,966
codebobbly/dvoconnector
Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php
AbstractDvoContextApiViewHelper.buildDateTimebyString
protected function buildDateTimebyString($stringDate, $base = null) { if (is_null($base)) { $base = time(); } try { $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base); $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base); $date = new \DateTime('@' . $dateTimestamp); $date->setTimezone(new \DateTimeZone(date_default_timezone_get())); } catch (\Exception $exception) { throw new Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579); } }
php
protected function buildDateTimebyString($stringDate, $base = null) { if (is_null($base)) { $base = time(); } try { $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base); $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base); $date = new \DateTime('@' . $dateTimestamp); $date->setTimezone(new \DateTimeZone(date_default_timezone_get())); } catch (\Exception $exception) { throw new Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579); } }
[ "protected", "function", "buildDateTimebyString", "(", "$", "stringDate", ",", "$", "base", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "base", ")", ")", "{", "$", "base", "=", "time", "(", ")", ";", "}", "try", "{", "$", "base", "=", "$", "base", "instanceof", "\\", "DateTimeInterface", "?", "$", "base", "->", "format", "(", "'U'", ")", ":", "strtotime", "(", "(", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "$", "base", ")", "?", "'@'", ":", "''", ")", ".", "$", "base", ")", ";", "$", "dateTimestamp", "=", "strtotime", "(", "(", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "$", "date", ")", "?", "'@'", ":", "''", ")", ".", "$", "date", ",", "$", "base", ")", ";", "$", "date", "=", "new", "\\", "DateTime", "(", "'@'", ".", "$", "dateTimestamp", ")", ";", "$", "date", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "date_default_timezone_get", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "throw", "new", "Exception", "(", "'\"'", ".", "$", "date", ".", "'\" could not be parsed by \\DateTime constructor: '", ".", "$", "exception", "->", "getMessage", "(", ")", ",", "1241722579", ")", ";", "}", "}" ]
Build a DateTime of a String @param string $stringDate @param mixed $base @return \DateTimeInterface @throws Exception
[ "Build", "a", "DateTime", "of", "a", "String" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/ViewHelpers/AbstractDvoContextApiViewHelper.php#L227-L241
2,967
Palmabit-IT/authenticator
src/controllers/AuthController.php
AuthController.postReminder
public function postReminder() { $email = Input::get('email'); try { $this->reminder->send($email); return Redirect::to("/user/recupero-success")->with(array ("messageReminder" => L::t('Check your mail inbox, we sent you an email to recover your password.'))); } catch (Pbi $e) { $errors = $this->reminder->getErrors(); return Redirect::back()->withErrors($errors); } }
php
public function postReminder() { $email = Input::get('email'); try { $this->reminder->send($email); return Redirect::to("/user/recupero-success")->with(array ("messageReminder" => L::t('Check your mail inbox, we sent you an email to recover your password.'))); } catch (Pbi $e) { $errors = $this->reminder->getErrors(); return Redirect::back()->withErrors($errors); } }
[ "public", "function", "postReminder", "(", ")", "{", "$", "email", "=", "Input", "::", "get", "(", "'email'", ")", ";", "try", "{", "$", "this", "->", "reminder", "->", "send", "(", "$", "email", ")", ";", "return", "Redirect", "::", "to", "(", "\"/user/recupero-success\"", ")", "->", "with", "(", "array", "(", "\"messageReminder\"", "=>", "L", "::", "t", "(", "'Check your mail inbox, we sent you an email to recover your password.'", ")", ")", ")", ";", "}", "catch", "(", "Pbi", "$", "e", ")", "{", "$", "errors", "=", "$", "this", "->", "reminder", "->", "getErrors", "(", ")", ";", "return", "Redirect", "::", "back", "(", ")", "->", "withErrors", "(", "$", "errors", ")", ";", "}", "}" ]
Invio token per set nuova password via mail @return mixed
[ "Invio", "token", "per", "set", "nuova", "password", "via", "mail" ]
986cfc7e666e0e1b0312e518d586ec61b08cdb42
https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/controllers/AuthController.php#L72-L82
2,968
99designs/ergo
classes/Ergo/Routing/Route.php
Route._getParameterPattern
private function _getParameterPattern($template) { // support star matches $template = preg_replace('/\*/','.*?',$template); return sprintf('#^%s$#', preg_replace_callback( self::REGEX_PARAM, array($this, '_typePatternCallback'), $template ) ); }
php
private function _getParameterPattern($template) { // support star matches $template = preg_replace('/\*/','.*?',$template); return sprintf('#^%s$#', preg_replace_callback( self::REGEX_PARAM, array($this, '_typePatternCallback'), $template ) ); }
[ "private", "function", "_getParameterPattern", "(", "$", "template", ")", "{", "// support star matches", "$", "template", "=", "preg_replace", "(", "'/\\*/'", ",", "'.*?'", ",", "$", "template", ")", ";", "return", "sprintf", "(", "'#^%s$#'", ",", "preg_replace_callback", "(", "self", "::", "REGEX_PARAM", ",", "array", "(", "$", "this", ",", "'_typePatternCallback'", ")", ",", "$", "template", ")", ")", ";", "}" ]
Gets a pattern that can be used for parsing a template @param string $template @return array list of
[ "Gets", "a", "pattern", "that", "can", "be", "used", "for", "parsing", "a", "template" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/Route.php#L197-L209
2,969
extendsframework/extends-servicelocator
src/Resolver/Factory/FactoryResolver.php
FactoryResolver.getService
public function getService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $factory = $this->getFactories()[$key]; if (is_string($factory) === true) { $factory = new $factory(); $this->factories[$key] = $factory; } try { return $factory->createService($key, $serviceLocator, $extra); } catch (Throwable $exception) { throw new ServiceCreateFailed($key, $exception); } }
php
public function getService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $factory = $this->getFactories()[$key]; if (is_string($factory) === true) { $factory = new $factory(); $this->factories[$key] = $factory; } try { return $factory->createService($key, $serviceLocator, $extra); } catch (Throwable $exception) { throw new ServiceCreateFailed($key, $exception); } }
[ "public", "function", "getService", "(", "string", "$", "key", ",", "ServiceLocatorInterface", "$", "serviceLocator", ",", "array", "$", "extra", "=", "null", ")", ":", "object", "{", "$", "factory", "=", "$", "this", "->", "getFactories", "(", ")", "[", "$", "key", "]", ";", "if", "(", "is_string", "(", "$", "factory", ")", "===", "true", ")", "{", "$", "factory", "=", "new", "$", "factory", "(", ")", ";", "$", "this", "->", "factories", "[", "$", "key", "]", "=", "$", "factory", ";", "}", "try", "{", "return", "$", "factory", "->", "createService", "(", "$", "key", ",", "$", "serviceLocator", ",", "$", "extra", ")", ";", "}", "catch", "(", "Throwable", "$", "exception", ")", "{", "throw", "new", "ServiceCreateFailed", "(", "$", "key", ",", "$", "exception", ")", ";", "}", "}" ]
When the factory is a string, a new instance will be created and replaces the string. @inheritDoc
[ "When", "the", "factory", "is", "a", "string", "a", "new", "instance", "will", "be", "created", "and", "replaces", "the", "string", "." ]
65596cf3f6af786c88afd689c74339052382473d
https://github.com/extendsframework/extends-servicelocator/blob/65596cf3f6af786c88afd689c74339052382473d/src/Resolver/Factory/FactoryResolver.php#L34-L47
2,970
MarcusFulbright/represent
src/Represent/Builder/ClassContextBuilder.php
ClassContextBuilder.buildClassContext
public function buildClassContext(\ReflectionClass $reflection, $hash, $view = null) { $classContext = new ClassContext(); $classContext->hash = $hash; $classContext = $this->handleExclusionPolicy($reflection, $classContext); $classContext->views = $view; $classContext = $this->handleView($classContext); return $classContext; }
php
public function buildClassContext(\ReflectionClass $reflection, $hash, $view = null) { $classContext = new ClassContext(); $classContext->hash = $hash; $classContext = $this->handleExclusionPolicy($reflection, $classContext); $classContext->views = $view; $classContext = $this->handleView($classContext); return $classContext; }
[ "public", "function", "buildClassContext", "(", "\\", "ReflectionClass", "$", "reflection", ",", "$", "hash", ",", "$", "view", "=", "null", ")", "{", "$", "classContext", "=", "new", "ClassContext", "(", ")", ";", "$", "classContext", "->", "hash", "=", "$", "hash", ";", "$", "classContext", "=", "$", "this", "->", "handleExclusionPolicy", "(", "$", "reflection", ",", "$", "classContext", ")", ";", "$", "classContext", "->", "views", "=", "$", "view", ";", "$", "classContext", "=", "$", "this", "->", "handleView", "(", "$", "classContext", ")", ";", "return", "$", "classContext", ";", "}" ]
Entry point to build the class context object. Currently only knows how to handle exclusion policy. Any new top level class annotations need a handler in here. @param \ReflectionClass $reflection @param $hash @param $view @return ClassContext
[ "Entry", "point", "to", "build", "the", "class", "context", "object", ".", "Currently", "only", "knows", "how", "to", "handle", "exclusion", "policy", ".", "Any", "new", "top", "level", "class", "annotations", "need", "a", "handler", "in", "here", "." ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/ClassContextBuilder.php#L35-L45
2,971
MarcusFulbright/represent
src/Represent/Builder/ClassContextBuilder.php
ClassContextBuilder.handleExclusionPolicy
private function handleExclusionPolicy(\ReflectionClass $reflection, ClassContext $classContext) { $annot = $this->annotationReader->getClassAnnotation($reflection, '\Represent\Annotations\ExclusionPolicy'); if (!is_null($annot) && $annot->getPolicy() === ExclusionPolicyEnum::BLACKLIST){ $classContext->policy = ExclusionPolicyEnum::BLACKLIST; $classContext = $this->generatePropertiesForBlackList($reflection, $classContext); } else { $classContext->policy = ExclusionPolicyEnum::WHITELIST; $classContext = $this->generatePropertiesForWhiteList($reflection, $classContext); } return $classContext; }
php
private function handleExclusionPolicy(\ReflectionClass $reflection, ClassContext $classContext) { $annot = $this->annotationReader->getClassAnnotation($reflection, '\Represent\Annotations\ExclusionPolicy'); if (!is_null($annot) && $annot->getPolicy() === ExclusionPolicyEnum::BLACKLIST){ $classContext->policy = ExclusionPolicyEnum::BLACKLIST; $classContext = $this->generatePropertiesForBlackList($reflection, $classContext); } else { $classContext->policy = ExclusionPolicyEnum::WHITELIST; $classContext = $this->generatePropertiesForWhiteList($reflection, $classContext); } return $classContext; }
[ "private", "function", "handleExclusionPolicy", "(", "\\", "ReflectionClass", "$", "reflection", ",", "ClassContext", "$", "classContext", ")", "{", "$", "annot", "=", "$", "this", "->", "annotationReader", "->", "getClassAnnotation", "(", "$", "reflection", ",", "'\\Represent\\Annotations\\ExclusionPolicy'", ")", ";", "if", "(", "!", "is_null", "(", "$", "annot", ")", "&&", "$", "annot", "->", "getPolicy", "(", ")", "===", "ExclusionPolicyEnum", "::", "BLACKLIST", ")", "{", "$", "classContext", "->", "policy", "=", "ExclusionPolicyEnum", "::", "BLACKLIST", ";", "$", "classContext", "=", "$", "this", "->", "generatePropertiesForBlackList", "(", "$", "reflection", ",", "$", "classContext", ")", ";", "}", "else", "{", "$", "classContext", "->", "policy", "=", "ExclusionPolicyEnum", "::", "WHITELIST", ";", "$", "classContext", "=", "$", "this", "->", "generatePropertiesForWhiteList", "(", "$", "reflection", ",", "$", "classContext", ")", ";", "}", "return", "$", "classContext", ";", "}" ]
Determines exclusion policy and hands off to the appropriate method. Defaults to white list @param \ReflectionClass $reflection @param \Represent\Context\ClassContext $classContext @return ClassContext
[ "Determines", "exclusion", "policy", "and", "hands", "off", "to", "the", "appropriate", "method", ".", "Defaults", "to", "white", "list" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/ClassContextBuilder.php#L53-L66
2,972
MarcusFulbright/represent
src/Represent/Builder/ClassContextBuilder.php
ClassContextBuilder.generatePropertiesForBlackList
private function generatePropertiesForBlackList(\ReflectionClass $reflection, ClassContext $classContext) { $properties = $reflection->getProperties(); $reader = $this->annotationReader; array_walk( $properties, function ($property) use ($classContext, $reader) { $annotation = $reader->getPropertyAnnotation($property, '\Represent\Annotations\Show'); if ($annotation) { $classContext->properties[] = $property; } } ); return $classContext; }
php
private function generatePropertiesForBlackList(\ReflectionClass $reflection, ClassContext $classContext) { $properties = $reflection->getProperties(); $reader = $this->annotationReader; array_walk( $properties, function ($property) use ($classContext, $reader) { $annotation = $reader->getPropertyAnnotation($property, '\Represent\Annotations\Show'); if ($annotation) { $classContext->properties[] = $property; } } ); return $classContext; }
[ "private", "function", "generatePropertiesForBlackList", "(", "\\", "ReflectionClass", "$", "reflection", ",", "ClassContext", "$", "classContext", ")", "{", "$", "properties", "=", "$", "reflection", "->", "getProperties", "(", ")", ";", "$", "reader", "=", "$", "this", "->", "annotationReader", ";", "array_walk", "(", "$", "properties", ",", "function", "(", "$", "property", ")", "use", "(", "$", "classContext", ",", "$", "reader", ")", "{", "$", "annotation", "=", "$", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "'\\Represent\\Annotations\\Show'", ")", ";", "if", "(", "$", "annotation", ")", "{", "$", "classContext", "->", "properties", "[", "]", "=", "$", "property", ";", "}", "}", ")", ";", "return", "$", "classContext", ";", "}" ]
Decides what properties should be represented using the black list policy @param \ReflectionClass $reflection @param \Represent\Context\ClassContext $classContext @return ClassContext
[ "Decides", "what", "properties", "should", "be", "represented", "using", "the", "black", "list", "policy" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/ClassContextBuilder.php#L74-L90
2,973
MarcusFulbright/represent
src/Represent/Builder/ClassContextBuilder.php
ClassContextBuilder.handleView
private function handleView(ClassContext $classContext) { $properties = $classContext->properties; $reader = $this->annotationReader; $classContext->properties = array_filter( $properties, function ($property) use ($reader, $classContext) { $annotation = $reader->getPropertyAnnotation($property,'\Represent\Annotations\View'); return $annotation == null || in_array($classContext->views, $annotation->name); } ); return $classContext; }
php
private function handleView(ClassContext $classContext) { $properties = $classContext->properties; $reader = $this->annotationReader; $classContext->properties = array_filter( $properties, function ($property) use ($reader, $classContext) { $annotation = $reader->getPropertyAnnotation($property,'\Represent\Annotations\View'); return $annotation == null || in_array($classContext->views, $annotation->name); } ); return $classContext; }
[ "private", "function", "handleView", "(", "ClassContext", "$", "classContext", ")", "{", "$", "properties", "=", "$", "classContext", "->", "properties", ";", "$", "reader", "=", "$", "this", "->", "annotationReader", ";", "$", "classContext", "->", "properties", "=", "array_filter", "(", "$", "properties", ",", "function", "(", "$", "property", ")", "use", "(", "$", "reader", ",", "$", "classContext", ")", "{", "$", "annotation", "=", "$", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "'\\Represent\\Annotations\\View'", ")", ";", "return", "$", "annotation", "==", "null", "||", "in_array", "(", "$", "classContext", "->", "views", ",", "$", "annotation", "->", "name", ")", ";", "}", ")", ";", "return", "$", "classContext", ";", "}" ]
Takes ClassContext and checks that each property belongs to the given view. @param \Represent\Context\ClassContext $classContext @return ClassContext
[ "Takes", "ClassContext", "and", "checks", "that", "each", "property", "belongs", "to", "the", "given", "view", "." ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/ClassContextBuilder.php#L121-L136
2,974
iRAP-software/package-table-creator
DatabaseField.php
DatabaseField.createChar
public static function createChar($name, $size) { $field = new DatabaseField($name, self::TYPE_CHAR); $field->m_constraint = intval($size); return $field; }
php
public static function createChar($name, $size) { $field = new DatabaseField($name, self::TYPE_CHAR); $field->m_constraint = intval($size); return $field; }
[ "public", "static", "function", "createChar", "(", "$", "name", ",", "$", "size", ")", "{", "$", "field", "=", "new", "DatabaseField", "(", "$", "name", ",", "self", "::", "TYPE_CHAR", ")", ";", "$", "field", "->", "m_constraint", "=", "intval", "(", "$", "size", ")", ";", "return", "$", "field", ";", "}" ]
for creating a varchar. @param type $numChars @param type $allow_null @param type $default_null @return array $specification - the specification necessary for dbforge.
[ "for", "creating", "a", "varchar", "." ]
069dfe5b95ec1bff4acc7d28affabce3e005c69c
https://github.com/iRAP-software/package-table-creator/blob/069dfe5b95ec1bff4acc7d28affabce3e005c69c/DatabaseField.php#L66-L71
2,975
iRAP-software/package-table-creator
DatabaseField.php
DatabaseField.createVarchar
public static function createVarchar($name, $size) { $field = new DatabaseField($name, self::TYPE_VARCHAR); $field->m_constraint = intval($size); return $field; }
php
public static function createVarchar($name, $size) { $field = new DatabaseField($name, self::TYPE_VARCHAR); $field->m_constraint = intval($size); return $field; }
[ "public", "static", "function", "createVarchar", "(", "$", "name", ",", "$", "size", ")", "{", "$", "field", "=", "new", "DatabaseField", "(", "$", "name", ",", "self", "::", "TYPE_VARCHAR", ")", ";", "$", "field", "->", "m_constraint", "=", "intval", "(", "$", "size", ")", ";", "return", "$", "field", ";", "}" ]
Create a VARCHAR field @param string $name - the name to give the field @param int $size - how many characters the field can hold @return \iRAP\TableCreator\DatabaseField
[ "Create", "a", "VARCHAR", "field" ]
069dfe5b95ec1bff4acc7d28affabce3e005c69c
https://github.com/iRAP-software/package-table-creator/blob/069dfe5b95ec1bff4acc7d28affabce3e005c69c/DatabaseField.php#L80-L85
2,976
iRAP-software/package-table-creator
DatabaseField.php
DatabaseField.createInt
public static function createInt($name, $size, $autoInc=false) { $field = new DatabaseField($name, self::TYPE_INT); $field->m_constraint = $size; $field->m_autoIncrementing = $autoInc; return $field; }
php
public static function createInt($name, $size, $autoInc=false) { $field = new DatabaseField($name, self::TYPE_INT); $field->m_constraint = $size; $field->m_autoIncrementing = $autoInc; return $field; }
[ "public", "static", "function", "createInt", "(", "$", "name", ",", "$", "size", ",", "$", "autoInc", "=", "false", ")", "{", "$", "field", "=", "new", "DatabaseField", "(", "$", "name", ",", "self", "::", "TYPE_INT", ")", ";", "$", "field", "->", "m_constraint", "=", "$", "size", ";", "$", "field", "->", "m_autoIncrementing", "=", "$", "autoInc", ";", "return", "$", "field", ";", "}" ]
Creates an integer type field. @param string $name @param int $size - the size the int can reach, e.g. 2 means you can reach the number 99 @param bool $autoInc - auto increment the field (will mark it as primary key!) @return \iRAP\TableCreator\DatabaseField
[ "Creates", "an", "integer", "type", "field", "." ]
069dfe5b95ec1bff4acc7d28affabce3e005c69c
https://github.com/iRAP-software/package-table-creator/blob/069dfe5b95ec1bff4acc7d28affabce3e005c69c/DatabaseField.php#L158-L165
2,977
iRAP-software/package-table-creator
DatabaseField.php
DatabaseField.createDecimal
public static function createDecimal($name, $precisionBefore, $precisionAfter) { $field = new DatabaseField($name, self::TYPE_DECIMAL); $field->m_constraint = intval($precisionBefore) . ',' . intval($precisionAfter); return $field; }
php
public static function createDecimal($name, $precisionBefore, $precisionAfter) { $field = new DatabaseField($name, self::TYPE_DECIMAL); $field->m_constraint = intval($precisionBefore) . ',' . intval($precisionAfter); return $field; }
[ "public", "static", "function", "createDecimal", "(", "$", "name", ",", "$", "precisionBefore", ",", "$", "precisionAfter", ")", "{", "$", "field", "=", "new", "DatabaseField", "(", "$", "name", ",", "self", "::", "TYPE_DECIMAL", ")", ";", "$", "field", "->", "m_constraint", "=", "intval", "(", "$", "precisionBefore", ")", ".", "','", ".", "intval", "(", "$", "precisionAfter", ")", ";", "return", "$", "field", ";", "}" ]
Creates the DECIMAL field type @param string $name - the name of the field/column in the database. @param int $precisionBefore - the precision before the decimal place. eg. 2 means you can reach the number 99 @param int $precisionAfter - precision after the decimal place. e.g. 2 means you can be accurate to 0.01 @return \iRAP\TableCreator\DatabaseField
[ "Creates", "the", "DECIMAL", "field", "type" ]
069dfe5b95ec1bff4acc7d28affabce3e005c69c
https://github.com/iRAP-software/package-table-creator/blob/069dfe5b95ec1bff4acc7d28affabce3e005c69c/DatabaseField.php#L202-L211
2,978
iRAP-software/package-table-creator
DatabaseField.php
DatabaseField.getFieldString
public function getFieldString() { $fieldString = "`" . $this->m_name . "` " . $this->m_type; if ($this->m_constraint != null) { $fieldString .= " (" . $this->m_constraint . ")"; } if ($this->isAutoIncrementing()) { $fieldString .= " AUTO_INCREMENT"; } if ($this->m_default !== null) { $fieldString .= " DEFAULT " . $this->m_default; } if (!$this->m_allowNull) { $fieldString .= " NOT NULL"; } return $fieldString; }
php
public function getFieldString() { $fieldString = "`" . $this->m_name . "` " . $this->m_type; if ($this->m_constraint != null) { $fieldString .= " (" . $this->m_constraint . ")"; } if ($this->isAutoIncrementing()) { $fieldString .= " AUTO_INCREMENT"; } if ($this->m_default !== null) { $fieldString .= " DEFAULT " . $this->m_default; } if (!$this->m_allowNull) { $fieldString .= " NOT NULL"; } return $fieldString; }
[ "public", "function", "getFieldString", "(", ")", "{", "$", "fieldString", "=", "\"`\"", ".", "$", "this", "->", "m_name", ".", "\"` \"", ".", "$", "this", "->", "m_type", ";", "if", "(", "$", "this", "->", "m_constraint", "!=", "null", ")", "{", "$", "fieldString", ".=", "\" (\"", ".", "$", "this", "->", "m_constraint", ".", "\")\"", ";", "}", "if", "(", "$", "this", "->", "isAutoIncrementing", "(", ")", ")", "{", "$", "fieldString", ".=", "\" AUTO_INCREMENT\"", ";", "}", "if", "(", "$", "this", "->", "m_default", "!==", "null", ")", "{", "$", "fieldString", ".=", "\" DEFAULT \"", ".", "$", "this", "->", "m_default", ";", "}", "if", "(", "!", "$", "this", "->", "m_allowNull", ")", "{", "$", "fieldString", ".=", "\" NOT NULL\"", ";", "}", "return", "$", "fieldString", ";", "}" ]
Returns the text representing this field's definition inside a create table statement. @return string - the string for defining this field in a mysql table.
[ "Returns", "the", "text", "representing", "this", "field", "s", "definition", "inside", "a", "create", "table", "statement", "." ]
069dfe5b95ec1bff4acc7d28affabce3e005c69c
https://github.com/iRAP-software/package-table-creator/blob/069dfe5b95ec1bff4acc7d28affabce3e005c69c/DatabaseField.php#L377-L402
2,979
Dhii/validation-abstract
src/ValidateCapableTrait.php
ValidateCapableTrait._validate
protected function _validate($subject) { $errors = $this->_getValidationErrors($subject); if (!$this->_countIterable($errors)) { return; } throw $this->_throwValidationFailedException($this->__('Validation failed'), null, null, true, $subject, $errors); }
php
protected function _validate($subject) { $errors = $this->_getValidationErrors($subject); if (!$this->_countIterable($errors)) { return; } throw $this->_throwValidationFailedException($this->__('Validation failed'), null, null, true, $subject, $errors); }
[ "protected", "function", "_validate", "(", "$", "subject", ")", "{", "$", "errors", "=", "$", "this", "->", "_getValidationErrors", "(", "$", "subject", ")", ";", "if", "(", "!", "$", "this", "->", "_countIterable", "(", "$", "errors", ")", ")", "{", "return", ";", "}", "throw", "$", "this", "->", "_throwValidationFailedException", "(", "$", "this", "->", "__", "(", "'Validation failed'", ")", ",", "null", ",", "null", ",", "true", ",", "$", "subject", ",", "$", "errors", ")", ";", "}" ]
Validates a subject. @since [*next-version*] @param mixed $subject The value to validate. @throws ValidationFailedExceptionInterface If subject is invalid. @throws RootException If problem validating.
[ "Validates", "a", "subject", "." ]
dff998ba3476927a0fc6d10bb022425de8f1c844
https://github.com/Dhii/validation-abstract/blob/dff998ba3476927a0fc6d10bb022425de8f1c844/src/ValidateCapableTrait.php#L29-L38
2,980
crysalead/validator
src/Checker.php
Checker.set
public static function set($name, $handler = null) { if (!is_array($name)) { $name = [$name => $handler]; } static::$_handlers = static::$_handlers + $name; }
php
public static function set($name, $handler = null) { if (!is_array($name)) { $name = [$name => $handler]; } static::$_handlers = static::$_handlers + $name; }
[ "public", "static", "function", "set", "(", "$", "name", ",", "$", "handler", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "name", ")", ")", "{", "$", "name", "=", "[", "$", "name", "=>", "$", "handler", "]", ";", "}", "static", "::", "$", "_handlers", "=", "static", "::", "$", "_handlers", "+", "$", "name", ";", "}" ]
Sets or replaces one or several built-in validation rules. For example: {{{ Checker::set('zeroToNine', '/^[0-9]$/'); $isValid = Checker::isZeroToNine("5"); // true $isValid = Checker::isZeroToNine("20"); // false }}} Alternatively, the first parameter may be an array of rules expressed as key/value pairs, as in the following: {{{ Checker::set([ 'zeroToNine' => '/^[0-9]$/', 'tenToNineteen' => '/^1[0-9]$/', ]); }}} In addition to regular expressions, validation rules can also be defined as full anonymous functions: {{{ use app\models\Account; Checker::set('accountActive', function($value, $options = [], &$params = []) { $value = is_int($value) ? Account::first($value) : $value; return (boolean) $value->is_active; }); $testAccount = Account::create(['is_active' => false]); Checker::isAccountActive($testAccount); // returns false }}} These functions can take up to 3 parameters: - `$value` _mixed_ : This is the actual value to be validated (as in the above example). - `$options` _array_: This parameter allows a validation rule to implement custom options. - `'check'` _string_: Often, validation rules come in multiple "formats", for example: credit cards, which vary by type of card. Defining multiple formats allows you to retain flexibility in how you validate data. The value of `'check'` can be a specific validation handler name or `'any'` which should pass if any validation handler matches. @param mixed $name The name of the validation rule (string), or an array of key/value pairs of names and rules. @param string $rule If $name is a string, this should be a string regular expression, or a closure that returns a boolean indicating success. Should be left blank if `$name` is an array.
[ "Sets", "or", "replaces", "one", "or", "several", "built", "-", "in", "validation", "rules", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Checker.php#L197-L203
2,981
zerospam/sdk-framework
src/Utils/Str.php
Str.containsAll
public static function containsAll($haystack, array $needles) { foreach ($needles as $needle) { if ($needle != '' && mb_strpos($haystack, $needle) === false) { return false; } } return true; }
php
public static function containsAll($haystack, array $needles) { foreach ($needles as $needle) { if ($needle != '' && mb_strpos($haystack, $needle) === false) { return false; } } return true; }
[ "public", "static", "function", "containsAll", "(", "$", "haystack", ",", "array", "$", "needles", ")", "{", "foreach", "(", "$", "needles", "as", "$", "needle", ")", "{", "if", "(", "$", "needle", "!=", "''", "&&", "mb_strpos", "(", "$", "haystack", ",", "$", "needle", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determine if a given string contains all given substring. @param string $haystack @param array $needles @return bool
[ "Determine", "if", "a", "given", "string", "contains", "all", "given", "substring", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Str.php#L188-L197
2,982
academic/VipaImportBundle
Importer/PKP/IssueImporter.php
IssueImporter.importJournalIssues
public function importJournalIssues($oldJournalId, $newJournalId, $sectionIds) { $issuesSql = "SELECT * FROM issues WHERE journal_id = :id"; $issuesStatement = $this->dbalConnection->prepare($issuesSql); $issuesStatement->bindValue('id', $oldJournalId); $issuesStatement->execute(); $issues = $issuesStatement->fetchAll(); return $this->importIssues($issues, $newJournalId, $sectionIds); }
php
public function importJournalIssues($oldJournalId, $newJournalId, $sectionIds) { $issuesSql = "SELECT * FROM issues WHERE journal_id = :id"; $issuesStatement = $this->dbalConnection->prepare($issuesSql); $issuesStatement->bindValue('id', $oldJournalId); $issuesStatement->execute(); $issues = $issuesStatement->fetchAll(); return $this->importIssues($issues, $newJournalId, $sectionIds); }
[ "public", "function", "importJournalIssues", "(", "$", "oldJournalId", ",", "$", "newJournalId", ",", "$", "sectionIds", ")", "{", "$", "issuesSql", "=", "\"SELECT * FROM issues WHERE journal_id = :id\"", ";", "$", "issuesStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "issuesSql", ")", ";", "$", "issuesStatement", "->", "bindValue", "(", "'id'", ",", "$", "oldJournalId", ")", ";", "$", "issuesStatement", "->", "execute", "(", ")", ";", "$", "issues", "=", "$", "issuesStatement", "->", "fetchAll", "(", ")", ";", "return", "$", "this", "->", "importIssues", "(", "$", "issues", ",", "$", "newJournalId", ",", "$", "sectionIds", ")", ";", "}" ]
Imports issues of given journal @param int $oldJournalId Issue's old Journal ID @param int $newJournalId Issue's new Journal ID @param array $sectionIds Sections that the created issue will include @return array An array whose keys are old IDs and values are new IDs @throws Exception @throws \Doctrine\DBAL\DBALException
[ "Imports", "issues", "of", "given", "journal" ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/IssueImporter.php#L26-L35
2,983
gamernetwork/yolk-core
src/exceptions/Handler.php
Handler.error
public static function error( $severity, $message, $file, $line ) { // Latest Twig raises a warning when accessing missing cached views - we can ignore it if( preg_match('/filemtime/', $message) ) return; // if the error was a type hint failure then throw an InvalidArgumentException instead elseif( preg_match('/^Argument (\d+) passed to ([\w\\\\]+)::(\w+)\(\) must be an instance of ([\w\\\\]+), ([\w\\\\]+) given, called in ([\w\s\.\/_-]+) on line (\d+)/', $message, $m) ) throw new \InvalidArgumentException("Argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given", $severity, new \ErrorException($message, 0, $severity, $m[6], $m[7])); // convert the error to an exception throw new \ErrorException($message, 0, $severity, $file, $line); }
php
public static function error( $severity, $message, $file, $line ) { // Latest Twig raises a warning when accessing missing cached views - we can ignore it if( preg_match('/filemtime/', $message) ) return; // if the error was a type hint failure then throw an InvalidArgumentException instead elseif( preg_match('/^Argument (\d+) passed to ([\w\\\\]+)::(\w+)\(\) must be an instance of ([\w\\\\]+), ([\w\\\\]+) given, called in ([\w\s\.\/_-]+) on line (\d+)/', $message, $m) ) throw new \InvalidArgumentException("Argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given", $severity, new \ErrorException($message, 0, $severity, $m[6], $m[7])); // convert the error to an exception throw new \ErrorException($message, 0, $severity, $file, $line); }
[ "public", "static", "function", "error", "(", "$", "severity", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "// Latest Twig raises a warning when accessing missing cached views - we can ignore it", "if", "(", "preg_match", "(", "'/filemtime/'", ",", "$", "message", ")", ")", "return", ";", "// if the error was a type hint failure then throw an InvalidArgumentException instead", "elseif", "(", "preg_match", "(", "'/^Argument (\\d+) passed to ([\\w\\\\\\\\]+)::(\\w+)\\(\\) must be an instance of ([\\w\\\\\\\\]+), ([\\w\\\\\\\\]+) given, called in ([\\w\\s\\.\\/_-]+) on line (\\d+)/'", ",", "$", "message", ",", "$", "m", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given\"", ",", "$", "severity", ",", "new", "\\", "ErrorException", "(", "$", "message", ",", "0", ",", "$", "severity", ",", "$", "m", "[", "6", "]", ",", "$", "m", "[", "7", "]", ")", ")", ";", "// convert the error to an exception", "throw", "new", "\\", "ErrorException", "(", "$", "message", ",", "0", ",", "$", "severity", ",", "$", "file", ",", "$", "line", ")", ";", "}" ]
Default error handler - convert errors to ErrorExceptions. @param int $severity the error level (http://php.net/manual/en/errorfunc.constants.php) @param string $message @param string $file @param int $line @return void
[ "Default", "error", "handler", "-", "convert", "errors", "to", "ErrorExceptions", "." ]
d9567dd55c51507dd34a55fd335a7b333e3db269
https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/exceptions/Handler.php#L26-L39
2,984
gamernetwork/yolk-core
src/exceptions/Handler.php
Handler.logException
public static function logException( \Exception $error ) { // fatal errors will already have been error_log()'d if( !static::isFatal($error) ) { $location = $error->getFile(). ':'. $error->getLine(); // type hinting error - make sure we give the correct location if( ($error instanceof \InvalidArgumentException) && ($error->getPrevious() instanceof \ErrorException) ) $location = $error->getPrevious()->getFile(). ':'. $error->getPrevious()->getLine(); error_log(get_class($error). ': '. $error->getMessage(). " [{$location}]"); } }
php
public static function logException( \Exception $error ) { // fatal errors will already have been error_log()'d if( !static::isFatal($error) ) { $location = $error->getFile(). ':'. $error->getLine(); // type hinting error - make sure we give the correct location if( ($error instanceof \InvalidArgumentException) && ($error->getPrevious() instanceof \ErrorException) ) $location = $error->getPrevious()->getFile(). ':'. $error->getPrevious()->getLine(); error_log(get_class($error). ': '. $error->getMessage(). " [{$location}]"); } }
[ "public", "static", "function", "logException", "(", "\\", "Exception", "$", "error", ")", "{", "// fatal errors will already have been error_log()'d", "if", "(", "!", "static", "::", "isFatal", "(", "$", "error", ")", ")", "{", "$", "location", "=", "$", "error", "->", "getFile", "(", ")", ".", "':'", ".", "$", "error", "->", "getLine", "(", ")", ";", "// type hinting error - make sure we give the correct location", "if", "(", "(", "$", "error", "instanceof", "\\", "InvalidArgumentException", ")", "&&", "(", "$", "error", "->", "getPrevious", "(", ")", "instanceof", "\\", "ErrorException", ")", ")", "$", "location", "=", "$", "error", "->", "getPrevious", "(", ")", "->", "getFile", "(", ")", ".", "':'", ".", "$", "error", "->", "getPrevious", "(", ")", "->", "getLine", "(", ")", ";", "error_log", "(", "get_class", "(", "$", "error", ")", ".", "': '", ".", "$", "error", "->", "getMessage", "(", ")", ".", "\" [{$location}]\"", ")", ";", "}", "}" ]
Log an exception to the error log. @param \Exception $error @return void
[ "Log", "an", "exception", "to", "the", "error", "log", "." ]
d9567dd55c51507dd34a55fd335a7b333e3db269
https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/exceptions/Handler.php#L71-L82
2,985
gamernetwork/yolk-core
src/exceptions/Handler.php
Handler.checkFatal
public static function checkFatal() { $error = error_get_last(); if( $error && static::isFatal($error['type']) ) { Yolk::exception(new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])); } }
php
public static function checkFatal() { $error = error_get_last(); if( $error && static::isFatal($error['type']) ) { Yolk::exception(new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])); } }
[ "public", "static", "function", "checkFatal", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "&&", "static", "::", "isFatal", "(", "$", "error", "[", "'type'", "]", ")", ")", "{", "Yolk", "::", "exception", "(", "new", "\\", "ErrorException", "(", "$", "error", "[", "'message'", "]", ",", "0", ",", "$", "error", "[", "'type'", "]", ",", "$", "error", "[", "'file'", "]", ",", "$", "error", "[", "'line'", "]", ")", ")", ";", "}", "}" ]
Shutdown function to catch fatal errors. @return void
[ "Shutdown", "function", "to", "catch", "fatal", "errors", "." ]
d9567dd55c51507dd34a55fd335a7b333e3db269
https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/exceptions/Handler.php#L88-L93
2,986
gamernetwork/yolk-core
src/exceptions/Handler.php
Handler.isFatal
protected static function isFatal( $error ) { if( $error instanceof \Exception ) return false; $fatal = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR; if( $error instanceof \ErrorException ) $error = $error->getSeverity(); return (bool) ($error & $fatal); }
php
protected static function isFatal( $error ) { if( $error instanceof \Exception ) return false; $fatal = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR; if( $error instanceof \ErrorException ) $error = $error->getSeverity(); return (bool) ($error & $fatal); }
[ "protected", "static", "function", "isFatal", "(", "$", "error", ")", "{", "if", "(", "$", "error", "instanceof", "\\", "Exception", ")", "return", "false", ";", "$", "fatal", "=", "E_ERROR", "|", "E_PARSE", "|", "E_CORE_ERROR", "|", "E_COMPILE_ERROR", "|", "E_USER_ERROR", ";", "if", "(", "$", "error", "instanceof", "\\", "ErrorException", ")", "$", "error", "=", "$", "error", "->", "getSeverity", "(", ")", ";", "return", "(", "bool", ")", "(", "$", "error", "&", "$", "fatal", ")", ";", "}" ]
Determine if an error code or Exception is a fatal error. @param \Exception|integer $error @return boolean
[ "Determine", "if", "an", "error", "code", "or", "Exception", "is", "a", "fatal", "error", "." ]
d9567dd55c51507dd34a55fd335a7b333e3db269
https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/exceptions/Handler.php#L100-L112
2,987
priskz/sorad-api
src/Priskz/SORAD/Responder/AbstractResponder.php
AbstractResponder.execute
public function execute() { if( ! is_null($this->action)) { $this->setResult($this->action->execute($this->request)); } else { $this->setResult(new Payload(null, 'valid')); } }
php
public function execute() { if( ! is_null($this->action)) { $this->setResult($this->action->execute($this->request)); } else { $this->setResult(new Payload(null, 'valid')); } }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "action", ")", ")", "{", "$", "this", "->", "setResult", "(", "$", "this", "->", "action", "->", "execute", "(", "$", "this", "->", "request", ")", ")", ";", "}", "else", "{", "$", "this", "->", "setResult", "(", "new", "Payload", "(", "null", ",", "'valid'", ")", ")", ";", "}", "}" ]
Perform logic.
[ "Perform", "logic", "." ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Responder/AbstractResponder.php#L121-L131
2,988
priskz/sorad-api
src/Priskz/SORAD/Responder/AbstractResponder.php
AbstractResponder.parseResult
protected function parseResult() { if(is_null($this->result)) { $this->setCode(self::HTTP_INTERNAL_SERVER_ERROR); } else { $this->setCode($this->parseStatusCode()); $this->setBody(); } }
php
protected function parseResult() { if(is_null($this->result)) { $this->setCode(self::HTTP_INTERNAL_SERVER_ERROR); } else { $this->setCode($this->parseStatusCode()); $this->setBody(); } }
[ "protected", "function", "parseResult", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "result", ")", ")", "{", "$", "this", "->", "setCode", "(", "self", "::", "HTTP_INTERNAL_SERVER_ERROR", ")", ";", "}", "else", "{", "$", "this", "->", "setCode", "(", "$", "this", "->", "parseStatusCode", "(", ")", ")", ";", "$", "this", "->", "setBody", "(", ")", ";", "}", "}" ]
Parse the resulting Action Payload.
[ "Parse", "the", "resulting", "Action", "Payload", "." ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Responder/AbstractResponder.php#L158-L170
2,989
priskz/sorad-api
src/Priskz/SORAD/Responder/AbstractResponder.php
AbstractResponder.parseStatusCode
protected function parseStatusCode() { try { // Check if a result status is configured. if( ! array_key_exists($this->result->getStatus(), $this->getStatus())) { throw new MisconfiguredStatusException(); } return $this->getStatus()[$this->result->getStatus()]; } catch(MisconfiguredStatusException $e) { return self::HTTP_INTERNAL_SERVER_ERROR; } catch(Exception $e) { return self::HTTP_BAD_REQUEST; } }
php
protected function parseStatusCode() { try { // Check if a result status is configured. if( ! array_key_exists($this->result->getStatus(), $this->getStatus())) { throw new MisconfiguredStatusException(); } return $this->getStatus()[$this->result->getStatus()]; } catch(MisconfiguredStatusException $e) { return self::HTTP_INTERNAL_SERVER_ERROR; } catch(Exception $e) { return self::HTTP_BAD_REQUEST; } }
[ "protected", "function", "parseStatusCode", "(", ")", "{", "try", "{", "// Check if a result status is configured.", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "result", "->", "getStatus", "(", ")", ",", "$", "this", "->", "getStatus", "(", ")", ")", ")", "{", "throw", "new", "MisconfiguredStatusException", "(", ")", ";", "}", "return", "$", "this", "->", "getStatus", "(", ")", "[", "$", "this", "->", "result", "->", "getStatus", "(", ")", "]", ";", "}", "catch", "(", "MisconfiguredStatusException", "$", "e", ")", "{", "return", "self", "::", "HTTP_INTERNAL_SERVER_ERROR", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "self", "::", "HTTP_BAD_REQUEST", ";", "}", "}" ]
Parse the resulting Payload status to a HTTP code.
[ "Parse", "the", "resulting", "Payload", "status", "to", "a", "HTTP", "code", "." ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Responder/AbstractResponder.php#L175-L195
2,990
priskz/sorad-api
src/Priskz/SORAD/Responder/AbstractResponder.php
AbstractResponder.getApiContext
public function getApiContext($prefix = false) { if(empty($this->apiContext)) { return $this->apiContext; } // Note: Laravel will convert view periods into directory slashes. // So we can easily interchange . with / $apiContextExplode = explode('/', $this->apiContext); // Remove 2nd segment if it exists, assuming it is an identifier. unset($apiContextExplode[1]); // Transform back into a string. $genericApiContext = implode('/', $apiContextExplode); if($prefix) { return $genericApiContext . '/'; } return $this->apiContext; }
php
public function getApiContext($prefix = false) { if(empty($this->apiContext)) { return $this->apiContext; } // Note: Laravel will convert view periods into directory slashes. // So we can easily interchange . with / $apiContextExplode = explode('/', $this->apiContext); // Remove 2nd segment if it exists, assuming it is an identifier. unset($apiContextExplode[1]); // Transform back into a string. $genericApiContext = implode('/', $apiContextExplode); if($prefix) { return $genericApiContext . '/'; } return $this->apiContext; }
[ "public", "function", "getApiContext", "(", "$", "prefix", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "apiContext", ")", ")", "{", "return", "$", "this", "->", "apiContext", ";", "}", "// Note: Laravel will convert view periods into directory slashes.", "// So we can easily interchange . with /", "$", "apiContextExplode", "=", "explode", "(", "'/'", ",", "$", "this", "->", "apiContext", ")", ";", "// Remove 2nd segment if it exists, assuming it is an identifier.", "unset", "(", "$", "apiContextExplode", "[", "1", "]", ")", ";", "// Transform back into a string.", "$", "genericApiContext", "=", "implode", "(", "'/'", ",", "$", "apiContextExplode", ")", ";", "if", "(", "$", "prefix", ")", "{", "return", "$", "genericApiContext", ".", "'/'", ";", "}", "return", "$", "this", "->", "apiContext", ";", "}" ]
Get API Context @param $string $prefix Format string for view string. @return string
[ "Get", "API", "Context" ]
7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74
https://github.com/priskz/sorad-api/blob/7fd7b5dfb487d9f6653f5a073ccc9eb8526e7b74/src/Priskz/SORAD/Responder/AbstractResponder.php#L254-L277
2,991
elastification/php-client
src/Response/V1x/DocumentResponse.php
DocumentResponse.getSource
public function getSource() { if (!$this->hasSource()) { throw new ResponseException(self::PROP_SOURCE . ' is not set.'); } return $this->get(self::PROP_SOURCE); }
php
public function getSource() { if (!$this->hasSource()) { throw new ResponseException(self::PROP_SOURCE . ' is not set.'); } return $this->get(self::PROP_SOURCE); }
[ "public", "function", "getSource", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasSource", "(", ")", ")", "{", "throw", "new", "ResponseException", "(", "self", "::", "PROP_SOURCE", ".", "' is not set.'", ")", ";", "}", "return", "$", "this", "->", "get", "(", "self", "::", "PROP_SOURCE", ")", ";", "}" ]
gets the source of the response @return array @throws \Elastification\Client\Exception\ResponseException
[ "gets", "the", "source", "of", "the", "response" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Response/V1x/DocumentResponse.php#L54-L61
2,992
gossi/trixionary
src/model/Base/SkillReferenceQuery.php
SkillReferenceQuery.create
public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildSkillReferenceQuery) { return $criteria; } $query = new ChildSkillReferenceQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildSkillReferenceQuery) { return $criteria; } $query = new ChildSkillReferenceQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "Criteria", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "ChildSkillReferenceQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "ChildSkillReferenceQuery", "(", ")", ";", "if", "(", "null", "!==", "$", "modelAlias", ")", "{", "$", "query", "->", "setModelAlias", "(", "$", "modelAlias", ")", ";", "}", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new ChildSkillReferenceQuery object. @param string $modelAlias The alias of a model in the query @param Criteria $criteria Optional Criteria to build the query from @return ChildSkillReferenceQuery
[ "Returns", "a", "new", "ChildSkillReferenceQuery", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillReferenceQuery.php#L85-L99
2,993
gossi/trixionary
src/model/Base/SkillReferenceQuery.php
SkillReferenceQuery.filterByReference
public function filterByReference($reference, $comparison = null) { if ($reference instanceof \gossi\trixionary\model\Reference) { return $this ->addUsingAlias(SkillReferenceTableMap::COL_REFERENCE_ID, $reference->getId(), $comparison); } elseif ($reference instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(SkillReferenceTableMap::COL_REFERENCE_ID, $reference->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByReference() only accepts arguments of type \gossi\trixionary\model\Reference or Collection'); } }
php
public function filterByReference($reference, $comparison = null) { if ($reference instanceof \gossi\trixionary\model\Reference) { return $this ->addUsingAlias(SkillReferenceTableMap::COL_REFERENCE_ID, $reference->getId(), $comparison); } elseif ($reference instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(SkillReferenceTableMap::COL_REFERENCE_ID, $reference->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByReference() only accepts arguments of type \gossi\trixionary\model\Reference or Collection'); } }
[ "public", "function", "filterByReference", "(", "$", "reference", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "reference", "instanceof", "\\", "gossi", "\\", "trixionary", "\\", "model", "\\", "Reference", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "SkillReferenceTableMap", "::", "COL_REFERENCE_ID", ",", "$", "reference", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "reference", "instanceof", "ObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "SkillReferenceTableMap", "::", "COL_REFERENCE_ID", ",", "$", "reference", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByReference() only accepts arguments of type \\gossi\\trixionary\\model\\Reference or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \gossi\trixionary\model\Reference object @param \gossi\trixionary\model\Reference|ObjectCollection $reference The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @throws \Propel\Runtime\Exception\PropelException @return ChildSkillReferenceQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "gossi", "\\", "trixionary", "\\", "model", "\\", "Reference", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillReferenceQuery.php#L425-L440
2,994
gossi/trixionary
src/model/Base/SkillReferenceQuery.php
SkillReferenceQuery.useReferenceQuery
public function useReferenceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinReference($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Reference', '\gossi\trixionary\model\ReferenceQuery'); }
php
public function useReferenceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinReference($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Reference', '\gossi\trixionary\model\ReferenceQuery'); }
[ "public", "function", "useReferenceQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinReference", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Reference'", ",", "'\\gossi\\trixionary\\model\\ReferenceQuery'", ")", ";", "}" ]
Use the Reference relation Reference object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\ReferenceQuery A secondary query class using the current class as primary query
[ "Use", "the", "Reference", "relation", "Reference", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillReferenceQuery.php#L485-L490
2,995
AnonymPHP/Anonym-Library
src/Anonym/Facades/Register.php
Register.getFacadeClass
protected static function getFacadeClass() { $base = App::make('database.base'); $tables = Config::get('database.tables'); return new RegisterDispatcher($base, $tables); }
php
protected static function getFacadeClass() { $base = App::make('database.base'); $tables = Config::get('database.tables'); return new RegisterDispatcher($base, $tables); }
[ "protected", "static", "function", "getFacadeClass", "(", ")", "{", "$", "base", "=", "App", "::", "make", "(", "'database.base'", ")", ";", "$", "tables", "=", "Config", "::", "get", "(", "'database.tables'", ")", ";", "return", "new", "RegisterDispatcher", "(", "$", "base", ",", "$", "tables", ")", ";", "}" ]
get the register dispatcher facade @return RegisterDispatcher
[ "get", "the", "register", "dispatcher", "facade" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Facades/Register.php#L30-L35
2,996
prooph/link-sql-connector
src/Service/DoctrineTableGateway.php
DoctrineTableGateway.getDbTypesForProperties
private function getDbTypesForProperties(TableRow $tableRow) { $dbTypes = []; foreach ($tableRow->properties() as $propName => $prop) { $dbTypes[$tableRow::toDbColumnName($propName)] = $tableRow::getDbTypeForProperty($propName); } return $dbTypes; }
php
private function getDbTypesForProperties(TableRow $tableRow) { $dbTypes = []; foreach ($tableRow->properties() as $propName => $prop) { $dbTypes[$tableRow::toDbColumnName($propName)] = $tableRow::getDbTypeForProperty($propName); } return $dbTypes; }
[ "private", "function", "getDbTypesForProperties", "(", "TableRow", "$", "tableRow", ")", "{", "$", "dbTypes", "=", "[", "]", ";", "foreach", "(", "$", "tableRow", "->", "properties", "(", ")", "as", "$", "propName", "=>", "$", "prop", ")", "{", "$", "dbTypes", "[", "$", "tableRow", "::", "toDbColumnName", "(", "$", "propName", ")", "]", "=", "$", "tableRow", "::", "getDbTypeForProperty", "(", "$", "propName", ")", ";", "}", "return", "$", "dbTypes", ";", "}" ]
Db types need to be an array in the same order as the properties @param TableRow $tableRow @return array
[ "Db", "types", "need", "to", "be", "an", "array", "in", "the", "same", "order", "as", "the", "properties" ]
8846d6abf18c2df809e150794f12efdfbe467933
https://github.com/prooph/link-sql-connector/blob/8846d6abf18c2df809e150794f12efdfbe467933/src/Service/DoctrineTableGateway.php#L692-L701
2,997
mlocati/composer-patcher
src/Util/VolatileDirectory.php
VolatileDirectory.getSystemTemporaryDirectory
public static function getSystemTemporaryDirectory() { $tempDir = @sys_get_temp_dir(); if (is_string($tempDir)) { $tempDir = str_replace(DIRECTORY_SEPARATOR, '/', (string) $tempDir); if ($tempDir !== '/') { $tempDir = rtrim($tempDir, '/'); } } else { $tempDir = ''; } if ($tempDir === '' || !is_dir($tempDir)) { throw new Exception\PathNotFound($tempDir, 'Unable to detect the system temporary directory.'); } return $tempDir; }
php
public static function getSystemTemporaryDirectory() { $tempDir = @sys_get_temp_dir(); if (is_string($tempDir)) { $tempDir = str_replace(DIRECTORY_SEPARATOR, '/', (string) $tempDir); if ($tempDir !== '/') { $tempDir = rtrim($tempDir, '/'); } } else { $tempDir = ''; } if ($tempDir === '' || !is_dir($tempDir)) { throw new Exception\PathNotFound($tempDir, 'Unable to detect the system temporary directory.'); } return $tempDir; }
[ "public", "static", "function", "getSystemTemporaryDirectory", "(", ")", "{", "$", "tempDir", "=", "@", "sys_get_temp_dir", "(", ")", ";", "if", "(", "is_string", "(", "$", "tempDir", ")", ")", "{", "$", "tempDir", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "(", "string", ")", "$", "tempDir", ")", ";", "if", "(", "$", "tempDir", "!==", "'/'", ")", "{", "$", "tempDir", "=", "rtrim", "(", "$", "tempDir", ",", "'/'", ")", ";", "}", "}", "else", "{", "$", "tempDir", "=", "''", ";", "}", "if", "(", "$", "tempDir", "===", "''", "||", "!", "is_dir", "(", "$", "tempDir", ")", ")", "{", "throw", "new", "Exception", "\\", "PathNotFound", "(", "$", "tempDir", ",", "'Unable to detect the system temporary directory.'", ")", ";", "}", "return", "$", "tempDir", ";", "}" ]
Get the path of the system temporary directory. @throws \ComposerPatcher\Exception\PathNotFound when the temporary directory can't be retrieved or when it does not exist @return string
[ "Get", "the", "path", "of", "the", "system", "temporary", "directory", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Util/VolatileDirectory.php#L78-L94
2,998
mlocati/composer-patcher
src/Util/VolatileDirectory.php
VolatileDirectory.getNewPath
public function getNewPath($suffix = '') { $result = $this->getPath().'/'.$this->uniqueCounter.(string) $suffix; ++$this->uniqueCounter; return $result; }
php
public function getNewPath($suffix = '') { $result = $this->getPath().'/'.$this->uniqueCounter.(string) $suffix; ++$this->uniqueCounter; return $result; }
[ "public", "function", "getNewPath", "(", "$", "suffix", "=", "''", ")", "{", "$", "result", "=", "$", "this", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "this", "->", "uniqueCounter", ".", "(", "string", ")", "$", "suffix", ";", "++", "$", "this", "->", "uniqueCounter", ";", "return", "$", "result", ";", "}" ]
Get the path of a new item inside this directory. @param string $suffix @return string
[ "Get", "the", "path", "of", "a", "new", "item", "inside", "this", "directory", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Util/VolatileDirectory.php#L103-L109
2,999
mlocati/composer-patcher
src/Util/VolatileDirectory.php
VolatileDirectory.getPath
public function getPath() { if ($this->path === null) { $parentDirectory = $this->parentDirectory; if ($parentDirectory === '') { $parentDirectory = static::getSystemTemporaryDirectory(); } else { if (!is_dir($parentDirectory)) { throw new Exception\PathNotFound($parentDirectory); } } if (!is_writable($parentDirectory)) { throw new Exception\PathNotWritable($parentDirectory); } for (; ;) { $tempNam = @tempnam($parentDirectory, 'PCH'); if ($tempNam === false) { throw new Exception\PathNotCreated("{$parentDirectory}/<TEMPORARY>"); } @unlink($tempNam); if (@mkdir($tempNam)) { break; } } $this->path = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $tempNam), '/'); } return $this->path; }
php
public function getPath() { if ($this->path === null) { $parentDirectory = $this->parentDirectory; if ($parentDirectory === '') { $parentDirectory = static::getSystemTemporaryDirectory(); } else { if (!is_dir($parentDirectory)) { throw new Exception\PathNotFound($parentDirectory); } } if (!is_writable($parentDirectory)) { throw new Exception\PathNotWritable($parentDirectory); } for (; ;) { $tempNam = @tempnam($parentDirectory, 'PCH'); if ($tempNam === false) { throw new Exception\PathNotCreated("{$parentDirectory}/<TEMPORARY>"); } @unlink($tempNam); if (@mkdir($tempNam)) { break; } } $this->path = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $tempNam), '/'); } return $this->path; }
[ "public", "function", "getPath", "(", ")", "{", "if", "(", "$", "this", "->", "path", "===", "null", ")", "{", "$", "parentDirectory", "=", "$", "this", "->", "parentDirectory", ";", "if", "(", "$", "parentDirectory", "===", "''", ")", "{", "$", "parentDirectory", "=", "static", "::", "getSystemTemporaryDirectory", "(", ")", ";", "}", "else", "{", "if", "(", "!", "is_dir", "(", "$", "parentDirectory", ")", ")", "{", "throw", "new", "Exception", "\\", "PathNotFound", "(", "$", "parentDirectory", ")", ";", "}", "}", "if", "(", "!", "is_writable", "(", "$", "parentDirectory", ")", ")", "{", "throw", "new", "Exception", "\\", "PathNotWritable", "(", "$", "parentDirectory", ")", ";", "}", "for", "(", ";", ";", ")", "{", "$", "tempNam", "=", "@", "tempnam", "(", "$", "parentDirectory", ",", "'PCH'", ")", ";", "if", "(", "$", "tempNam", "===", "false", ")", "{", "throw", "new", "Exception", "\\", "PathNotCreated", "(", "\"{$parentDirectory}/<TEMPORARY>\"", ")", ";", "}", "@", "unlink", "(", "$", "tempNam", ")", ";", "if", "(", "@", "mkdir", "(", "$", "tempNam", ")", ")", "{", "break", ";", "}", "}", "$", "this", "->", "path", "=", "rtrim", "(", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "tempNam", ")", ",", "'/'", ")", ";", "}", "return", "$", "this", "->", "path", ";", "}" ]
Get the path to the volatile directory. @throws \ComposerPatcher\Exception\PathNotFound when the parent directory is not specified and the system temporary directory can't be retrieved or when it does not exist @throws \ComposerPatcher\Exception\PathNotFound when $parentDirectory is supplied but it does not exist @throws \ComposerPatcher\Exception\PathNotWritable when the directory where the volatile directory will be created is not writable @throws \ComposerPatcher\Exception\PathNotCreated when the temporary directory could not be created @return string
[ "Get", "the", "path", "to", "the", "volatile", "directory", "." ]
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Util/VolatileDirectory.php#L129-L157