repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
symfony/security-acl
Domain/Entry.php
Entry.unserialize
public function unserialize($serialized) { list($this->mask, $this->id, $this->securityIdentity, $this->strategy, $this->auditFailure, $this->auditSuccess, $this->granting ) = unserialize($serialized); }
php
public function unserialize($serialized) { list($this->mask, $this->id, $this->securityIdentity, $this->strategy, $this->auditFailure, $this->auditSuccess, $this->granting ) = unserialize($serialized); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "mask", ",", "$", "this", "->", "id", ",", "$", "this", "->", "securityIdentity", ",", "$", "this", "->", "strategy", ",", "$", "this", "->", "audi...
Implementation of \Serializable. @param string $serialized
[ "Implementation", "of", "\\", "Serializable", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Entry.php#L197-L207
symfony/security-acl
Domain/RoleSecurityIdentity.php
RoleSecurityIdentity.equals
public function equals(SecurityIdentityInterface $sid) { if (!$sid instanceof self) { return false; } return $this->role === $sid->getRole(); }
php
public function equals(SecurityIdentityInterface $sid) { if (!$sid instanceof self) { return false; } return $this->role === $sid->getRole(); }
[ "public", "function", "equals", "(", "SecurityIdentityInterface", "$", "sid", ")", "{", "if", "(", "!", "$", "sid", "instanceof", "self", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "role", "===", "$", "sid", "->", "getRole", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/RoleSecurityIdentity.php#L53-L60
symfony/security-acl
Domain/UserSecurityIdentity.php
UserSecurityIdentity.fromToken
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof UserInterface) { return self::fromAccount($user); } return new self((string) $user, is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token)); }
php
public static function fromToken(TokenInterface $token) { $user = $token->getUser(); if ($user instanceof UserInterface) { return self::fromAccount($user); } return new self((string) $user, is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token)); }
[ "public", "static", "function", "fromToken", "(", "TokenInterface", "$", "token", ")", "{", "$", "user", "=", "$", "token", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "UserInterface", ")", "{", "return", "self", "::", "fromAcco...
Creates a user security identity from a TokenInterface. @param TokenInterface $token @return UserSecurityIdentity
[ "Creates", "a", "user", "security", "identity", "from", "a", "TokenInterface", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/UserSecurityIdentity.php#L69-L78
symfony/security-acl
Domain/UserSecurityIdentity.php
UserSecurityIdentity.equals
public function equals(SecurityIdentityInterface $sid) { if (!$sid instanceof self) { return false; } return $this->username === $sid->getUsername() && $this->class === $sid->getClass(); }
php
public function equals(SecurityIdentityInterface $sid) { if (!$sid instanceof self) { return false; } return $this->username === $sid->getUsername() && $this->class === $sid->getClass(); }
[ "public", "function", "equals", "(", "SecurityIdentityInterface", "$", "sid", ")", "{", "if", "(", "!", "$", "sid", "instanceof", "self", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "username", "===", "$", "sid", "->", "getUsernam...
{@inheritdoc}
[ "{" ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/UserSecurityIdentity.php#L103-L111
symfony/security-acl
Domain/ObjectIdentity.php
ObjectIdentity.fromDomainObject
public static function fromDomainObject($domainObject) { if (!is_object($domainObject)) { throw new InvalidDomainObjectException('$domainObject must be an object.'); } try { if ($domainObject instanceof DomainObjectInterface) { return new self($domainObject->getObjectIdentifier(), ClassUtils::getRealClass($domainObject)); } elseif (method_exists($domainObject, 'getId')) { return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject)); } } catch (\InvalidArgumentException $e) { throw new InvalidDomainObjectException($e->getMessage(), 0, $e); } throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".'); }
php
public static function fromDomainObject($domainObject) { if (!is_object($domainObject)) { throw new InvalidDomainObjectException('$domainObject must be an object.'); } try { if ($domainObject instanceof DomainObjectInterface) { return new self($domainObject->getObjectIdentifier(), ClassUtils::getRealClass($domainObject)); } elseif (method_exists($domainObject, 'getId')) { return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject)); } } catch (\InvalidArgumentException $e) { throw new InvalidDomainObjectException($e->getMessage(), 0, $e); } throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".'); }
[ "public", "static", "function", "fromDomainObject", "(", "$", "domainObject", ")", "{", "if", "(", "!", "is_object", "(", "$", "domainObject", ")", ")", "{", "throw", "new", "InvalidDomainObjectException", "(", "'$domainObject must be an object.'", ")", ";", "}", ...
Constructs an ObjectIdentity for the given domain object. @param object $domainObject @throws InvalidDomainObjectException @return ObjectIdentity
[ "Constructs", "an", "ObjectIdentity", "for", "the", "given", "domain", "object", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/ObjectIdentity.php#L59-L76
symfony/security-acl
Domain/ObjectIdentity.php
ObjectIdentity.equals
public function equals(ObjectIdentityInterface $identity) { // comparing the identifier with === might lead to problems, so we // waive this restriction return $this->identifier == $identity->getIdentifier() && $this->type === $identity->getType(); }
php
public function equals(ObjectIdentityInterface $identity) { // comparing the identifier with === might lead to problems, so we // waive this restriction return $this->identifier == $identity->getIdentifier() && $this->type === $identity->getType(); }
[ "public", "function", "equals", "(", "ObjectIdentityInterface", "$", "identity", ")", "{", "// comparing the identifier with === might lead to problems, so we", "// waive this restriction", "return", "$", "this", "->", "identifier", "==", "$", "identity", "->", "getIdentifier...
{@inheritdoc}
[ "{" ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/ObjectIdentity.php#L97-L103
symfony/security-acl
Domain/AclCollectionCache.php
AclCollectionCache.cache
public function cache($collection, array $tokens = array()) { $sids = array(); foreach ($tokens as $token) { $sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token)); } $oids = array(); foreach ($collection as $domainObject) { $oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject); } $this->aclProvider->findAcls($oids, $sids); }
php
public function cache($collection, array $tokens = array()) { $sids = array(); foreach ($tokens as $token) { $sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token)); } $oids = array(); foreach ($collection as $domainObject) { $oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject); } $this->aclProvider->findAcls($oids, $sids); }
[ "public", "function", "cache", "(", "$", "collection", ",", "array", "$", "tokens", "=", "array", "(", ")", ")", "{", "$", "sids", "=", "array", "(", ")", ";", "foreach", "(", "$", "tokens", "as", "$", "token", ")", "{", "$", "sids", "=", "array_...
Batch loads ACLs for an entire collection; thus, it reduces the number of required queries considerably. @param mixed $collection anything that can be passed to foreach() @param TokenInterface[] $tokens an array of TokenInterface implementations
[ "Batch", "loads", "ACLs", "for", "an", "entire", "collection", ";", "thus", "it", "reduces", "the", "number", "of", "required", "queries", "considerably", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/AclCollectionCache.php#L51-L64
symfony/security-acl
Domain/FieldEntry.php
FieldEntry.unserialize
public function unserialize($serialized) { list($this->field, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); }
php
public function unserialize($serialized) { list($this->field, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "field", ",", "$", "parentStr", ")", "=", "unserialize", "(", "$", "serialized", ")", ";", "parent", "::", "unserialize", "(", "$", "parentStr", ")", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/FieldEntry.php#L69-L73
symfony/security-acl
Dbal/Schema.php
Schema.addToSchema
public function addToSchema(BaseSchema $schema) { foreach ($this->getTables() as $table) { $schema->_addTable($table); } foreach ($this->getSequences() as $sequence) { $schema->_addSequence($sequence); } }
php
public function addToSchema(BaseSchema $schema) { foreach ($this->getTables() as $table) { $schema->_addTable($table); } foreach ($this->getSequences() as $sequence) { $schema->_addSequence($sequence); } }
[ "public", "function", "addToSchema", "(", "BaseSchema", "$", "schema", ")", "{", "foreach", "(", "$", "this", "->", "getTables", "(", ")", "as", "$", "table", ")", "{", "$", "schema", "->", "_addTable", "(", "$", "table", ")", ";", "}", "foreach", "(...
Merges ACL schema with the given schema. @param BaseSchema $schema
[ "Merges", "ACL", "schema", "with", "the", "given", "schema", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/Schema.php#L52-L61
symfony/security-acl
Dbal/Schema.php
Schema.addClassTable
protected function addClassTable() { $table = $this->createTable($this->options['class_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_type', 'string', array('length' => 200)); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('class_type')); }
php
protected function addClassTable() { $table = $this->createTable($this->options['class_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_type', 'string', array('length' => 200)); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('class_type')); }
[ "protected", "function", "addClassTable", "(", ")", "{", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "this", "->", "options", "[", "'class_table_name'", "]", ")", ";", "$", "table", "->", "addColumn", "(", "'id'", ",", "'integer'", ","...
Adds the class table to the schema.
[ "Adds", "the", "class", "table", "to", "the", "schema", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/Schema.php#L66-L73
symfony/security-acl
Dbal/Schema.php
Schema.addEntryTable
protected function addEntryTable() { $table = $this->createTable($this->options['entry_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_id', 'integer', array('unsigned' => true)); $table->addColumn('object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); $table->addColumn('field_name', 'string', array('length' => 50, 'notnull' => false)); $table->addColumn('ace_order', 'smallint', array('unsigned' => true)); $table->addColumn('security_identity_id', 'integer', array('unsigned' => true)); $table->addColumn('mask', 'integer'); $table->addColumn('granting', 'boolean'); $table->addColumn('granting_strategy', 'string', array('length' => 30)); $table->addColumn('audit_success', 'boolean'); $table->addColumn('audit_failure', 'boolean'); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('class_id', 'object_identity_id', 'field_name', 'ace_order')); $table->addIndex(array('class_id', 'object_identity_id', 'security_identity_id')); $table->addForeignKeyConstraint($this->getTable($this->options['class_table_name']), array('class_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($this->getTable($this->options['oid_table_name']), array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($this->getTable($this->options['sid_table_name']), array('security_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); }
php
protected function addEntryTable() { $table = $this->createTable($this->options['entry_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_id', 'integer', array('unsigned' => true)); $table->addColumn('object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); $table->addColumn('field_name', 'string', array('length' => 50, 'notnull' => false)); $table->addColumn('ace_order', 'smallint', array('unsigned' => true)); $table->addColumn('security_identity_id', 'integer', array('unsigned' => true)); $table->addColumn('mask', 'integer'); $table->addColumn('granting', 'boolean'); $table->addColumn('granting_strategy', 'string', array('length' => 30)); $table->addColumn('audit_success', 'boolean'); $table->addColumn('audit_failure', 'boolean'); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('class_id', 'object_identity_id', 'field_name', 'ace_order')); $table->addIndex(array('class_id', 'object_identity_id', 'security_identity_id')); $table->addForeignKeyConstraint($this->getTable($this->options['class_table_name']), array('class_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($this->getTable($this->options['oid_table_name']), array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($this->getTable($this->options['sid_table_name']), array('security_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); }
[ "protected", "function", "addEntryTable", "(", ")", "{", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "this", "->", "options", "[", "'entry_table_name'", "]", ")", ";", "$", "table", "->", "addColumn", "(", "'id'", ",", "'integer'", ","...
Adds the entry table to the schema.
[ "Adds", "the", "entry", "table", "to", "the", "schema", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/Schema.php#L78-L101
symfony/security-acl
Dbal/Schema.php
Schema.addObjectIdentitiesTable
protected function addObjectIdentitiesTable() { $table = $this->createTable($this->options['oid_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_id', 'integer', array('unsigned' => true)); $table->addColumn('object_identifier', 'string', array('length' => 100)); $table->addColumn('parent_object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); $table->addColumn('entries_inheriting', 'boolean'); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('object_identifier', 'class_id')); $table->addIndex(array('parent_object_identity_id')); $table->addForeignKeyConstraint($table, array('parent_object_identity_id'), array('id')); }
php
protected function addObjectIdentitiesTable() { $table = $this->createTable($this->options['oid_table_name']); $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); $table->addColumn('class_id', 'integer', array('unsigned' => true)); $table->addColumn('object_identifier', 'string', array('length' => 100)); $table->addColumn('parent_object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); $table->addColumn('entries_inheriting', 'boolean'); $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('object_identifier', 'class_id')); $table->addIndex(array('parent_object_identity_id')); $table->addForeignKeyConstraint($table, array('parent_object_identity_id'), array('id')); }
[ "protected", "function", "addObjectIdentitiesTable", "(", ")", "{", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "this", "->", "options", "[", "'oid_table_name'", "]", ")", ";", "$", "table", "->", "addColumn", "(", "'id'", ",", "'integer...
Adds the object identity table to the schema.
[ "Adds", "the", "object", "identity", "table", "to", "the", "schema", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/Schema.php#L106-L121
symfony/security-acl
Dbal/Schema.php
Schema.addObjectIdentityAncestorsTable
protected function addObjectIdentityAncestorsTable() { $table = $this->createTable($this->options['oid_ancestors_table_name']); $table->addColumn('object_identity_id', 'integer', array('unsigned' => true)); $table->addColumn('ancestor_id', 'integer', array('unsigned' => true)); $table->setPrimaryKey(array('object_identity_id', 'ancestor_id')); $oidTable = $this->getTable($this->options['oid_table_name']); $table->addForeignKeyConstraint($oidTable, array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($oidTable, array('ancestor_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); }
php
protected function addObjectIdentityAncestorsTable() { $table = $this->createTable($this->options['oid_ancestors_table_name']); $table->addColumn('object_identity_id', 'integer', array('unsigned' => true)); $table->addColumn('ancestor_id', 'integer', array('unsigned' => true)); $table->setPrimaryKey(array('object_identity_id', 'ancestor_id')); $oidTable = $this->getTable($this->options['oid_table_name']); $table->addForeignKeyConstraint($oidTable, array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); $table->addForeignKeyConstraint($oidTable, array('ancestor_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); }
[ "protected", "function", "addObjectIdentityAncestorsTable", "(", ")", "{", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "this", "->", "options", "[", "'oid_ancestors_table_name'", "]", ")", ";", "$", "table", "->", "addColumn", "(", "'object_...
Adds the object identity relation table to the schema.
[ "Adds", "the", "object", "identity", "relation", "table", "to", "the", "schema", "." ]
train
https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/Schema.php#L126-L138
Roave/BackwardCompatibilityCheck
src/Git/GitParseRevision.php
GitParseRevision.fromStringForRepository
public function fromStringForRepository(string $something, CheckedOutRepository $repository) : Revision { return Revision::fromSha1( (new Process(['git', 'rev-parse', $something])) ->setWorkingDirectory($repository->__toString()) ->mustRun() ->getOutput() ); }
php
public function fromStringForRepository(string $something, CheckedOutRepository $repository) : Revision { return Revision::fromSha1( (new Process(['git', 'rev-parse', $something])) ->setWorkingDirectory($repository->__toString()) ->mustRun() ->getOutput() ); }
[ "public", "function", "fromStringForRepository", "(", "string", "$", "something", ",", "CheckedOutRepository", "$", "repository", ")", ":", "Revision", "{", "return", "Revision", "::", "fromSha1", "(", "(", "new", "Process", "(", "[", "'git'", ",", "'rev-parse'"...
{@inheritDoc} @throws RuntimeException
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Git/GitParseRevision.php#L17-L25
Roave/BackwardCompatibilityCheck
src/CompareClasses.php
CompareClasses.makeSymbolsIterator
private function makeSymbolsIterator( array $definedApiClassNames, ClassReflector $pastSourcesWithDependencies, ClassReflector $newSourcesWithDependencies ) : iterable { foreach ($definedApiClassNames as $apiClassName) { /** @var ReflectionClass $oldSymbol */ $oldSymbol = $pastSourcesWithDependencies->reflect($apiClassName); yield from $this->examineSymbol($oldSymbol, $newSourcesWithDependencies); } }
php
private function makeSymbolsIterator( array $definedApiClassNames, ClassReflector $pastSourcesWithDependencies, ClassReflector $newSourcesWithDependencies ) : iterable { foreach ($definedApiClassNames as $apiClassName) { /** @var ReflectionClass $oldSymbol */ $oldSymbol = $pastSourcesWithDependencies->reflect($apiClassName); yield from $this->examineSymbol($oldSymbol, $newSourcesWithDependencies); } }
[ "private", "function", "makeSymbolsIterator", "(", "array", "$", "definedApiClassNames", ",", "ClassReflector", "$", "pastSourcesWithDependencies", ",", "ClassReflector", "$", "newSourcesWithDependencies", ")", ":", "iterable", "{", "foreach", "(", "$", "definedApiClassNa...
@param string[] $definedApiClassNames @return iterable|Change[]
[ "@param", "string", "[]", "$definedApiClassNames" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/CompareClasses.php#L71-L82
Roave/BackwardCompatibilityCheck
src/Git/GitCheckoutRevisionToTemporaryPath.php
GitCheckoutRevisionToTemporaryPath.checkout
public function checkout(CheckedOutRepository $sourceRepository, Revision $revision) : CheckedOutRepository { $checkoutDirectory = $this->generateTemporaryPathFor($revision); (new Process(['git', 'clone', $sourceRepository, $checkoutDirectory]))->mustRun(); (new Process(['git', 'checkout', $revision]))->setWorkingDirectory($checkoutDirectory)->mustRun(); return CheckedOutRepository::fromPath($checkoutDirectory); }
php
public function checkout(CheckedOutRepository $sourceRepository, Revision $revision) : CheckedOutRepository { $checkoutDirectory = $this->generateTemporaryPathFor($revision); (new Process(['git', 'clone', $sourceRepository, $checkoutDirectory]))->mustRun(); (new Process(['git', 'checkout', $revision]))->setWorkingDirectory($checkoutDirectory)->mustRun(); return CheckedOutRepository::fromPath($checkoutDirectory); }
[ "public", "function", "checkout", "(", "CheckedOutRepository", "$", "sourceRepository", ",", "Revision", "$", "revision", ")", ":", "CheckedOutRepository", "{", "$", "checkoutDirectory", "=", "$", "this", "->", "generateTemporaryPathFor", "(", "$", "revision", ")", ...
{@inheritDoc} @throws ProcessRuntimeException
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Git/GitCheckoutRevisionToTemporaryPath.php#L29-L37
Roave/BackwardCompatibilityCheck
src/DetectChanges/BCBreak/ClassBased/MethodChanged.php
MethodChanged.checkSymbols
private function checkSymbols(array $from, array $to) : iterable { foreach (array_keys(array_intersect_key($from, $to)) as $name) { yield from $this->checkMethod->__invoke($from[$name], $to[$name]); } }
php
private function checkSymbols(array $from, array $to) : iterable { foreach (array_keys(array_intersect_key($from, $to)) as $name) { yield from $this->checkMethod->__invoke($from[$name], $to[$name]); } }
[ "private", "function", "checkSymbols", "(", "array", "$", "from", ",", "array", "$", "to", ")", ":", "iterable", "{", "foreach", "(", "array_keys", "(", "array_intersect_key", "(", "$", "from", ",", "$", "to", ")", ")", "as", "$", "name", ")", "{", "...
@param ReflectionMethod[] $from @param ReflectionMethod[] $to @return iterable|Change[]
[ "@param", "ReflectionMethod", "[]", "$from", "@param", "ReflectionMethod", "[]", "$to" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/DetectChanges/BCBreak/ClassBased/MethodChanged.php#L39-L44
Roave/BackwardCompatibilityCheck
src/DetectChanges/BCBreak/FunctionBased/ParameterTypeChanged.php
ParameterTypeChanged.checkSymbols
private function checkSymbols(array $from, array $to) : iterable { foreach (array_intersect_key($from, $to) as $index => $commonParameter) { yield from $this->compareParameter($commonParameter, $to[$index]); } }
php
private function checkSymbols(array $from, array $to) : iterable { foreach (array_intersect_key($from, $to) as $index => $commonParameter) { yield from $this->compareParameter($commonParameter, $to[$index]); } }
[ "private", "function", "checkSymbols", "(", "array", "$", "from", ",", "array", "$", "to", ")", ":", "iterable", "{", "foreach", "(", "array_intersect_key", "(", "$", "from", ",", "$", "to", ")", "as", "$", "index", "=>", "$", "commonParameter", ")", "...
@param ReflectionParameter[] $from @param ReflectionParameter[] $to @return iterable|Change[]
[ "@param", "ReflectionParameter", "[]", "$from", "@param", "ReflectionParameter", "[]", "$to" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/DetectChanges/BCBreak/FunctionBased/ParameterTypeChanged.php#L47-L52
Roave/BackwardCompatibilityCheck
src/Git/PickLastMinorVersionFromCollection.php
PickLastMinorVersionFromCollection.forVersions
public function forVersions(VersionsCollection $versions) : Version { Assert::that($versions->count()) ->greaterThan(0, 'Cannot determine latest minor version from an empty collection'); $stableVersions = $versions->matching(new class implements ConstraintInterface { public function assert(Version $version) : bool { return ! $version->isPreRelease(); } }); $versionsSortedDescending = $stableVersions->sortedDescending(); /** @var Version $lastVersion */ $lastVersion = array_values(iterator_to_array($versionsSortedDescending))[0]; $matchingMinorVersions = $stableVersions ->matching(new CompositeConstraint( CompositeConstraint::OPERATOR_AND, new ComparisonConstraint(ComparisonConstraint::OPERATOR_LTE, $lastVersion), new ComparisonConstraint( ComparisonConstraint::OPERATOR_GTE, Version::fromString($lastVersion->getMajor() . '.' . $lastVersion->getMinor() . '.0') ) )) ->sortedAscending(); /** @var Version[] $matchingMinorVersionsAsArray */ $matchingMinorVersionsAsArray = array_values(iterator_to_array($matchingMinorVersions)); return $matchingMinorVersionsAsArray[0]; }
php
public function forVersions(VersionsCollection $versions) : Version { Assert::that($versions->count()) ->greaterThan(0, 'Cannot determine latest minor version from an empty collection'); $stableVersions = $versions->matching(new class implements ConstraintInterface { public function assert(Version $version) : bool { return ! $version->isPreRelease(); } }); $versionsSortedDescending = $stableVersions->sortedDescending(); /** @var Version $lastVersion */ $lastVersion = array_values(iterator_to_array($versionsSortedDescending))[0]; $matchingMinorVersions = $stableVersions ->matching(new CompositeConstraint( CompositeConstraint::OPERATOR_AND, new ComparisonConstraint(ComparisonConstraint::OPERATOR_LTE, $lastVersion), new ComparisonConstraint( ComparisonConstraint::OPERATOR_GTE, Version::fromString($lastVersion->getMajor() . '.' . $lastVersion->getMinor() . '.0') ) )) ->sortedAscending(); /** @var Version[] $matchingMinorVersionsAsArray */ $matchingMinorVersionsAsArray = array_values(iterator_to_array($matchingMinorVersions)); return $matchingMinorVersionsAsArray[0]; }
[ "public", "function", "forVersions", "(", "VersionsCollection", "$", "versions", ")", ":", "Version", "{", "Assert", "::", "that", "(", "$", "versions", "->", "count", "(", ")", ")", "->", "greaterThan", "(", "0", ",", "'Cannot determine latest minor version fro...
{@inheritDoc} @throws LogicException @throws RuntimeException
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Git/PickLastMinorVersionFromCollection.php#L26-L58
Roave/BackwardCompatibilityCheck
src/Changes.php
Changes.getIterator
public function getIterator() : iterable { foreach ($this->bufferedChanges as $change) { yield $change; } foreach ($this->unBufferedChanges ?? [] as $change) { $this->bufferedChanges[] = $change; yield $change; } $this->unBufferedChanges = null; }
php
public function getIterator() : iterable { foreach ($this->bufferedChanges as $change) { yield $change; } foreach ($this->unBufferedChanges ?? [] as $change) { $this->bufferedChanges[] = $change; yield $change; } $this->unBufferedChanges = null; }
[ "public", "function", "getIterator", "(", ")", ":", "iterable", "{", "foreach", "(", "$", "this", "->", "bufferedChanges", "as", "$", "change", ")", "{", "yield", "$", "change", ";", "}", "foreach", "(", "$", "this", "->", "unBufferedChanges", "??", "[",...
{@inheritDoc} @return iterable|Change[]
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Changes.php#L83-L96
Roave/BackwardCompatibilityCheck
src/SourceLocator/StubClassSourceLocator.php
StubClassSourceLocator.createLocatedSource
protected function createLocatedSource(Identifier $identifier) : ?LocatedSource { if (! $identifier->isClass()) { return null; } if ($identifier->getName() === Identifier::WILDCARD) { return null; } $fqcn = $identifier->getName(); $classNameParts = explode('\\', $fqcn); $shortName = array_slice($classNameParts, -1)[0]; $namespaceName = implode('\\', array_slice($classNameParts, 0, count($classNameParts) - 1)); return new LocatedSource( sprintf('<?php namespace %s{interface %s {}}', $namespaceName, $shortName), null ); }
php
protected function createLocatedSource(Identifier $identifier) : ?LocatedSource { if (! $identifier->isClass()) { return null; } if ($identifier->getName() === Identifier::WILDCARD) { return null; } $fqcn = $identifier->getName(); $classNameParts = explode('\\', $fqcn); $shortName = array_slice($classNameParts, -1)[0]; $namespaceName = implode('\\', array_slice($classNameParts, 0, count($classNameParts) - 1)); return new LocatedSource( sprintf('<?php namespace %s{interface %s {}}', $namespaceName, $shortName), null ); }
[ "protected", "function", "createLocatedSource", "(", "Identifier", "$", "identifier", ")", ":", "?", "LocatedSource", "{", "if", "(", "!", "$", "identifier", "->", "isClass", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "$", "identifier", "...
{@inheritDoc}
[ "{" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/SourceLocator/StubClassSourceLocator.php#L27-L46
Roave/BackwardCompatibilityCheck
src/Git/GetVersionCollectionFromGitRepository.php
GetVersionCollectionFromGitRepository.fromRepository
public function fromRepository(CheckedOutRepository $checkedOutRepository) : VersionsCollection { $output = (new Process(['git', 'tag', '-l'])) ->setWorkingDirectory($checkedOutRepository->__toString()) ->mustRun() ->getOutput(); return new VersionsCollection(...array_filter( array_map(static function (string $maybeVersion) : ?Version { try { return Version::fromString($maybeVersion); } catch (InvalidVersionStringException $e) { return null; } }, explode("\n", $output)) )); }
php
public function fromRepository(CheckedOutRepository $checkedOutRepository) : VersionsCollection { $output = (new Process(['git', 'tag', '-l'])) ->setWorkingDirectory($checkedOutRepository->__toString()) ->mustRun() ->getOutput(); return new VersionsCollection(...array_filter( array_map(static function (string $maybeVersion) : ?Version { try { return Version::fromString($maybeVersion); } catch (InvalidVersionStringException $e) { return null; } }, explode("\n", $output)) )); }
[ "public", "function", "fromRepository", "(", "CheckedOutRepository", "$", "checkedOutRepository", ")", ":", "VersionsCollection", "{", "$", "output", "=", "(", "new", "Process", "(", "[", "'git'", ",", "'tag'", ",", "'-l'", "]", ")", ")", "->", "setWorkingDire...
{@inheritDoc} @throws ProcessFailedException @throws LogicException @throws RuntimeException
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Git/GetVersionCollectionFromGitRepository.php#L27-L43
Roave/BackwardCompatibilityCheck
src/Support/ArrayHelpers.php
ArrayHelpers.stringArrayContainsString
public static function stringArrayContainsString(string $value, array $arrayOfStrings) : bool { Assert::that($arrayOfStrings)->all()->string(); return in_array($value, $arrayOfStrings); }
php
public static function stringArrayContainsString(string $value, array $arrayOfStrings) : bool { Assert::that($arrayOfStrings)->all()->string(); return in_array($value, $arrayOfStrings); }
[ "public", "static", "function", "stringArrayContainsString", "(", "string", "$", "value", ",", "array", "$", "arrayOfStrings", ")", ":", "bool", "{", "Assert", "::", "that", "(", "$", "arrayOfStrings", ")", "->", "all", "(", ")", "->", "string", "(", ")", ...
Yes, this is just a very pedantic version of `in_array()`, written to avoid mutations and designed to throw an exception if `$arrayOfStrings` is not a `string[]` as requested. @param string[] $arrayOfStrings @throws InvalidArgumentException
[ "Yes", "this", "is", "just", "a", "very", "pedantic", "version", "of", "in_array", "()", "written", "to", "avoid", "mutations", "and", "designed", "to", "throw", "an", "exception", "if", "$arrayOfStrings", "is", "not", "a", "string", "[]", "as", "requested",...
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/Support/ArrayHelpers.php#L24-L29
Roave/BackwardCompatibilityCheck
src/SourceLocator/StaticClassMapSourceLocator.php
StaticClassMapSourceLocator.createLocatedSource
protected function createLocatedSource(Identifier $identifier) : ?LocatedSource { if (! $identifier->isClass()) { return null; } $classFile = $this->classMap[$identifier->getName()] ?? null; if ($classFile === null) { return null; } $fileContents = file_get_contents($classFile); Assert::that($fileContents)->string(); return new LocatedSource($fileContents, $classFile); }
php
protected function createLocatedSource(Identifier $identifier) : ?LocatedSource { if (! $identifier->isClass()) { return null; } $classFile = $this->classMap[$identifier->getName()] ?? null; if ($classFile === null) { return null; } $fileContents = file_get_contents($classFile); Assert::that($fileContents)->string(); return new LocatedSource($fileContents, $classFile); }
[ "protected", "function", "createLocatedSource", "(", "Identifier", "$", "identifier", ")", ":", "?", "LocatedSource", "{", "if", "(", "!", "$", "identifier", "->", "isClass", "(", ")", ")", "{", "return", "null", ";", "}", "$", "classFile", "=", "$", "th...
{@inheritDoc}
[ "{" ]
train
https://github.com/Roave/BackwardCompatibilityCheck/blob/3af8bc43ec6689e2af62e72c7a25fd6ac1868de9/src/SourceLocator/StaticClassMapSourceLocator.php#L40-L57
rdlowrey/auryn
lib/InjectionException.php
InjectionException.fromInvalidCallable
public static function fromInvalidCallable( array $inProgressMakes, $callableOrMethodStr, \Exception $previous = null ) { $callableString = null; if (is_string($callableOrMethodStr)) { $callableString .= $callableOrMethodStr; } else if (is_array($callableOrMethodStr) && array_key_exists(0, $callableOrMethodStr) && array_key_exists(0, $callableOrMethodStr)) { if (is_string($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) { $callableString .= $callableOrMethodStr[0].'::'.$callableOrMethodStr[1]; } else if (is_object($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) { $callableString .= sprintf( "[object(%s), '%s']", get_class($callableOrMethodStr[0]), $callableOrMethodStr[1] ); } } if ($callableString) { // Prevent accidental usage of long strings from filling logs. $callableString = substr($callableString, 0, 250); $message = sprintf( "%s. Invalid callable was '%s'", Injector::M_INVOKABLE, $callableString ); } else { $message = \Auryn\Injector::M_INVOKABLE; } return new self($inProgressMakes, $message, Injector::E_INVOKABLE, $previous); }
php
public static function fromInvalidCallable( array $inProgressMakes, $callableOrMethodStr, \Exception $previous = null ) { $callableString = null; if (is_string($callableOrMethodStr)) { $callableString .= $callableOrMethodStr; } else if (is_array($callableOrMethodStr) && array_key_exists(0, $callableOrMethodStr) && array_key_exists(0, $callableOrMethodStr)) { if (is_string($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) { $callableString .= $callableOrMethodStr[0].'::'.$callableOrMethodStr[1]; } else if (is_object($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) { $callableString .= sprintf( "[object(%s), '%s']", get_class($callableOrMethodStr[0]), $callableOrMethodStr[1] ); } } if ($callableString) { // Prevent accidental usage of long strings from filling logs. $callableString = substr($callableString, 0, 250); $message = sprintf( "%s. Invalid callable was '%s'", Injector::M_INVOKABLE, $callableString ); } else { $message = \Auryn\Injector::M_INVOKABLE; } return new self($inProgressMakes, $message, Injector::E_INVOKABLE, $previous); }
[ "public", "static", "function", "fromInvalidCallable", "(", "array", "$", "inProgressMakes", ",", "$", "callableOrMethodStr", ",", "\\", "Exception", "$", "previous", "=", "null", ")", "{", "$", "callableString", "=", "null", ";", "if", "(", "is_string", "(", ...
Add a human readable version of the invalid callable to the standard 'invalid invokable' message.
[ "Add", "a", "human", "readable", "version", "of", "the", "invalid", "callable", "to", "the", "standard", "invalid", "invokable", "message", "." ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/InjectionException.php#L20-L56
rdlowrey/auryn
lib/Injector.php
Injector.define
public function define($name, array $args) { list(, $normalizedName) = $this->resolveAlias($name); $this->classDefinitions[$normalizedName] = $args; return $this; }
php
public function define($name, array $args) { list(, $normalizedName) = $this->resolveAlias($name); $this->classDefinitions[$normalizedName] = $args; return $this; }
[ "public", "function", "define", "(", "$", "name", ",", "array", "$", "args", ")", "{", "list", "(", ",", "$", "normalizedName", ")", "=", "$", "this", "->", "resolveAlias", "(", "$", "name", ")", ";", "$", "this", "->", "classDefinitions", "[", "$", ...
Define instantiation directives for the specified class @param string $name The class (or alias) whose constructor arguments we wish to define @param array $args An array mapping parameter names to values/instructions @return self
[ "Define", "instantiation", "directives", "for", "the", "specified", "class" ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/Injector.php#L68-L74
rdlowrey/auryn
lib/Injector.php
Injector.share
public function share($nameOrInstance) { if (is_string($nameOrInstance)) { $this->shareClass($nameOrInstance); } elseif (is_object($nameOrInstance)) { $this->shareInstance($nameOrInstance); } else { throw new ConfigException( sprintf( self::M_SHARE_ARGUMENT, __CLASS__, gettype($nameOrInstance) ), self::E_SHARE_ARGUMENT ); } return $this; }
php
public function share($nameOrInstance) { if (is_string($nameOrInstance)) { $this->shareClass($nameOrInstance); } elseif (is_object($nameOrInstance)) { $this->shareInstance($nameOrInstance); } else { throw new ConfigException( sprintf( self::M_SHARE_ARGUMENT, __CLASS__, gettype($nameOrInstance) ), self::E_SHARE_ARGUMENT ); } return $this; }
[ "public", "function", "share", "(", "$", "nameOrInstance", ")", "{", "if", "(", "is_string", "(", "$", "nameOrInstance", ")", ")", "{", "$", "this", "->", "shareClass", "(", "$", "nameOrInstance", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "n...
Share the specified class/instance across the Injector context @param mixed $nameOrInstance The class or object to share @throws ConfigException if $nameOrInstance is not a string or an object @return self
[ "Share", "the", "specified", "class", "/", "instance", "across", "the", "Injector", "context" ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/Injector.php#L154-L172
rdlowrey/auryn
lib/Injector.php
Injector.prepare
public function prepare($name, $callableOrMethodStr) { if ($this->isExecutable($callableOrMethodStr) === false) { throw InjectionException::fromInvalidCallable( $this->inProgressMakes, $callableOrMethodStr ); } list(, $normalizedName) = $this->resolveAlias($name); $this->prepares[$normalizedName] = $callableOrMethodStr; return $this; }
php
public function prepare($name, $callableOrMethodStr) { if ($this->isExecutable($callableOrMethodStr) === false) { throw InjectionException::fromInvalidCallable( $this->inProgressMakes, $callableOrMethodStr ); } list(, $normalizedName) = $this->resolveAlias($name); $this->prepares[$normalizedName] = $callableOrMethodStr; return $this; }
[ "public", "function", "prepare", "(", "$", "name", ",", "$", "callableOrMethodStr", ")", "{", "if", "(", "$", "this", "->", "isExecutable", "(", "$", "callableOrMethodStr", ")", "===", "false", ")", "{", "throw", "InjectionException", "::", "fromInvalidCallabl...
Register a prepare callable to modify/prepare objects of type $name after instantiation Any callable or provisionable invokable may be specified. Preparers are passed two arguments: the instantiated object to be mutated and the current Injector instance. @param string $name @param mixed $callableOrMethodStr Any callable or provisionable invokable method @throws InjectionException if $callableOrMethodStr is not a callable. See https://github.com/rdlowrey/auryn#injecting-for-execution @return self
[ "Register", "a", "prepare", "callable", "to", "modify", "/", "prepare", "objects", "of", "type", "$name", "after", "instantiation" ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/Injector.php#L222-L235
rdlowrey/auryn
lib/Injector.php
Injector.execute
public function execute($callableOrMethodStr, array $args = array()) { list($reflFunc, $invocationObj) = $this->buildExecutableStruct($callableOrMethodStr); $executable = new Executable($reflFunc, $invocationObj); $args = $this->provisionFuncArgs($reflFunc, $args, null, $invocationObj === null ? null : get_class($invocationObj)); return call_user_func_array(array($executable, '__invoke'), $args); }
php
public function execute($callableOrMethodStr, array $args = array()) { list($reflFunc, $invocationObj) = $this->buildExecutableStruct($callableOrMethodStr); $executable = new Executable($reflFunc, $invocationObj); $args = $this->provisionFuncArgs($reflFunc, $args, null, $invocationObj === null ? null : get_class($invocationObj)); return call_user_func_array(array($executable, '__invoke'), $args); }
[ "public", "function", "execute", "(", "$", "callableOrMethodStr", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "list", "(", "$", "reflFunc", ",", "$", "invocationObj", ")", "=", "$", "this", "->", "buildExecutableStruct", "(", "$", "calla...
Invoke the specified callable or class::method string, provisioning dependencies along the way @param mixed $callableOrMethodStr A valid PHP callable or a provisionable ClassName::methodName string @param array $args Optional array specifying params with which to invoke the provisioned callable @throws \Auryn\InjectionException @return mixed Returns the invocation result returned from calling the generated executable
[ "Invoke", "the", "specified", "callable", "or", "class", "::", "method", "string", "provisioning", "dependencies", "along", "the", "way" ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/Injector.php#L635-L642
rdlowrey/auryn
lib/Injector.php
Injector.buildExecutable
public function buildExecutable($callableOrMethodStr) { try { list($reflFunc, $invocationObj) = $this->buildExecutableStruct($callableOrMethodStr); } catch (\ReflectionException $e) { throw InjectionException::fromInvalidCallable( $this->inProgressMakes, $callableOrMethodStr, $e ); } return new Executable($reflFunc, $invocationObj); }
php
public function buildExecutable($callableOrMethodStr) { try { list($reflFunc, $invocationObj) = $this->buildExecutableStruct($callableOrMethodStr); } catch (\ReflectionException $e) { throw InjectionException::fromInvalidCallable( $this->inProgressMakes, $callableOrMethodStr, $e ); } return new Executable($reflFunc, $invocationObj); }
[ "public", "function", "buildExecutable", "(", "$", "callableOrMethodStr", ")", "{", "try", "{", "list", "(", "$", "reflFunc", ",", "$", "invocationObj", ")", "=", "$", "this", "->", "buildExecutableStruct", "(", "$", "callableOrMethodStr", ")", ";", "}", "ca...
Provision an Executable instance from any valid callable or class::method string @param mixed $callableOrMethodStr A valid PHP callable or a provisionable ClassName::methodName string @return \Auryn\Executable
[ "Provision", "an", "Executable", "instance", "from", "any", "valid", "callable", "or", "class", "::", "method", "string" ]
train
https://github.com/rdlowrey/auryn/blob/f48890ba64c3cf696d9c950f508c73c451f8778f/lib/Injector.php#L650-L663
thephpleague/flysystem-cached-adapter
src/Storage/Memcached.php
Memcached.load
public function load() { $contents = $this->memcached->get($this->key); if ($contents !== false) { $this->setFromStorage($contents); } }
php
public function load() { $contents = $this->memcached->get($this->key); if ($contents !== false) { $this->setFromStorage($contents); } }
[ "public", "function", "load", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "memcached", "->", "get", "(", "$", "this", "->", "key", ")", ";", "if", "(", "$", "contents", "!==", "false", ")", "{", "$", "this", "->", "setFromStorage", "(",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Memcached.php#L41-L48
thephpleague/flysystem-cached-adapter
src/Storage/Memcached.php
Memcached.save
public function save() { $contents = $this->getForStorage(); $expiration = $this->expire === null ? 0 : time() + $this->expire; $this->memcached->set($this->key, $contents, $expiration); }
php
public function save() { $contents = $this->getForStorage(); $expiration = $this->expire === null ? 0 : time() + $this->expire; $this->memcached->set($this->key, $contents, $expiration); }
[ "public", "function", "save", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "getForStorage", "(", ")", ";", "$", "expiration", "=", "$", "this", "->", "expire", "===", "null", "?", "0", ":", "time", "(", ")", "+", "$", "this", "->", "ex...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Memcached.php#L53-L58
thephpleague/flysystem-cached-adapter
src/Storage/Psr6Cache.php
Psr6Cache.save
public function save() { $item = $this->pool->getItem($this->key); $item->set($this->getForStorage()); $item->expiresAfter($this->expire); $this->pool->save($item); }
php
public function save() { $item = $this->pool->getItem($this->key); $item->set($this->getForStorage()); $item->expiresAfter($this->expire); $this->pool->save($item); }
[ "public", "function", "save", "(", ")", "{", "$", "item", "=", "$", "this", "->", "pool", "->", "getItem", "(", "$", "this", "->", "key", ")", ";", "$", "item", "->", "set", "(", "$", "this", "->", "getForStorage", "(", ")", ")", ";", "$", "ite...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Psr6Cache.php#L41-L47
thephpleague/flysystem-cached-adapter
src/Storage/Psr6Cache.php
Psr6Cache.load
public function load() { $item = $this->pool->getItem($this->key); if ($item->isHit()) { $this->setFromStorage($item->get()); } }
php
public function load() { $item = $this->pool->getItem($this->key); if ($item->isHit()) { $this->setFromStorage($item->get()); } }
[ "public", "function", "load", "(", ")", "{", "$", "item", "=", "$", "this", "->", "pool", "->", "getItem", "(", "$", "this", "->", "key", ")", ";", "if", "(", "$", "item", "->", "isHit", "(", ")", ")", "{", "$", "this", "->", "setFromStorage", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Psr6Cache.php#L52-L58
thephpleague/flysystem-cached-adapter
src/Storage/Adapter.php
Adapter.setFromStorage
public function setFromStorage($json) { list($cache, $complete, $expire) = json_decode($json, true); if (! $expire || $expire > $this->getTime()) { $this->cache = $cache; $this->complete = $complete; } else { $this->adapter->delete($this->file); } }
php
public function setFromStorage($json) { list($cache, $complete, $expire) = json_decode($json, true); if (! $expire || $expire > $this->getTime()) { $this->cache = $cache; $this->complete = $complete; } else { $this->adapter->delete($this->file); } }
[ "public", "function", "setFromStorage", "(", "$", "json", ")", "{", "list", "(", "$", "cache", ",", "$", "complete", ",", "$", "expire", ")", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "!", "$", "expire", "||", "$", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Adapter.php#L66-L76
thephpleague/flysystem-cached-adapter
src/Storage/Adapter.php
Adapter.load
public function load() { if ($this->adapter->has($this->file)) { $file = $this->adapter->read($this->file); if ($file && !empty($file['contents'])) { $this->setFromStorage($file['contents']); } } }
php
public function load() { if ($this->adapter->has($this->file)) { $file = $this->adapter->read($this->file); if ($file && !empty($file['contents'])) { $this->setFromStorage($file['contents']); } } }
[ "public", "function", "load", "(", ")", "{", "if", "(", "$", "this", "->", "adapter", "->", "has", "(", "$", "this", "->", "file", ")", ")", "{", "$", "file", "=", "$", "this", "->", "adapter", "->", "read", "(", "$", "this", "->", "file", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Adapter.php#L81-L89
thephpleague/flysystem-cached-adapter
src/Storage/Adapter.php
Adapter.getForStorage
public function getForStorage() { $cleaned = $this->cleanContents($this->cache); return json_encode([$cleaned, $this->complete, $this->expire]); }
php
public function getForStorage() { $cleaned = $this->cleanContents($this->cache); return json_encode([$cleaned, $this->complete, $this->expire]); }
[ "public", "function", "getForStorage", "(", ")", "{", "$", "cleaned", "=", "$", "this", "->", "cleanContents", "(", "$", "this", "->", "cache", ")", ";", "return", "json_encode", "(", "[", "$", "cleaned", ",", "$", "this", "->", "complete", ",", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Adapter.php#L94-L99
thephpleague/flysystem-cached-adapter
src/Storage/Adapter.php
Adapter.save
public function save() { $config = new Config(); $contents = $this->getForStorage(); if ($this->adapter->has($this->file)) { $this->adapter->update($this->file, $contents, $config); } else { $this->adapter->write($this->file, $contents, $config); } }
php
public function save() { $config = new Config(); $contents = $this->getForStorage(); if ($this->adapter->has($this->file)) { $this->adapter->update($this->file, $contents, $config); } else { $this->adapter->write($this->file, $contents, $config); } }
[ "public", "function", "save", "(", ")", "{", "$", "config", "=", "new", "Config", "(", ")", ";", "$", "contents", "=", "$", "this", "->", "getForStorage", "(", ")", ";", "if", "(", "$", "this", "->", "adapter", "->", "has", "(", "$", "this", "->"...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Adapter.php#L104-L114
thephpleague/flysystem-cached-adapter
src/Storage/PhpRedis.php
PhpRedis.load
public function load() { $contents = $this->client->get($this->key); if ($contents !== false) { $this->setFromStorage($contents); } }
php
public function load() { $contents = $this->client->get($this->key); if ($contents !== false) { $this->setFromStorage($contents); } }
[ "public", "function", "load", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "key", ")", ";", "if", "(", "$", "contents", "!==", "false", ")", "{", "$", "this", "->", "setFromStorage", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/PhpRedis.php#L41-L48
thephpleague/flysystem-cached-adapter
src/Storage/PhpRedis.php
PhpRedis.save
public function save() { $contents = $this->getForStorage(); $this->client->set($this->key, $contents); if ($this->expire !== null) { $this->client->expire($this->key, $this->expire); } }
php
public function save() { $contents = $this->getForStorage(); $this->client->set($this->key, $contents); if ($this->expire !== null) { $this->client->expire($this->key, $this->expire); } }
[ "public", "function", "save", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "getForStorage", "(", ")", ";", "$", "this", "->", "client", "->", "set", "(", "$", "this", "->", "key", ",", "$", "contents", ")", ";", "if", "(", "$", "this",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/PhpRedis.php#L53-L61
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.storeContents
public function storeContents($directory, array $contents, $recursive = false) { $directories = [$directory]; foreach ($contents as $object) { $this->updateObject($object['path'], $object); $object = $this->cache[$object['path']]; if ($recursive && $this->pathIsInDirectory($directory, $object['path'])) { $directories[] = $object['dirname']; } } foreach (array_unique($directories) as $directory) { $this->setComplete($directory, $recursive); } $this->autosave(); }
php
public function storeContents($directory, array $contents, $recursive = false) { $directories = [$directory]; foreach ($contents as $object) { $this->updateObject($object['path'], $object); $object = $this->cache[$object['path']]; if ($recursive && $this->pathIsInDirectory($directory, $object['path'])) { $directories[] = $object['dirname']; } } foreach (array_unique($directories) as $directory) { $this->setComplete($directory, $recursive); } $this->autosave(); }
[ "public", "function", "storeContents", "(", "$", "directory", ",", "array", "$", "contents", ",", "$", "recursive", "=", "false", ")", "{", "$", "directories", "=", "[", "$", "directory", "]", ";", "foreach", "(", "$", "contents", "as", "$", "object", ...
Store the contents listing. @param string $directory @param array $contents @param bool $recursive @return array contents listing
[ "Store", "the", "contents", "listing", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L64-L82
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.updateObject
public function updateObject($path, array $object, $autosave = false) { if (! $this->has($path)) { $this->cache[$path] = Util::pathinfo($path); } $this->cache[$path] = array_merge($this->cache[$path], $object); if ($autosave) { $this->autosave(); } $this->ensureParentDirectories($path); }
php
public function updateObject($path, array $object, $autosave = false) { if (! $this->has($path)) { $this->cache[$path] = Util::pathinfo($path); } $this->cache[$path] = array_merge($this->cache[$path], $object); if ($autosave) { $this->autosave(); } $this->ensureParentDirectories($path); }
[ "public", "function", "updateObject", "(", "$", "path", ",", "array", "$", "object", ",", "$", "autosave", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "path", ")", ")", "{", "$", "this", "->", "cache", "[", "$", ...
Update the metadata for an object. @param string $path object path @param array $object object metadata @param bool $autosave whether to trigger the autosave routine
[ "Update", "the", "metadata", "for", "an", "object", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L91-L104
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.listContents
public function listContents($dirname = '', $recursive = false) { $result = []; foreach ($this->cache as $object) { if ($object === false) { continue; } if ($object['dirname'] === $dirname) { $result[] = $object; } elseif ($recursive && $this->pathIsInDirectory($dirname, $object['path'])) { $result[] = $object; } } return $result; }
php
public function listContents($dirname = '', $recursive = false) { $result = []; foreach ($this->cache as $object) { if ($object === false) { continue; } if ($object['dirname'] === $dirname) { $result[] = $object; } elseif ($recursive && $this->pathIsInDirectory($dirname, $object['path'])) { $result[] = $object; } } return $result; }
[ "public", "function", "listContents", "(", "$", "dirname", "=", "''", ",", "$", "recursive", "=", "false", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "cache", "as", "$", "object", ")", "{", "if", "(", "$", "ob...
Get the contents listing. @param string $dirname @param bool $recursive @return array contents listing
[ "Get", "the", "contents", "listing", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L125-L141
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.has
public function has($path) { if ($path !== false && array_key_exists($path, $this->cache)) { return $this->cache[$path] !== false; } if ($this->isComplete(Util::dirname($path), false)) { return false; } }
php
public function has($path) { if ($path !== false && array_key_exists($path, $this->cache)) { return $this->cache[$path] !== false; } if ($this->isComplete(Util::dirname($path), false)) { return false; } }
[ "public", "function", "has", "(", "$", "path", ")", "{", "if", "(", "$", "path", "!==", "false", "&&", "array_key_exists", "(", "$", "path", ",", "$", "this", "->", "cache", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L146-L155
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.read
public function read($path) { if (isset($this->cache[$path]['contents']) && $this->cache[$path]['contents'] !== false) { return $this->cache[$path]; } return false; }
php
public function read($path) { if (isset($this->cache[$path]['contents']) && $this->cache[$path]['contents'] !== false) { return $this->cache[$path]; } return false; }
[ "public", "function", "read", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'contents'", "]", ")", "&&", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'contents'", "]", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L160-L167
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.rename
public function rename($path, $newpath) { if ($this->has($path)) { $object = $this->cache[$path]; unset($this->cache[$path]); $object['path'] = $newpath; $object = array_merge($object, Util::pathinfo($newpath)); $this->cache[$newpath] = $object; $this->autosave(); } }
php
public function rename($path, $newpath) { if ($this->has($path)) { $object = $this->cache[$path]; unset($this->cache[$path]); $object['path'] = $newpath; $object = array_merge($object, Util::pathinfo($newpath)); $this->cache[$newpath] = $object; $this->autosave(); } }
[ "public", "function", "rename", "(", "$", "path", ",", "$", "newpath", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "path", ")", ")", "{", "$", "object", "=", "$", "this", "->", "cache", "[", "$", "path", "]", ";", "unset", "(", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L180-L190
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.copy
public function copy($path, $newpath) { if ($this->has($path)) { $object = $this->cache[$path]; $object = array_merge($object, Util::pathinfo($newpath)); $this->updateObject($newpath, $object, true); } }
php
public function copy($path, $newpath) { if ($this->has($path)) { $object = $this->cache[$path]; $object = array_merge($object, Util::pathinfo($newpath)); $this->updateObject($newpath, $object, true); } }
[ "public", "function", "copy", "(", "$", "path", ",", "$", "newpath", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "path", ")", ")", "{", "$", "object", "=", "$", "this", "->", "cache", "[", "$", "path", "]", ";", "$", "object", "=...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L195-L202
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.deleteDir
public function deleteDir($dirname) { foreach ($this->cache as $path => $object) { if ($this->pathIsInDirectory($dirname, $path) || $path === $dirname) { unset($this->cache[$path]); } } unset($this->complete[$dirname]); $this->autosave(); }
php
public function deleteDir($dirname) { foreach ($this->cache as $path => $object) { if ($this->pathIsInDirectory($dirname, $path) || $path === $dirname) { unset($this->cache[$path]); } } unset($this->complete[$dirname]); $this->autosave(); }
[ "public", "function", "deleteDir", "(", "$", "dirname", ")", "{", "foreach", "(", "$", "this", "->", "cache", "as", "$", "path", "=>", "$", "object", ")", "{", "if", "(", "$", "this", "->", "pathIsInDirectory", "(", "$", "dirname", ",", "$", "path", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L215-L226
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.getMimetype
public function getMimetype($path) { if (isset($this->cache[$path]['mimetype'])) { return $this->cache[$path]; } if (! $result = $this->read($path)) { return false; } $mimetype = Util::guessMimeType($path, $result['contents']); $this->cache[$path]['mimetype'] = $mimetype; return $this->cache[$path]; }
php
public function getMimetype($path) { if (isset($this->cache[$path]['mimetype'])) { return $this->cache[$path]; } if (! $result = $this->read($path)) { return false; } $mimetype = Util::guessMimeType($path, $result['contents']); $this->cache[$path]['mimetype'] = $mimetype; return $this->cache[$path]; }
[ "public", "function", "getMimetype", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'mimetype'", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "]", ";", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L231-L245
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.getSize
public function getSize($path) { if (isset($this->cache[$path]['size'])) { return $this->cache[$path]; } return false; }
php
public function getSize($path) { if (isset($this->cache[$path]['size'])) { return $this->cache[$path]; } return false; }
[ "public", "function", "getSize", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'size'", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "]", ";", "}", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L250-L257
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.getTimestamp
public function getTimestamp($path) { if (isset($this->cache[$path]['timestamp'])) { return $this->cache[$path]; } return false; }
php
public function getTimestamp($path) { if (isset($this->cache[$path]['timestamp'])) { return $this->cache[$path]; } return false; }
[ "public", "function", "getTimestamp", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'timestamp'", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "]", ";"...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L262-L269
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.getVisibility
public function getVisibility($path) { if (isset($this->cache[$path]['visibility'])) { return $this->cache[$path]; } return false; }
php
public function getVisibility($path) { if (isset($this->cache[$path]['visibility'])) { return $this->cache[$path]; } return false; }
[ "public", "function", "getVisibility", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'visibility'", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "]", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L274-L281
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.getMetadata
public function getMetadata($path) { if (isset($this->cache[$path]['type'])) { return $this->cache[$path]; } return false; }
php
public function getMetadata($path) { if (isset($this->cache[$path]['type'])) { return $this->cache[$path]; } return false; }
[ "public", "function", "getMetadata", "(", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "path", "]", "[", "'type'", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "path", "]", ";", "}...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L286-L293
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.isComplete
public function isComplete($dirname, $recursive) { if (! array_key_exists($dirname, $this->complete)) { return false; } if ($recursive && $this->complete[$dirname] !== 'recursive') { return false; } return true; }
php
public function isComplete($dirname, $recursive) { if (! array_key_exists($dirname, $this->complete)) { return false; } if ($recursive && $this->complete[$dirname] !== 'recursive') { return false; } return true; }
[ "public", "function", "isComplete", "(", "$", "dirname", ",", "$", "recursive", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "dirname", ",", "$", "this", "->", "complete", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "recurs...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L298-L309
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.cleanContents
public function cleanContents(array $contents) { $cachedProperties = array_flip([ 'path', 'dirname', 'basename', 'extension', 'filename', 'size', 'mimetype', 'visibility', 'timestamp', 'type', ]); foreach ($contents as $path => $object) { if (is_array($object)) { $contents[$path] = array_intersect_key($object, $cachedProperties); } } return $contents; }
php
public function cleanContents(array $contents) { $cachedProperties = array_flip([ 'path', 'dirname', 'basename', 'extension', 'filename', 'size', 'mimetype', 'visibility', 'timestamp', 'type', ]); foreach ($contents as $path => $object) { if (is_array($object)) { $contents[$path] = array_intersect_key($object, $cachedProperties); } } return $contents; }
[ "public", "function", "cleanContents", "(", "array", "$", "contents", ")", "{", "$", "cachedProperties", "=", "array_flip", "(", "[", "'path'", ",", "'dirname'", ",", "'basename'", ",", "'extension'", ",", "'filename'", ",", "'size'", ",", "'mimetype'", ",", ...
Filter the contents from a listing. @param array $contents object listing @return array filtered contents
[ "Filter", "the", "contents", "from", "a", "listing", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L326-L340
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.setFromStorage
public function setFromStorage($json) { list($cache, $complete) = json_decode($json, true); if (json_last_error() === JSON_ERROR_NONE && is_array($cache) && is_array($complete)) { $this->cache = $cache; $this->complete = $complete; } }
php
public function setFromStorage($json) { list($cache, $complete) = json_decode($json, true); if (json_last_error() === JSON_ERROR_NONE && is_array($cache) && is_array($complete)) { $this->cache = $cache; $this->complete = $complete; } }
[ "public", "function", "setFromStorage", "(", "$", "json", ")", "{", "list", "(", "$", "cache", ",", "$", "complete", ")", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "===", "JSON_ERROR_NONE", "&&...
Load from serialized cache data. @param string $json
[ "Load", "from", "serialized", "cache", "data", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L379-L387
thephpleague/flysystem-cached-adapter
src/Storage/AbstractCache.php
AbstractCache.ensureParentDirectories
public function ensureParentDirectories($path) { $object = $this->cache[$path]; while ($object['dirname'] !== '' && ! isset($this->cache[$object['dirname']])) { $object = Util::pathinfo($object['dirname']); $object['type'] = 'dir'; $this->cache[$object['path']] = $object; } }
php
public function ensureParentDirectories($path) { $object = $this->cache[$path]; while ($object['dirname'] !== '' && ! isset($this->cache[$object['dirname']])) { $object = Util::pathinfo($object['dirname']); $object['type'] = 'dir'; $this->cache[$object['path']] = $object; } }
[ "public", "function", "ensureParentDirectories", "(", "$", "path", ")", "{", "$", "object", "=", "$", "this", "->", "cache", "[", "$", "path", "]", ";", "while", "(", "$", "object", "[", "'dirname'", "]", "!==", "''", "&&", "!", "isset", "(", "$", ...
Ensure parent directories of an object. @param string $path object path
[ "Ensure", "parent", "directories", "of", "an", "object", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/AbstractCache.php#L394-L403
thephpleague/flysystem-cached-adapter
src/Storage/Predis.php
Predis.load
public function load() { if (($contents = $this->executeCommand('get', [$this->key])) !== null) { $this->setFromStorage($contents); } }
php
public function load() { if (($contents = $this->executeCommand('get', [$this->key])) !== null) { $this->setFromStorage($contents); } }
[ "public", "function", "load", "(", ")", "{", "if", "(", "(", "$", "contents", "=", "$", "this", "->", "executeCommand", "(", "'get'", ",", "[", "$", "this", "->", "key", "]", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "setFromStorage", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Predis.php#L41-L46
thephpleague/flysystem-cached-adapter
src/Storage/Predis.php
Predis.save
public function save() { $contents = $this->getForStorage(); $this->executeCommand('set', [$this->key, $contents]); if ($this->expire !== null) { $this->executeCommand('expire', [$this->key, $this->expire]); } }
php
public function save() { $contents = $this->getForStorage(); $this->executeCommand('set', [$this->key, $contents]); if ($this->expire !== null) { $this->executeCommand('expire', [$this->key, $this->expire]); } }
[ "public", "function", "save", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "getForStorage", "(", ")", ";", "$", "this", "->", "executeCommand", "(", "'set'", ",", "[", "$", "this", "->", "key", ",", "$", "contents", "]", ")", ";", "if", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Predis.php#L51-L59
thephpleague/flysystem-cached-adapter
src/Storage/Predis.php
Predis.executeCommand
protected function executeCommand($name, array $arguments) { $command = $this->client->createCommand($name, $arguments); return $this->client->executeCommand($command); }
php
protected function executeCommand($name, array $arguments) { $command = $this->client->createCommand($name, $arguments); return $this->client->executeCommand($command); }
[ "protected", "function", "executeCommand", "(", "$", "name", ",", "array", "$", "arguments", ")", "{", "$", "command", "=", "$", "this", "->", "client", "->", "createCommand", "(", "$", "name", ",", "$", "arguments", ")", ";", "return", "$", "this", "-...
Execute a Predis command. @param string $name @param array $arguments @return string
[ "Execute", "a", "Predis", "command", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Predis.php#L69-L74
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.update
public function update($path, $contents, Config $config) { $result = $this->adapter->update($path, $contents, $config); if ($result !== false) { $result['type'] = 'file'; $this->cache->updateObject($path, $result + compact('path', 'contents'), true); } return $result; }
php
public function update($path, $contents, Config $config) { $result = $this->adapter->update($path, $contents, $config); if ($result !== false) { $result['type'] = 'file'; $this->cache->updateObject($path, $result + compact('path', 'contents'), true); } return $result; }
[ "public", "function", "update", "(", "$", "path", ",", "$", "contents", ",", "Config", "$", "config", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "update", "(", "$", "path", ",", "$", "contents", ",", "$", "config", ")", ";", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L87-L97
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.rename
public function rename($path, $newPath) { $result = $this->adapter->rename($path, $newPath); if ($result !== false) { $this->cache->rename($path, $newPath); } return $result; }
php
public function rename($path, $newPath) { $result = $this->adapter->rename($path, $newPath); if ($result !== false) { $this->cache->rename($path, $newPath); } return $result; }
[ "public", "function", "rename", "(", "$", "path", ",", "$", "newPath", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "rename", "(", "$", "path", ",", "$", "newPath", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{"...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L118-L127
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.copy
public function copy($path, $newpath) { $result = $this->adapter->copy($path, $newpath); if ($result !== false) { $this->cache->copy($path, $newpath); } return $result; }
php
public function copy($path, $newpath) { $result = $this->adapter->copy($path, $newpath); if ($result !== false) { $this->cache->copy($path, $newpath); } return $result; }
[ "public", "function", "copy", "(", "$", "path", ",", "$", "newpath", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "copy", "(", "$", "path", ",", "$", "newpath", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L132-L141
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.delete
public function delete($path) { $result = $this->adapter->delete($path); if ($result !== false) { $this->cache->delete($path); } return $result; }
php
public function delete($path) { $result = $this->adapter->delete($path); if ($result !== false) { $this->cache->delete($path); } return $result; }
[ "public", "function", "delete", "(", "$", "path", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "delete", "(", "$", "path", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "$", "this", "->", "cache", "->", "delet...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L146-L155
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.deleteDir
public function deleteDir($dirname) { $result = $this->adapter->deleteDir($dirname); if ($result !== false) { $this->cache->deleteDir($dirname); } return $result; }
php
public function deleteDir($dirname) { $result = $this->adapter->deleteDir($dirname); if ($result !== false) { $this->cache->deleteDir($dirname); } return $result; }
[ "public", "function", "deleteDir", "(", "$", "dirname", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "deleteDir", "(", "$", "dirname", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "$", "this", "->", "cache", "-...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L160-L169
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.createDir
public function createDir($dirname, Config $config) { $result = $this->adapter->createDir($dirname, $config); if ($result !== false) { $type = 'dir'; $path = $dirname; $this->cache->updateObject($dirname, compact('path', 'type'), true); } return $result; }
php
public function createDir($dirname, Config $config) { $result = $this->adapter->createDir($dirname, $config); if ($result !== false) { $type = 'dir'; $path = $dirname; $this->cache->updateObject($dirname, compact('path', 'type'), true); } return $result; }
[ "public", "function", "createDir", "(", "$", "dirname", ",", "Config", "$", "config", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "createDir", "(", "$", "dirname", ",", "$", "config", ")", ";", "if", "(", "$", "result", "!==", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L174-L185
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.setVisibility
public function setVisibility($path, $visibility) { $result = $this->adapter->setVisibility($path, $visibility); if ($result !== false) { $this->cache->updateObject($path, compact('path', 'visibility'), true); } return $result; }
php
public function setVisibility($path, $visibility) { $result = $this->adapter->setVisibility($path, $visibility); if ($result !== false) { $this->cache->updateObject($path, compact('path', 'visibility'), true); } return $result; }
[ "public", "function", "setVisibility", "(", "$", "path", ",", "$", "visibility", ")", "{", "$", "result", "=", "$", "this", "->", "adapter", "->", "setVisibility", "(", "$", "path", ",", "$", "visibility", ")", ";", "if", "(", "$", "result", "!==", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L190-L199
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.has
public function has($path) { $cacheHas = $this->cache->has($path); if ($cacheHas !== null) { return $cacheHas; } $adapterResponse = $this->adapter->has($path); if (! $adapterResponse) { $this->cache->storeMiss($path); } else { $cacheEntry = is_array($adapterResponse) ? $adapterResponse : compact('path'); $this->cache->updateObject($path, $cacheEntry, true); } return $adapterResponse; }
php
public function has($path) { $cacheHas = $this->cache->has($path); if ($cacheHas !== null) { return $cacheHas; } $adapterResponse = $this->adapter->has($path); if (! $adapterResponse) { $this->cache->storeMiss($path); } else { $cacheEntry = is_array($adapterResponse) ? $adapterResponse : compact('path'); $this->cache->updateObject($path, $cacheEntry, true); } return $adapterResponse; }
[ "public", "function", "has", "(", "$", "path", ")", "{", "$", "cacheHas", "=", "$", "this", "->", "cache", "->", "has", "(", "$", "path", ")", ";", "if", "(", "$", "cacheHas", "!==", "null", ")", "{", "return", "$", "cacheHas", ";", "}", "$", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L204-L222
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.listContents
public function listContents($directory = '', $recursive = false) { if ($this->cache->isComplete($directory, $recursive)) { return $this->cache->listContents($directory, $recursive); } $result = $this->adapter->listContents($directory, $recursive); if ($result !== false) { $this->cache->storeContents($directory, $result, $recursive); } return $result; }
php
public function listContents($directory = '', $recursive = false) { if ($this->cache->isComplete($directory, $recursive)) { return $this->cache->listContents($directory, $recursive); } $result = $this->adapter->listContents($directory, $recursive); if ($result !== false) { $this->cache->storeContents($directory, $result, $recursive); } return $result; }
[ "public", "function", "listContents", "(", "$", "directory", "=", "''", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "isComplete", "(", "$", "directory", ",", "$", "recursive", ")", ")", "{", "return", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L243-L256
thephpleague/flysystem-cached-adapter
src/CachedAdapter.php
CachedAdapter.callWithFallback
protected function callWithFallback($property, $path, $method) { $result = $this->cache->{$method}($path); if ($result !== false && ($property === null || array_key_exists($property, $result))) { return $result; } $result = $this->adapter->{$method}($path); if ($result) { $object = $result + compact('path'); $this->cache->updateObject($path, $object, true); } return $result; }
php
protected function callWithFallback($property, $path, $method) { $result = $this->cache->{$method}($path); if ($result !== false && ($property === null || array_key_exists($property, $result))) { return $result; } $result = $this->adapter->{$method}($path); if ($result) { $object = $result + compact('path'); $this->cache->updateObject($path, $object, true); } return $result; }
[ "protected", "function", "callWithFallback", "(", "$", "property", ",", "$", "path", ",", "$", "method", ")", "{", "$", "result", "=", "$", "this", "->", "cache", "->", "{", "$", "method", "}", "(", "$", "path", ")", ";", "if", "(", "$", "result", ...
Call a method and cache the response. @param string $property @param string $path @param string $method @return mixed
[ "Call", "a", "method", "and", "cache", "the", "response", "." ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/CachedAdapter.php#L307-L323
thephpleague/flysystem-cached-adapter
src/Storage/Stash.php
Stash.load
public function load() { $item = $this->pool->getItem($this->key); $contents = $item->get(); if ($item->isMiss() === false) { $this->setFromStorage($contents); } }
php
public function load() { $item = $this->pool->getItem($this->key); $contents = $item->get(); if ($item->isMiss() === false) { $this->setFromStorage($contents); } }
[ "public", "function", "load", "(", ")", "{", "$", "item", "=", "$", "this", "->", "pool", "->", "getItem", "(", "$", "this", "->", "key", ")", ";", "$", "contents", "=", "$", "item", "->", "get", "(", ")", ";", "if", "(", "$", "item", "->", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Stash.php#L41-L49
thephpleague/flysystem-cached-adapter
src/Storage/Stash.php
Stash.save
public function save() { $contents = $this->getForStorage(); $item = $this->pool->getItem($this->key); $item->set($contents, $this->expire); }
php
public function save() { $contents = $this->getForStorage(); $item = $this->pool->getItem($this->key); $item->set($contents, $this->expire); }
[ "public", "function", "save", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "getForStorage", "(", ")", ";", "$", "item", "=", "$", "this", "->", "pool", "->", "getItem", "(", "$", "this", "->", "key", ")", ";", "$", "item", "->", "set",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/flysystem-cached-adapter/blob/08ef74e9be88100807a3b92cc9048a312bf01d6f/src/Storage/Stash.php#L54-L59
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.getModelAttributes
public function getModelAttributes() { $attributes = $this->getModel()->getAttributes(); foreach ($attributes as $key => $value) { // The validator doesn't handle Carbon instances, so instead of casting // them we'll return their raw value instead. if (in_array($key, $this->getDates()) || $this->isDateCastable($key)) { $attributes[$key] = $value; continue; } $attributes[$key] = $this->getModel()->getAttributeValue($key); } return $attributes; }
php
public function getModelAttributes() { $attributes = $this->getModel()->getAttributes(); foreach ($attributes as $key => $value) { // The validator doesn't handle Carbon instances, so instead of casting // them we'll return their raw value instead. if (in_array($key, $this->getDates()) || $this->isDateCastable($key)) { $attributes[$key] = $value; continue; } $attributes[$key] = $this->getModel()->getAttributeValue($key); } return $attributes; }
[ "public", "function", "getModelAttributes", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "getModel", "(", ")", "->", "getAttributes", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "// The...
Get the casted model attributes. @return array
[ "Get", "the", "casted", "model", "attributes", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L130-L146
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.forceSave
public function forceSave(array $options = []) { $currentValidatingSetting = $this->getValidating(); $this->setValidating(false); $result = $this->getModel()->save($options); $this->setValidating($currentValidatingSetting); return $result; }
php
public function forceSave(array $options = []) { $currentValidatingSetting = $this->getValidating(); $this->setValidating(false); $result = $this->getModel()->save($options); $this->setValidating($currentValidatingSetting); return $result; }
[ "public", "function", "forceSave", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "currentValidatingSetting", "=", "$", "this", "->", "getValidating", "(", ")", ";", "$", "this", "->", "setValidating", "(", "false", ")", ";", "$", "result", ...
Force the model to be saved without undergoing validation. @param array $options @return bool
[ "Force", "the", "model", "to", "be", "saved", "without", "undergoing", "validation", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L307-L318
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.saveOrFail
public function saveOrFail(array $options = []) { if ($this->isInvalid()) { return $this->throwValidationException(); } return $this->getModel()->parentSaveOrFail($options); }
php
public function saveOrFail(array $options = []) { if ($this->isInvalid()) { return $this->throwValidationException(); } return $this->getModel()->parentSaveOrFail($options); }
[ "public", "function", "saveOrFail", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isInvalid", "(", ")", ")", "{", "return", "$", "this", "->", "throwValidationException", "(", ")", ";", "}", "return", "$", "thi...
Perform a one-off save that will raise an exception on validation error instead of returning a boolean (which is the default behaviour). @param array $options @return bool @throws \Throwable
[ "Perform", "a", "one", "-", "off", "save", "that", "will", "raise", "an", "exception", "on", "validation", "error", "instead", "of", "returning", "a", "boolean", "(", "which", "is", "the", "default", "behaviour", ")", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L328-L335
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.makeValidator
protected function makeValidator($rules = []) { // Get the casted model attributes. $attributes = $this->getModelAttributes(); if ($this->getInjectUniqueIdentifier()) { $rules = $this->injectUniqueIdentifierToRules($rules); } $messages = $this->getValidationMessages(); $validator = $this->getValidator()->make($attributes, $rules, $messages); if ($this->getValidationAttributeNames()) { $validator->setAttributeNames($this->getValidationAttributeNames()); } return $validator; }
php
protected function makeValidator($rules = []) { // Get the casted model attributes. $attributes = $this->getModelAttributes(); if ($this->getInjectUniqueIdentifier()) { $rules = $this->injectUniqueIdentifierToRules($rules); } $messages = $this->getValidationMessages(); $validator = $this->getValidator()->make($attributes, $rules, $messages); if ($this->getValidationAttributeNames()) { $validator->setAttributeNames($this->getValidationAttributeNames()); } return $validator; }
[ "protected", "function", "makeValidator", "(", "$", "rules", "=", "[", "]", ")", "{", "// Get the casted model attributes.", "$", "attributes", "=", "$", "this", "->", "getModelAttributes", "(", ")", ";", "if", "(", "$", "this", "->", "getInjectUniqueIdentifier"...
Make a Validator instance for a given ruleset. @param array $rules @return \Illuminate\Validation\Factory
[ "Make", "a", "Validator", "instance", "for", "a", "given", "ruleset", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L387-L405
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.performValidation
protected function performValidation($rules = []) { $validation = $this->makeValidator($rules); $result = $validation->passes(); $this->setErrors($validation->messages()); return $result; }
php
protected function performValidation($rules = []) { $validation = $this->makeValidator($rules); $result = $validation->passes(); $this->setErrors($validation->messages()); return $result; }
[ "protected", "function", "performValidation", "(", "$", "rules", "=", "[", "]", ")", "{", "$", "validation", "=", "$", "this", "->", "makeValidator", "(", "$", "rules", ")", ";", "$", "result", "=", "$", "validation", "->", "passes", "(", ")", ";", "...
Validate the model against it's rules, returning whether or not it passes and setting the error messages on the model if required. @param array $rules @return bool @throws \Watson\Validating\ValidationException
[ "Validate", "the", "model", "against", "it", "s", "rules", "returning", "whether", "or", "not", "it", "passes", "and", "setting", "the", "error", "messages", "on", "the", "model", "if", "required", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L416-L425
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.injectUniqueIdentifierToRules
protected function injectUniqueIdentifierToRules(array $rules) { foreach ($rules as $field => &$ruleset) { // If the ruleset is a pipe-delimited string, convert it to an array. $ruleset = is_string($ruleset) ? explode('|', $ruleset) : $ruleset; foreach ($ruleset as &$rule) { // Only treat stringy definitions and leave Rule classes and Closures as-is. if (is_string($rule)) { $parameters = explode(':', $rule); $validationRule = array_shift($parameters); if ($method = $this->getUniqueIdentifierInjectorMethod($validationRule)) { $rule = call_user_func_array( [$this, $method], [explode(',', head($parameters)), $field] ); } } } } return $rules; }
php
protected function injectUniqueIdentifierToRules(array $rules) { foreach ($rules as $field => &$ruleset) { // If the ruleset is a pipe-delimited string, convert it to an array. $ruleset = is_string($ruleset) ? explode('|', $ruleset) : $ruleset; foreach ($ruleset as &$rule) { // Only treat stringy definitions and leave Rule classes and Closures as-is. if (is_string($rule)) { $parameters = explode(':', $rule); $validationRule = array_shift($parameters); if ($method = $this->getUniqueIdentifierInjectorMethod($validationRule)) { $rule = call_user_func_array( [$this, $method], [explode(',', head($parameters)), $field] ); } } } } return $rules; }
[ "protected", "function", "injectUniqueIdentifierToRules", "(", "array", "$", "rules", ")", "{", "foreach", "(", "$", "rules", "as", "$", "field", "=>", "&", "$", "ruleset", ")", "{", "// If the ruleset is a pipe-delimited string, convert it to an array.", "$", "rulese...
If the model already exists and it has unique validations it is going to fail validation unless we also pass it's primary key to the rule so that it may be ignored. This will go through all the rules and append the model's primary key to the unique rules so that the validation will work as expected. @param array $rules @return array
[ "If", "the", "model", "already", "exists", "and", "it", "has", "unique", "validations", "it", "is", "going", "to", "fail", "validation", "unless", "we", "also", "pass", "it", "s", "primary", "key", "to", "the", "rule", "so", "that", "it", "may", "be", ...
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L464-L487
dwightwatson/validating
src/ValidatingTrait.php
ValidatingTrait.getUniqueIdentifierInjectorMethod
protected function getUniqueIdentifierInjectorMethod($validationRule) { $method = 'prepare' . studly_case($validationRule) . 'Rule'; return method_exists($this, $method) ? $method : false; }
php
protected function getUniqueIdentifierInjectorMethod($validationRule) { $method = 'prepare' . studly_case($validationRule) . 'Rule'; return method_exists($this, $method) ? $method : false; }
[ "protected", "function", "getUniqueIdentifierInjectorMethod", "(", "$", "validationRule", ")", "{", "$", "method", "=", "'prepare'", ".", "studly_case", "(", "$", "validationRule", ")", ".", "'Rule'", ";", "return", "method_exists", "(", "$", "this", ",", "$", ...
Get the dynamic method name for a unique identifier injector rule if it exists, otherwise return false. @param string $validationRule @return mixed
[ "Get", "the", "dynamic", "method", "name", "for", "a", "unique", "identifier", "injector", "rule", "if", "it", "exists", "otherwise", "return", "false", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingTrait.php#L496-L501
dwightwatson/validating
src/Injectors/UniqueWithInjector.php
UniqueWithInjector.prepareUniqueWithRule
protected function prepareUniqueWithRule($parameters, $field) { // Table and intermediary fields are required for this validator to work and cannot be guessed. // Let's just check the model identifier. if ($this->exists) { // If the identifier isn't set, add it. if (count($parameters) < 3 || ! preg_match('/^\d+(\s?=\s?\w*)?$/', last($parameters))) { $parameters[] = $this->getModel()->getKey(); } } return 'unique_with:' . implode(',', $parameters); }
php
protected function prepareUniqueWithRule($parameters, $field) { // Table and intermediary fields are required for this validator to work and cannot be guessed. // Let's just check the model identifier. if ($this->exists) { // If the identifier isn't set, add it. if (count($parameters) < 3 || ! preg_match('/^\d+(\s?=\s?\w*)?$/', last($parameters))) { $parameters[] = $this->getModel()->getKey(); } } return 'unique_with:' . implode(',', $parameters); }
[ "protected", "function", "prepareUniqueWithRule", "(", "$", "parameters", ",", "$", "field", ")", "{", "// Table and intermediary fields are required for this validator to work and cannot be guessed.", "// Let's just check the model identifier.", "if", "(", "$", "this", "->", "ex...
Prepare a unique_with rule, adding the model identifier if required. @param array $parameters @param string $field @return string
[ "Prepare", "a", "unique_with", "rule", "adding", "the", "model", "identifier", "if", "required", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/Injectors/UniqueWithInjector.php#L14-L26
dwightwatson/validating
src/ValidatingObserver.php
ValidatingObserver.performValidation
protected function performValidation(Model $model, $event) { // If the model has validating enabled, perform it. if ($model->getValidating()) { // Fire the namespaced validating event and prevent validation // if it returns a value. if ($this->fireValidatingEvent($model, $event) !== null) { return; } if ($model->isValid() === false) { // Fire the validating failed event. $this->fireValidatedEvent($model, 'failed'); if ($model->getThrowValidationExceptions()) { $model->throwValidationException(); } return false; } // Fire the validating.passed event. $this->fireValidatedEvent($model, 'passed'); } else { $this->fireValidatedEvent($model, 'skipped'); } }
php
protected function performValidation(Model $model, $event) { // If the model has validating enabled, perform it. if ($model->getValidating()) { // Fire the namespaced validating event and prevent validation // if it returns a value. if ($this->fireValidatingEvent($model, $event) !== null) { return; } if ($model->isValid() === false) { // Fire the validating failed event. $this->fireValidatedEvent($model, 'failed'); if ($model->getThrowValidationExceptions()) { $model->throwValidationException(); } return false; } // Fire the validating.passed event. $this->fireValidatedEvent($model, 'passed'); } else { $this->fireValidatedEvent($model, 'skipped'); } }
[ "protected", "function", "performValidation", "(", "Model", "$", "model", ",", "$", "event", ")", "{", "// If the model has validating enabled, perform it.", "if", "(", "$", "model", "->", "getValidating", "(", ")", ")", "{", "// Fire the namespaced validating event and...
Perform validation with the specified ruleset. @param \Illuminate\Database\Eloquent\Model $model @param string $event @return boolean
[ "Perform", "validation", "with", "the", "specified", "ruleset", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingObserver.php#L41-L66
dwightwatson/validating
src/ValidatingObserver.php
ValidatingObserver.fireValidatingEvent
protected function fireValidatingEvent(Model $model, $event) { return Event::until("eloquent.validating: ".get_class($model), [$model, $event]); }
php
protected function fireValidatingEvent(Model $model, $event) { return Event::until("eloquent.validating: ".get_class($model), [$model, $event]); }
[ "protected", "function", "fireValidatingEvent", "(", "Model", "$", "model", ",", "$", "event", ")", "{", "return", "Event", "::", "until", "(", "\"eloquent.validating: \"", ".", "get_class", "(", "$", "model", ")", ",", "[", "$", "model", ",", "$", "event"...
Fire the namespaced validating event. @param \Illuminate\Database\Eloquent\Model $model @param string $event @return mixed
[ "Fire", "the", "namespaced", "validating", "event", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingObserver.php#L75-L78
dwightwatson/validating
src/ValidatingObserver.php
ValidatingObserver.fireValidatedEvent
protected function fireValidatedEvent(Model $model, $status) { Event::dispatch("eloquent.validated: ".get_class($model), [$model, $status]); }
php
protected function fireValidatedEvent(Model $model, $status) { Event::dispatch("eloquent.validated: ".get_class($model), [$model, $status]); }
[ "protected", "function", "fireValidatedEvent", "(", "Model", "$", "model", ",", "$", "status", ")", "{", "Event", "::", "dispatch", "(", "\"eloquent.validated: \"", ".", "get_class", "(", "$", "model", ")", ",", "[", "$", "model", ",", "$", "status", "]", ...
Fire the namespaced post-validation event. @param \Illuminate\Database\Eloquent\Model $model @param string $status @return void
[ "Fire", "the", "namespaced", "post", "-", "validation", "event", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/ValidatingObserver.php#L87-L90
dwightwatson/validating
src/Injectors/UniqueInjector.php
UniqueInjector.prepareUniqueRule
protected function prepareUniqueRule($parameters, $field) { // If the table name isn't set, infer it. if (empty($parameters[0])) { $parameters[0] = $this->getModel()->getTable(); } // If the connection name isn't set but exists, infer it. if ((strpos($parameters[0], '.') === false) && (($connectionName = $this->getModel()->getConnectionName()) !== null)) { $parameters[0] = $connectionName.'.'.$parameters[0]; } // If the field name isn't get, infer it. if (! isset($parameters[1])) { $parameters[1] = $field; } if ($this->exists) { // If the identifier isn't set, infer it. if (! isset($parameters[2]) || strtolower($parameters[2]) === 'null') { $parameters[2] = $this->getModel()->getKey(); } // If the primary key isn't set, infer it. if (! isset($parameters[3])) { $parameters[3] = $this->getModel()->getKeyName(); } // If the additional where clause isn't set, infer it. // Example: unique:users,email,123,id,username,NULL foreach ($parameters as $key => $parameter) { if (strtolower((string) $parameter) === 'null') { // Maintain NULL as string in case the model returns a null value $value = $this->getModel()->{$parameters[$key - 1]}; $parameters[$key] = is_null($value) ? 'NULL' : $value; } } } return 'unique:' . implode(',', $parameters); }
php
protected function prepareUniqueRule($parameters, $field) { // If the table name isn't set, infer it. if (empty($parameters[0])) { $parameters[0] = $this->getModel()->getTable(); } // If the connection name isn't set but exists, infer it. if ((strpos($parameters[0], '.') === false) && (($connectionName = $this->getModel()->getConnectionName()) !== null)) { $parameters[0] = $connectionName.'.'.$parameters[0]; } // If the field name isn't get, infer it. if (! isset($parameters[1])) { $parameters[1] = $field; } if ($this->exists) { // If the identifier isn't set, infer it. if (! isset($parameters[2]) || strtolower($parameters[2]) === 'null') { $parameters[2] = $this->getModel()->getKey(); } // If the primary key isn't set, infer it. if (! isset($parameters[3])) { $parameters[3] = $this->getModel()->getKeyName(); } // If the additional where clause isn't set, infer it. // Example: unique:users,email,123,id,username,NULL foreach ($parameters as $key => $parameter) { if (strtolower((string) $parameter) === 'null') { // Maintain NULL as string in case the model returns a null value $value = $this->getModel()->{$parameters[$key - 1]}; $parameters[$key] = is_null($value) ? 'NULL' : $value; } } } return 'unique:' . implode(',', $parameters); }
[ "protected", "function", "prepareUniqueRule", "(", "$", "parameters", ",", "$", "field", ")", "{", "// If the table name isn't set, infer it.", "if", "(", "empty", "(", "$", "parameters", "[", "0", "]", ")", ")", "{", "$", "parameters", "[", "0", "]", "=", ...
Prepare a unique rule, adding the table name, column and model identifier if required. @param array $parameters @param string $field @return string
[ "Prepare", "a", "unique", "rule", "adding", "the", "table", "name", "column", "and", "model", "identifier", "if", "required", "." ]
train
https://github.com/dwightwatson/validating/blob/b8fa204e59d3a6766185f841b75d8ffa0c47a978/src/Injectors/UniqueInjector.php#L15-L55
simplepie/simplepie
library/SimplePie.php
SimplePie.get_language
public function get_language() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['headers']['content-language'])) { return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); } return null; }
php
public function get_language() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) { return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif (isset($this->data['headers']['content-language'])) { return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); } return null; }
[ "public", "function", "get_language", "(", ")", "{", "if", "(", "$", "return", "=", "$", "this", "->", "get_channel_tags", "(", "SIMPLEPIE_NAMESPACE_RSS_20", ",", "'language'", ")", ")", "{", "return", "$", "this", "->", "sanitize", "(", "$", "return", "["...
Get the language for the feed Uses `<language>`, `<dc:language>`, or @xml_lang @since 1.0 (previously called `get_feed_language()` since 0.8) @return string|null
[ "Get", "the", "language", "for", "the", "feed" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2693-L2725
simplepie/simplepie
library/SimplePie.php
SimplePie.get_image_title
public function get_image_title() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } return null; }
php
public function get_image_title() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } return null; }
[ "public", "function", "get_image_title", "(", ")", "{", "if", "(", "$", "return", "=", "$", "this", "->", "get_image_tags", "(", "SIMPLEPIE_NAMESPACE_RSS_10", ",", "'title'", ")", ")", "{", "return", "$", "this", "->", "sanitize", "(", "$", "return", "[", ...
Get the feed logo's title RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" title. Uses `<image><title>` or `<image><dc:title>` @return string|null
[ "Get", "the", "feed", "logo", "s", "title" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2793-L2817
simplepie/simplepie
library/SimplePie.php
SimplePie.get_image_link
public function get_image_link() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } return null; }
php
public function get_image_link() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } return null; }
[ "public", "function", "get_image_link", "(", ")", "{", "if", "(", "$", "return", "=", "$", "this", "->", "get_image_tags", "(", "SIMPLEPIE_NAMESPACE_RSS_10", ",", "'link'", ")", ")", "{", "return", "$", "this", "->", "sanitize", "(", "$", "return", "[", ...
Get the feed logo's link RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" link. This points to a human-readable page that the image should link to. Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`, `<image><title>` or `<image><dc:title>` @return string|null
[ "Get", "the", "feed", "logo", "s", "link" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2872-L2888
simplepie/simplepie
library/SimplePie.php
SimplePie.get_image_width
public function get_image_width() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) { return round($return[0]['data']); } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 88.0; } return null; }
php
public function get_image_width() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) { return round($return[0]['data']); } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 88.0; } return null; }
[ "public", "function", "get_image_width", "(", ")", "{", "if", "(", "$", "return", "=", "$", "this", "->", "get_image_tags", "(", "SIMPLEPIE_NAMESPACE_RSS_20", ",", "'width'", ")", ")", "{", "return", "round", "(", "$", "return", "[", "0", "]", "[", "'dat...
Get the feed logo's link RSS 2.0 feeds are allowed to have a "feed logo" width. Uses `<image><width>` or defaults to 88.0 if no width is specified and the feed is an RSS 2.0 feed. @return int|float|null
[ "Get", "the", "feed", "logo", "s", "link" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2900-L2912
simplepie/simplepie
library/SimplePie.php
SimplePie.get_image_height
public function get_image_height() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) { return round($return[0]['data']); } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 31.0; } return null; }
php
public function get_image_height() { if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) { return round($return[0]['data']); } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 31.0; } return null; }
[ "public", "function", "get_image_height", "(", ")", "{", "if", "(", "$", "return", "=", "$", "this", "->", "get_image_tags", "(", "SIMPLEPIE_NAMESPACE_RSS_20", ",", "'height'", ")", ")", "{", "return", "round", "(", "$", "return", "[", "0", "]", "[", "'d...
Get the feed logo's height RSS 2.0 feeds are allowed to have a "feed logo" height. Uses `<image><height>` or defaults to 31.0 if no height is specified and the feed is an RSS 2.0 feed. @return int|float|null
[ "Get", "the", "feed", "logo", "s", "height" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2924-L2936
simplepie/simplepie
library/SimplePie.php
SimplePie.get_item_quantity
public function get_item_quantity($max = 0) { $max = (int) $max; $qty = count($this->get_items()); if ($max === 0) { return $qty; } return ($qty > $max) ? $max : $qty; }
php
public function get_item_quantity($max = 0) { $max = (int) $max; $qty = count($this->get_items()); if ($max === 0) { return $qty; } return ($qty > $max) ? $max : $qty; }
[ "public", "function", "get_item_quantity", "(", "$", "max", "=", "0", ")", "{", "$", "max", "=", "(", "int", ")", "$", "max", ";", "$", "qty", "=", "count", "(", "$", "this", "->", "get_items", "(", ")", ")", ";", "if", "(", "$", "max", "===", ...
Get the number of items in the feed This is well-suited for {@link http://php.net/for for()} loops with {@see get_item()} @param int $max Maximum value to return. 0 for no limit @return int Number of items in the feed
[ "Get", "the", "number", "of", "items", "in", "the", "feed" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2947-L2957
simplepie/simplepie
library/SimplePie.php
SimplePie.get_item
public function get_item($key = 0) { $items = $this->get_items(); if (isset($items[$key])) { return $items[$key]; } return null; }
php
public function get_item($key = 0) { $items = $this->get_items(); if (isset($items[$key])) { return $items[$key]; } return null; }
[ "public", "function", "get_item", "(", "$", "key", "=", "0", ")", "{", "$", "items", "=", "$", "this", "->", "get_items", "(", ")", ";", "if", "(", "isset", "(", "$", "items", "[", "$", "key", "]", ")", ")", "{", "return", "$", "items", "[", ...
Get a single item from the feed This is better suited for {@link http://php.net/for for()} loops, whereas {@see get_items()} is better suited for {@link http://php.net/foreach foreach()} loops. @see get_item_quantity() @since Beta 2 @param int $key The item that you want to return. Remember that arrays begin with 0, not 1 @return SimplePie_Item|null
[ "Get", "a", "single", "item", "from", "the", "feed" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie.php#L2971-L2980
simplepie/simplepie
library/SimplePie/Parse/Date.php
SimplePie_Parse_Date.date_asctime
public function date_asctime($date) { static $pcre; if (!$pcre) { $space = '[\x09\x20]+'; $wday_name = $this->day_pcre; $mon_name = $this->month_pcre; $day = '([0-9]{1,2})'; $hour = $sec = $min = '([0-9]{2})'; $year = '([0-9]{4})'; $terminator = '\x0A?\x00?'; $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; } if (preg_match($pcre, $date, $match)) { /* Capturing subpatterns: 1: Day name 2: Month 3: Day 4: Hour 5: Minute 6: Second 7: Year */ $month = $this->month[strtolower($match[2])]; return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); } return false; }
php
public function date_asctime($date) { static $pcre; if (!$pcre) { $space = '[\x09\x20]+'; $wday_name = $this->day_pcre; $mon_name = $this->month_pcre; $day = '([0-9]{1,2})'; $hour = $sec = $min = '([0-9]{2})'; $year = '([0-9]{4})'; $terminator = '\x0A?\x00?'; $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; } if (preg_match($pcre, $date, $match)) { /* Capturing subpatterns: 1: Day name 2: Month 3: Day 4: Hour 5: Minute 6: Second 7: Year */ $month = $this->month[strtolower($match[2])]; return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); } return false; }
[ "public", "function", "date_asctime", "(", "$", "date", ")", "{", "static", "$", "pcre", ";", "if", "(", "!", "$", "pcre", ")", "{", "$", "space", "=", "'[\\x09\\x20]+'", ";", "$", "wday_name", "=", "$", "this", "->", "day_pcre", ";", "$", "mon_name"...
Parse C99's asctime()'s date format @access protected @return int Timestamp
[ "Parse", "C99", "s", "asctime", "()", "s", "date", "format" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Parse/Date.php#L956-L988
simplepie/simplepie
library/SimplePie/Cache/MySQL.php
SimplePie_Cache_MySQL.mtime
public function mtime() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); if ($query->execute() && ($time = $query->fetchColumn())) { return $time; } return false; }
php
public function mtime() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); if ($query->execute() && ($time = $query->fetchColumn())) { return $time; } return false; }
[ "public", "function", "mtime", "(", ")", "{", "if", "(", "$", "this", "->", "mysql", "===", "null", ")", "{", "return", "false", ";", "}", "$", "query", "=", "$", "this", "->", "mysql", "->", "prepare", "(", "'SELECT `mtime` FROM `'", ".", "$", "this...
Retrieve the last modified time for the cache @return int Timestamp
[ "Retrieve", "the", "last", "modified", "time", "for", "the", "cache" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Cache/MySQL.php#L385-L400
simplepie/simplepie
library/SimplePie/Cache/MySQL.php
SimplePie_Cache_MySQL.touch
public function touch() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); $query->bindValue(':time', time()); $query->bindValue(':id', $this->id); return $query->execute() && $query->rowCount() > 0; }
php
public function touch() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); $query->bindValue(':time', time()); $query->bindValue(':id', $this->id); return $query->execute() && $query->rowCount() > 0; }
[ "public", "function", "touch", "(", ")", "{", "if", "(", "$", "this", "->", "mysql", "===", "null", ")", "{", "return", "false", ";", "}", "$", "query", "=", "$", "this", "->", "mysql", "->", "prepare", "(", "'UPDATE `'", ".", "$", "this", "->", ...
Set the last modified time to the current time @return bool Success status
[ "Set", "the", "last", "modified", "time", "to", "the", "current", "time" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Cache/MySQL.php#L407-L419
simplepie/simplepie
library/SimplePie/Cache/MySQL.php
SimplePie_Cache_MySQL.unlink
public function unlink() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); $query2->bindValue(':id', $this->id); return $query->execute() && $query2->execute(); }
php
public function unlink() { if ($this->mysql === null) { return false; } $query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); $query->bindValue(':id', $this->id); $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); $query2->bindValue(':id', $this->id); return $query->execute() && $query2->execute(); }
[ "public", "function", "unlink", "(", ")", "{", "if", "(", "$", "this", "->", "mysql", "===", "null", ")", "{", "return", "false", ";", "}", "$", "query", "=", "$", "this", "->", "mysql", "->", "prepare", "(", "'DELETE FROM `'", ".", "$", "this", "-...
Remove the cache @return bool Success status
[ "Remove", "the", "cache" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Cache/MySQL.php#L426-L439
simplepie/simplepie
library/SimplePie/Enclosure.php
SimplePie_Enclosure.get_hash
public function get_hash($key = 0) { $hashes = $this->get_hashes(); if (isset($hashes[$key])) { return $hashes[$key]; } return null; }
php
public function get_hash($key = 0) { $hashes = $this->get_hashes(); if (isset($hashes[$key])) { return $hashes[$key]; } return null; }
[ "public", "function", "get_hash", "(", "$", "key", "=", "0", ")", "{", "$", "hashes", "=", "$", "this", "->", "get_hashes", "(", ")", ";", "if", "(", "isset", "(", "$", "hashes", "[", "$", "key", "]", ")", ")", "{", "return", "$", "hashes", "["...
Get a single hash @link http://www.rssboard.org/media-rss#media-hash @param int $key @return string|null Hash as per `media:hash`, prefixed with "$algo:"
[ "Get", "a", "single", "hash" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Enclosure.php#L517-L526
simplepie/simplepie
library/SimplePie/Enclosure.php
SimplePie_Enclosure.get_keyword
public function get_keyword($key = 0) { $keywords = $this->get_keywords(); if (isset($keywords[$key])) { return $keywords[$key]; } return null; }
php
public function get_keyword($key = 0) { $keywords = $this->get_keywords(); if (isset($keywords[$key])) { return $keywords[$key]; } return null; }
[ "public", "function", "get_keyword", "(", "$", "key", "=", "0", ")", "{", "$", "keywords", "=", "$", "this", "->", "get_keywords", "(", ")", ";", "if", "(", "isset", "(", "$", "keywords", "[", "$", "key", "]", ")", ")", "{", "return", "$", "keywo...
Get a single keyword @param int $key @return string|null
[ "Get", "a", "single", "keyword" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Enclosure.php#L580-L589
simplepie/simplepie
library/SimplePie/Enclosure.php
SimplePie_Enclosure.get_rating
public function get_rating($key = 0) { $ratings = $this->get_ratings(); if (isset($ratings[$key])) { return $ratings[$key]; } return null; }
php
public function get_rating($key = 0) { $ratings = $this->get_ratings(); if (isset($ratings[$key])) { return $ratings[$key]; } return null; }
[ "public", "function", "get_rating", "(", "$", "key", "=", "0", ")", "{", "$", "ratings", "=", "$", "this", "->", "get_ratings", "(", ")", ";", "if", "(", "isset", "(", "$", "ratings", "[", "$", "key", "]", ")", ")", "{", "return", "$", "ratings",...
Get a single rating @param int $key @return SimplePie_Rating|null
[ "Get", "a", "single", "rating" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Enclosure.php#L674-L683
simplepie/simplepie
library/SimplePie/Enclosure.php
SimplePie_Enclosure.get_restriction
public function get_restriction($key = 0) { $restrictions = $this->get_restrictions(); if (isset($restrictions[$key])) { return $restrictions[$key]; } return null; }
php
public function get_restriction($key = 0) { $restrictions = $this->get_restrictions(); if (isset($restrictions[$key])) { return $restrictions[$key]; } return null; }
[ "public", "function", "get_restriction", "(", "$", "key", "=", "0", ")", "{", "$", "restrictions", "=", "$", "this", "->", "get_restrictions", "(", ")", ";", "if", "(", "isset", "(", "$", "restrictions", "[", "$", "key", "]", ")", ")", "{", "return",...
Get a single restriction @param int $key @return SimplePie_Restriction|null
[ "Get", "a", "single", "restriction" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Enclosure.php#L706-L715
simplepie/simplepie
library/SimplePie/Enclosure.php
SimplePie_Enclosure.get_thumbnail
public function get_thumbnail($key = 0) { $thumbnails = $this->get_thumbnails(); if (isset($thumbnails[$key])) { return $thumbnails[$key]; } return null; }
php
public function get_thumbnail($key = 0) { $thumbnails = $this->get_thumbnails(); if (isset($thumbnails[$key])) { return $thumbnails[$key]; } return null; }
[ "public", "function", "get_thumbnail", "(", "$", "key", "=", "0", ")", "{", "$", "thumbnails", "=", "$", "this", "->", "get_thumbnails", "(", ")", ";", "if", "(", "isset", "(", "$", "thumbnails", "[", "$", "key", "]", ")", ")", "{", "return", "$", ...
Get a single thumbnail @param int $key @return string|null Thumbnail URL
[ "Get", "a", "single", "thumbnail" ]
train
https://github.com/simplepie/simplepie/blob/11ddaed291ccd1b2628eef433a6bef58a1e4f920/library/SimplePie/Enclosure.php#L769-L778