id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
225,900
puli/cli
src/Handler/UrlCommandHandler.php
UrlCommandHandler.handle
public function handle(Args $args, IO $io) { foreach ($args->getArgument('path') as $path) { if (!Glob::isDynamic($path)) { $this->printUrl($path, $io); continue; } foreach ($this->repo->find($path) as $resource) { $this->printUrl($resource->getPath(), $io); } } return 0; }
php
public function handle(Args $args, IO $io) { foreach ($args->getArgument('path') as $path) { if (!Glob::isDynamic($path)) { $this->printUrl($path, $io); continue; } foreach ($this->repo->find($path) as $resource) { $this->printUrl($resource->getPath(), $io); } } return 0; }
[ "public", "function", "handle", "(", "Args", "$", "args", ",", "IO", "$", "io", ")", "{", "foreach", "(", "$", "args", "->", "getArgument", "(", "'path'", ")", "as", "$", "path", ")", "{", "if", "(", "!", "Glob", "::", "isDynamic", "(", "$", "path", ")", ")", "{", "$", "this", "->", "printUrl", "(", "$", "path", ",", "$", "io", ")", ";", "continue", ";", "}", "foreach", "(", "$", "this", "->", "repo", "->", "find", "(", "$", "path", ")", "as", "$", "resource", ")", "{", "$", "this", "->", "printUrl", "(", "$", "resource", "->", "getPath", "(", ")", ",", "$", "io", ")", ";", "}", "}", "return", "0", ";", "}" ]
Handles the "url" command. @param Args $args The console arguments. @param IO $io The I/O. @return int The status code.
[ "Handles", "the", "url", "command", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/UrlCommandHandler.php#L65-L80
225,901
puli/cli
src/Handler/UrlCommandHandler.php
UrlCommandHandler.printUrl
private function printUrl($path, IO $io) { $path = Path::makeAbsolute($path, $this->currentPath); $io->writeLine($this->urlGenerator->generateUrl($path)); }
php
private function printUrl($path, IO $io) { $path = Path::makeAbsolute($path, $this->currentPath); $io->writeLine($this->urlGenerator->generateUrl($path)); }
[ "private", "function", "printUrl", "(", "$", "path", ",", "IO", "$", "io", ")", "{", "$", "path", "=", "Path", "::", "makeAbsolute", "(", "$", "path", ",", "$", "this", "->", "currentPath", ")", ";", "$", "io", "->", "writeLine", "(", "$", "this", "->", "urlGenerator", "->", "generateUrl", "(", "$", "path", ")", ")", ";", "}" ]
Prints the URL of a Puli path. @param string $path A Puli path. @param IO $io The I/O.
[ "Prints", "the", "URL", "of", "a", "Puli", "path", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/UrlCommandHandler.php#L88-L92
225,902
ccottet/ldap
Core/DiffTracker.php
DiffTracker.logAddition
public function logAddition($value) { if ($this->isOverridden()) { return; } if (isset($this->deleted[$value])) { unset($this->deleted[$value]); $this->replaced[$value] = $value; return; } if (! isset($this->replaced[$value])) { $this->added[$value] = $value; } }
php
public function logAddition($value) { if ($this->isOverridden()) { return; } if (isset($this->deleted[$value])) { unset($this->deleted[$value]); $this->replaced[$value] = $value; return; } if (! isset($this->replaced[$value])) { $this->added[$value] = $value; } }
[ "public", "function", "logAddition", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isOverridden", "(", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "deleted", "[", "$", "value", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "deleted", "[", "$", "value", "]", ")", ";", "$", "this", "->", "replaced", "[", "$", "value", "]", "=", "$", "value", ";", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "replaced", "[", "$", "value", "]", ")", ")", "{", "$", "this", "->", "added", "[", "$", "value", "]", "=", "$", "value", ";", "}", "}" ]
Logs an addition in the diff tracker @param string $value Added value @return void
[ "Logs", "an", "addition", "in", "the", "diff", "tracker" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/DiffTracker.php#L52-L65
225,903
ccottet/ldap
Core/DiffTracker.php
DiffTracker.logDeletion
public function logDeletion($value) { if ($this->isOverridden()) { return; } if (isset($this->added[$value])) { unset($this->added[$value]); $this->ignored[$value] = $value; return; } if (isset($this->replaced[$value])) { unset($this->replaced[$value]); } if (! isset($this->ignored[$value])) { $this->deleted[$value] = $value; } }
php
public function logDeletion($value) { if ($this->isOverridden()) { return; } if (isset($this->added[$value])) { unset($this->added[$value]); $this->ignored[$value] = $value; return; } if (isset($this->replaced[$value])) { unset($this->replaced[$value]); } if (! isset($this->ignored[$value])) { $this->deleted[$value] = $value; } }
[ "public", "function", "logDeletion", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isOverridden", "(", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "added", "[", "$", "value", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "added", "[", "$", "value", "]", ")", ";", "$", "this", "->", "ignored", "[", "$", "value", "]", "=", "$", "value", ";", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "replaced", "[", "$", "value", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "replaced", "[", "$", "value", "]", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "ignored", "[", "$", "value", "]", ")", ")", "{", "$", "this", "->", "deleted", "[", "$", "value", "]", "=", "$", "value", ";", "}", "}" ]
Logs a deletion in the diff tracker @param string $value Added value @return void
[ "Logs", "a", "deletion", "in", "the", "diff", "tracker" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/DiffTracker.php#L74-L90
225,904
ccottet/ldap
Core/DiffTracker.php
DiffTracker.logReplacement
public function logReplacement($value) { if ($this->isOverridden()) { return; } if (isset($this->added[$value])) { unset($this->added[$value]); } if (isset($this->deleted[$value])) { unset($this->deleted[$value]); } $this->replaced[$value] = $value; }
php
public function logReplacement($value) { if ($this->isOverridden()) { return; } if (isset($this->added[$value])) { unset($this->added[$value]); } if (isset($this->deleted[$value])) { unset($this->deleted[$value]); } $this->replaced[$value] = $value; }
[ "public", "function", "logReplacement", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isOverridden", "(", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "added", "[", "$", "value", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "added", "[", "$", "value", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "deleted", "[", "$", "value", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "deleted", "[", "$", "value", "]", ")", ";", "}", "$", "this", "->", "replaced", "[", "$", "value", "]", "=", "$", "value", ";", "}" ]
Logs a replacement in the diff tracker @param string $value Replaced value @return void
[ "Logs", "a", "replacement", "in", "the", "diff", "tracker" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/DiffTracker.php#L99-L111
225,905
ccottet/ldap
Core/SearchResult.php
SearchResult.setSearch
public function setSearch(SearchInterface $search) { if (null !== $this->search) { $this->search->free(); } $this->search = $search; $this->rewind(); }
php
public function setSearch(SearchInterface $search) { if (null !== $this->search) { $this->search->free(); } $this->search = $search; $this->rewind(); }
[ "public", "function", "setSearch", "(", "SearchInterface", "$", "search", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "search", ")", "{", "$", "this", "->", "search", "->", "free", "(", ")", ";", "}", "$", "this", "->", "search", "=", "$", "search", ";", "$", "this", "->", "rewind", "(", ")", ";", "}" ]
Setter for search @param SearchInterface $search Backend search result set @return void
[ "Setter", "for", "search" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/SearchResult.php#L36-L43
225,906
ccottet/ldap
Platform/Native/Connection.php
Connection.getOption
public function getOption($option) { $value = null; if (! (@ldap_get_option($this->connection, $option, $value))) { $code = @ldap_errno($this->connection); throw new OptionException( sprintf( 'Could not retrieve option %s value: Ldap Error Code=%s - %s', $code, ldap_err2str($code) ) ); } return $value; }
php
public function getOption($option) { $value = null; if (! (@ldap_get_option($this->connection, $option, $value))) { $code = @ldap_errno($this->connection); throw new OptionException( sprintf( 'Could not retrieve option %s value: Ldap Error Code=%s - %s', $code, ldap_err2str($code) ) ); } return $value; }
[ "public", "function", "getOption", "(", "$", "option", ")", "{", "$", "value", "=", "null", ";", "if", "(", "!", "(", "@", "ldap_get_option", "(", "$", "this", "->", "connection", ",", "$", "option", ",", "$", "value", ")", ")", ")", "{", "$", "code", "=", "@", "ldap_errno", "(", "$", "this", "->", "connection", ")", ";", "throw", "new", "OptionException", "(", "sprintf", "(", "'Could not retrieve option %s value: Ldap Error Code=%s - %s'", ",", "$", "code", ",", "ldap_err2str", "(", "$", "code", ")", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Gets current value set for an option @param int $option Ldap option name @return mixed value set for the option @throws OptionException if option cannot be retrieved
[ "Gets", "current", "value", "set", "for", "an", "option" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L80-L94
225,907
ccottet/ldap
Platform/Native/Connection.php
Connection.bind
public function bind($rdn = null, $password = null) { $isAnonymous = false; if ((null === $rdn) || (null === $password)) { if ((null !== $rdn) || (null !== $password)) { throw new BindException( 'For an anonymous binding, both rdn & passwords have to be null' ); } $isAnonymous = true; } if (! (@ldap_bind($this->connection, $rdn, $password))) { $code = @ldap_errno($this->connection); throw new BindException( sprintf( 'Could not bind %s user: Ldap Error Code=%s - %s', $isAnonymous?'anonymous':'privileged', $code, ldap_err2str($code) ) ); } }
php
public function bind($rdn = null, $password = null) { $isAnonymous = false; if ((null === $rdn) || (null === $password)) { if ((null !== $rdn) || (null !== $password)) { throw new BindException( 'For an anonymous binding, both rdn & passwords have to be null' ); } $isAnonymous = true; } if (! (@ldap_bind($this->connection, $rdn, $password))) { $code = @ldap_errno($this->connection); throw new BindException( sprintf( 'Could not bind %s user: Ldap Error Code=%s - %s', $isAnonymous?'anonymous':'privileged', $code, ldap_err2str($code) ) ); } }
[ "public", "function", "bind", "(", "$", "rdn", "=", "null", ",", "$", "password", "=", "null", ")", "{", "$", "isAnonymous", "=", "false", ";", "if", "(", "(", "null", "===", "$", "rdn", ")", "||", "(", "null", "===", "$", "password", ")", ")", "{", "if", "(", "(", "null", "!==", "$", "rdn", ")", "||", "(", "null", "!==", "$", "password", ")", ")", "{", "throw", "new", "BindException", "(", "'For an anonymous binding, both rdn & passwords have to be null'", ")", ";", "}", "$", "isAnonymous", "=", "true", ";", "}", "if", "(", "!", "(", "@", "ldap_bind", "(", "$", "this", "->", "connection", ",", "$", "rdn", ",", "$", "password", ")", ")", ")", "{", "$", "code", "=", "@", "ldap_errno", "(", "$", "this", "->", "connection", ")", ";", "throw", "new", "BindException", "(", "sprintf", "(", "'Could not bind %s user: Ldap Error Code=%s - %s'", ",", "$", "isAnonymous", "?", "'anonymous'", ":", "'privileged'", ",", "$", "code", ",", "ldap_err2str", "(", "$", "code", ")", ")", ")", ";", "}", "}" ]
Binds to the LDAP directory with specified RDN and password @param string $rdn Rdn to use for binding (Default: null) @param string $password Plain or hashed password for binding (Default: null) @return void @throws BindException if binding fails
[ "Binds", "to", "the", "LDAP", "directory", "with", "specified", "RDN", "and", "password" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L106-L129
225,908
ccottet/ldap
Platform/Native/Connection.php
Connection.addEntry
public function addEntry($dn, $data) { $data = $this->normalizeData($data); if (! (@ldap_add($this->connection, $dn, $data))) { $code = @ldap_errno($this->connection); throw new PersistenceException( sprintf( 'Could not add entry %s: Ldap Error Code=%s - %s', $dn, $code, ldap_err2str($code) ) ); } }
php
public function addEntry($dn, $data) { $data = $this->normalizeData($data); if (! (@ldap_add($this->connection, $dn, $data))) { $code = @ldap_errno($this->connection); throw new PersistenceException( sprintf( 'Could not add entry %s: Ldap Error Code=%s - %s', $dn, $code, ldap_err2str($code) ) ); } }
[ "public", "function", "addEntry", "(", "$", "dn", ",", "$", "data", ")", "{", "$", "data", "=", "$", "this", "->", "normalizeData", "(", "$", "data", ")", ";", "if", "(", "!", "(", "@", "ldap_add", "(", "$", "this", "->", "connection", ",", "$", "dn", ",", "$", "data", ")", ")", ")", "{", "$", "code", "=", "@", "ldap_errno", "(", "$", "this", "->", "connection", ")", ";", "throw", "new", "PersistenceException", "(", "sprintf", "(", "'Could not add entry %s: Ldap Error Code=%s - %s'", ",", "$", "dn", ",", "$", "code", ",", "ldap_err2str", "(", "$", "code", ")", ")", ")", ";", "}", "}" ]
Adds a Ldap entry @param string $dn Distinguished name to register entry for @param array $data Ldap attributes to save along with the entry @return void @throws PersistenceException if entry could not be added
[ "Adds", "a", "Ldap", "entry" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L164-L179
225,909
ccottet/ldap
Platform/Native/Connection.php
Connection.deleteEntry
public function deleteEntry($dn) { if (! (@ldap_delete($this->connection, $dn))) { $code = @ldap_errno($this->connection); throw new PersistenceException( sprintf( 'Could not delete entry %s: Ldap Error Code=%s - %s', $dn, $code, ldap_err2str($code) ) ); } }
php
public function deleteEntry($dn) { if (! (@ldap_delete($this->connection, $dn))) { $code = @ldap_errno($this->connection); throw new PersistenceException( sprintf( 'Could not delete entry %s: Ldap Error Code=%s - %s', $dn, $code, ldap_err2str($code) ) ); } }
[ "public", "function", "deleteEntry", "(", "$", "dn", ")", "{", "if", "(", "!", "(", "@", "ldap_delete", "(", "$", "this", "->", "connection", ",", "$", "dn", ")", ")", ")", "{", "$", "code", "=", "@", "ldap_errno", "(", "$", "this", "->", "connection", ")", ";", "throw", "new", "PersistenceException", "(", "sprintf", "(", "'Could not delete entry %s: Ldap Error Code=%s - %s'", ",", "$", "dn", ",", "$", "code", ",", "ldap_err2str", "(", "$", "code", ")", ")", ")", ";", "}", "}" ]
Deletes an existing Ldap entry @param string $dn Distinguished name of the entry to delete @return void @throws PersistenceException if entry could not be deleted
[ "Deletes", "an", "existing", "Ldap", "entry" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L190-L203
225,910
ccottet/ldap
Platform/Native/Connection.php
Connection.search
public function search($scope, $baseDn, $filter, $attributes = null) { switch ($scope) { case SearchInterface::SCOPE_BASE: $function = 'ldap_read'; break; case SearchInterface::SCOPE_ONE: $function = 'ldap_list'; break; case SearchInterface::SCOPE_ALL: $function = 'ldap_search'; break; default: throw new SearchException(sprintf('Scope %s not supported', $scope)); } $params = array($this->connection, $baseDn, $filter); if (is_array($attributes)) { $params[] = $attributes; } if (false === ($search = @call_user_func_array($function, $params))) { $code = @ldap_errno($this->connection); switch ($code) { case 32: throw new NoResultException('No result retrieved for the given search'); break; case 4: throw new SizeLimitException( 'Size limit reached while performing the expected search' ); break; case 87: throw new MalformedFilterException( sprintf('Search for filter %s fails for a malformed filter', $filter) ); break; default: throw new SearchException( sprintf( 'Search on %s with filter %s failed. Ldap Error Code:%s - %s', $baseDn, $filter, $code, ldap_err2str($code) ) ); } } return new Search($this->connection, $search); }
php
public function search($scope, $baseDn, $filter, $attributes = null) { switch ($scope) { case SearchInterface::SCOPE_BASE: $function = 'ldap_read'; break; case SearchInterface::SCOPE_ONE: $function = 'ldap_list'; break; case SearchInterface::SCOPE_ALL: $function = 'ldap_search'; break; default: throw new SearchException(sprintf('Scope %s not supported', $scope)); } $params = array($this->connection, $baseDn, $filter); if (is_array($attributes)) { $params[] = $attributes; } if (false === ($search = @call_user_func_array($function, $params))) { $code = @ldap_errno($this->connection); switch ($code) { case 32: throw new NoResultException('No result retrieved for the given search'); break; case 4: throw new SizeLimitException( 'Size limit reached while performing the expected search' ); break; case 87: throw new MalformedFilterException( sprintf('Search for filter %s fails for a malformed filter', $filter) ); break; default: throw new SearchException( sprintf( 'Search on %s with filter %s failed. Ldap Error Code:%s - %s', $baseDn, $filter, $code, ldap_err2str($code) ) ); } } return new Search($this->connection, $search); }
[ "public", "function", "search", "(", "$", "scope", ",", "$", "baseDn", ",", "$", "filter", ",", "$", "attributes", "=", "null", ")", "{", "switch", "(", "$", "scope", ")", "{", "case", "SearchInterface", "::", "SCOPE_BASE", ":", "$", "function", "=", "'ldap_read'", ";", "break", ";", "case", "SearchInterface", "::", "SCOPE_ONE", ":", "$", "function", "=", "'ldap_list'", ";", "break", ";", "case", "SearchInterface", "::", "SCOPE_ALL", ":", "$", "function", "=", "'ldap_search'", ";", "break", ";", "default", ":", "throw", "new", "SearchException", "(", "sprintf", "(", "'Scope %s not supported'", ",", "$", "scope", ")", ")", ";", "}", "$", "params", "=", "array", "(", "$", "this", "->", "connection", ",", "$", "baseDn", ",", "$", "filter", ")", ";", "if", "(", "is_array", "(", "$", "attributes", ")", ")", "{", "$", "params", "[", "]", "=", "$", "attributes", ";", "}", "if", "(", "false", "===", "(", "$", "search", "=", "@", "call_user_func_array", "(", "$", "function", ",", "$", "params", ")", ")", ")", "{", "$", "code", "=", "@", "ldap_errno", "(", "$", "this", "->", "connection", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "32", ":", "throw", "new", "NoResultException", "(", "'No result retrieved for the given search'", ")", ";", "break", ";", "case", "4", ":", "throw", "new", "SizeLimitException", "(", "'Size limit reached while performing the expected search'", ")", ";", "break", ";", "case", "87", ":", "throw", "new", "MalformedFilterException", "(", "sprintf", "(", "'Search for filter %s fails for a malformed filter'", ",", "$", "filter", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "SearchException", "(", "sprintf", "(", "'Search on %s with filter %s failed. Ldap Error Code:%s - %s'", ",", "$", "baseDn", ",", "$", "filter", ",", "$", "code", ",", "ldap_err2str", "(", "$", "code", ")", ")", ")", ";", "}", "}", "return", "new", "Search", "(", "$", "this", "->", "connection", ",", "$", "search", ")", ";", "}" ]
Searches for entries in the directory @param int $scope Search scope (ALL, ONE or BASE) @param string $baseDn Base distinguished name to look below @param string $filter Filter for the search @param array $attributes Names of attributes to retrieve (Default: All) @return SearchInterface Search result set @throws NoResultException if no result can be retrieved @throws SizeLimitException if size limit got exceeded @throws MalformedFilterException if filter is wrongly formatted @throws SearchException if search failed otherwise
[ "Searches", "for", "entries", "in", "the", "directory" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L340-L392
225,911
ccottet/ldap
Platform/Native/Connection.php
Connection.normalizeData
protected function normalizeData($data) { foreach ($data as $attribute => $info) { if (is_array($info)) { if (count($info) == 1) { $data[$attribute] = $info[0]; continue; } } } return $data; }
php
protected function normalizeData($data) { foreach ($data as $attribute => $info) { if (is_array($info)) { if (count($info) == 1) { $data[$attribute] = $info[0]; continue; } } } return $data; }
[ "protected", "function", "normalizeData", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "attribute", "=>", "$", "info", ")", "{", "if", "(", "is_array", "(", "$", "info", ")", ")", "{", "if", "(", "count", "(", "$", "info", ")", "==", "1", ")", "{", "$", "data", "[", "$", "attribute", "]", "=", "$", "info", "[", "0", "]", ";", "continue", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Normalizes data for Ldap storage @param array $data Ldap data to store @return array Normalized data
[ "Normalizes", "data", "for", "Ldap", "storage" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Connection.php#L401-L412
225,912
ccottet/ldap
Core/Manager.php
Manager.connect
public function connect() { $this->isBound = false; $this->connection = $this->driver->connect( $this->configuration['hostname'], $this->configuration['port'], $this->configuration['withSSL'], $this->configuration['withTLS'] ); foreach ($this->configuration['options'] as $key => $value) { $this->connection->setOption($key, $value); } }
php
public function connect() { $this->isBound = false; $this->connection = $this->driver->connect( $this->configuration['hostname'], $this->configuration['port'], $this->configuration['withSSL'], $this->configuration['withTLS'] ); foreach ($this->configuration['options'] as $key => $value) { $this->connection->setOption($key, $value); } }
[ "public", "function", "connect", "(", ")", "{", "$", "this", "->", "isBound", "=", "false", ";", "$", "this", "->", "connection", "=", "$", "this", "->", "driver", "->", "connect", "(", "$", "this", "->", "configuration", "[", "'hostname'", "]", ",", "$", "this", "->", "configuration", "[", "'port'", "]", ",", "$", "this", "->", "configuration", "[", "'withSSL'", "]", ",", "$", "this", "->", "configuration", "[", "'withTLS'", "]", ")", ";", "foreach", "(", "$", "this", "->", "configuration", "[", "'options'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "connection", "->", "setOption", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Connects to the Ldap store @return void @throws Toyota\Component\Ldap\Exception\ConnectionException if connection fails @throws Toyota\Component\Ldap\Exception\OptionException if connection configuration fails
[ "Connects", "to", "the", "Ldap", "store" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L74-L87
225,913
ccottet/ldap
Core/Manager.php
Manager.bind
public function bind($name = null, $password = null) { if (strlen(trim($name)) > 0) { $password = (null === $password)?'':$password; $this->connection->bind($name, $password); $this->isBound = true; return; } if ($this->configuration['bind_anonymous']) { $this->connection->bind(); $this->isBound = true; return; } $this->connection->bind( $this->configuration['bind_dn'], $this->configuration['bind_password'] ); $this->isBound = true; }
php
public function bind($name = null, $password = null) { if (strlen(trim($name)) > 0) { $password = (null === $password)?'':$password; $this->connection->bind($name, $password); $this->isBound = true; return; } if ($this->configuration['bind_anonymous']) { $this->connection->bind(); $this->isBound = true; return; } $this->connection->bind( $this->configuration['bind_dn'], $this->configuration['bind_password'] ); $this->isBound = true; }
[ "public", "function", "bind", "(", "$", "name", "=", "null", ",", "$", "password", "=", "null", ")", "{", "if", "(", "strlen", "(", "trim", "(", "$", "name", ")", ")", ">", "0", ")", "{", "$", "password", "=", "(", "null", "===", "$", "password", ")", "?", "''", ":", "$", "password", ";", "$", "this", "->", "connection", "->", "bind", "(", "$", "name", ",", "$", "password", ")", ";", "$", "this", "->", "isBound", "=", "true", ";", "return", ";", "}", "if", "(", "$", "this", "->", "configuration", "[", "'bind_anonymous'", "]", ")", "{", "$", "this", "->", "connection", "->", "bind", "(", ")", ";", "$", "this", "->", "isBound", "=", "true", ";", "return", ";", "}", "$", "this", "->", "connection", "->", "bind", "(", "$", "this", "->", "configuration", "[", "'bind_dn'", "]", ",", "$", "this", "->", "configuration", "[", "'bind_password'", "]", ")", ";", "$", "this", "->", "isBound", "=", "true", ";", "}" ]
Binds to the Ldap connection @param string $name Bind rdn (Default: null) @param string $password Bind password (Default: null) @return void @throws Toyota\Component\Ldap\Exception\BindException if binding fails
[ "Binds", "to", "the", "Ldap", "connection" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L99-L119
225,914
ccottet/ldap
Core/Manager.php
Manager.configure
protected function configure(array $params) { $required = array('hostname', 'base_dn'); $missing = array(); foreach ($required as $key) { if (! array_key_exists($key, $params)) { $missing[] = $key; } } if (count($missing) > 0) { throw new \InvalidArgumentException( 'Required parameters missing: ' . implode(', ', $missing) ); } $idx = strpos($params['hostname'], '://'); $enforceSSL = false; if (false !== $idx) { $prefix = strtolower(substr($params['hostname'], 0, $idx)); if ($prefix === 'ldaps') { $enforceSSL = true; } $params['hostname'] = substr($params['hostname'], $idx+3); } $params['withSSL'] = false; $params['withTLS'] = false; if (array_key_exists('security', $params)) { switch($params['security']) { case 'SSL': $params['withSSL'] = true; break; case 'TLS': $params['withTLS'] = true; break; default: throw new \InvalidArgumentException( sprintf( 'Security mode %s not supported - only SSL or TLS are supported', $params['security'] ) ); } } elseif ($enforceSSL) { $params['withSSL'] = true; } if (! array_key_exists('port', $params)) { if ($params['withSSL']) { $params['port'] = 636; } else { $params['port'] = 389; } } if (! array_key_exists('options', $params)) { $params['options'] = array(); } $params['bind_anonymous'] = false; if ((! array_key_exists('bind_dn', $params)) || (strlen(trim($params['bind_dn'])) == 0)) { $params['bind_anonymous'] = true; $params['bind_dn'] = ''; $params['bind_password'] = ''; } if (! array_key_exists('bind_password', $params)) { $params['bind_password'] = ''; } $this->configuration = $params; }
php
protected function configure(array $params) { $required = array('hostname', 'base_dn'); $missing = array(); foreach ($required as $key) { if (! array_key_exists($key, $params)) { $missing[] = $key; } } if (count($missing) > 0) { throw new \InvalidArgumentException( 'Required parameters missing: ' . implode(', ', $missing) ); } $idx = strpos($params['hostname'], '://'); $enforceSSL = false; if (false !== $idx) { $prefix = strtolower(substr($params['hostname'], 0, $idx)); if ($prefix === 'ldaps') { $enforceSSL = true; } $params['hostname'] = substr($params['hostname'], $idx+3); } $params['withSSL'] = false; $params['withTLS'] = false; if (array_key_exists('security', $params)) { switch($params['security']) { case 'SSL': $params['withSSL'] = true; break; case 'TLS': $params['withTLS'] = true; break; default: throw new \InvalidArgumentException( sprintf( 'Security mode %s not supported - only SSL or TLS are supported', $params['security'] ) ); } } elseif ($enforceSSL) { $params['withSSL'] = true; } if (! array_key_exists('port', $params)) { if ($params['withSSL']) { $params['port'] = 636; } else { $params['port'] = 389; } } if (! array_key_exists('options', $params)) { $params['options'] = array(); } $params['bind_anonymous'] = false; if ((! array_key_exists('bind_dn', $params)) || (strlen(trim($params['bind_dn'])) == 0)) { $params['bind_anonymous'] = true; $params['bind_dn'] = ''; $params['bind_password'] = ''; } if (! array_key_exists('bind_password', $params)) { $params['bind_password'] = ''; } $this->configuration = $params; }
[ "protected", "function", "configure", "(", "array", "$", "params", ")", "{", "$", "required", "=", "array", "(", "'hostname'", ",", "'base_dn'", ")", ";", "$", "missing", "=", "array", "(", ")", ";", "foreach", "(", "$", "required", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "params", ")", ")", "{", "$", "missing", "[", "]", "=", "$", "key", ";", "}", "}", "if", "(", "count", "(", "$", "missing", ")", ">", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Required parameters missing: '", ".", "implode", "(", "', '", ",", "$", "missing", ")", ")", ";", "}", "$", "idx", "=", "strpos", "(", "$", "params", "[", "'hostname'", "]", ",", "'://'", ")", ";", "$", "enforceSSL", "=", "false", ";", "if", "(", "false", "!==", "$", "idx", ")", "{", "$", "prefix", "=", "strtolower", "(", "substr", "(", "$", "params", "[", "'hostname'", "]", ",", "0", ",", "$", "idx", ")", ")", ";", "if", "(", "$", "prefix", "===", "'ldaps'", ")", "{", "$", "enforceSSL", "=", "true", ";", "}", "$", "params", "[", "'hostname'", "]", "=", "substr", "(", "$", "params", "[", "'hostname'", "]", ",", "$", "idx", "+", "3", ")", ";", "}", "$", "params", "[", "'withSSL'", "]", "=", "false", ";", "$", "params", "[", "'withTLS'", "]", "=", "false", ";", "if", "(", "array_key_exists", "(", "'security'", ",", "$", "params", ")", ")", "{", "switch", "(", "$", "params", "[", "'security'", "]", ")", "{", "case", "'SSL'", ":", "$", "params", "[", "'withSSL'", "]", "=", "true", ";", "break", ";", "case", "'TLS'", ":", "$", "params", "[", "'withTLS'", "]", "=", "true", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Security mode %s not supported - only SSL or TLS are supported'", ",", "$", "params", "[", "'security'", "]", ")", ")", ";", "}", "}", "elseif", "(", "$", "enforceSSL", ")", "{", "$", "params", "[", "'withSSL'", "]", "=", "true", ";", "}", "if", "(", "!", "array_key_exists", "(", "'port'", ",", "$", "params", ")", ")", "{", "if", "(", "$", "params", "[", "'withSSL'", "]", ")", "{", "$", "params", "[", "'port'", "]", "=", "636", ";", "}", "else", "{", "$", "params", "[", "'port'", "]", "=", "389", ";", "}", "}", "if", "(", "!", "array_key_exists", "(", "'options'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'options'", "]", "=", "array", "(", ")", ";", "}", "$", "params", "[", "'bind_anonymous'", "]", "=", "false", ";", "if", "(", "(", "!", "array_key_exists", "(", "'bind_dn'", ",", "$", "params", ")", ")", "||", "(", "strlen", "(", "trim", "(", "$", "params", "[", "'bind_dn'", "]", ")", ")", "==", "0", ")", ")", "{", "$", "params", "[", "'bind_anonymous'", "]", "=", "true", ";", "$", "params", "[", "'bind_dn'", "]", "=", "''", ";", "$", "params", "[", "'bind_password'", "]", "=", "''", ";", "}", "if", "(", "!", "array_key_exists", "(", "'bind_password'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'bind_password'", "]", "=", "''", ";", "}", "$", "this", "->", "configuration", "=", "$", "params", ";", "}" ]
Complete and validates given parameters with default settings @param array $params Parameters to be cleaned @return array Cleaned parameters @throws \InvalidArgumentException
[ "Complete", "and", "validates", "given", "parameters", "with", "default", "settings" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L130-L200
225,915
ccottet/ldap
Core/Manager.php
Manager.getNode
public function getNode($dn, $attributes = null, $filter = null) { $this->validateBinding(); $attributes = (is_array($attributes))?$attributes:null; $filter = (null === $filter)?'(objectclass=*)':$filter; try { $search = $this->connection->search( SearchInterface::SCOPE_BASE, $dn, $filter, $attributes ); } catch (NoResultException $e) { throw new NodeNotFoundException(sprintf('Node %s not found', $dn)); } if (null === ($entry = $search->next())) { throw new NodeNotFoundException(sprintf('Node %s not found', $dn)); } $node = new Node(); $node->hydrateFromEntry($entry); return $node; }
php
public function getNode($dn, $attributes = null, $filter = null) { $this->validateBinding(); $attributes = (is_array($attributes))?$attributes:null; $filter = (null === $filter)?'(objectclass=*)':$filter; try { $search = $this->connection->search( SearchInterface::SCOPE_BASE, $dn, $filter, $attributes ); } catch (NoResultException $e) { throw new NodeNotFoundException(sprintf('Node %s not found', $dn)); } if (null === ($entry = $search->next())) { throw new NodeNotFoundException(sprintf('Node %s not found', $dn)); } $node = new Node(); $node->hydrateFromEntry($entry); return $node; }
[ "public", "function", "getNode", "(", "$", "dn", ",", "$", "attributes", "=", "null", ",", "$", "filter", "=", "null", ")", "{", "$", "this", "->", "validateBinding", "(", ")", ";", "$", "attributes", "=", "(", "is_array", "(", "$", "attributes", ")", ")", "?", "$", "attributes", ":", "null", ";", "$", "filter", "=", "(", "null", "===", "$", "filter", ")", "?", "'(objectclass=*)'", ":", "$", "filter", ";", "try", "{", "$", "search", "=", "$", "this", "->", "connection", "->", "search", "(", "SearchInterface", "::", "SCOPE_BASE", ",", "$", "dn", ",", "$", "filter", ",", "$", "attributes", ")", ";", "}", "catch", "(", "NoResultException", "$", "e", ")", "{", "throw", "new", "NodeNotFoundException", "(", "sprintf", "(", "'Node %s not found'", ",", "$", "dn", ")", ")", ";", "}", "if", "(", "null", "===", "(", "$", "entry", "=", "$", "search", "->", "next", "(", ")", ")", ")", "{", "throw", "new", "NodeNotFoundException", "(", "sprintf", "(", "'Node %s not found'", ",", "$", "dn", ")", ")", ";", "}", "$", "node", "=", "new", "Node", "(", ")", ";", "$", "node", "->", "hydrateFromEntry", "(", "$", "entry", ")", ";", "return", "$", "node", ";", "}" ]
Retrieve a node knowing its dn @param string $dn Distinguished name of the node to look for @param array $attributes Filter attributes to be retrieved (Optional) @param string $filter Ldap filter according to RFC4515 (Optional) @return Node @throws NodeNotFoundException if node cannot be retrieved
[ "Retrieve", "a", "node", "knowing", "its", "dn" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L213-L239
225,916
ccottet/ldap
Core/Manager.php
Manager.search
public function search( $baseDn = null, $filter = null, $inDepth = true, $attributes = null ) { $this->validateBinding(); $result = new SearchResult(); $baseDn = (null === $baseDn)?$this->configuration['base_dn']:$baseDn; $filter = (null === $filter)?'(objectclass=*)':$filter; $attributes = (is_array($attributes))?$attributes:null; $scope = $inDepth?SearchInterface::SCOPE_ALL:SearchInterface::SCOPE_ONE; try { $search = $this->connection->search($scope, $baseDn, $filter, $attributes); } catch (NoResultException $e) { return $result; } $result->setSearch($search); return $result; }
php
public function search( $baseDn = null, $filter = null, $inDepth = true, $attributes = null ) { $this->validateBinding(); $result = new SearchResult(); $baseDn = (null === $baseDn)?$this->configuration['base_dn']:$baseDn; $filter = (null === $filter)?'(objectclass=*)':$filter; $attributes = (is_array($attributes))?$attributes:null; $scope = $inDepth?SearchInterface::SCOPE_ALL:SearchInterface::SCOPE_ONE; try { $search = $this->connection->search($scope, $baseDn, $filter, $attributes); } catch (NoResultException $e) { return $result; } $result->setSearch($search); return $result; }
[ "public", "function", "search", "(", "$", "baseDn", "=", "null", ",", "$", "filter", "=", "null", ",", "$", "inDepth", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "validateBinding", "(", ")", ";", "$", "result", "=", "new", "SearchResult", "(", ")", ";", "$", "baseDn", "=", "(", "null", "===", "$", "baseDn", ")", "?", "$", "this", "->", "configuration", "[", "'base_dn'", "]", ":", "$", "baseDn", ";", "$", "filter", "=", "(", "null", "===", "$", "filter", ")", "?", "'(objectclass=*)'", ":", "$", "filter", ";", "$", "attributes", "=", "(", "is_array", "(", "$", "attributes", ")", ")", "?", "$", "attributes", ":", "null", ";", "$", "scope", "=", "$", "inDepth", "?", "SearchInterface", "::", "SCOPE_ALL", ":", "SearchInterface", "::", "SCOPE_ONE", ";", "try", "{", "$", "search", "=", "$", "this", "->", "connection", "->", "search", "(", "$", "scope", ",", "$", "baseDn", ",", "$", "filter", ",", "$", "attributes", ")", ";", "}", "catch", "(", "NoResultException", "$", "e", ")", "{", "return", "$", "result", ";", "}", "$", "result", "->", "setSearch", "(", "$", "search", ")", ";", "return", "$", "result", ";", "}" ]
Execites a search on the ldap @param string $baseDn Base distinguished name to search in (Default = configured dn) @param string $filter Ldap filter according to RFC4515 (Default = null) @param boolean $inDepth Whether to search through all subtree depth (Default = true) @param array $attributes Filter attributes to be retrieved (Default: null) @return SearchResult
[ "Execites", "a", "search", "on", "the", "ldap" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L251-L274
225,917
ccottet/ldap
Core/Manager.php
Manager.save
public function save(Node $node) { $this->validateBinding(); if (strlen(trim($node->getDn())) == 0) { throw new PersistenceException('Cannot save: dn missing for the entry'); } if (! $node->isHydrated()) { try { $origin = $this->getNode($node->getDn()); $node->rebaseDiff($origin); } catch(NodeNotFoundException $e) { $this->connection->addEntry($node->getDn(), $node->getRawAttributes()); $node->snapshot(); return true; } } if (count($data = $node->getDiffAdditions()) > 0) { $this->connection->addAttributeValues($node->getDn(), $data); } if (count($data = $node->getDiffDeletions()) > 0) { $this->connection->deleteAttributeValues($node->getDn(), $data); } if (count($data = $node->getDiffReplacements()) > 0) { $this->connection->replaceAttributeValues($node->getDn(), $data); } $node->snapshot(); return false; }
php
public function save(Node $node) { $this->validateBinding(); if (strlen(trim($node->getDn())) == 0) { throw new PersistenceException('Cannot save: dn missing for the entry'); } if (! $node->isHydrated()) { try { $origin = $this->getNode($node->getDn()); $node->rebaseDiff($origin); } catch(NodeNotFoundException $e) { $this->connection->addEntry($node->getDn(), $node->getRawAttributes()); $node->snapshot(); return true; } } if (count($data = $node->getDiffAdditions()) > 0) { $this->connection->addAttributeValues($node->getDn(), $data); } if (count($data = $node->getDiffDeletions()) > 0) { $this->connection->deleteAttributeValues($node->getDn(), $data); } if (count($data = $node->getDiffReplacements()) > 0) { $this->connection->replaceAttributeValues($node->getDn(), $data); } $node->snapshot(); return false; }
[ "public", "function", "save", "(", "Node", "$", "node", ")", "{", "$", "this", "->", "validateBinding", "(", ")", ";", "if", "(", "strlen", "(", "trim", "(", "$", "node", "->", "getDn", "(", ")", ")", ")", "==", "0", ")", "{", "throw", "new", "PersistenceException", "(", "'Cannot save: dn missing for the entry'", ")", ";", "}", "if", "(", "!", "$", "node", "->", "isHydrated", "(", ")", ")", "{", "try", "{", "$", "origin", "=", "$", "this", "->", "getNode", "(", "$", "node", "->", "getDn", "(", ")", ")", ";", "$", "node", "->", "rebaseDiff", "(", "$", "origin", ")", ";", "}", "catch", "(", "NodeNotFoundException", "$", "e", ")", "{", "$", "this", "->", "connection", "->", "addEntry", "(", "$", "node", "->", "getDn", "(", ")", ",", "$", "node", "->", "getRawAttributes", "(", ")", ")", ";", "$", "node", "->", "snapshot", "(", ")", ";", "return", "true", ";", "}", "}", "if", "(", "count", "(", "$", "data", "=", "$", "node", "->", "getDiffAdditions", "(", ")", ")", ">", "0", ")", "{", "$", "this", "->", "connection", "->", "addAttributeValues", "(", "$", "node", "->", "getDn", "(", ")", ",", "$", "data", ")", ";", "}", "if", "(", "count", "(", "$", "data", "=", "$", "node", "->", "getDiffDeletions", "(", ")", ")", ">", "0", ")", "{", "$", "this", "->", "connection", "->", "deleteAttributeValues", "(", "$", "node", "->", "getDn", "(", ")", ",", "$", "data", ")", ";", "}", "if", "(", "count", "(", "$", "data", "=", "$", "node", "->", "getDiffReplacements", "(", ")", ")", ">", "0", ")", "{", "$", "this", "->", "connection", "->", "replaceAttributeValues", "(", "$", "node", "->", "getDn", "(", ")", ",", "$", "data", ")", ";", "}", "$", "node", "->", "snapshot", "(", ")", ";", "return", "false", ";", "}" ]
Saves a node to the Ldap store @param Node $node Node to be saved @return boolean True if node got created, false if it was updated @throws PersistenceException If saving operation fails writing to the Ldap
[ "Saves", "a", "node", "to", "the", "Ldap", "store" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L299-L329
225,918
ccottet/ldap
Core/Manager.php
Manager.getChildrenNodes
public function getChildrenNodes(Node $node) { $result = $this->search($node->getDn(), null, false); $nodes = array(); foreach ($result as $node) { $nodes[] = $node; } return $nodes; }
php
public function getChildrenNodes(Node $node) { $result = $this->search($node->getDn(), null, false); $nodes = array(); foreach ($result as $node) { $nodes[] = $node; } return $nodes; }
[ "public", "function", "getChildrenNodes", "(", "Node", "$", "node", ")", "{", "$", "result", "=", "$", "this", "->", "search", "(", "$", "node", "->", "getDn", "(", ")", ",", "null", ",", "false", ")", ";", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "node", ")", "{", "$", "nodes", "[", "]", "=", "$", "node", ";", "}", "return", "$", "nodes", ";", "}" ]
Retrieves immediate children for the given node @param Node $node Node to retrieve children for @return array(Node) a set of Nodes
[ "Retrieves", "immediate", "children", "for", "the", "given", "node" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L338-L348
225,919
ccottet/ldap
Core/Manager.php
Manager.delete
public function delete(Node $node, $isRecursive = false) { if (! $node->isHydrated()) { $node = $this->getNode($node->getDn()); } $children = $this->getChildrenNodes($node); if (count($children) > 0) { if (! $isRecursive) { throw new DeleteException( sprintf('%s cannot be deleted - it has some children left', $node->getDn()) ); } foreach ($children as $child) { $this->delete($child, true); } } $this->connection->deleteEntry($node->getDn()); }
php
public function delete(Node $node, $isRecursive = false) { if (! $node->isHydrated()) { $node = $this->getNode($node->getDn()); } $children = $this->getChildrenNodes($node); if (count($children) > 0) { if (! $isRecursive) { throw new DeleteException( sprintf('%s cannot be deleted - it has some children left', $node->getDn()) ); } foreach ($children as $child) { $this->delete($child, true); } } $this->connection->deleteEntry($node->getDn()); }
[ "public", "function", "delete", "(", "Node", "$", "node", ",", "$", "isRecursive", "=", "false", ")", "{", "if", "(", "!", "$", "node", "->", "isHydrated", "(", ")", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "node", "->", "getDn", "(", ")", ")", ";", "}", "$", "children", "=", "$", "this", "->", "getChildrenNodes", "(", "$", "node", ")", ";", "if", "(", "count", "(", "$", "children", ")", ">", "0", ")", "{", "if", "(", "!", "$", "isRecursive", ")", "{", "throw", "new", "DeleteException", "(", "sprintf", "(", "'%s cannot be deleted - it has some children left'", ",", "$", "node", "->", "getDn", "(", ")", ")", ")", ";", "}", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "delete", "(", "$", "child", ",", "true", ")", ";", "}", "}", "$", "this", "->", "connection", "->", "deleteEntry", "(", "$", "node", "->", "getDn", "(", ")", ")", ";", "}" ]
Deletes a node from the Ldap store @param Node $node Node to delete @param boolean $isRecursive Whether to delete node with its children (Default: false) @return void @throws DeletionException If node to delete has some children and recursion disabled
[ "Deletes", "a", "node", "from", "the", "Ldap", "store" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Manager.php#L360-L378
225,920
sokil/php-upload
src/Handler.php
Handler.getTransport
private function getTransport() { if ($this->transport) { return $this->transport; } $transportClassName = '\\Sokil\\Upload\\Transport\\' . $this->options['transport'] . 'Transport'; $this->transport = new $transportClassName( $this->options['fieldName'], $this->options['supportedFormats'], $this->options['validateChecksum'] ); return $this->transport; }
php
private function getTransport() { if ($this->transport) { return $this->transport; } $transportClassName = '\\Sokil\\Upload\\Transport\\' . $this->options['transport'] . 'Transport'; $this->transport = new $transportClassName( $this->options['fieldName'], $this->options['supportedFormats'], $this->options['validateChecksum'] ); return $this->transport; }
[ "private", "function", "getTransport", "(", ")", "{", "if", "(", "$", "this", "->", "transport", ")", "{", "return", "$", "this", "->", "transport", ";", "}", "$", "transportClassName", "=", "'\\\\Sokil\\\\Upload\\\\Transport\\\\'", ".", "$", "this", "->", "options", "[", "'transport'", "]", ".", "'Transport'", ";", "$", "this", "->", "transport", "=", "new", "$", "transportClassName", "(", "$", "this", "->", "options", "[", "'fieldName'", "]", ",", "$", "this", "->", "options", "[", "'supportedFormats'", "]", ",", "$", "this", "->", "options", "[", "'validateChecksum'", "]", ")", ";", "return", "$", "this", "->", "transport", ";", "}" ]
Get uploaded file instance @return \Sokil\Upload\Transport\AbstractTransport @throws \Exception
[ "Get", "uploaded", "file", "instance" ]
3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a
https://github.com/sokil/php-upload/blob/3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a/src/Handler.php#L86-L101
225,921
sokil/php-upload
src/Handler.php
Handler.moveLocal
public function moveLocal($targetDir = null, $targetFilename = null) { // source file $sourceFile = $this->getTransport()->getFile(); // target base name $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename); // target path if (!$targetDir) { $targetDir = $this->getDefaultLocalUploadDirectory(); } $targetPath = $targetDir . '/' . $targetBasename; // if target dir not exists - create it if (!file_exists($targetDir)) { $oldUmast = umask(0); mkdir($targetDir, 0777, true); umask($oldUmast); } // move file to target dir return $this ->getTransport() ->moveLocal($targetPath); }
php
public function moveLocal($targetDir = null, $targetFilename = null) { // source file $sourceFile = $this->getTransport()->getFile(); // target base name $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename); // target path if (!$targetDir) { $targetDir = $this->getDefaultLocalUploadDirectory(); } $targetPath = $targetDir . '/' . $targetBasename; // if target dir not exists - create it if (!file_exists($targetDir)) { $oldUmast = umask(0); mkdir($targetDir, 0777, true); umask($oldUmast); } // move file to target dir return $this ->getTransport() ->moveLocal($targetPath); }
[ "public", "function", "moveLocal", "(", "$", "targetDir", "=", "null", ",", "$", "targetFilename", "=", "null", ")", "{", "// source file", "$", "sourceFile", "=", "$", "this", "->", "getTransport", "(", ")", "->", "getFile", "(", ")", ";", "// target base name", "$", "targetBasename", "=", "$", "this", "->", "buildTargetBasename", "(", "$", "sourceFile", ",", "$", "targetFilename", ")", ";", "// target path", "if", "(", "!", "$", "targetDir", ")", "{", "$", "targetDir", "=", "$", "this", "->", "getDefaultLocalUploadDirectory", "(", ")", ";", "}", "$", "targetPath", "=", "$", "targetDir", ".", "'/'", ".", "$", "targetBasename", ";", "// if target dir not exists - create it", "if", "(", "!", "file_exists", "(", "$", "targetDir", ")", ")", "{", "$", "oldUmast", "=", "umask", "(", "0", ")", ";", "mkdir", "(", "$", "targetDir", ",", "0777", ",", "true", ")", ";", "umask", "(", "$", "oldUmast", ")", ";", "}", "// move file to target dir", "return", "$", "this", "->", "getTransport", "(", ")", "->", "moveLocal", "(", "$", "targetPath", ")", ";", "}" ]
Move file to local filesystem @param string $targetDir File system to store file. If omitted - store in php's upload_tmp_dir @param string $targetFilename New file name. If omitted - use original filename @return \Sokil\Upload\File uploaded file
[ "Move", "file", "to", "local", "filesystem" ]
3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a
https://github.com/sokil/php-upload/blob/3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a/src/Handler.php#L150-L175
225,922
sokil/php-upload
src/Handler.php
Handler.move
public function move(Filesystem $filesystem = null, $targetFilename = null, $overwrite = true) { // source file $sourceFile = $this->getTransport()->getFile(); // target base name $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename); // move file to target storage $content = stream_get_contents($sourceFile->getStream()); // write file $filesystem->write( $targetBasename, $content, $overwrite ); return $filesystem->get($targetBasename); }
php
public function move(Filesystem $filesystem = null, $targetFilename = null, $overwrite = true) { // source file $sourceFile = $this->getTransport()->getFile(); // target base name $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename); // move file to target storage $content = stream_get_contents($sourceFile->getStream()); // write file $filesystem->write( $targetBasename, $content, $overwrite ); return $filesystem->get($targetBasename); }
[ "public", "function", "move", "(", "Filesystem", "$", "filesystem", "=", "null", ",", "$", "targetFilename", "=", "null", ",", "$", "overwrite", "=", "true", ")", "{", "// source file", "$", "sourceFile", "=", "$", "this", "->", "getTransport", "(", ")", "->", "getFile", "(", ")", ";", "// target base name", "$", "targetBasename", "=", "$", "this", "->", "buildTargetBasename", "(", "$", "sourceFile", ",", "$", "targetFilename", ")", ";", "// move file to target storage", "$", "content", "=", "stream_get_contents", "(", "$", "sourceFile", "->", "getStream", "(", ")", ")", ";", "// write file", "$", "filesystem", "->", "write", "(", "$", "targetBasename", ",", "$", "content", ",", "$", "overwrite", ")", ";", "return", "$", "filesystem", "->", "get", "(", "$", "targetBasename", ")", ";", "}" ]
Move file to external filesystem @param Filesystem $filesystem File system to store file. If omitted - store in php's upload_tmp_dir @param string $targetFilename New file name. If omitted - use original filename @return \Gaufrette\File
[ "Move", "file", "to", "external", "filesystem" ]
3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a
https://github.com/sokil/php-upload/blob/3e0d7d91866781e9a19ab4d2ec3c443f0ca1666a/src/Handler.php#L184-L203
225,923
puli/cli
src/Handler/MapCommandHandler.php
MapCommandHandler.handleAdd
public function handleAdd(Args $args) { $flags = $args->isOptionSet('force') ? RepositoryManager::OVERRIDE | RepositoryManager::IGNORE_FILE_NOT_FOUND : 0; $repositoryPath = Path::makeAbsolute($args->getArgument('path'), $this->currentPath); $pathReferences = $args->getArgument('file'); $this->repoManager->addRootPathMapping(new PathMapping($repositoryPath, $pathReferences), $flags); return 0; }
php
public function handleAdd(Args $args) { $flags = $args->isOptionSet('force') ? RepositoryManager::OVERRIDE | RepositoryManager::IGNORE_FILE_NOT_FOUND : 0; $repositoryPath = Path::makeAbsolute($args->getArgument('path'), $this->currentPath); $pathReferences = $args->getArgument('file'); $this->repoManager->addRootPathMapping(new PathMapping($repositoryPath, $pathReferences), $flags); return 0; }
[ "public", "function", "handleAdd", "(", "Args", "$", "args", ")", "{", "$", "flags", "=", "$", "args", "->", "isOptionSet", "(", "'force'", ")", "?", "RepositoryManager", "::", "OVERRIDE", "|", "RepositoryManager", "::", "IGNORE_FILE_NOT_FOUND", ":", "0", ";", "$", "repositoryPath", "=", "Path", "::", "makeAbsolute", "(", "$", "args", "->", "getArgument", "(", "'path'", ")", ",", "$", "this", "->", "currentPath", ")", ";", "$", "pathReferences", "=", "$", "args", "->", "getArgument", "(", "'file'", ")", ";", "$", "this", "->", "repoManager", "->", "addRootPathMapping", "(", "new", "PathMapping", "(", "$", "repositoryPath", ",", "$", "pathReferences", ")", ",", "$", "flags", ")", ";", "return", "0", ";", "}" ]
Handles the "puli map" command. @param Args $args The console arguments @return int The status code
[ "Handles", "the", "puli", "map", "command", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/MapCommandHandler.php#L157-L168
225,924
puli/cli
src/Handler/MapCommandHandler.php
MapCommandHandler.printMappingTable
private function printMappingTable(IO $io, array $mappings, $indentation = 0, $enabled = true) { $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Puli Path', 'Real Path(s)')); $pathTag = $enabled ? 'c1' : 'bad'; foreach ($mappings as $mapping) { if ($enabled) { $pathReferences = array(); foreach ($mapping->getPathReferences() as $pathReference) { // Underline referenced packages $pathReference = preg_replace('~^@([^:]+):~', '@<u>$1</u>:', $pathReference); // Highlight path parts $pathReference = preg_replace('~^(@([^:]+):)?(.*)$~', '$1<c2>$3</c2>', $pathReference); $pathReferences[] = $pathReference; } $pathReferences = implode(', ', $pathReferences); } else { $pathReferences = '<bad>'.implode(', ', $mapping->getPathReferences()).'</bad>'; } $table->addRow(array( sprintf('<%s>%s</%s>', $pathTag, $mapping->getRepositoryPath(), $pathTag), $pathReferences, )); } $table->render($io, $indentation); }
php
private function printMappingTable(IO $io, array $mappings, $indentation = 0, $enabled = true) { $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Puli Path', 'Real Path(s)')); $pathTag = $enabled ? 'c1' : 'bad'; foreach ($mappings as $mapping) { if ($enabled) { $pathReferences = array(); foreach ($mapping->getPathReferences() as $pathReference) { // Underline referenced packages $pathReference = preg_replace('~^@([^:]+):~', '@<u>$1</u>:', $pathReference); // Highlight path parts $pathReference = preg_replace('~^(@([^:]+):)?(.*)$~', '$1<c2>$3</c2>', $pathReference); $pathReferences[] = $pathReference; } $pathReferences = implode(', ', $pathReferences); } else { $pathReferences = '<bad>'.implode(', ', $mapping->getPathReferences()).'</bad>'; } $table->addRow(array( sprintf('<%s>%s</%s>', $pathTag, $mapping->getRepositoryPath(), $pathTag), $pathReferences, )); } $table->render($io, $indentation); }
[ "private", "function", "printMappingTable", "(", "IO", "$", "io", ",", "array", "$", "mappings", ",", "$", "indentation", "=", "0", ",", "$", "enabled", "=", "true", ")", "{", "$", "table", "=", "new", "Table", "(", "PuliTableStyle", "::", "borderless", "(", ")", ")", ";", "$", "table", "->", "setHeaderRow", "(", "array", "(", "'Puli Path'", ",", "'Real Path(s)'", ")", ")", ";", "$", "pathTag", "=", "$", "enabled", "?", "'c1'", ":", "'bad'", ";", "foreach", "(", "$", "mappings", "as", "$", "mapping", ")", "{", "if", "(", "$", "enabled", ")", "{", "$", "pathReferences", "=", "array", "(", ")", ";", "foreach", "(", "$", "mapping", "->", "getPathReferences", "(", ")", "as", "$", "pathReference", ")", "{", "// Underline referenced packages", "$", "pathReference", "=", "preg_replace", "(", "'~^@([^:]+):~'", ",", "'@<u>$1</u>:'", ",", "$", "pathReference", ")", ";", "// Highlight path parts", "$", "pathReference", "=", "preg_replace", "(", "'~^(@([^:]+):)?(.*)$~'", ",", "'$1<c2>$3</c2>'", ",", "$", "pathReference", ")", ";", "$", "pathReferences", "[", "]", "=", "$", "pathReference", ";", "}", "$", "pathReferences", "=", "implode", "(", "', '", ",", "$", "pathReferences", ")", ";", "}", "else", "{", "$", "pathReferences", "=", "'<bad>'", ".", "implode", "(", "', '", ",", "$", "mapping", "->", "getPathReferences", "(", ")", ")", ".", "'</bad>'", ";", "}", "$", "table", "->", "addRow", "(", "array", "(", "sprintf", "(", "'<%s>%s</%s>'", ",", "$", "pathTag", ",", "$", "mapping", "->", "getRepositoryPath", "(", ")", ",", "$", "pathTag", ")", ",", "$", "pathReferences", ",", ")", ")", ";", "}", "$", "table", "->", "render", "(", "$", "io", ",", "$", "indentation", ")", ";", "}" ]
Prints a list of path mappings. @param IO $io The I/O @param PathMapping[] $mappings The path mappings @param int $indentation The number of spaces to indent the output @param bool $enabled Whether the path mappings are enabled. If not, the output is printed in red
[ "Prints", "a", "list", "of", "path", "mappings", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/MapCommandHandler.php#L245-L279
225,925
puli/cli
src/Handler/MapCommandHandler.php
MapCommandHandler.printConflictTable
private function printConflictTable(IO $io, array $mappings, $indentation = 0) { /** @var PathConflict[] $conflicts */ $conflicts = array(); $shortPrefix = str_repeat(' ', $indentation); $prefix = str_repeat(' ', $indentation + 4); $printNewline = false; foreach ($mappings as $mapping) { foreach ($mapping->getConflicts() as $conflict) { $conflicts[spl_object_hash($conflict)] = $conflict; } } foreach ($conflicts as $conflict) { if ($printNewline) { $io->writeLine(''); } $io->writeLine(sprintf('%sConflicting path: %s', $shortPrefix, $conflict->getRepositoryPath())); $io->writeLine(''); $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Module', 'Puli Path', 'Real Path(s)')); foreach ($conflict->getMappings() as $mapping) { $table->addRow(array( '<bad>'.$mapping->getContainingModule()->getName().'</bad>', '<bad>'.$mapping->getRepositoryPath().'</bad>', '<bad>'.implode(', ', $mapping->getPathReferences()).'</bad>', )); } $io->writeLine(sprintf('%sMapped by the following mappings:', $prefix)); $io->writeLine(''); $table->render($io, $indentation + 4); $printNewline = true; } }
php
private function printConflictTable(IO $io, array $mappings, $indentation = 0) { /** @var PathConflict[] $conflicts */ $conflicts = array(); $shortPrefix = str_repeat(' ', $indentation); $prefix = str_repeat(' ', $indentation + 4); $printNewline = false; foreach ($mappings as $mapping) { foreach ($mapping->getConflicts() as $conflict) { $conflicts[spl_object_hash($conflict)] = $conflict; } } foreach ($conflicts as $conflict) { if ($printNewline) { $io->writeLine(''); } $io->writeLine(sprintf('%sConflicting path: %s', $shortPrefix, $conflict->getRepositoryPath())); $io->writeLine(''); $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Module', 'Puli Path', 'Real Path(s)')); foreach ($conflict->getMappings() as $mapping) { $table->addRow(array( '<bad>'.$mapping->getContainingModule()->getName().'</bad>', '<bad>'.$mapping->getRepositoryPath().'</bad>', '<bad>'.implode(', ', $mapping->getPathReferences()).'</bad>', )); } $io->writeLine(sprintf('%sMapped by the following mappings:', $prefix)); $io->writeLine(''); $table->render($io, $indentation + 4); $printNewline = true; } }
[ "private", "function", "printConflictTable", "(", "IO", "$", "io", ",", "array", "$", "mappings", ",", "$", "indentation", "=", "0", ")", "{", "/** @var PathConflict[] $conflicts */", "$", "conflicts", "=", "array", "(", ")", ";", "$", "shortPrefix", "=", "str_repeat", "(", "' '", ",", "$", "indentation", ")", ";", "$", "prefix", "=", "str_repeat", "(", "' '", ",", "$", "indentation", "+", "4", ")", ";", "$", "printNewline", "=", "false", ";", "foreach", "(", "$", "mappings", "as", "$", "mapping", ")", "{", "foreach", "(", "$", "mapping", "->", "getConflicts", "(", ")", "as", "$", "conflict", ")", "{", "$", "conflicts", "[", "spl_object_hash", "(", "$", "conflict", ")", "]", "=", "$", "conflict", ";", "}", "}", "foreach", "(", "$", "conflicts", "as", "$", "conflict", ")", "{", "if", "(", "$", "printNewline", ")", "{", "$", "io", "->", "writeLine", "(", "''", ")", ";", "}", "$", "io", "->", "writeLine", "(", "sprintf", "(", "'%sConflicting path: %s'", ",", "$", "shortPrefix", ",", "$", "conflict", "->", "getRepositoryPath", "(", ")", ")", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "$", "table", "=", "new", "Table", "(", "PuliTableStyle", "::", "borderless", "(", ")", ")", ";", "$", "table", "->", "setHeaderRow", "(", "array", "(", "'Module'", ",", "'Puli Path'", ",", "'Real Path(s)'", ")", ")", ";", "foreach", "(", "$", "conflict", "->", "getMappings", "(", ")", "as", "$", "mapping", ")", "{", "$", "table", "->", "addRow", "(", "array", "(", "'<bad>'", ".", "$", "mapping", "->", "getContainingModule", "(", ")", "->", "getName", "(", ")", ".", "'</bad>'", ",", "'<bad>'", ".", "$", "mapping", "->", "getRepositoryPath", "(", ")", ".", "'</bad>'", ",", "'<bad>'", ".", "implode", "(", "', '", ",", "$", "mapping", "->", "getPathReferences", "(", ")", ")", ".", "'</bad>'", ",", ")", ")", ";", "}", "$", "io", "->", "writeLine", "(", "sprintf", "(", "'%sMapped by the following mappings:'", ",", "$", "prefix", ")", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "$", "table", "->", "render", "(", "$", "io", ",", "$", "indentation", "+", "4", ")", ";", "$", "printNewline", "=", "true", ";", "}", "}" ]
Prints a list of conflicting path mappings. @param IO $io The I/O @param PathMapping[] $mappings The path mappings @param int $indentation The number of spaces to indent the output
[ "Prints", "a", "list", "of", "conflicting", "path", "mappings", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/MapCommandHandler.php#L289-L330
225,926
puli/cli
src/Handler/MapCommandHandler.php
MapCommandHandler.getPathMappingStates
private function getPathMappingStates(Args $args) { $states = array( PathMappingState::ENABLED => 'enabled', PathMappingState::NOT_FOUND => 'not-found', PathMappingState::CONFLICT => 'conflict', ); $states = array_filter($states, function ($option) use ($args) { return $args->isOptionSet($option); }); return array_keys($states) ?: PathMappingState::all(); }
php
private function getPathMappingStates(Args $args) { $states = array( PathMappingState::ENABLED => 'enabled', PathMappingState::NOT_FOUND => 'not-found', PathMappingState::CONFLICT => 'conflict', ); $states = array_filter($states, function ($option) use ($args) { return $args->isOptionSet($option); }); return array_keys($states) ?: PathMappingState::all(); }
[ "private", "function", "getPathMappingStates", "(", "Args", "$", "args", ")", "{", "$", "states", "=", "array", "(", "PathMappingState", "::", "ENABLED", "=>", "'enabled'", ",", "PathMappingState", "::", "NOT_FOUND", "=>", "'not-found'", ",", "PathMappingState", "::", "CONFLICT", "=>", "'conflict'", ",", ")", ";", "$", "states", "=", "array_filter", "(", "$", "states", ",", "function", "(", "$", "option", ")", "use", "(", "$", "args", ")", "{", "return", "$", "args", "->", "isOptionSet", "(", "$", "option", ")", ";", "}", ")", ";", "return", "array_keys", "(", "$", "states", ")", "?", ":", "PathMappingState", "::", "all", "(", ")", ";", "}" ]
Returns the path mapping states selected in the console arguments. @param Args $args The console arguments @return int[] The selected {@link PathMappingState} constants
[ "Returns", "the", "path", "mapping", "states", "selected", "in", "the", "console", "arguments", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/MapCommandHandler.php#L339-L352
225,927
puli/cli
src/Handler/MapCommandHandler.php
MapCommandHandler.printPathMappingStateHeader
private function printPathMappingStateHeader(IO $io, $pathMappingState) { switch ($pathMappingState) { case PathMappingState::ENABLED: $io->writeLine('The following path mappings are currently enabled:'); $io->writeLine(''); return; case PathMappingState::NOT_FOUND: $io->writeLine('The target paths of the following path mappings were not found:'); $io->writeLine(''); return; case PathMappingState::CONFLICT: $io->writeLine('Some path mappings have conflicting paths:'); $io->writeLine(' (add the module names to the "override-order" key in puli.json to resolve)'); $io->writeLine(''); return; } }
php
private function printPathMappingStateHeader(IO $io, $pathMappingState) { switch ($pathMappingState) { case PathMappingState::ENABLED: $io->writeLine('The following path mappings are currently enabled:'); $io->writeLine(''); return; case PathMappingState::NOT_FOUND: $io->writeLine('The target paths of the following path mappings were not found:'); $io->writeLine(''); return; case PathMappingState::CONFLICT: $io->writeLine('Some path mappings have conflicting paths:'); $io->writeLine(' (add the module names to the "override-order" key in puli.json to resolve)'); $io->writeLine(''); return; } }
[ "private", "function", "printPathMappingStateHeader", "(", "IO", "$", "io", ",", "$", "pathMappingState", ")", "{", "switch", "(", "$", "pathMappingState", ")", "{", "case", "PathMappingState", "::", "ENABLED", ":", "$", "io", "->", "writeLine", "(", "'The following path mappings are currently enabled:'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "PathMappingState", "::", "NOT_FOUND", ":", "$", "io", "->", "writeLine", "(", "'The target paths of the following path mappings were not found:'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "PathMappingState", "::", "CONFLICT", ":", "$", "io", "->", "writeLine", "(", "'Some path mappings have conflicting paths:'", ")", ";", "$", "io", "->", "writeLine", "(", "' (add the module names to the \"override-order\" key in puli.json to resolve)'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "}", "}" ]
Prints the header for a path mapping state. @param IO $io The I/O @param int $pathMappingState The {@link PathMappingState} constant
[ "Prints", "the", "header", "for", "a", "path", "mapping", "state", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/MapCommandHandler.php#L360-L380
225,928
puli/cli
src/Handler/LsCommandHandler.php
LsCommandHandler.formatName
private function formatName(PuliResource $resource) { $name = $resource->getName(); if ($resource->hasChildren()) { return '<c1>'.$name.'</c1>'; } return $name; }
php
private function formatName(PuliResource $resource) { $name = $resource->getName(); if ($resource->hasChildren()) { return '<c1>'.$name.'</c1>'; } return $name; }
[ "private", "function", "formatName", "(", "PuliResource", "$", "resource", ")", "{", "$", "name", "=", "$", "resource", "->", "getName", "(", ")", ";", "if", "(", "$", "resource", "->", "hasChildren", "(", ")", ")", "{", "return", "'<c1>'", ".", "$", "name", ".", "'</c1>'", ";", "}", "return", "$", "name", ";", "}" ]
Formats the name of the resource. Resources with children are colored. @param PuliResource $resource The resource. @return string|null The formatted name.
[ "Formats", "the", "name", "of", "the", "resource", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/LsCommandHandler.php#L162-L171
225,929
puli/cli
src/Handler/LsCommandHandler.php
LsCommandHandler.formatSize
private function formatSize($size) { $suffixes = array('', 'K', 'M', 'G', 'T', 'P'); reset($suffixes); $suffix = current($suffixes); while ($size > 1023) { next($suffixes); if (null === key($suffixes)) { break; } $size /= 1024; $suffix = current($suffixes); } if ($size < 10) { return number_format($size, 1).$suffix; } return round($size).$suffix; }
php
private function formatSize($size) { $suffixes = array('', 'K', 'M', 'G', 'T', 'P'); reset($suffixes); $suffix = current($suffixes); while ($size > 1023) { next($suffixes); if (null === key($suffixes)) { break; } $size /= 1024; $suffix = current($suffixes); } if ($size < 10) { return number_format($size, 1).$suffix; } return round($size).$suffix; }
[ "private", "function", "formatSize", "(", "$", "size", ")", "{", "$", "suffixes", "=", "array", "(", "''", ",", "'K'", ",", "'M'", ",", "'G'", ",", "'T'", ",", "'P'", ")", ";", "reset", "(", "$", "suffixes", ")", ";", "$", "suffix", "=", "current", "(", "$", "suffixes", ")", ";", "while", "(", "$", "size", ">", "1023", ")", "{", "next", "(", "$", "suffixes", ")", ";", "if", "(", "null", "===", "key", "(", "$", "suffixes", ")", ")", "{", "break", ";", "}", "$", "size", "/=", "1024", ";", "$", "suffix", "=", "current", "(", "$", "suffixes", ")", ";", "}", "if", "(", "$", "size", "<", "10", ")", "{", "return", "number_format", "(", "$", "size", ",", "1", ")", ".", "$", "suffix", ";", "}", "return", "round", "(", "$", "size", ")", ".", "$", "suffix", ";", "}" ]
Formats the given size. @param int $size The size in bytes. @return string
[ "Formats", "the", "given", "size", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/LsCommandHandler.php#L180-L203
225,930
tyxla/carbon-breadcrumbs
admin/class-carbon-breadcrumb-admin-settings.php
Carbon_Breadcrumb_Admin_Settings.get_field_data
public static function get_field_data() { return array( 'glue' => array( 'type' => 'text', 'title' => __( 'Glue', 'carbon_breadcrumbs' ), 'default' => ' > ', 'help' => __( 'This is displayed between the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'link_before' => array( 'type' => 'text', 'title' => __( 'Link Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before the breadcrumb item link.', 'carbon_breadcrumbs' ), ), 'link_after' => array( 'type' => 'text', 'title' => __( 'Link After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after the breadcrumb item link.', 'carbon_breadcrumbs' ), ), 'wrapper_before' => array( 'type' => 'text', 'title' => __( 'Wrapper Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before displaying the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'wrapper_after' => array( 'type' => 'text', 'title' => __( 'Wrapper After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after displaying the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'title_before' => array( 'type' => 'text', 'title' => __( 'Title Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before the breadcrumb item title.', 'carbon_breadcrumbs' ), ), 'title_after' => array( 'type' => 'text', 'title' => __( 'Title After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after the breadcrumb item title.', 'carbon_breadcrumbs' ), ), 'min_items' => array( 'type' => 'text', 'title' => __( 'Min Items', 'carbon_breadcrumbs' ), 'default' => 2, 'help' => __( 'Determines the minimum number of items, required to display the breadcrumb trail.', 'carbon_breadcrumbs' ), ), 'last_item_link' => array( 'type' => 'checkbox', 'title' => __( 'Last Item Link', 'carbon_breadcrumbs' ), 'default' => true, 'help' => __( 'Whether the last breadcrumb item should be a link.', 'carbon_breadcrumbs' ), ), 'display_home_item' => array( 'type' => 'checkbox', 'title' => __( 'Display Home Item?', 'carbon_breadcrumbs' ), 'default' => true, 'help' => __( 'Whether the home breadcrumb item should be displayed.', 'carbon_breadcrumbs' ), ), 'home_item_title' => array( 'type' => 'text', 'title' => __( 'Home Item Title', 'carbon_breadcrumbs' ), 'default' => __( 'Home', 'carbon_breadcrumbs' ), 'help' => __( 'Determines the title of the home item.', 'carbon_breadcrumbs' ), ), ); }
php
public static function get_field_data() { return array( 'glue' => array( 'type' => 'text', 'title' => __( 'Glue', 'carbon_breadcrumbs' ), 'default' => ' > ', 'help' => __( 'This is displayed between the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'link_before' => array( 'type' => 'text', 'title' => __( 'Link Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before the breadcrumb item link.', 'carbon_breadcrumbs' ), ), 'link_after' => array( 'type' => 'text', 'title' => __( 'Link After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after the breadcrumb item link.', 'carbon_breadcrumbs' ), ), 'wrapper_before' => array( 'type' => 'text', 'title' => __( 'Wrapper Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before displaying the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'wrapper_after' => array( 'type' => 'text', 'title' => __( 'Wrapper After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after displaying the breadcrumb items.', 'carbon_breadcrumbs' ), ), 'title_before' => array( 'type' => 'text', 'title' => __( 'Title Before', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed before the breadcrumb item title.', 'carbon_breadcrumbs' ), ), 'title_after' => array( 'type' => 'text', 'title' => __( 'Title After', 'carbon_breadcrumbs' ), 'default' => '', 'help' => __( 'This is displayed after the breadcrumb item title.', 'carbon_breadcrumbs' ), ), 'min_items' => array( 'type' => 'text', 'title' => __( 'Min Items', 'carbon_breadcrumbs' ), 'default' => 2, 'help' => __( 'Determines the minimum number of items, required to display the breadcrumb trail.', 'carbon_breadcrumbs' ), ), 'last_item_link' => array( 'type' => 'checkbox', 'title' => __( 'Last Item Link', 'carbon_breadcrumbs' ), 'default' => true, 'help' => __( 'Whether the last breadcrumb item should be a link.', 'carbon_breadcrumbs' ), ), 'display_home_item' => array( 'type' => 'checkbox', 'title' => __( 'Display Home Item?', 'carbon_breadcrumbs' ), 'default' => true, 'help' => __( 'Whether the home breadcrumb item should be displayed.', 'carbon_breadcrumbs' ), ), 'home_item_title' => array( 'type' => 'text', 'title' => __( 'Home Item Title', 'carbon_breadcrumbs' ), 'default' => __( 'Home', 'carbon_breadcrumbs' ), 'help' => __( 'Determines the title of the home item.', 'carbon_breadcrumbs' ), ), ); }
[ "public", "static", "function", "get_field_data", "(", ")", "{", "return", "array", "(", "'glue'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Glue'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "' > '", ",", "'help'", "=>", "__", "(", "'This is displayed between the breadcrumb items.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'link_before'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Link Before'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed before the breadcrumb item link.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'link_after'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Link After'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed after the breadcrumb item link.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'wrapper_before'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Wrapper Before'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed before displaying the breadcrumb items.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'wrapper_after'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Wrapper After'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed after displaying the breadcrumb items.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'title_before'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Title Before'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed before the breadcrumb item title.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'title_after'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Title After'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "''", ",", "'help'", "=>", "__", "(", "'This is displayed after the breadcrumb item title.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'min_items'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Min Items'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "2", ",", "'help'", "=>", "__", "(", "'Determines the minimum number of items, required to display the breadcrumb trail.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'last_item_link'", "=>", "array", "(", "'type'", "=>", "'checkbox'", ",", "'title'", "=>", "__", "(", "'Last Item Link'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "true", ",", "'help'", "=>", "__", "(", "'Whether the last breadcrumb item should be a link.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'display_home_item'", "=>", "array", "(", "'type'", "=>", "'checkbox'", ",", "'title'", "=>", "__", "(", "'Display Home Item?'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "true", ",", "'help'", "=>", "__", "(", "'Whether the home breadcrumb item should be displayed.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", "'home_item_title'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'title'", "=>", "__", "(", "'Home Item Title'", ",", "'carbon_breadcrumbs'", ")", ",", "'default'", "=>", "__", "(", "'Home'", ",", "'carbon_breadcrumbs'", ")", ",", "'help'", "=>", "__", "(", "'Determines the title of the home item.'", ",", "'carbon_breadcrumbs'", ")", ",", ")", ",", ")", ";", "}" ]
Get field data. Defines and describes the fields that will be registered. @access public @static @return array $fields The fields and their data.
[ "Get", "field", "data", ".", "Defines", "and", "describes", "the", "fields", "that", "will", "be", "registered", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings.php#L44-L113
225,931
tyxla/carbon-breadcrumbs
admin/class-carbon-breadcrumb-admin-settings.php
Carbon_Breadcrumb_Admin_Settings.admin_menu
public function admin_menu() { // Register settings page. add_options_page( self::get_page_title(), self::get_page_title(), 'manage_options', self::get_page_name(), array( $this, 'settings_page' ) ); // Register settings section. add_settings_section( self::get_page_name(), __( 'General Settings', 'carbon_breadcrumbs' ), '', self::get_page_name() ); }
php
public function admin_menu() { // Register settings page. add_options_page( self::get_page_title(), self::get_page_title(), 'manage_options', self::get_page_name(), array( $this, 'settings_page' ) ); // Register settings section. add_settings_section( self::get_page_name(), __( 'General Settings', 'carbon_breadcrumbs' ), '', self::get_page_name() ); }
[ "public", "function", "admin_menu", "(", ")", "{", "// Register settings page.", "add_options_page", "(", "self", "::", "get_page_title", "(", ")", ",", "self", "::", "get_page_title", "(", ")", ",", "'manage_options'", ",", "self", "::", "get_page_name", "(", ")", ",", "array", "(", "$", "this", ",", "'settings_page'", ")", ")", ";", "// Register settings section.", "add_settings_section", "(", "self", "::", "get_page_name", "(", ")", ",", "__", "(", "'General Settings'", ",", "'carbon_breadcrumbs'", ")", ",", "''", ",", "self", "::", "get_page_name", "(", ")", ")", ";", "}" ]
Register the settings page & default section. @access public
[ "Register", "the", "settings", "page", "&", "default", "section", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings.php#L144-L163
225,932
tyxla/carbon-breadcrumbs
admin/class-carbon-breadcrumb-admin-settings.php
Carbon_Breadcrumb_Admin_Settings.register_settings
public function register_settings() { // Register fields. $field_data = self::get_field_data(); foreach ( $field_data as $field_id => $field ) { $this->fields[] = Carbon_Breadcrumb_Admin_Settings_Field::factory( $field['type'], 'carbon_breadcrumbs_' . $field_id, $field['title'], self::get_page_name() ); } }
php
public function register_settings() { // Register fields. $field_data = self::get_field_data(); foreach ( $field_data as $field_id => $field ) { $this->fields[] = Carbon_Breadcrumb_Admin_Settings_Field::factory( $field['type'], 'carbon_breadcrumbs_' . $field_id, $field['title'], self::get_page_name() ); } }
[ "public", "function", "register_settings", "(", ")", "{", "// Register fields.", "$", "field_data", "=", "self", "::", "get_field_data", "(", ")", ";", "foreach", "(", "$", "field_data", "as", "$", "field_id", "=>", "$", "field", ")", "{", "$", "this", "->", "fields", "[", "]", "=", "Carbon_Breadcrumb_Admin_Settings_Field", "::", "factory", "(", "$", "field", "[", "'type'", "]", ",", "'carbon_breadcrumbs_'", ".", "$", "field_id", ",", "$", "field", "[", "'title'", "]", ",", "self", "::", "get_page_name", "(", ")", ")", ";", "}", "}" ]
Register the settings sections and fields. @access public
[ "Register", "the", "settings", "sections", "and", "fields", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings.php#L170-L176
225,933
tyxla/carbon-breadcrumbs
admin/class-carbon-breadcrumb-admin-settings.php
Carbon_Breadcrumb_Admin_Settings.settings_page
public function settings_page() { ?> <div class="wrap"> <h2><?php echo esc_html( self::get_page_title() ); ?></h2> </div> <form method="POST" action="options.php"> <?php settings_fields( self::get_page_name() ); do_settings_sections( self::get_page_name() ); submit_button(); ?> </form> <?php }
php
public function settings_page() { ?> <div class="wrap"> <h2><?php echo esc_html( self::get_page_title() ); ?></h2> </div> <form method="POST" action="options.php"> <?php settings_fields( self::get_page_name() ); do_settings_sections( self::get_page_name() ); submit_button(); ?> </form> <?php }
[ "public", "function", "settings_page", "(", ")", "{", "?>\n\t\t<div class=\"wrap\">\n\t\t\t<h2><?php", "echo", "esc_html", "(", "self", "::", "get_page_title", "(", ")", ")", ";", "?></h2>\n\t\t</div>\n\n\t\t<form method=\"POST\" action=\"options.php\">\n\t\t\t<?php", "settings_fields", "(", "self", "::", "get_page_name", "(", ")", ")", ";", "do_settings_sections", "(", "self", "::", "get_page_name", "(", ")", ")", ";", "submit_button", "(", ")", ";", "?>\n\t\t</form>\n\t\t<?php", "}" ]
Content of the settings page. @access public
[ "Content", "of", "the", "settings", "page", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings.php#L183-L197
225,934
andersondanilo/modelform
src/FormSet.php
FormSet.getModelByPrimaryKey
public function getModelByPrimaryKey($id) { foreach($this->models as $model) { $primaryKey = $model->getKeyName(); if($model->$primaryKey == $id) return $model; } }
php
public function getModelByPrimaryKey($id) { foreach($this->models as $model) { $primaryKey = $model->getKeyName(); if($model->$primaryKey == $id) return $model; } }
[ "public", "function", "getModelByPrimaryKey", "(", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "models", "as", "$", "model", ")", "{", "$", "primaryKey", "=", "$", "model", "->", "getKeyName", "(", ")", ";", "if", "(", "$", "model", "->", "$", "primaryKey", "==", "$", "id", ")", "return", "$", "model", ";", "}", "}" ]
Return a model of formset by id
[ "Return", "a", "model", "of", "formset", "by", "id" ]
4c735326e2837cd6590b6b4d69f62c072de19bd8
https://github.com/andersondanilo/modelform/blob/4c735326e2837cd6590b6b4d69f62c072de19bd8/src/FormSet.php#L185-L193
225,935
BKWLD/upchuck
src/Observer.php
Observer.onSaving
public function onSaving($event, $payload) { // Destructure params list($model) = $payload; // Check that the model supports uploads through Upchuck if (!$this->supportsUploads($model) || !($attributes = $model->getUploadAttributes())) return; // Loop through the all of the upload attributes ... event(new Events\HandlingSaving($model)); foreach($attributes as $attribute) { // Check if there is an uploaded file in the upload attribute if (($file = $model->getAttribute($attribute)) && is_a($file, UploadedFile::class)) { // Move the upload and get the new URL $url = $this->storage->moveUpload($file); $model->setUploadAttribute($attribute, $url); } // If the attribute field is dirty, delete the old file if ($model->isDirty($attribute) && !$this->keepsFilesOnDelete($model) && ($old = $model->getOriginal($attribute))) { $this->storage->delete($old); } } event(new Events\HandledSaving($model)); }
php
public function onSaving($event, $payload) { // Destructure params list($model) = $payload; // Check that the model supports uploads through Upchuck if (!$this->supportsUploads($model) || !($attributes = $model->getUploadAttributes())) return; // Loop through the all of the upload attributes ... event(new Events\HandlingSaving($model)); foreach($attributes as $attribute) { // Check if there is an uploaded file in the upload attribute if (($file = $model->getAttribute($attribute)) && is_a($file, UploadedFile::class)) { // Move the upload and get the new URL $url = $this->storage->moveUpload($file); $model->setUploadAttribute($attribute, $url); } // If the attribute field is dirty, delete the old file if ($model->isDirty($attribute) && !$this->keepsFilesOnDelete($model) && ($old = $model->getOriginal($attribute))) { $this->storage->delete($old); } } event(new Events\HandledSaving($model)); }
[ "public", "function", "onSaving", "(", "$", "event", ",", "$", "payload", ")", "{", "// Destructure params", "list", "(", "$", "model", ")", "=", "$", "payload", ";", "// Check that the model supports uploads through Upchuck", "if", "(", "!", "$", "this", "->", "supportsUploads", "(", "$", "model", ")", "||", "!", "(", "$", "attributes", "=", "$", "model", "->", "getUploadAttributes", "(", ")", ")", ")", "return", ";", "// Loop through the all of the upload attributes ...", "event", "(", "new", "Events", "\\", "HandlingSaving", "(", "$", "model", ")", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "// Check if there is an uploaded file in the upload attribute", "if", "(", "(", "$", "file", "=", "$", "model", "->", "getAttribute", "(", "$", "attribute", ")", ")", "&&", "is_a", "(", "$", "file", ",", "UploadedFile", "::", "class", ")", ")", "{", "// Move the upload and get the new URL", "$", "url", "=", "$", "this", "->", "storage", "->", "moveUpload", "(", "$", "file", ")", ";", "$", "model", "->", "setUploadAttribute", "(", "$", "attribute", ",", "$", "url", ")", ";", "}", "// If the attribute field is dirty, delete the old file", "if", "(", "$", "model", "->", "isDirty", "(", "$", "attribute", ")", "&&", "!", "$", "this", "->", "keepsFilesOnDelete", "(", "$", "model", ")", "&&", "(", "$", "old", "=", "$", "model", "->", "getOriginal", "(", "$", "attribute", ")", ")", ")", "{", "$", "this", "->", "storage", "->", "delete", "(", "$", "old", ")", ";", "}", "}", "event", "(", "new", "Events", "\\", "HandledSaving", "(", "$", "model", ")", ")", ";", "}" ]
A model is saving, check for files being uploaded @param string $event @param array $payload containg: - Illuminate\Database\Eloquent\Model @return void
[ "A", "model", "is", "saving", "check", "for", "files", "being", "uploaded" ]
2d2202b1bc4a86a0a91ceb319521a263b0c88f54
https://github.com/BKWLD/upchuck/blob/2d2202b1bc4a86a0a91ceb319521a263b0c88f54/src/Observer.php#L42-L72
225,936
BKWLD/upchuck
src/Observer.php
Observer.onDeleted
public function onDeleted($event, $payload) { // Destructure params list($model) = $payload; // If the model is soft deleted and the config states to NOT delete if // soft deleted, abort here. if ($this->keepsFilesOnDelete($model)) return; // Check that the model supports uploads through Upchuck if (!$this->supportsUploads($model) || !($attributes = $model->getUploadAttributes())) return; // Loop through the all of the upload attributes and get the values using // "original" so that you get the file value before it may have been cleared. event(new Events\HandlingDeleted($model)); foreach($attributes as $attribute) { if (!$url = $model->getOriginal($attribute)) continue; $this->storage->delete($url); } event(new Events\HandledDeleted($model)); }
php
public function onDeleted($event, $payload) { // Destructure params list($model) = $payload; // If the model is soft deleted and the config states to NOT delete if // soft deleted, abort here. if ($this->keepsFilesOnDelete($model)) return; // Check that the model supports uploads through Upchuck if (!$this->supportsUploads($model) || !($attributes = $model->getUploadAttributes())) return; // Loop through the all of the upload attributes and get the values using // "original" so that you get the file value before it may have been cleared. event(new Events\HandlingDeleted($model)); foreach($attributes as $attribute) { if (!$url = $model->getOriginal($attribute)) continue; $this->storage->delete($url); } event(new Events\HandledDeleted($model)); }
[ "public", "function", "onDeleted", "(", "$", "event", ",", "$", "payload", ")", "{", "// Destructure params", "list", "(", "$", "model", ")", "=", "$", "payload", ";", "// If the model is soft deleted and the config states to NOT delete if", "// soft deleted, abort here.", "if", "(", "$", "this", "->", "keepsFilesOnDelete", "(", "$", "model", ")", ")", "return", ";", "// Check that the model supports uploads through Upchuck", "if", "(", "!", "$", "this", "->", "supportsUploads", "(", "$", "model", ")", "||", "!", "(", "$", "attributes", "=", "$", "model", "->", "getUploadAttributes", "(", ")", ")", ")", "return", ";", "// Loop through the all of the upload attributes and get the values using", "// \"original\" so that you get the file value before it may have been cleared.", "event", "(", "new", "Events", "\\", "HandlingDeleted", "(", "$", "model", ")", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "!", "$", "url", "=", "$", "model", "->", "getOriginal", "(", "$", "attribute", ")", ")", "continue", ";", "$", "this", "->", "storage", "->", "delete", "(", "$", "url", ")", ";", "}", "event", "(", "new", "Events", "\\", "HandledDeleted", "(", "$", "model", ")", ")", ";", "}" ]
A model has been deleted, trash all of it's files @param string $event @param array $payload containg: - Illuminate\Database\Eloquent\Model @return void
[ "A", "model", "has", "been", "deleted", "trash", "all", "of", "it", "s", "files" ]
2d2202b1bc4a86a0a91ceb319521a263b0c88f54
https://github.com/BKWLD/upchuck/blob/2d2202b1bc4a86a0a91ceb319521a263b0c88f54/src/Observer.php#L82-L103
225,937
heyday/silverstripe-responsive-images
code/ResponsiveImageExtension.php
ResponsiveImageExtension.createResponsiveSet
protected function createResponsiveSet($config, $defaultArgs, $set) { Requirements::javascript('heyday/silverstripe-responsive-images:javascript/picturefill/picturefill.min.js'); if (!isset($config['arguments']) || !is_array($config['arguments'])) { throw new Exception("Responsive set $set does not have any arguments defined in its config."); } if (empty($defaultArgs)) { if (isset($config['default_arguments'])) { $defaultArgs = $config['default_arguments']; } else { $defaultArgs = Config::inst()->get(__CLASS__, 'default_arguments'); } } if (isset($config['method'])) { $methodName = $config['method']; } else { $methodName = Config::inst()->get(__CLASS__, 'default_method'); } if (!$this->owner->hasMethod($methodName)) { throw new RuntimeException(get_class($this->owner) . ' has no method ' . $methodName); } // Create the resampled images for each query in the set $sizes = ArrayList::create(); foreach ($config['arguments'] as $query => $args) { if (is_numeric($query) || !$query) { throw new Exception("Responsive set $set has an empty media query. Please check your config format"); } if (!is_array($args) || empty($args)) { throw new Exception("Responsive set $set doesn't have any arguments provided for the query: $query"); } $sizes->push(ArrayData::create([ 'Image' => $this->getResampledImage($methodName, $args), 'Query' => $query ])); } $templatePath = isset($config['template']) ? $config['template'] : 'Includes/ResponsiveImageSet'; return $this->owner->customise([ 'Sizes' => $sizes, 'DefaultImage' => $this->getResampledImage($methodName, $defaultArgs) ])->renderWith($templatePath); }
php
protected function createResponsiveSet($config, $defaultArgs, $set) { Requirements::javascript('heyday/silverstripe-responsive-images:javascript/picturefill/picturefill.min.js'); if (!isset($config['arguments']) || !is_array($config['arguments'])) { throw new Exception("Responsive set $set does not have any arguments defined in its config."); } if (empty($defaultArgs)) { if (isset($config['default_arguments'])) { $defaultArgs = $config['default_arguments']; } else { $defaultArgs = Config::inst()->get(__CLASS__, 'default_arguments'); } } if (isset($config['method'])) { $methodName = $config['method']; } else { $methodName = Config::inst()->get(__CLASS__, 'default_method'); } if (!$this->owner->hasMethod($methodName)) { throw new RuntimeException(get_class($this->owner) . ' has no method ' . $methodName); } // Create the resampled images for each query in the set $sizes = ArrayList::create(); foreach ($config['arguments'] as $query => $args) { if (is_numeric($query) || !$query) { throw new Exception("Responsive set $set has an empty media query. Please check your config format"); } if (!is_array($args) || empty($args)) { throw new Exception("Responsive set $set doesn't have any arguments provided for the query: $query"); } $sizes->push(ArrayData::create([ 'Image' => $this->getResampledImage($methodName, $args), 'Query' => $query ])); } $templatePath = isset($config['template']) ? $config['template'] : 'Includes/ResponsiveImageSet'; return $this->owner->customise([ 'Sizes' => $sizes, 'DefaultImage' => $this->getResampledImage($methodName, $defaultArgs) ])->renderWith($templatePath); }
[ "protected", "function", "createResponsiveSet", "(", "$", "config", ",", "$", "defaultArgs", ",", "$", "set", ")", "{", "Requirements", "::", "javascript", "(", "'heyday/silverstripe-responsive-images:javascript/picturefill/picturefill.min.js'", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'arguments'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'arguments'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"Responsive set $set does not have any arguments defined in its config.\"", ")", ";", "}", "if", "(", "empty", "(", "$", "defaultArgs", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'default_arguments'", "]", ")", ")", "{", "$", "defaultArgs", "=", "$", "config", "[", "'default_arguments'", "]", ";", "}", "else", "{", "$", "defaultArgs", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "__CLASS__", ",", "'default_arguments'", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "config", "[", "'method'", "]", ")", ")", "{", "$", "methodName", "=", "$", "config", "[", "'method'", "]", ";", "}", "else", "{", "$", "methodName", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "__CLASS__", ",", "'default_method'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "owner", "->", "hasMethod", "(", "$", "methodName", ")", ")", "{", "throw", "new", "RuntimeException", "(", "get_class", "(", "$", "this", "->", "owner", ")", ".", "' has no method '", ".", "$", "methodName", ")", ";", "}", "// Create the resampled images for each query in the set", "$", "sizes", "=", "ArrayList", "::", "create", "(", ")", ";", "foreach", "(", "$", "config", "[", "'arguments'", "]", "as", "$", "query", "=>", "$", "args", ")", "{", "if", "(", "is_numeric", "(", "$", "query", ")", "||", "!", "$", "query", ")", "{", "throw", "new", "Exception", "(", "\"Responsive set $set has an empty media query. Please check your config format\"", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "args", ")", "||", "empty", "(", "$", "args", ")", ")", "{", "throw", "new", "Exception", "(", "\"Responsive set $set doesn't have any arguments provided for the query: $query\"", ")", ";", "}", "$", "sizes", "->", "push", "(", "ArrayData", "::", "create", "(", "[", "'Image'", "=>", "$", "this", "->", "getResampledImage", "(", "$", "methodName", ",", "$", "args", ")", ",", "'Query'", "=>", "$", "query", "]", ")", ")", ";", "}", "$", "templatePath", "=", "isset", "(", "$", "config", "[", "'template'", "]", ")", "?", "$", "config", "[", "'template'", "]", ":", "'Includes/ResponsiveImageSet'", ";", "return", "$", "this", "->", "owner", "->", "customise", "(", "[", "'Sizes'", "=>", "$", "sizes", ",", "'DefaultImage'", "=>", "$", "this", "->", "getResampledImage", "(", "$", "methodName", ",", "$", "defaultArgs", ")", "]", ")", "->", "renderWith", "(", "$", "templatePath", ")", ";", "}" ]
Requires the necessary JS and sends the required HTML structure to the template for a responsive image set. @param array $config The configuration of the responsive image set @param array $defaultArgs The arguments passed to the responsive image method call, e.g. $MyImage.ResponsiveSet(800x600) @param string $set The method, or responsive image set, to generate @return SSViewer
[ "Requires", "the", "necessary", "JS", "and", "sends", "the", "required", "HTML", "structure", "to", "the", "template", "for", "a", "responsive", "image", "set", "." ]
c5d1b396b4e0f97c740d1ebeb3dfc8843ce4e911
https://github.com/heyday/silverstripe-responsive-images/blob/c5d1b396b4e0f97c740d1ebeb3dfc8843ce4e911/code/ResponsiveImageExtension.php#L89-L140
225,938
xmeltrut/WordSearch
src/Generator.php
Generator.generate
public function generate() { $this->initialise(); $this->populate(); $this->fill(); return new Puzzle($this->grid, $this->wordList); }
php
public function generate() { $this->initialise(); $this->populate(); $this->fill(); return new Puzzle($this->grid, $this->wordList); }
[ "public", "function", "generate", "(", ")", "{", "$", "this", "->", "initialise", "(", ")", ";", "$", "this", "->", "populate", "(", ")", ";", "$", "this", "->", "fill", "(", ")", ";", "return", "new", "Puzzle", "(", "$", "this", "->", "grid", ",", "$", "this", "->", "wordList", ")", ";", "}" ]
Generate the puzzle. @return Puzzle
[ "Generate", "the", "puzzle", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L82-L89
225,939
xmeltrut/WordSearch
src/Generator.php
Generator.initialise
private function initialise() { for ($i = 0; $i < $this->size; $i++) { for ($j = 0; $j < $this->size; $j++) { $this->grid[$i][$j] = null; } $this->rowsAvailable[] = $i; $this->columnsAvailable[] = $i; } }
php
private function initialise() { for ($i = 0; $i < $this->size; $i++) { for ($j = 0; $j < $this->size; $j++) { $this->grid[$i][$j] = null; } $this->rowsAvailable[] = $i; $this->columnsAvailable[] = $i; } }
[ "private", "function", "initialise", "(", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "size", ";", "$", "i", "++", ")", "{", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "this", "->", "size", ";", "$", "j", "++", ")", "{", "$", "this", "->", "grid", "[", "$", "i", "]", "[", "$", "j", "]", "=", "null", ";", "}", "$", "this", "->", "rowsAvailable", "[", "]", "=", "$", "i", ";", "$", "this", "->", "columnsAvailable", "[", "]", "=", "$", "i", ";", "}", "}" ]
Initialise the grid. @return void
[ "Initialise", "the", "grid", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L96-L106
225,940
xmeltrut/WordSearch
src/Generator.php
Generator.populate
private function populate() { foreach ($this->words as $word) { $rowOrColumn = rand(1, 2); if ($rowOrColumn == 1) { shuffle($this->rowsAvailable); foreach ($this->rowsAvailable as $key => $row) { $maxStart = ($this->size - Utils::stringLength($word)); $startOptions = Utils::integerAsOptions($maxStart); foreach ($startOptions as $startIndex) { if ($this->tryWordInRow($word, $row, $startIndex)) { $this->insertWordIntoRow($word, $row, $startIndex); unset($this->rowsAvailable[$key]); break(2); } } } } else { shuffle($this->columnsAvailable); foreach ($this->columnsAvailable as $key => $column) { $maxStart = ($this->size - Utils::stringLength($word)); $startOptions = Utils::integerAsOptions($maxStart); foreach ($startOptions as $startIndex) { if ($this->tryWordInColumn($word, $column, $startIndex)) { $this->insertWordIntoColumn($word, $column, $startIndex); unset($this->columnsAvailable[$key]); break(2); } } } } } }
php
private function populate() { foreach ($this->words as $word) { $rowOrColumn = rand(1, 2); if ($rowOrColumn == 1) { shuffle($this->rowsAvailable); foreach ($this->rowsAvailable as $key => $row) { $maxStart = ($this->size - Utils::stringLength($word)); $startOptions = Utils::integerAsOptions($maxStart); foreach ($startOptions as $startIndex) { if ($this->tryWordInRow($word, $row, $startIndex)) { $this->insertWordIntoRow($word, $row, $startIndex); unset($this->rowsAvailable[$key]); break(2); } } } } else { shuffle($this->columnsAvailable); foreach ($this->columnsAvailable as $key => $column) { $maxStart = ($this->size - Utils::stringLength($word)); $startOptions = Utils::integerAsOptions($maxStart); foreach ($startOptions as $startIndex) { if ($this->tryWordInColumn($word, $column, $startIndex)) { $this->insertWordIntoColumn($word, $column, $startIndex); unset($this->columnsAvailable[$key]); break(2); } } } } } }
[ "private", "function", "populate", "(", ")", "{", "foreach", "(", "$", "this", "->", "words", "as", "$", "word", ")", "{", "$", "rowOrColumn", "=", "rand", "(", "1", ",", "2", ")", ";", "if", "(", "$", "rowOrColumn", "==", "1", ")", "{", "shuffle", "(", "$", "this", "->", "rowsAvailable", ")", ";", "foreach", "(", "$", "this", "->", "rowsAvailable", "as", "$", "key", "=>", "$", "row", ")", "{", "$", "maxStart", "=", "(", "$", "this", "->", "size", "-", "Utils", "::", "stringLength", "(", "$", "word", ")", ")", ";", "$", "startOptions", "=", "Utils", "::", "integerAsOptions", "(", "$", "maxStart", ")", ";", "foreach", "(", "$", "startOptions", "as", "$", "startIndex", ")", "{", "if", "(", "$", "this", "->", "tryWordInRow", "(", "$", "word", ",", "$", "row", ",", "$", "startIndex", ")", ")", "{", "$", "this", "->", "insertWordIntoRow", "(", "$", "word", ",", "$", "row", ",", "$", "startIndex", ")", ";", "unset", "(", "$", "this", "->", "rowsAvailable", "[", "$", "key", "]", ")", ";", "break", "(", "2", ")", ";", "}", "}", "}", "}", "else", "{", "shuffle", "(", "$", "this", "->", "columnsAvailable", ")", ";", "foreach", "(", "$", "this", "->", "columnsAvailable", "as", "$", "key", "=>", "$", "column", ")", "{", "$", "maxStart", "=", "(", "$", "this", "->", "size", "-", "Utils", "::", "stringLength", "(", "$", "word", ")", ")", ";", "$", "startOptions", "=", "Utils", "::", "integerAsOptions", "(", "$", "maxStart", ")", ";", "foreach", "(", "$", "startOptions", "as", "$", "startIndex", ")", "{", "if", "(", "$", "this", "->", "tryWordInColumn", "(", "$", "word", ",", "$", "column", ",", "$", "startIndex", ")", ")", "{", "$", "this", "->", "insertWordIntoColumn", "(", "$", "word", ",", "$", "column", ",", "$", "startIndex", ")", ";", "unset", "(", "$", "this", "->", "columnsAvailable", "[", "$", "key", "]", ")", ";", "break", "(", "2", ")", ";", "}", "}", "}", "}", "}", "}" ]
Populate the grid with the words. @return void
[ "Populate", "the", "grid", "with", "the", "words", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L113-L148
225,941
xmeltrut/WordSearch
src/Generator.php
Generator.insertWordIntoRow
private function insertWordIntoRow($word, $row, $col) { $this->wordList->add($word, ($row + 1), (1 + $col)); $wordArray = Utils::stringToArray($word); foreach ($wordArray as $letter) { $this->grid[$row][$col] = $letter; $col++; } }
php
private function insertWordIntoRow($word, $row, $col) { $this->wordList->add($word, ($row + 1), (1 + $col)); $wordArray = Utils::stringToArray($word); foreach ($wordArray as $letter) { $this->grid[$row][$col] = $letter; $col++; } }
[ "private", "function", "insertWordIntoRow", "(", "$", "word", ",", "$", "row", ",", "$", "col", ")", "{", "$", "this", "->", "wordList", "->", "add", "(", "$", "word", ",", "(", "$", "row", "+", "1", ")", ",", "(", "1", "+", "$", "col", ")", ")", ";", "$", "wordArray", "=", "Utils", "::", "stringToArray", "(", "$", "word", ")", ";", "foreach", "(", "$", "wordArray", "as", "$", "letter", ")", "{", "$", "this", "->", "grid", "[", "$", "row", "]", "[", "$", "col", "]", "=", "$", "letter", ";", "$", "col", "++", ";", "}", "}" ]
Insert a word into a row. @param string $word Word. @param integer $row Row index. @param integer $col Column index.
[ "Insert", "a", "word", "into", "a", "row", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L180-L190
225,942
xmeltrut/WordSearch
src/Generator.php
Generator.tryWordInColumn
private function tryWordInColumn($word, $col, $row) { $wordArray = Utils::stringToArray($word); foreach ($wordArray as $letter) { if ($this->grid[$row][$col] !== null && $this->grid[$row][$col] !== $letter ) { return false; } $row++; } return true; }
php
private function tryWordInColumn($word, $col, $row) { $wordArray = Utils::stringToArray($word); foreach ($wordArray as $letter) { if ($this->grid[$row][$col] !== null && $this->grid[$row][$col] !== $letter ) { return false; } $row++; } return true; }
[ "private", "function", "tryWordInColumn", "(", "$", "word", ",", "$", "col", ",", "$", "row", ")", "{", "$", "wordArray", "=", "Utils", "::", "stringToArray", "(", "$", "word", ")", ";", "foreach", "(", "$", "wordArray", "as", "$", "letter", ")", "{", "if", "(", "$", "this", "->", "grid", "[", "$", "row", "]", "[", "$", "col", "]", "!==", "null", "&&", "$", "this", "->", "grid", "[", "$", "row", "]", "[", "$", "col", "]", "!==", "$", "letter", ")", "{", "return", "false", ";", "}", "$", "row", "++", ";", "}", "return", "true", ";", "}" ]
Try to fit a word into a column. @param string $word Word. @param integer $col Column index. @param integer $row Row index.
[ "Try", "to", "fit", "a", "word", "into", "a", "column", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L199-L213
225,943
xmeltrut/WordSearch
src/Generator.php
Generator.fill
private function fill() { foreach ($this->grid as $r => $row) { foreach ($row as $c => $cell) { if ($cell === null) { $this->grid[$r][$c] = $this->alphabet->randomLetter(); } } } // fill them }
php
private function fill() { foreach ($this->grid as $r => $row) { foreach ($row as $c => $cell) { if ($cell === null) { $this->grid[$r][$c] = $this->alphabet->randomLetter(); } } } // fill them }
[ "private", "function", "fill", "(", ")", "{", "foreach", "(", "$", "this", "->", "grid", "as", "$", "r", "=>", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "c", "=>", "$", "cell", ")", "{", "if", "(", "$", "cell", "===", "null", ")", "{", "$", "this", "->", "grid", "[", "$", "r", "]", "[", "$", "c", "]", "=", "$", "this", "->", "alphabet", "->", "randomLetter", "(", ")", ";", "}", "}", "}", "// fill them", "}" ]
Fill any empty slots. @return void
[ "Fill", "any", "empty", "slots", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Generator.php#L239-L249
225,944
xmeltrut/WordSearch
src/Factory.php
Factory.create
public static function create(array $words, $size = 15, $lang = 'en') { $alphabet = ($lang == 'fi') ? new Alphabet\Finnish : null; $generator = new Generator($words, $size, $alphabet); return $generator->generate(); }
php
public static function create(array $words, $size = 15, $lang = 'en') { $alphabet = ($lang == 'fi') ? new Alphabet\Finnish : null; $generator = new Generator($words, $size, $alphabet); return $generator->generate(); }
[ "public", "static", "function", "create", "(", "array", "$", "words", ",", "$", "size", "=", "15", ",", "$", "lang", "=", "'en'", ")", "{", "$", "alphabet", "=", "(", "$", "lang", "==", "'fi'", ")", "?", "new", "Alphabet", "\\", "Finnish", ":", "null", ";", "$", "generator", "=", "new", "Generator", "(", "$", "words", ",", "$", "size", ",", "$", "alphabet", ")", ";", "return", "$", "generator", "->", "generate", "(", ")", ";", "}" ]
Create a puzzle. @param array $words List of words. @param integer $size Grid size. @param string $lang Language. @return Puzzle
[ "Create", "a", "puzzle", "." ]
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Factory.php#L15-L20
225,945
ccottet/ldap
Platform/Native/Search.php
Search.next
public function next() { if ($this->isEndReached) { return null; } if (null === $this->previous) { $this->previous = @ldap_first_entry($this->connection, $this->resultSet); } else { $this->previous = @ldap_next_entry($this->connection, $this->previous); } if (false === $this->previous) { $this->previous = null; $this->isEndReached = true; return null; } return new Entry($this->connection, $this->previous); }
php
public function next() { if ($this->isEndReached) { return null; } if (null === $this->previous) { $this->previous = @ldap_first_entry($this->connection, $this->resultSet); } else { $this->previous = @ldap_next_entry($this->connection, $this->previous); } if (false === $this->previous) { $this->previous = null; $this->isEndReached = true; return null; } return new Entry($this->connection, $this->previous); }
[ "public", "function", "next", "(", ")", "{", "if", "(", "$", "this", "->", "isEndReached", ")", "{", "return", "null", ";", "}", "if", "(", "null", "===", "$", "this", "->", "previous", ")", "{", "$", "this", "->", "previous", "=", "@", "ldap_first_entry", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "resultSet", ")", ";", "}", "else", "{", "$", "this", "->", "previous", "=", "@", "ldap_next_entry", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "previous", ")", ";", "}", "if", "(", "false", "===", "$", "this", "->", "previous", ")", "{", "$", "this", "->", "previous", "=", "null", ";", "$", "this", "->", "isEndReached", "=", "true", ";", "return", "null", ";", "}", "return", "new", "Entry", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "previous", ")", ";", "}" ]
Retrieves next available entry from the search result set @return EntryInterface next entry if available, null otherwise
[ "Retrieves", "next", "available", "entry", "from", "the", "search", "result", "set" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Search.php#L53-L69
225,946
okvpn/datadog-symfony
src/Services/SkipCaptureService.php
SkipCaptureService.shouldExceptionCaptureBeSkipped
public function shouldExceptionCaptureBeSkipped(\Throwable $exception): bool { if (in_array(get_class($exception), $this->skipCapture, true)) { return true; } if ($this->skipHash && in_array($this->hashService->hash($exception), $this->skipHash, true)) { return true; } foreach ($this->skipInstanceof as $class) { if ($exception instanceof $class) { return true; } } if (function_exists('fnmatch')) { $message = $exception->getMessage(); foreach ($this->skipWildcard as $wildcard) { if (fnmatch($wildcard, $message)) { return true; } } } return false; }
php
public function shouldExceptionCaptureBeSkipped(\Throwable $exception): bool { if (in_array(get_class($exception), $this->skipCapture, true)) { return true; } if ($this->skipHash && in_array($this->hashService->hash($exception), $this->skipHash, true)) { return true; } foreach ($this->skipInstanceof as $class) { if ($exception instanceof $class) { return true; } } if (function_exists('fnmatch')) { $message = $exception->getMessage(); foreach ($this->skipWildcard as $wildcard) { if (fnmatch($wildcard, $message)) { return true; } } } return false; }
[ "public", "function", "shouldExceptionCaptureBeSkipped", "(", "\\", "Throwable", "$", "exception", ")", ":", "bool", "{", "if", "(", "in_array", "(", "get_class", "(", "$", "exception", ")", ",", "$", "this", "->", "skipCapture", ",", "true", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "skipHash", "&&", "in_array", "(", "$", "this", "->", "hashService", "->", "hash", "(", "$", "exception", ")", ",", "$", "this", "->", "skipHash", ",", "true", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "skipInstanceof", "as", "$", "class", ")", "{", "if", "(", "$", "exception", "instanceof", "$", "class", ")", "{", "return", "true", ";", "}", "}", "if", "(", "function_exists", "(", "'fnmatch'", ")", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "foreach", "(", "$", "this", "->", "skipWildcard", "as", "$", "wildcard", ")", "{", "if", "(", "fnmatch", "(", "$", "wildcard", ",", "$", "message", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check that exception should be skip @param \Throwable $exception @return bool
[ "Check", "that", "exception", "should", "be", "skip" ]
310eb65b648db692fa877dfb5de6005bf4b9b640
https://github.com/okvpn/datadog-symfony/blob/310eb65b648db692fa877dfb5de6005bf4b9b640/src/Services/SkipCaptureService.php#L47-L71
225,947
okvpn/datadog-symfony
src/Services/SkipCaptureService.php
SkipCaptureService.shouldMessageCaptureBeSkipped
public function shouldMessageCaptureBeSkipped(string $message): bool { if (function_exists('fnmatch')) { foreach ($this->skipWildcard as $wildcard) { if (fnmatch($wildcard, $message)) { return true; } } } if (in_array($message, $this->skipCapture, true)) { return true; } if (in_array($message, $this->skipCommand, true)) { return true; } return false; }
php
public function shouldMessageCaptureBeSkipped(string $message): bool { if (function_exists('fnmatch')) { foreach ($this->skipWildcard as $wildcard) { if (fnmatch($wildcard, $message)) { return true; } } } if (in_array($message, $this->skipCapture, true)) { return true; } if (in_array($message, $this->skipCommand, true)) { return true; } return false; }
[ "public", "function", "shouldMessageCaptureBeSkipped", "(", "string", "$", "message", ")", ":", "bool", "{", "if", "(", "function_exists", "(", "'fnmatch'", ")", ")", "{", "foreach", "(", "$", "this", "->", "skipWildcard", "as", "$", "wildcard", ")", "{", "if", "(", "fnmatch", "(", "$", "wildcard", ",", "$", "message", ")", ")", "{", "return", "true", ";", "}", "}", "}", "if", "(", "in_array", "(", "$", "message", ",", "$", "this", "->", "skipCapture", ",", "true", ")", ")", "{", "return", "true", ";", "}", "if", "(", "in_array", "(", "$", "message", ",", "$", "this", "->", "skipCommand", ",", "true", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check that message or command should be skip @param string $message @return bool
[ "Check", "that", "message", "or", "command", "should", "be", "skip" ]
310eb65b648db692fa877dfb5de6005bf4b9b640
https://github.com/okvpn/datadog-symfony/blob/310eb65b648db692fa877dfb5de6005bf4b9b640/src/Services/SkipCaptureService.php#L79-L96
225,948
puli/cli
src/Handler/FindCommandHandler.php
FindCommandHandler.handle
public function handle(Args $args, IO $io) { $criteria = array(); if ($args->isOptionSet('path')) { $criteria['path'] = $args->getOption('path'); $criteria['language'] = $args->getOption('language'); } if ($args->isOptionSet('name')) { if (isset($criteria['path'])) { throw new RuntimeException('The options --name and --path cannot be combined.'); } $criteria['path'] = '/**/'.$args->getOption('name'); $criteria['language'] = $args->getOption('language'); } if ($args->isOptionSet('class')) { $criteria['class'] = $args->getOption('class'); } if ($args->isOptionSet('type')) { $criteria['bindingType'] = $args->getOption('type'); } if (empty($criteria)) { throw new RuntimeException('No search criteria specified.'); } return $this->listMatches($io, $criteria); }
php
public function handle(Args $args, IO $io) { $criteria = array(); if ($args->isOptionSet('path')) { $criteria['path'] = $args->getOption('path'); $criteria['language'] = $args->getOption('language'); } if ($args->isOptionSet('name')) { if (isset($criteria['path'])) { throw new RuntimeException('The options --name and --path cannot be combined.'); } $criteria['path'] = '/**/'.$args->getOption('name'); $criteria['language'] = $args->getOption('language'); } if ($args->isOptionSet('class')) { $criteria['class'] = $args->getOption('class'); } if ($args->isOptionSet('type')) { $criteria['bindingType'] = $args->getOption('type'); } if (empty($criteria)) { throw new RuntimeException('No search criteria specified.'); } return $this->listMatches($io, $criteria); }
[ "public", "function", "handle", "(", "Args", "$", "args", ",", "IO", "$", "io", ")", "{", "$", "criteria", "=", "array", "(", ")", ";", "if", "(", "$", "args", "->", "isOptionSet", "(", "'path'", ")", ")", "{", "$", "criteria", "[", "'path'", "]", "=", "$", "args", "->", "getOption", "(", "'path'", ")", ";", "$", "criteria", "[", "'language'", "]", "=", "$", "args", "->", "getOption", "(", "'language'", ")", ";", "}", "if", "(", "$", "args", "->", "isOptionSet", "(", "'name'", ")", ")", "{", "if", "(", "isset", "(", "$", "criteria", "[", "'path'", "]", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'The options --name and --path cannot be combined.'", ")", ";", "}", "$", "criteria", "[", "'path'", "]", "=", "'/**/'", ".", "$", "args", "->", "getOption", "(", "'name'", ")", ";", "$", "criteria", "[", "'language'", "]", "=", "$", "args", "->", "getOption", "(", "'language'", ")", ";", "}", "if", "(", "$", "args", "->", "isOptionSet", "(", "'class'", ")", ")", "{", "$", "criteria", "[", "'class'", "]", "=", "$", "args", "->", "getOption", "(", "'class'", ")", ";", "}", "if", "(", "$", "args", "->", "isOptionSet", "(", "'type'", ")", ")", "{", "$", "criteria", "[", "'bindingType'", "]", "=", "$", "args", "->", "getOption", "(", "'type'", ")", ";", "}", "if", "(", "empty", "(", "$", "criteria", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'No search criteria specified.'", ")", ";", "}", "return", "$", "this", "->", "listMatches", "(", "$", "io", ",", "$", "criteria", ")", ";", "}" ]
Handles the "find" command. @param Args $args The console arguments. @param IO $io The I/O. @return int The status code.
[ "Handles", "the", "find", "command", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/FindCommandHandler.php#L64-L95
225,949
puli/cli
src/Handler/FindCommandHandler.php
FindCommandHandler.listMatches
private function listMatches(IO $io, array $criteria) { if (isset($criteria['path']) && isset($criteria['bindingType'])) { $matches = array_intersect_key( $this->findByPath($criteria['path'], $criteria['language']), $this->findByBindingType($criteria['bindingType']) ); } elseif (isset($criteria['path'])) { $matches = $this->findByPath($criteria['path'], $criteria['language']); } elseif (isset($criteria['bindingType'])) { $matches = $this->findByBindingType($criteria['bindingType']); } else { $matches = $this->findByPath('/*'); } if (isset($criteria['class'])) { $shortClass = $criteria['class']; $matches = array_filter($matches, function ($value) use ($shortClass) { return $value === $shortClass; }); } $this->printTable($io, $matches); return 0; }
php
private function listMatches(IO $io, array $criteria) { if (isset($criteria['path']) && isset($criteria['bindingType'])) { $matches = array_intersect_key( $this->findByPath($criteria['path'], $criteria['language']), $this->findByBindingType($criteria['bindingType']) ); } elseif (isset($criteria['path'])) { $matches = $this->findByPath($criteria['path'], $criteria['language']); } elseif (isset($criteria['bindingType'])) { $matches = $this->findByBindingType($criteria['bindingType']); } else { $matches = $this->findByPath('/*'); } if (isset($criteria['class'])) { $shortClass = $criteria['class']; $matches = array_filter($matches, function ($value) use ($shortClass) { return $value === $shortClass; }); } $this->printTable($io, $matches); return 0; }
[ "private", "function", "listMatches", "(", "IO", "$", "io", ",", "array", "$", "criteria", ")", "{", "if", "(", "isset", "(", "$", "criteria", "[", "'path'", "]", ")", "&&", "isset", "(", "$", "criteria", "[", "'bindingType'", "]", ")", ")", "{", "$", "matches", "=", "array_intersect_key", "(", "$", "this", "->", "findByPath", "(", "$", "criteria", "[", "'path'", "]", ",", "$", "criteria", "[", "'language'", "]", ")", ",", "$", "this", "->", "findByBindingType", "(", "$", "criteria", "[", "'bindingType'", "]", ")", ")", ";", "}", "elseif", "(", "isset", "(", "$", "criteria", "[", "'path'", "]", ")", ")", "{", "$", "matches", "=", "$", "this", "->", "findByPath", "(", "$", "criteria", "[", "'path'", "]", ",", "$", "criteria", "[", "'language'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "criteria", "[", "'bindingType'", "]", ")", ")", "{", "$", "matches", "=", "$", "this", "->", "findByBindingType", "(", "$", "criteria", "[", "'bindingType'", "]", ")", ";", "}", "else", "{", "$", "matches", "=", "$", "this", "->", "findByPath", "(", "'/*'", ")", ";", "}", "if", "(", "isset", "(", "$", "criteria", "[", "'class'", "]", ")", ")", "{", "$", "shortClass", "=", "$", "criteria", "[", "'class'", "]", ";", "$", "matches", "=", "array_filter", "(", "$", "matches", ",", "function", "(", "$", "value", ")", "use", "(", "$", "shortClass", ")", "{", "return", "$", "value", "===", "$", "shortClass", ";", "}", ")", ";", "}", "$", "this", "->", "printTable", "(", "$", "io", ",", "$", "matches", ")", ";", "return", "0", ";", "}" ]
Lists the matches for the given search criteria. @param IO $io The I/O. @param array $criteria The array with the optional keys "pattern", "shortClass" and "bindingType". @return int The status code.
[ "Lists", "the", "matches", "for", "the", "given", "search", "criteria", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/FindCommandHandler.php#L106-L132
225,950
puli/cli
src/Handler/FindCommandHandler.php
FindCommandHandler.findByPath
private function findByPath($query, $language = 'glob') { $matches = array(); $query = '/'.ltrim($query, '/'); foreach ($this->repo->find($query, $language) as $resource) { $matches[$resource->getPath()] = StringUtil::getShortClassName(get_class($resource)); } return $matches; }
php
private function findByPath($query, $language = 'glob') { $matches = array(); $query = '/'.ltrim($query, '/'); foreach ($this->repo->find($query, $language) as $resource) { $matches[$resource->getPath()] = StringUtil::getShortClassName(get_class($resource)); } return $matches; }
[ "private", "function", "findByPath", "(", "$", "query", ",", "$", "language", "=", "'glob'", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "$", "query", "=", "'/'", ".", "ltrim", "(", "$", "query", ",", "'/'", ")", ";", "foreach", "(", "$", "this", "->", "repo", "->", "find", "(", "$", "query", ",", "$", "language", ")", "as", "$", "resource", ")", "{", "$", "matches", "[", "$", "resource", "->", "getPath", "(", ")", "]", "=", "StringUtil", "::", "getShortClassName", "(", "get_class", "(", "$", "resource", ")", ")", ";", "}", "return", "$", "matches", ";", "}" ]
Finds the resources for a given path pattern. @param string $query The resource query. @param string $language The language of the query. @return string[] An array of short resource class names indexed by the resource path.
[ "Finds", "the", "resources", "for", "a", "given", "path", "pattern", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/FindCommandHandler.php#L143-L153
225,951
puli/cli
src/Handler/FindCommandHandler.php
FindCommandHandler.findByBindingType
private function findByBindingType($typeName) { $matches = array(); $expr = Expr::isInstanceOf('Puli\Discovery\Binding\ResourceBinding'); foreach ($this->discovery->findBindings($typeName, $expr) as $binding) { /** @var ResourceBinding $binding */ foreach ($binding->getResources() as $resource) { $matches[$resource->getPath()] = StringUtil::getShortClassName(get_class($resource)); } } ksort($matches); return $matches; }
php
private function findByBindingType($typeName) { $matches = array(); $expr = Expr::isInstanceOf('Puli\Discovery\Binding\ResourceBinding'); foreach ($this->discovery->findBindings($typeName, $expr) as $binding) { /** @var ResourceBinding $binding */ foreach ($binding->getResources() as $resource) { $matches[$resource->getPath()] = StringUtil::getShortClassName(get_class($resource)); } } ksort($matches); return $matches; }
[ "private", "function", "findByBindingType", "(", "$", "typeName", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "$", "expr", "=", "Expr", "::", "isInstanceOf", "(", "'Puli\\Discovery\\Binding\\ResourceBinding'", ")", ";", "foreach", "(", "$", "this", "->", "discovery", "->", "findBindings", "(", "$", "typeName", ",", "$", "expr", ")", "as", "$", "binding", ")", "{", "/** @var ResourceBinding $binding */", "foreach", "(", "$", "binding", "->", "getResources", "(", ")", "as", "$", "resource", ")", "{", "$", "matches", "[", "$", "resource", "->", "getPath", "(", ")", "]", "=", "StringUtil", "::", "getShortClassName", "(", "get_class", "(", "$", "resource", ")", ")", ";", "}", "}", "ksort", "(", "$", "matches", ")", ";", "return", "$", "matches", ";", "}" ]
Finds the resources for a given binding type. @param string $typeName The type name. @return string[] An array of short resource class names indexed by the resource path.
[ "Finds", "the", "resources", "for", "a", "given", "binding", "type", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/FindCommandHandler.php#L163-L179
225,952
puli/cli
src/Handler/FindCommandHandler.php
FindCommandHandler.printTable
private function printTable(IO $io, array $matches) { $table = new Table(TableStyle::borderless()); foreach ($matches as $path => $shortClass) { $table->addRow(array($shortClass, sprintf('<c1>%s</c1>', $path))); } $table->render($io); }
php
private function printTable(IO $io, array $matches) { $table = new Table(TableStyle::borderless()); foreach ($matches as $path => $shortClass) { $table->addRow(array($shortClass, sprintf('<c1>%s</c1>', $path))); } $table->render($io); }
[ "private", "function", "printTable", "(", "IO", "$", "io", ",", "array", "$", "matches", ")", "{", "$", "table", "=", "new", "Table", "(", "TableStyle", "::", "borderless", "(", ")", ")", ";", "foreach", "(", "$", "matches", "as", "$", "path", "=>", "$", "shortClass", ")", "{", "$", "table", "->", "addRow", "(", "array", "(", "$", "shortClass", ",", "sprintf", "(", "'<c1>%s</c1>'", ",", "$", "path", ")", ")", ")", ";", "}", "$", "table", "->", "render", "(", "$", "io", ")", ";", "}" ]
Prints the given resources. @param IO $io The I/O. @param string[] $matches An array of short resource class names indexed by the resource path.
[ "Prints", "the", "given", "resources", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/FindCommandHandler.php#L188-L197
225,953
ccottet/ldap
Core/Node.php
Node.hydrateFromEntry
public function hydrateFromEntry(EntryInterface $entry) { $this->dn = $entry->getDn(); $this->attributes = array(); foreach ($entry->getAttributes() as $name => $data) { $attr = new NodeAttribute($name); $attr->add($data); $this->mergeAttribute($attr); } $this->snapshot(); }
php
public function hydrateFromEntry(EntryInterface $entry) { $this->dn = $entry->getDn(); $this->attributes = array(); foreach ($entry->getAttributes() as $name => $data) { $attr = new NodeAttribute($name); $attr->add($data); $this->mergeAttribute($attr); } $this->snapshot(); }
[ "public", "function", "hydrateFromEntry", "(", "EntryInterface", "$", "entry", ")", "{", "$", "this", "->", "dn", "=", "$", "entry", "->", "getDn", "(", ")", ";", "$", "this", "->", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "$", "entry", "->", "getAttributes", "(", ")", "as", "$", "name", "=>", "$", "data", ")", "{", "$", "attr", "=", "new", "NodeAttribute", "(", "$", "name", ")", ";", "$", "attr", "->", "add", "(", "$", "data", ")", ";", "$", "this", "->", "mergeAttribute", "(", "$", "attr", ")", ";", "}", "$", "this", "->", "snapshot", "(", ")", ";", "}" ]
Hydrate from a LDAP entry @param EntryInterface $entry Entry to use for loading @return void
[ "Hydrate", "from", "a", "LDAP", "entry" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L51-L64
225,954
ccottet/ldap
Core/Node.php
Node.setDn
public function setDn($dn, $force = false) { if (($this->isHydrated) && (! $force)) { throw new \InvalidArgumentException('Dn cannot be updated manually'); } $this->dn = $dn; }
php
public function setDn($dn, $force = false) { if (($this->isHydrated) && (! $force)) { throw new \InvalidArgumentException('Dn cannot be updated manually'); } $this->dn = $dn; }
[ "public", "function", "setDn", "(", "$", "dn", ",", "$", "force", "=", "false", ")", "{", "if", "(", "(", "$", "this", "->", "isHydrated", ")", "&&", "(", "!", "$", "force", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Dn cannot be updated manually'", ")", ";", "}", "$", "this", "->", "dn", "=", "$", "dn", ";", "}" ]
Setter for distinguished name @param string $dn Distinguished name @param boolean $force Whether to force dn change (Default: false) @return void @throws InvalidArgumentException If entry is bound
[ "Setter", "for", "distinguished", "name" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L86-L92
225,955
ccottet/ldap
Core/Node.php
Node.removeAttribute
public function removeAttribute($name) { if (! $this->has($name)) { return false; } unset($this->attributes[$name]); $this->tracker->logDeletion($name); return true; }
php
public function removeAttribute($name) { if (! $this->has($name)) { return false; } unset($this->attributes[$name]); $this->tracker->logDeletion($name); return true; }
[ "public", "function", "removeAttribute", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "unset", "(", "$", "this", "->", "attributes", "[", "$", "name", "]", ")", ";", "$", "this", "->", "tracker", "->", "logDeletion", "(", "$", "name", ")", ";", "return", "true", ";", "}" ]
Removes an attribute from the node store @param string $name Attribute name @return boolean true on success
[ "Removes", "an", "attribute", "from", "the", "node", "store" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L144-L152
225,956
ccottet/ldap
Core/Node.php
Node.get
public function get($name, $create = false) { if (! $this->has($name)) { if (! $create) { return null; } $this->mergeAttribute(new NodeAttribute($name)); } return $this->attributes[$name]; }
php
public function get($name, $create = false) { if (! $this->has($name)) { if (! $create) { return null; } $this->mergeAttribute(new NodeAttribute($name)); } return $this->attributes[$name]; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "create", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "if", "(", "!", "$", "create", ")", "{", "return", "null", ";", "}", "$", "this", "->", "mergeAttribute", "(", "new", "NodeAttribute", "(", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "attributes", "[", "$", "name", "]", ";", "}" ]
Retrieves an attribute from its name @param string $name Name of the attribute to look for @param boolean $create Whether to create a new instance if it is not set (Default: false) @return NodeAttribute or null if it does not exist and $create is false
[ "Retrieves", "an", "attribute", "from", "its", "name" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L162-L171
225,957
ccottet/ldap
Core/Node.php
Node.getDiffAdditions
public function getDiffAdditions() { $data = $this->getValueDiffData('getDiffAdditions'); foreach ($this->tracker->getAdditions() as $name) { $data[$name] = $this->get($name)->getValues(); } return $data; }
php
public function getDiffAdditions() { $data = $this->getValueDiffData('getDiffAdditions'); foreach ($this->tracker->getAdditions() as $name) { $data[$name] = $this->get($name)->getValues(); } return $data; }
[ "public", "function", "getDiffAdditions", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getValueDiffData", "(", "'getDiffAdditions'", ")", ";", "foreach", "(", "$", "this", "->", "tracker", "->", "getAdditions", "(", ")", "as", "$", "name", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "this", "->", "get", "(", "$", "name", ")", "->", "getValues", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retrieves diff additions for the attribute @return array Added values
[ "Retrieves", "diff", "additions", "for", "the", "attribute" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L190-L197
225,958
ccottet/ldap
Core/Node.php
Node.getDiffDeletions
public function getDiffDeletions() { $data = $this->getValueDiffData('getDiffDeletions'); foreach ($this->tracker->getDeletions() as $name) { $data[$name] = array(); } return $data; }
php
public function getDiffDeletions() { $data = $this->getValueDiffData('getDiffDeletions'); foreach ($this->tracker->getDeletions() as $name) { $data[$name] = array(); } return $data; }
[ "public", "function", "getDiffDeletions", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getValueDiffData", "(", "'getDiffDeletions'", ")", ";", "foreach", "(", "$", "this", "->", "tracker", "->", "getDeletions", "(", ")", "as", "$", "name", ")", "{", "$", "data", "[", "$", "name", "]", "=", "array", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retrieves diff deletions for the attribute @return array Deleted values
[ "Retrieves", "diff", "deletions", "for", "the", "attribute" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L204-L211
225,959
ccottet/ldap
Core/Node.php
Node.getValueDiffData
protected function getValueDiffData($method) { $data = array(); foreach ($this->getSafeAttributes() as $attribute) { $buffer = call_user_func(array($attribute, $method)); if (count($buffer) > 0) { $data[$attribute->getName()] = $buffer; } } return $data; }
php
protected function getValueDiffData($method) { $data = array(); foreach ($this->getSafeAttributes() as $attribute) { $buffer = call_user_func(array($attribute, $method)); if (count($buffer) > 0) { $data[$attribute->getName()] = $buffer; } } return $data; }
[ "protected", "function", "getValueDiffData", "(", "$", "method", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getSafeAttributes", "(", ")", "as", "$", "attribute", ")", "{", "$", "buffer", "=", "call_user_func", "(", "array", "(", "$", "attribute", ",", "$", "method", ")", ")", ";", "if", "(", "count", "(", "$", "buffer", ")", ">", "0", ")", "{", "$", "data", "[", "$", "attribute", "->", "getName", "(", ")", "]", "=", "$", "buffer", ";", "}", "}", "return", "$", "data", ";", "}" ]
Retrieve attribute value level diff information @param string $method Name of the diff method to use on the attribute @return array Diff data
[ "Retrieve", "attribute", "value", "level", "diff", "information" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L220-L230
225,960
ccottet/ldap
Core/Node.php
Node.getDiffReplacements
public function getDiffReplacements() { $data = array(); foreach ($this->getSafeAttributes() as $attribute) { if ($attribute->isReplaced()) { $data[$attribute->getName()] = $attribute->getValues(); } } foreach ($this->tracker->getReplacements() as $name) { $data[$name] = $this->get($name)->getValues(); } return $data; }
php
public function getDiffReplacements() { $data = array(); foreach ($this->getSafeAttributes() as $attribute) { if ($attribute->isReplaced()) { $data[$attribute->getName()] = $attribute->getValues(); } } foreach ($this->tracker->getReplacements() as $name) { $data[$name] = $this->get($name)->getValues(); } return $data; }
[ "public", "function", "getDiffReplacements", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getSafeAttributes", "(", ")", "as", "$", "attribute", ")", "{", "if", "(", "$", "attribute", "->", "isReplaced", "(", ")", ")", "{", "$", "data", "[", "$", "attribute", "->", "getName", "(", ")", "]", "=", "$", "attribute", "->", "getValues", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "tracker", "->", "getReplacements", "(", ")", "as", "$", "name", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "this", "->", "get", "(", "$", "name", ")", "->", "getValues", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retrieves diff replacements for the attribute @return array Replaced values
[ "Retrieves", "diff", "replacements", "for", "the", "attribute" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L259-L271
225,961
ccottet/ldap
Core/Node.php
Node.snapshot
public function snapshot($isHydrated = true) { $this->tracker->reset(); foreach ($this->attributes as $attribute) { $attribute->snapshot(); } if ($isHydrated) { $this->isHydrated = true; } }
php
public function snapshot($isHydrated = true) { $this->tracker->reset(); foreach ($this->attributes as $attribute) { $attribute->snapshot(); } if ($isHydrated) { $this->isHydrated = true; } }
[ "public", "function", "snapshot", "(", "$", "isHydrated", "=", "true", ")", "{", "$", "this", "->", "tracker", "->", "reset", "(", ")", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attribute", ")", "{", "$", "attribute", "->", "snapshot", "(", ")", ";", "}", "if", "(", "$", "isHydrated", ")", "{", "$", "this", "->", "isHydrated", "=", "true", ";", "}", "}" ]
Snapshot resets diff tracking @param boolean $isHydrated Whether snapshot is due to hydration (Default: true) @return void
[ "Snapshot", "resets", "diff", "tracking" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L280-L289
225,962
ccottet/ldap
Core/Node.php
Node.getRawAttributes
public function getRawAttributes() { $data = array(); foreach ($this->attributes as $name => $attribute) { $data[$name] = $attribute->getValues(); } return $data; }
php
public function getRawAttributes() { $data = array(); foreach ($this->attributes as $name => $attribute) { $data[$name] = $attribute->getValues(); } return $data; }
[ "public", "function", "getRawAttributes", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "name", "=>", "$", "attribute", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "attribute", "->", "getValues", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retrieves attribute data in a raw format for persistence operations @return array Raw data of attributes
[ "Retrieves", "attribute", "data", "in", "a", "raw", "format", "for", "persistence", "operations" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L306-L313
225,963
ccottet/ldap
Core/Node.php
Node.rebaseDiff
public function rebaseDiff(Node $node) { $changes = array_merge( $node->getDiffAdditions(), $node->getDiffDeletions(), $node->getDiffReplacements() ); if (count($changes) > 0) { throw new RebaseException( sprintf( '%s has some uncommitted changes - Cannot rebase %s on %s', $node->getDn(), $this->getDn(), $node->getDn() ) ); } $additions = $this->getDiffAdditions(); $deletions = $this->getDiffDeletions(); $replacements = $this->getDiffReplacements(); $this->snapshot(); $this->attributes = $node->getAttributes(); foreach ($additions as $attribute => $values) { $this->get($attribute, true)->add($values); } foreach ($deletions as $attribute => $values) { if (count($values) == 0) { $this->removeAttribute($attribute); } else { if ($this->has($attribute)) { $this->get($attribute)->remove($values); } } } foreach ($replacements as $attribute => $values) { $this->get($attribute, true)->set($values); } }
php
public function rebaseDiff(Node $node) { $changes = array_merge( $node->getDiffAdditions(), $node->getDiffDeletions(), $node->getDiffReplacements() ); if (count($changes) > 0) { throw new RebaseException( sprintf( '%s has some uncommitted changes - Cannot rebase %s on %s', $node->getDn(), $this->getDn(), $node->getDn() ) ); } $additions = $this->getDiffAdditions(); $deletions = $this->getDiffDeletions(); $replacements = $this->getDiffReplacements(); $this->snapshot(); $this->attributes = $node->getAttributes(); foreach ($additions as $attribute => $values) { $this->get($attribute, true)->add($values); } foreach ($deletions as $attribute => $values) { if (count($values) == 0) { $this->removeAttribute($attribute); } else { if ($this->has($attribute)) { $this->get($attribute)->remove($values); } } } foreach ($replacements as $attribute => $values) { $this->get($attribute, true)->set($values); } }
[ "public", "function", "rebaseDiff", "(", "Node", "$", "node", ")", "{", "$", "changes", "=", "array_merge", "(", "$", "node", "->", "getDiffAdditions", "(", ")", ",", "$", "node", "->", "getDiffDeletions", "(", ")", ",", "$", "node", "->", "getDiffReplacements", "(", ")", ")", ";", "if", "(", "count", "(", "$", "changes", ")", ">", "0", ")", "{", "throw", "new", "RebaseException", "(", "sprintf", "(", "'%s has some uncommitted changes - Cannot rebase %s on %s'", ",", "$", "node", "->", "getDn", "(", ")", ",", "$", "this", "->", "getDn", "(", ")", ",", "$", "node", "->", "getDn", "(", ")", ")", ")", ";", "}", "$", "additions", "=", "$", "this", "->", "getDiffAdditions", "(", ")", ";", "$", "deletions", "=", "$", "this", "->", "getDiffDeletions", "(", ")", ";", "$", "replacements", "=", "$", "this", "->", "getDiffReplacements", "(", ")", ";", "$", "this", "->", "snapshot", "(", ")", ";", "$", "this", "->", "attributes", "=", "$", "node", "->", "getAttributes", "(", ")", ";", "foreach", "(", "$", "additions", "as", "$", "attribute", "=>", "$", "values", ")", "{", "$", "this", "->", "get", "(", "$", "attribute", ",", "true", ")", "->", "add", "(", "$", "values", ")", ";", "}", "foreach", "(", "$", "deletions", "as", "$", "attribute", "=>", "$", "values", ")", "{", "if", "(", "count", "(", "$", "values", ")", "==", "0", ")", "{", "$", "this", "->", "removeAttribute", "(", "$", "attribute", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "$", "this", "->", "get", "(", "$", "attribute", ")", "->", "remove", "(", "$", "values", ")", ";", "}", "}", "}", "foreach", "(", "$", "replacements", "as", "$", "attribute", "=>", "$", "values", ")", "{", "$", "this", "->", "get", "(", "$", "attribute", ",", "true", ")", "->", "set", "(", "$", "values", ")", ";", "}", "}" ]
Rebase diff based on source node as an origin @param Node $node Node to use as a source for origin @return void @throws RebaseException If source of origin node has uncommitted changes
[ "Rebase", "diff", "based", "on", "source", "node", "as", "an", "origin" ]
0759f17996fbb434ee5155dc527b95d8059c6d41
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/Node.php#L324-L361
225,964
web3p/rlp
src/RLP.php
RLP.decode
public function decode(string $input) { // if (!is_string($input)) { // throw new InvalidArgumentException('Input must be string when call decode.'); // } $input = $this->toBuffer($input); $decoded = $this->decodeData($input); return $decoded['data']; }
php
public function decode(string $input) { // if (!is_string($input)) { // throw new InvalidArgumentException('Input must be string when call decode.'); // } $input = $this->toBuffer($input); $decoded = $this->decodeData($input); return $decoded['data']; }
[ "public", "function", "decode", "(", "string", "$", "input", ")", "{", "// if (!is_string($input)) {\r", "// throw new InvalidArgumentException('Input must be string when call decode.');\r", "// }\r", "$", "input", "=", "$", "this", "->", "toBuffer", "(", "$", "input", ")", ";", "$", "decoded", "=", "$", "this", "->", "decodeData", "(", "$", "input", ")", ";", "return", "$", "decoded", "[", "'data'", "]", ";", "}" ]
decode Maybe use bignumber future. @param string $input @return array
[ "decode", "Maybe", "use", "bignumber", "future", "." ]
76f2a6a1800e2756bf2eb9b41bd4f2f91ce05c37
https://github.com/web3p/rlp/blob/76f2a6a1800e2756bf2eb9b41bd4f2f91ce05c37/src/RLP.php#L55-L64
225,965
web3p/rlp
src/RLP.php
RLP.toBuffer
protected function toBuffer($input) { if (is_string($input)) { if (strpos($input, '0x') === 0) { // hex string // $input = str_replace('0x', '', $input); return new Buffer($input, 'hex'); } return new Buffer(str_split($input, 1)); } elseif (is_numeric($input)) { if (!$input || $input < 0) { return new Buffer([]); } if (is_float($input)) { $input = number_format($input, 0, '', ''); var_dump($input); } $gmpInput = gmp_init($input, 10); return new Buffer('0x' . gmp_strval($gmpInput, 16), 'hex'); } elseif ($input === null) { return new Buffer([]); } elseif (is_array($input)) { return new Buffer($input); } elseif ($input instanceof Buffer) { return $input; } throw new InvalidArgumentException('The input type didn\'t support.'); }
php
protected function toBuffer($input) { if (is_string($input)) { if (strpos($input, '0x') === 0) { // hex string // $input = str_replace('0x', '', $input); return new Buffer($input, 'hex'); } return new Buffer(str_split($input, 1)); } elseif (is_numeric($input)) { if (!$input || $input < 0) { return new Buffer([]); } if (is_float($input)) { $input = number_format($input, 0, '', ''); var_dump($input); } $gmpInput = gmp_init($input, 10); return new Buffer('0x' . gmp_strval($gmpInput, 16), 'hex'); } elseif ($input === null) { return new Buffer([]); } elseif (is_array($input)) { return new Buffer($input); } elseif ($input instanceof Buffer) { return $input; } throw new InvalidArgumentException('The input type didn\'t support.'); }
[ "protected", "function", "toBuffer", "(", "$", "input", ")", "{", "if", "(", "is_string", "(", "$", "input", ")", ")", "{", "if", "(", "strpos", "(", "$", "input", ",", "'0x'", ")", "===", "0", ")", "{", "// hex string\r", "// $input = str_replace('0x', '', $input);\r", "return", "new", "Buffer", "(", "$", "input", ",", "'hex'", ")", ";", "}", "return", "new", "Buffer", "(", "str_split", "(", "$", "input", ",", "1", ")", ")", ";", "}", "elseif", "(", "is_numeric", "(", "$", "input", ")", ")", "{", "if", "(", "!", "$", "input", "||", "$", "input", "<", "0", ")", "{", "return", "new", "Buffer", "(", "[", "]", ")", ";", "}", "if", "(", "is_float", "(", "$", "input", ")", ")", "{", "$", "input", "=", "number_format", "(", "$", "input", ",", "0", ",", "''", ",", "''", ")", ";", "var_dump", "(", "$", "input", ")", ";", "}", "$", "gmpInput", "=", "gmp_init", "(", "$", "input", ",", "10", ")", ";", "return", "new", "Buffer", "(", "'0x'", ".", "gmp_strval", "(", "$", "gmpInput", ",", "16", ")", ",", "'hex'", ")", ";", "}", "elseif", "(", "$", "input", "===", "null", ")", "{", "return", "new", "Buffer", "(", "[", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "input", ")", ")", "{", "return", "new", "Buffer", "(", "$", "input", ")", ";", "}", "elseif", "(", "$", "input", "instanceof", "Buffer", ")", "{", "return", "$", "input", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'The input type didn\\'t support.'", ")", ";", "}" ]
toBuffer Format input to buffer. @param mixed $input @return \Web3p\RLP\Buffer
[ "toBuffer", "Format", "input", "to", "buffer", "." ]
76f2a6a1800e2756bf2eb9b41bd4f2f91ce05c37
https://github.com/web3p/rlp/blob/76f2a6a1800e2756bf2eb9b41bd4f2f91ce05c37/src/RLP.php#L245-L272
225,966
puli/cli
src/Handler/UpgradeCommandHandler.php
UpgradeCommandHandler.handle
public function handle(Args $args, IO $io) { $moduleFile = $this->moduleFileManager->getModuleFile(); $originVersion = $moduleFile->getVersion(); $targetVersion = $args->getArgument('version'); if (version_compare($originVersion, $targetVersion, '=')) { $io->writeLine(sprintf('Your puli.json is already at version %s.', $targetVersion)); return 0; } $this->moduleFileManager->migrate($targetVersion); $io->writeLine(sprintf( 'Migrated your puli.json from version %s to version %s.', $originVersion, $targetVersion )); return 0; }
php
public function handle(Args $args, IO $io) { $moduleFile = $this->moduleFileManager->getModuleFile(); $originVersion = $moduleFile->getVersion(); $targetVersion = $args->getArgument('version'); if (version_compare($originVersion, $targetVersion, '=')) { $io->writeLine(sprintf('Your puli.json is already at version %s.', $targetVersion)); return 0; } $this->moduleFileManager->migrate($targetVersion); $io->writeLine(sprintf( 'Migrated your puli.json from version %s to version %s.', $originVersion, $targetVersion )); return 0; }
[ "public", "function", "handle", "(", "Args", "$", "args", ",", "IO", "$", "io", ")", "{", "$", "moduleFile", "=", "$", "this", "->", "moduleFileManager", "->", "getModuleFile", "(", ")", ";", "$", "originVersion", "=", "$", "moduleFile", "->", "getVersion", "(", ")", ";", "$", "targetVersion", "=", "$", "args", "->", "getArgument", "(", "'version'", ")", ";", "if", "(", "version_compare", "(", "$", "originVersion", ",", "$", "targetVersion", ",", "'='", ")", ")", "{", "$", "io", "->", "writeLine", "(", "sprintf", "(", "'Your puli.json is already at version %s.'", ",", "$", "targetVersion", ")", ")", ";", "return", "0", ";", "}", "$", "this", "->", "moduleFileManager", "->", "migrate", "(", "$", "targetVersion", ")", ";", "$", "io", "->", "writeLine", "(", "sprintf", "(", "'Migrated your puli.json from version %s to version %s.'", ",", "$", "originVersion", ",", "$", "targetVersion", ")", ")", ";", "return", "0", ";", "}" ]
Handles the "upgrade" command. @param Args $args The console arguments @param IO $io The I/O @return int The status code
[ "Handles", "the", "upgrade", "command", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/UpgradeCommandHandler.php#L51-L72
225,967
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.render
public function render() { $item_output = ''; $item = $this->get_item(); $index = $this->get_index(); $trail = $this->get_trail(); $trail_renderer = $this->get_trail_renderer(); // Link before and opening <a>. $item_output .= $this->render_link_before(); // Title along with its wrappers. $item_output .= $this->render_title(); // Closing </a> and link after. $item_output .= $this->render_link_after(); // Allow item output to be filtered. return apply_filters( 'carbon_breadcrumbs_item_output', $item_output, $item, $trail, $trail_renderer, $index ); }
php
public function render() { $item_output = ''; $item = $this->get_item(); $index = $this->get_index(); $trail = $this->get_trail(); $trail_renderer = $this->get_trail_renderer(); // Link before and opening <a>. $item_output .= $this->render_link_before(); // Title along with its wrappers. $item_output .= $this->render_title(); // Closing </a> and link after. $item_output .= $this->render_link_after(); // Allow item output to be filtered. return apply_filters( 'carbon_breadcrumbs_item_output', $item_output, $item, $trail, $trail_renderer, $index ); }
[ "public", "function", "render", "(", ")", "{", "$", "item_output", "=", "''", ";", "$", "item", "=", "$", "this", "->", "get_item", "(", ")", ";", "$", "index", "=", "$", "this", "->", "get_index", "(", ")", ";", "$", "trail", "=", "$", "this", "->", "get_trail", "(", ")", ";", "$", "trail_renderer", "=", "$", "this", "->", "get_trail_renderer", "(", ")", ";", "// Link before and opening <a>.", "$", "item_output", ".=", "$", "this", "->", "render_link_before", "(", ")", ";", "// Title along with its wrappers.", "$", "item_output", ".=", "$", "this", "->", "render_title", "(", ")", ";", "// Closing </a> and link after.", "$", "item_output", ".=", "$", "this", "->", "render_link_after", "(", ")", ";", "// Allow item output to be filtered.", "return", "apply_filters", "(", "'carbon_breadcrumbs_item_output'", ",", "$", "item_output", ",", "$", "item", ",", "$", "trail", ",", "$", "trail_renderer", ",", "$", "index", ")", ";", "}" ]
Render the item. @access public @return string $item_output The HTML of this item.
[ "Render", "the", "item", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L73-L91
225,968
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.get_item_link
public function get_item_link() { $item = $this->get_item(); $item_link = apply_filters( 'carbon_breadcrumbs_item_link', $item->get_link(), $item ); return $item_link; }
php
public function get_item_link() { $item = $this->get_item(); $item_link = apply_filters( 'carbon_breadcrumbs_item_link', $item->get_link(), $item ); return $item_link; }
[ "public", "function", "get_item_link", "(", ")", "{", "$", "item", "=", "$", "this", "->", "get_item", "(", ")", ";", "$", "item_link", "=", "apply_filters", "(", "'carbon_breadcrumbs_item_link'", ",", "$", "item", "->", "get_link", "(", ")", ",", "$", "item", ")", ";", "return", "$", "item_link", ";", "}" ]
Retrieve the item link URL. @access public @return string $item_link The link URL of this item.
[ "Retrieve", "the", "item", "link", "URL", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L100-L104
225,969
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.render_link_before
public function render_link_before() { $trail_renderer = $this->get_trail_renderer(); $item_link = $this->get_item_link(); // HTML before link opening tag. $output = $trail_renderer->get_link_before(); // Link can be optional or disabled. if ( $item_link && $this->is_link_enabled() ) { $output .= '<a href="' . $item_link . '"' . $this->get_item_attributes_html() . '>'; } return $output; }
php
public function render_link_before() { $trail_renderer = $this->get_trail_renderer(); $item_link = $this->get_item_link(); // HTML before link opening tag. $output = $trail_renderer->get_link_before(); // Link can be optional or disabled. if ( $item_link && $this->is_link_enabled() ) { $output .= '<a href="' . $item_link . '"' . $this->get_item_attributes_html() . '>'; } return $output; }
[ "public", "function", "render_link_before", "(", ")", "{", "$", "trail_renderer", "=", "$", "this", "->", "get_trail_renderer", "(", ")", ";", "$", "item_link", "=", "$", "this", "->", "get_item_link", "(", ")", ";", "// HTML before link opening tag.", "$", "output", "=", "$", "trail_renderer", "->", "get_link_before", "(", ")", ";", "// Link can be optional or disabled.", "if", "(", "$", "item_link", "&&", "$", "this", "->", "is_link_enabled", "(", ")", ")", "{", "$", "output", ".=", "'<a href=\"'", ".", "$", "item_link", ".", "'\"'", ".", "$", "this", "->", "get_item_attributes_html", "(", ")", ".", "'>'", ";", "}", "return", "$", "output", ";", "}" ]
Render the item link opening tag and its "before" wrapper. @access public @return string $output The output HTML.
[ "Render", "the", "item", "link", "opening", "tag", "and", "its", "before", "wrapper", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L113-L126
225,970
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.render_link_after
public function render_link_after() { $trail_renderer = $this->get_trail_renderer(); $item_link = $this->get_item_link(); $output = ''; // Link can be optional or disabled. if ( $item_link && $this->is_link_enabled() ) { $output .= '</a>'; } // HTML after link closing tag. $output .= $trail_renderer->get_link_after(); return $output; }
php
public function render_link_after() { $trail_renderer = $this->get_trail_renderer(); $item_link = $this->get_item_link(); $output = ''; // Link can be optional or disabled. if ( $item_link && $this->is_link_enabled() ) { $output .= '</a>'; } // HTML after link closing tag. $output .= $trail_renderer->get_link_after(); return $output; }
[ "public", "function", "render_link_after", "(", ")", "{", "$", "trail_renderer", "=", "$", "this", "->", "get_trail_renderer", "(", ")", ";", "$", "item_link", "=", "$", "this", "->", "get_item_link", "(", ")", ";", "$", "output", "=", "''", ";", "// Link can be optional or disabled.", "if", "(", "$", "item_link", "&&", "$", "this", "->", "is_link_enabled", "(", ")", ")", "{", "$", "output", ".=", "'</a>'", ";", "}", "// HTML after link closing tag.", "$", "output", ".=", "$", "trail_renderer", "->", "get_link_after", "(", ")", ";", "return", "$", "output", ";", "}" ]
Render the item link closing tag and its "after" wrapper. @access public @return string $output The output HTML.
[ "Render", "the", "item", "link", "closing", "tag", "and", "its", "after", "wrapper", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L135-L149
225,971
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.render_title
public function render_title() { $item = $this->get_item(); $trail_renderer = $this->get_trail_renderer(); // HTML before title. $output = $trail_renderer->get_title_before(); // Breadcrumb item title. $output .= apply_filters( 'carbon_breadcrumbs_item_title', $item->get_title(), $item ); // HTML after title. $output .= $trail_renderer->get_title_after(); return $output; }
php
public function render_title() { $item = $this->get_item(); $trail_renderer = $this->get_trail_renderer(); // HTML before title. $output = $trail_renderer->get_title_before(); // Breadcrumb item title. $output .= apply_filters( 'carbon_breadcrumbs_item_title', $item->get_title(), $item ); // HTML after title. $output .= $trail_renderer->get_title_after(); return $output; }
[ "public", "function", "render_title", "(", ")", "{", "$", "item", "=", "$", "this", "->", "get_item", "(", ")", ";", "$", "trail_renderer", "=", "$", "this", "->", "get_trail_renderer", "(", ")", ";", "// HTML before title.", "$", "output", "=", "$", "trail_renderer", "->", "get_title_before", "(", ")", ";", "// Breadcrumb item title.", "$", "output", ".=", "apply_filters", "(", "'carbon_breadcrumbs_item_title'", ",", "$", "item", "->", "get_title", "(", ")", ",", "$", "item", ")", ";", "// HTML after title.", "$", "output", ".=", "$", "trail_renderer", "->", "get_title_after", "(", ")", ";", "return", "$", "output", ";", "}" ]
Render the item title, along with its before & after wrappers. @access public @return string $output The output HTML.
[ "Render", "the", "item", "title", "along", "with", "its", "before", "&", "after", "wrappers", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L158-L172
225,972
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.get_item_attributes_html
public function get_item_attributes_html() { $item = $this->get_item(); // Get the item attributes. $item_attributes = apply_filters( 'carbon_breadcrumbs_item_attributes', $item->get_attributes(), $item ); // Prepare the item attributes. $attributes_html = ''; foreach ( $item_attributes as $attr => $attr_value ) { $attributes_html .= ' ' . $attr . '="' . esc_attr( $attr_value ) . '"'; } return $attributes_html; }
php
public function get_item_attributes_html() { $item = $this->get_item(); // Get the item attributes. $item_attributes = apply_filters( 'carbon_breadcrumbs_item_attributes', $item->get_attributes(), $item ); // Prepare the item attributes. $attributes_html = ''; foreach ( $item_attributes as $attr => $attr_value ) { $attributes_html .= ' ' . $attr . '="' . esc_attr( $attr_value ) . '"'; } return $attributes_html; }
[ "public", "function", "get_item_attributes_html", "(", ")", "{", "$", "item", "=", "$", "this", "->", "get_item", "(", ")", ";", "// Get the item attributes.", "$", "item_attributes", "=", "apply_filters", "(", "'carbon_breadcrumbs_item_attributes'", ",", "$", "item", "->", "get_attributes", "(", ")", ",", "$", "item", ")", ";", "// Prepare the item attributes.", "$", "attributes_html", "=", "''", ";", "foreach", "(", "$", "item_attributes", "as", "$", "attr", "=>", "$", "attr_value", ")", "{", "$", "attributes_html", ".=", "' '", ".", "$", "attr", ".", "'=\"'", ".", "esc_attr", "(", "$", "attr_value", ")", ".", "'\"'", ";", "}", "return", "$", "attributes_html", ";", "}" ]
Retrieve the attributes of the item link. @access public @return string $attributes_html The HTML of the item attributes.
[ "Retrieve", "the", "attributes", "of", "the", "item", "link", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L181-L194
225,973
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item-renderer.php
Carbon_Breadcrumb_Item_Renderer.is_link_enabled
public function is_link_enabled() { $trail = $this->get_trail(); $trail_renderer = $this->get_trail_renderer(); $total_items = $trail->get_total_items(); $index = $this->get_index(); return $trail_renderer->get_last_item_link() || $index < $total_items; }
php
public function is_link_enabled() { $trail = $this->get_trail(); $trail_renderer = $this->get_trail_renderer(); $total_items = $trail->get_total_items(); $index = $this->get_index(); return $trail_renderer->get_last_item_link() || $index < $total_items; }
[ "public", "function", "is_link_enabled", "(", ")", "{", "$", "trail", "=", "$", "this", "->", "get_trail", "(", ")", ";", "$", "trail_renderer", "=", "$", "this", "->", "get_trail_renderer", "(", ")", ";", "$", "total_items", "=", "$", "trail", "->", "get_total_items", "(", ")", ";", "$", "index", "=", "$", "this", "->", "get_index", "(", ")", ";", "return", "$", "trail_renderer", "->", "get_last_item_link", "(", ")", "||", "$", "index", "<", "$", "total_items", ";", "}" ]
Whether the link of this item is enabled. @access public @return bool
[ "Whether", "the", "link", "of", "this", "item", "is", "enabled", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-renderer.php#L203-L210
225,974
growthexponent/laravel-html-dom-parser
src/LaravelHtmlDomParser/CurlProxy.php
CurlProxy.get
public function get($url, $proxy = null) { $referer = "http://example.com/"; $agent = "My PHP Script"; $aHTTP['http']['proxy'] = 'tcp://'.$proxy[0].':'.$proxy[1]; // The proxy ip and port number $aHTTP['http']['request_fulluri'] = true; // use the full URI in the Request. I.e. http://brugbart.com/Examples/ip.php $aHTTP['http']['method'] = 'GET'; $aHTTP['http']['header'] = "User-Agent: ".$agent."\r\n"; $aHTTP['http']['header'] .= "Referer: ".$referer."\r\n"; $context = stream_context_create($aHTTP); $content = file_get_contents($url, false, $context); /* * // Couldn't get working using Curl in the short timeframe I had, may come back to it later * $ch = curl_init($url); if ($proxy != null) { curl_setopt($ch, CURLOPT_PROXY, $proxy[0]); curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]); } curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $content = curl_exec($ch); */ if ($content === false) { // there was a problem //$error = curl_error($ch); //throw new CurlException('Error retrieving "'.$url.'" ('.$error.')'); throw new CurlException('Error retrieving "'.$url.'"'); } return $content; }
php
public function get($url, $proxy = null) { $referer = "http://example.com/"; $agent = "My PHP Script"; $aHTTP['http']['proxy'] = 'tcp://'.$proxy[0].':'.$proxy[1]; // The proxy ip and port number $aHTTP['http']['request_fulluri'] = true; // use the full URI in the Request. I.e. http://brugbart.com/Examples/ip.php $aHTTP['http']['method'] = 'GET'; $aHTTP['http']['header'] = "User-Agent: ".$agent."\r\n"; $aHTTP['http']['header'] .= "Referer: ".$referer."\r\n"; $context = stream_context_create($aHTTP); $content = file_get_contents($url, false, $context); /* * // Couldn't get working using Curl in the short timeframe I had, may come back to it later * $ch = curl_init($url); if ($proxy != null) { curl_setopt($ch, CURLOPT_PROXY, $proxy[0]); curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]); } curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $content = curl_exec($ch); */ if ($content === false) { // there was a problem //$error = curl_error($ch); //throw new CurlException('Error retrieving "'.$url.'" ('.$error.')'); throw new CurlException('Error retrieving "'.$url.'"'); } return $content; }
[ "public", "function", "get", "(", "$", "url", ",", "$", "proxy", "=", "null", ")", "{", "$", "referer", "=", "\"http://example.com/\"", ";", "$", "agent", "=", "\"My PHP Script\"", ";", "$", "aHTTP", "[", "'http'", "]", "[", "'proxy'", "]", "=", "'tcp://'", ".", "$", "proxy", "[", "0", "]", ".", "':'", ".", "$", "proxy", "[", "1", "]", ";", "// The proxy ip and port number", "$", "aHTTP", "[", "'http'", "]", "[", "'request_fulluri'", "]", "=", "true", ";", "// use the full URI in the Request. I.e. http://brugbart.com/Examples/ip.php", "$", "aHTTP", "[", "'http'", "]", "[", "'method'", "]", "=", "'GET'", ";", "$", "aHTTP", "[", "'http'", "]", "[", "'header'", "]", "=", "\"User-Agent: \"", ".", "$", "agent", ".", "\"\\r\\n\"", ";", "$", "aHTTP", "[", "'http'", "]", "[", "'header'", "]", ".=", "\"Referer: \"", ".", "$", "referer", ".", "\"\\r\\n\"", ";", "$", "context", "=", "stream_context_create", "(", "$", "aHTTP", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "url", ",", "false", ",", "$", "context", ")", ";", "/*\n * // Couldn't get working using Curl in the short timeframe I had, may come back to it later\n *\n $ch = curl_init($url);\n if ($proxy != null) {\n curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);\n curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);\n }\n curl_setopt($ch, CURLOPT_REFERER, $referer);\n curl_setopt($ch, CURLOPT_USERAGENT, $agent);\n\n curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);\n\n $content = curl_exec($ch);\n */", "if", "(", "$", "content", "===", "false", ")", "{", "// there was a problem", "//$error = curl_error($ch);", "//throw new CurlException('Error retrieving \"'.$url.'\" ('.$error.')');", "throw", "new", "CurlException", "(", "'Error retrieving \"'", ".", "$", "url", ".", "'\"'", ")", ";", "}", "return", "$", "content", ";", "}" ]
A simple curl implementation to get the content of the url via a proxy server. @param string $url @param array $proxy // server[0] and port[1] @return string @throws CurlException
[ "A", "simple", "curl", "implementation", "to", "get", "the", "content", "of", "the", "url", "via", "a", "proxy", "server", "." ]
36c84d704f2360b214f457a5e3a0930a19bd7b57
https://github.com/growthexponent/laravel-html-dom-parser/blob/36c84d704f2360b214f457a5e3a0930a19bd7b57/src/LaravelHtmlDomParser/CurlProxy.php#L25-L65
225,975
tyxla/carbon-breadcrumbs
core/class-carbon-breadcrumb-item.php
Carbon_Breadcrumb_Item.factory
public static function factory( $type = 'custom', $priority = 1000 ) { $class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb item type: "' . $type . '".' ); $item = new $class( $priority ); $item->set_type( $type ); return $item; }
php
public static function factory( $type = 'custom', $priority = 1000 ) { $class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb item type: "' . $type . '".' ); $item = new $class( $priority ); $item->set_type( $type ); return $item; }
[ "public", "static", "function", "factory", "(", "$", "type", "=", "'custom'", ",", "$", "priority", "=", "1000", ")", "{", "$", "class", "=", "self", "::", "verify_class_name", "(", "__CLASS__", ".", "'_'", ".", "$", "type", ",", "'Unexisting breadcrumb item type: \"'", ".", "$", "type", ".", "'\".'", ")", ";", "$", "item", "=", "new", "$", "class", "(", "$", "priority", ")", ";", "$", "item", "->", "set_type", "(", "$", "type", ")", ";", "return", "$", "item", ";", "}" ]
Build a new breadcrumb item of the selected type. @static @access public @param string $type Type of the breadcrumb item. @param int $priority Priority of this breadcrumb item. @return Carbon_Breadcrumb_Item $item The new breadcrumb item.
[ "Build", "a", "new", "breadcrumb", "item", "of", "the", "selected", "type", "." ]
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item.php#L75-L82
225,976
puli/cli
src/Util/ArgsUtil.php
ArgsUtil.getModuleNames
public static function getModuleNames(Args $args, ModuleList $modules) { // Display all modules if "all" is set if ($args->isOptionSet('all')) { return $modules->getModuleNames(); } $moduleNames = array(); if ($args->isOptionSet('root')) { $moduleNames[] = $modules->getRootModuleName(); } foreach ($args->getOption('module') as $moduleName) { $moduleNames[] = $moduleName; } return $moduleNames ?: $modules->getModuleNames(); }
php
public static function getModuleNames(Args $args, ModuleList $modules) { // Display all modules if "all" is set if ($args->isOptionSet('all')) { return $modules->getModuleNames(); } $moduleNames = array(); if ($args->isOptionSet('root')) { $moduleNames[] = $modules->getRootModuleName(); } foreach ($args->getOption('module') as $moduleName) { $moduleNames[] = $moduleName; } return $moduleNames ?: $modules->getModuleNames(); }
[ "public", "static", "function", "getModuleNames", "(", "Args", "$", "args", ",", "ModuleList", "$", "modules", ")", "{", "// Display all modules if \"all\" is set", "if", "(", "$", "args", "->", "isOptionSet", "(", "'all'", ")", ")", "{", "return", "$", "modules", "->", "getModuleNames", "(", ")", ";", "}", "$", "moduleNames", "=", "array", "(", ")", ";", "if", "(", "$", "args", "->", "isOptionSet", "(", "'root'", ")", ")", "{", "$", "moduleNames", "[", "]", "=", "$", "modules", "->", "getRootModuleName", "(", ")", ";", "}", "foreach", "(", "$", "args", "->", "getOption", "(", "'module'", ")", "as", "$", "moduleName", ")", "{", "$", "moduleNames", "[", "]", "=", "$", "moduleName", ";", "}", "return", "$", "moduleNames", "?", ":", "$", "modules", "->", "getModuleNames", "(", ")", ";", "}" ]
Returns the modules selected in the console arguments. @param Args $args The console arguments @param ModuleList $modules The available modules @return string[] The module names
[ "Returns", "the", "modules", "selected", "in", "the", "console", "arguments", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Util/ArgsUtil.php#L34-L52
225,977
puli/cli
src/Util/ArgsUtil.php
ArgsUtil.getModuleNamesWithoutRoot
public static function getModuleNamesWithoutRoot(Args $args, ModuleList $modules) { // Display all modules if "all" is set if ($args->isOptionSet('all')) { return $modules->getInstalledModuleNames(); } $moduleNames = array(); foreach ($args->getOption('module') as $moduleName) { $moduleNames[] = $moduleName; } return $moduleNames ?: $modules->getInstalledModuleNames(); }
php
public static function getModuleNamesWithoutRoot(Args $args, ModuleList $modules) { // Display all modules if "all" is set if ($args->isOptionSet('all')) { return $modules->getInstalledModuleNames(); } $moduleNames = array(); foreach ($args->getOption('module') as $moduleName) { $moduleNames[] = $moduleName; } return $moduleNames ?: $modules->getInstalledModuleNames(); }
[ "public", "static", "function", "getModuleNamesWithoutRoot", "(", "Args", "$", "args", ",", "ModuleList", "$", "modules", ")", "{", "// Display all modules if \"all\" is set", "if", "(", "$", "args", "->", "isOptionSet", "(", "'all'", ")", ")", "{", "return", "$", "modules", "->", "getInstalledModuleNames", "(", ")", ";", "}", "$", "moduleNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "args", "->", "getOption", "(", "'module'", ")", "as", "$", "moduleName", ")", "{", "$", "moduleNames", "[", "]", "=", "$", "moduleName", ";", "}", "return", "$", "moduleNames", "?", ":", "$", "modules", "->", "getInstalledModuleNames", "(", ")", ";", "}" ]
Returns the non-root modules selected in the console arguments. @param Args $args The console arguments @param ModuleList $modules The available modules @return string[] The module names
[ "Returns", "the", "non", "-", "root", "modules", "selected", "in", "the", "console", "arguments", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Util/ArgsUtil.php#L62-L76
225,978
puli/cli
src/Handler/BindCommandHandler.php
BindCommandHandler.getBindingStates
private function getBindingStates(Args $args) { $states = array( BindingState::ENABLED => 'enabled', BindingState::DISABLED => 'disabled', BindingState::TYPE_NOT_FOUND => 'type-not-found', BindingState::TYPE_NOT_ENABLED => 'type-not-enabled', BindingState::INVALID => 'invalid', ); $states = array_filter($states, function ($option) use ($args) { return $args->isOptionSet($option); }); return array_keys($states) ?: BindingState::all(); }
php
private function getBindingStates(Args $args) { $states = array( BindingState::ENABLED => 'enabled', BindingState::DISABLED => 'disabled', BindingState::TYPE_NOT_FOUND => 'type-not-found', BindingState::TYPE_NOT_ENABLED => 'type-not-enabled', BindingState::INVALID => 'invalid', ); $states = array_filter($states, function ($option) use ($args) { return $args->isOptionSet($option); }); return array_keys($states) ?: BindingState::all(); }
[ "private", "function", "getBindingStates", "(", "Args", "$", "args", ")", "{", "$", "states", "=", "array", "(", "BindingState", "::", "ENABLED", "=>", "'enabled'", ",", "BindingState", "::", "DISABLED", "=>", "'disabled'", ",", "BindingState", "::", "TYPE_NOT_FOUND", "=>", "'type-not-found'", ",", "BindingState", "::", "TYPE_NOT_ENABLED", "=>", "'type-not-enabled'", ",", "BindingState", "::", "INVALID", "=>", "'invalid'", ",", ")", ";", "$", "states", "=", "array_filter", "(", "$", "states", ",", "function", "(", "$", "option", ")", "use", "(", "$", "args", ")", "{", "return", "$", "args", "->", "isOptionSet", "(", "$", "option", ")", ";", "}", ")", ";", "return", "array_keys", "(", "$", "states", ")", "?", ":", "BindingState", "::", "all", "(", ")", ";", "}" ]
Returns the binding states selected in the console arguments. @param Args $args The console arguments @return int[] The selected {@link BindingState} constants
[ "Returns", "the", "binding", "states", "selected", "in", "the", "console", "arguments", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/BindCommandHandler.php#L289-L304
225,979
puli/cli
src/Handler/BindCommandHandler.php
BindCommandHandler.printBindingTable
private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true) { $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('UUID', 'Glob', 'Type')); $paramTag = $enabled ? 'c1' : 'bad'; $artifactTag = $enabled ? 'c1' : 'bad'; $typeTag = $enabled ? 'u' : 'bad'; foreach ($descriptors as $descriptor) { $parameters = array(); $binding = $descriptor->getBinding(); foreach ($binding->getParameterValues() as $parameterName => $parameterValue) { $parameters[] = $parameterName.'='.StringUtil::formatValue($parameterValue); } $uuid = substr($descriptor->getUuid(), 0, 6); if (!$enabled) { $uuid = sprintf('<bad>%s</bad>', $uuid); } $paramString = ''; if (!empty($parameters)) { // \xc2\xa0 is a non-breaking space $paramString = sprintf( ' <%s>(%s)</%s>', $paramTag, implode(",\xc2\xa0", $parameters), $paramTag ); } if ($binding instanceof ResourceBinding) { $artifact = $binding->getQuery(); } elseif ($binding instanceof ClassBinding) { $artifact = StringUtil::getShortClassName($binding->getClassName()); } else { continue; } $typeString = StringUtil::getShortClassName($binding->getTypeName()); $table->addRow(array( $uuid, sprintf('<%s>%s</%s>', $artifactTag, $artifact, $artifactTag), sprintf('<%s>%s</%s>%s', $typeTag, $typeString, $typeTag, $paramString), )); } $table->render($io, $indentation); }
php
private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true) { $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('UUID', 'Glob', 'Type')); $paramTag = $enabled ? 'c1' : 'bad'; $artifactTag = $enabled ? 'c1' : 'bad'; $typeTag = $enabled ? 'u' : 'bad'; foreach ($descriptors as $descriptor) { $parameters = array(); $binding = $descriptor->getBinding(); foreach ($binding->getParameterValues() as $parameterName => $parameterValue) { $parameters[] = $parameterName.'='.StringUtil::formatValue($parameterValue); } $uuid = substr($descriptor->getUuid(), 0, 6); if (!$enabled) { $uuid = sprintf('<bad>%s</bad>', $uuid); } $paramString = ''; if (!empty($parameters)) { // \xc2\xa0 is a non-breaking space $paramString = sprintf( ' <%s>(%s)</%s>', $paramTag, implode(",\xc2\xa0", $parameters), $paramTag ); } if ($binding instanceof ResourceBinding) { $artifact = $binding->getQuery(); } elseif ($binding instanceof ClassBinding) { $artifact = StringUtil::getShortClassName($binding->getClassName()); } else { continue; } $typeString = StringUtil::getShortClassName($binding->getTypeName()); $table->addRow(array( $uuid, sprintf('<%s>%s</%s>', $artifactTag, $artifact, $artifactTag), sprintf('<%s>%s</%s>%s', $typeTag, $typeString, $typeTag, $paramString), )); } $table->render($io, $indentation); }
[ "private", "function", "printBindingTable", "(", "IO", "$", "io", ",", "array", "$", "descriptors", ",", "$", "indentation", "=", "0", ",", "$", "enabled", "=", "true", ")", "{", "$", "table", "=", "new", "Table", "(", "PuliTableStyle", "::", "borderless", "(", ")", ")", ";", "$", "table", "->", "setHeaderRow", "(", "array", "(", "'UUID'", ",", "'Glob'", ",", "'Type'", ")", ")", ";", "$", "paramTag", "=", "$", "enabled", "?", "'c1'", ":", "'bad'", ";", "$", "artifactTag", "=", "$", "enabled", "?", "'c1'", ":", "'bad'", ";", "$", "typeTag", "=", "$", "enabled", "?", "'u'", ":", "'bad'", ";", "foreach", "(", "$", "descriptors", "as", "$", "descriptor", ")", "{", "$", "parameters", "=", "array", "(", ")", ";", "$", "binding", "=", "$", "descriptor", "->", "getBinding", "(", ")", ";", "foreach", "(", "$", "binding", "->", "getParameterValues", "(", ")", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "$", "parameters", "[", "]", "=", "$", "parameterName", ".", "'='", ".", "StringUtil", "::", "formatValue", "(", "$", "parameterValue", ")", ";", "}", "$", "uuid", "=", "substr", "(", "$", "descriptor", "->", "getUuid", "(", ")", ",", "0", ",", "6", ")", ";", "if", "(", "!", "$", "enabled", ")", "{", "$", "uuid", "=", "sprintf", "(", "'<bad>%s</bad>'", ",", "$", "uuid", ")", ";", "}", "$", "paramString", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "parameters", ")", ")", "{", "// \\xc2\\xa0 is a non-breaking space", "$", "paramString", "=", "sprintf", "(", "' <%s>(%s)</%s>'", ",", "$", "paramTag", ",", "implode", "(", "\",\\xc2\\xa0\"", ",", "$", "parameters", ")", ",", "$", "paramTag", ")", ";", "}", "if", "(", "$", "binding", "instanceof", "ResourceBinding", ")", "{", "$", "artifact", "=", "$", "binding", "->", "getQuery", "(", ")", ";", "}", "elseif", "(", "$", "binding", "instanceof", "ClassBinding", ")", "{", "$", "artifact", "=", "StringUtil", "::", "getShortClassName", "(", "$", "binding", "->", "getClassName", "(", ")", ")", ";", "}", "else", "{", "continue", ";", "}", "$", "typeString", "=", "StringUtil", "::", "getShortClassName", "(", "$", "binding", "->", "getTypeName", "(", ")", ")", ";", "$", "table", "->", "addRow", "(", "array", "(", "$", "uuid", ",", "sprintf", "(", "'<%s>%s</%s>'", ",", "$", "artifactTag", ",", "$", "artifact", ",", "$", "artifactTag", ")", ",", "sprintf", "(", "'<%s>%s</%s>%s'", ",", "$", "typeTag", ",", "$", "typeString", ",", "$", "typeTag", ",", "$", "paramString", ")", ",", ")", ")", ";", "}", "$", "table", "->", "render", "(", "$", "io", ",", "$", "indentation", ")", ";", "}" ]
Prints a list of binding descriptors. @param IO $io The I/O @param BindingDescriptor[] $descriptors The binding descriptors @param int $indentation The number of spaces to indent @param bool $enabled Whether the binding descriptors are enabled. If not, the output is printed in red
[ "Prints", "a", "list", "of", "binding", "descriptors", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/BindCommandHandler.php#L316-L370
225,980
puli/cli
src/Handler/BindCommandHandler.php
BindCommandHandler.printBindingStateHeader
private function printBindingStateHeader(IO $io, $bindingState) { switch ($bindingState) { case BindingState::ENABLED: $io->writeLine('The following bindings are currently enabled:'); $io->writeLine(''); return; case BindingState::DISABLED: $io->writeLine('The following bindings are disabled:'); $io->writeLine(' (use "puli bind --enable <uuid>" to enable)'); $io->writeLine(''); return; case BindingState::TYPE_NOT_FOUND: $io->writeLine('The types of the following bindings could not be found:'); $io->writeLine(' (install or create their type definitions to enable)'); $io->writeLine(''); return; case BindingState::TYPE_NOT_ENABLED: $io->writeLine('The types of the following bindings are not enabled:'); $io->writeLine(' (remove the duplicate type definitions to enable)'); $io->writeLine(''); return; case BindingState::INVALID: $io->writeLine('The following bindings have invalid parameters:'); $io->writeLine(' (remove the binding and add again with correct parameters)'); $io->writeLine(''); return; } }
php
private function printBindingStateHeader(IO $io, $bindingState) { switch ($bindingState) { case BindingState::ENABLED: $io->writeLine('The following bindings are currently enabled:'); $io->writeLine(''); return; case BindingState::DISABLED: $io->writeLine('The following bindings are disabled:'); $io->writeLine(' (use "puli bind --enable <uuid>" to enable)'); $io->writeLine(''); return; case BindingState::TYPE_NOT_FOUND: $io->writeLine('The types of the following bindings could not be found:'); $io->writeLine(' (install or create their type definitions to enable)'); $io->writeLine(''); return; case BindingState::TYPE_NOT_ENABLED: $io->writeLine('The types of the following bindings are not enabled:'); $io->writeLine(' (remove the duplicate type definitions to enable)'); $io->writeLine(''); return; case BindingState::INVALID: $io->writeLine('The following bindings have invalid parameters:'); $io->writeLine(' (remove the binding and add again with correct parameters)'); $io->writeLine(''); return; } }
[ "private", "function", "printBindingStateHeader", "(", "IO", "$", "io", ",", "$", "bindingState", ")", "{", "switch", "(", "$", "bindingState", ")", "{", "case", "BindingState", "::", "ENABLED", ":", "$", "io", "->", "writeLine", "(", "'The following bindings are currently enabled:'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "BindingState", "::", "DISABLED", ":", "$", "io", "->", "writeLine", "(", "'The following bindings are disabled:'", ")", ";", "$", "io", "->", "writeLine", "(", "' (use \"puli bind --enable <uuid>\" to enable)'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "BindingState", "::", "TYPE_NOT_FOUND", ":", "$", "io", "->", "writeLine", "(", "'The types of the following bindings could not be found:'", ")", ";", "$", "io", "->", "writeLine", "(", "' (install or create their type definitions to enable)'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "BindingState", "::", "TYPE_NOT_ENABLED", ":", "$", "io", "->", "writeLine", "(", "'The types of the following bindings are not enabled:'", ")", ";", "$", "io", "->", "writeLine", "(", "' (remove the duplicate type definitions to enable)'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "case", "BindingState", "::", "INVALID", ":", "$", "io", "->", "writeLine", "(", "'The following bindings have invalid parameters:'", ")", ";", "$", "io", "->", "writeLine", "(", "' (remove the binding and add again with correct parameters)'", ")", ";", "$", "io", "->", "writeLine", "(", "''", ")", ";", "return", ";", "}", "}" ]
Prints the header for a binding state. @param IO $io The I/O @param int $bindingState The {@link BindingState} constant
[ "Prints", "the", "header", "for", "a", "binding", "state", "." ]
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/BindCommandHandler.php#L378-L411
225,981
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.resetPath
public function resetPath($path = '') { $this->blob = (new Blob($this->package))->setPath($path); // Ensure that user folder exists on first load $userFolder = Str::normalizePath(config('cripfilesys.user_folder')); if ($this->blob->path == $userFolder) { $this->makeDirectory(); } }
php
public function resetPath($path = '') { $this->blob = (new Blob($this->package))->setPath($path); // Ensure that user folder exists on first load $userFolder = Str::normalizePath(config('cripfilesys.user_folder')); if ($this->blob->path == $userFolder) { $this->makeDirectory(); } }
[ "public", "function", "resetPath", "(", "$", "path", "=", "''", ")", "{", "$", "this", "->", "blob", "=", "(", "new", "Blob", "(", "$", "this", "->", "package", ")", ")", "->", "setPath", "(", "$", "path", ")", ";", "// Ensure that user folder exists on first load", "$", "userFolder", "=", "Str", "::", "normalizePath", "(", "config", "(", "'cripfilesys.user_folder'", ")", ")", ";", "if", "(", "$", "this", "->", "blob", "->", "path", "==", "$", "userFolder", ")", "{", "$", "this", "->", "makeDirectory", "(", ")", ";", "}", "}" ]
Reset current blob instance to the new path. @param string $path
[ "Reset", "current", "blob", "instance", "to", "the", "new", "path", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L50-L59
225,982
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.upload
public function upload(UploadedFile $uploadedFile) { if ($this->blob === null) { throw new \Exception('Blob path is not set yet.'); } $this->makeDirectory(); $path = $this->blob->path; $ext = $uploadedFile->getClientOriginalExtension(); $name = Slug::make(pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME)); $uniqueName = $this->getUniqueFileName($path, $name, $ext); $fullName = $uniqueName . '.' . $ext; $this->storage->putFileAs($path, $uploadedFile, $fullName); $path .= '/' . $fullName; $this->blob->path = $path; if ($this->getMetaData()->isImage()) { (new ThumbService($this->package)) ->resize($this->getMetaData()->getPath()); } return $this->fullDetails(); }
php
public function upload(UploadedFile $uploadedFile) { if ($this->blob === null) { throw new \Exception('Blob path is not set yet.'); } $this->makeDirectory(); $path = $this->blob->path; $ext = $uploadedFile->getClientOriginalExtension(); $name = Slug::make(pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME)); $uniqueName = $this->getUniqueFileName($path, $name, $ext); $fullName = $uniqueName . '.' . $ext; $this->storage->putFileAs($path, $uploadedFile, $fullName); $path .= '/' . $fullName; $this->blob->path = $path; if ($this->getMetaData()->isImage()) { (new ThumbService($this->package)) ->resize($this->getMetaData()->getPath()); } return $this->fullDetails(); }
[ "public", "function", "upload", "(", "UploadedFile", "$", "uploadedFile", ")", "{", "if", "(", "$", "this", "->", "blob", "===", "null", ")", "{", "throw", "new", "\\", "Exception", "(", "'Blob path is not set yet.'", ")", ";", "}", "$", "this", "->", "makeDirectory", "(", ")", ";", "$", "path", "=", "$", "this", "->", "blob", "->", "path", ";", "$", "ext", "=", "$", "uploadedFile", "->", "getClientOriginalExtension", "(", ")", ";", "$", "name", "=", "Slug", "::", "make", "(", "pathinfo", "(", "$", "uploadedFile", "->", "getClientOriginalName", "(", ")", ",", "PATHINFO_FILENAME", ")", ")", ";", "$", "uniqueName", "=", "$", "this", "->", "getUniqueFileName", "(", "$", "path", ",", "$", "name", ",", "$", "ext", ")", ";", "$", "fullName", "=", "$", "uniqueName", ".", "'.'", ".", "$", "ext", ";", "$", "this", "->", "storage", "->", "putFileAs", "(", "$", "path", ",", "$", "uploadedFile", ",", "$", "fullName", ")", ";", "$", "path", ".=", "'/'", ".", "$", "fullName", ";", "$", "this", "->", "blob", "->", "path", "=", "$", "path", ";", "if", "(", "$", "this", "->", "getMetaData", "(", ")", "->", "isImage", "(", ")", ")", "{", "(", "new", "ThumbService", "(", "$", "this", "->", "package", ")", ")", "->", "resize", "(", "$", "this", "->", "getMetaData", "(", ")", "->", "getPath", "(", ")", ")", ";", "}", "return", "$", "this", "->", "fullDetails", "(", ")", ";", "}" ]
Write the contents of a file on storage. @param UploadedFile $uploadedFile @return array|File|Folder @throws \Exception
[ "Write", "the", "contents", "of", "a", "file", "on", "storage", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L67-L94
225,983
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.rename
public function rename($name) { $name = Str::slug($name); if ($this->isFile()) { return $this->renameFile($name, $this->getMetaData()->getExtension()); } return $this->renameFolder($name); }
php
public function rename($name) { $name = Str::slug($name); if ($this->isFile()) { return $this->renameFile($name, $this->getMetaData()->getExtension()); } return $this->renameFolder($name); }
[ "public", "function", "rename", "(", "$", "name", ")", "{", "$", "name", "=", "Str", "::", "slug", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "isFile", "(", ")", ")", "{", "return", "$", "this", "->", "renameFile", "(", "$", "name", ",", "$", "this", "->", "getMetaData", "(", ")", "->", "getExtension", "(", ")", ")", ";", "}", "return", "$", "this", "->", "renameFolder", "(", "$", "name", ")", ";", "}" ]
Rename blob. @param string $name @return File|Folder
[ "Rename", "blob", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L101-L109
225,984
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.delete
public function delete() { $meta = $this->getMetaData(); if ($meta->isImage() || !$meta->isFile()) { $service = new ThumbService($this->package); $service->delete($meta->getPath(), !$meta->isFile()); } if ($meta->isFile()) { return $this->storage->delete($meta->getPath()); } return $this->storage->deleteDirectory($meta->getPath()); }
php
public function delete() { $meta = $this->getMetaData(); if ($meta->isImage() || !$meta->isFile()) { $service = new ThumbService($this->package); $service->delete($meta->getPath(), !$meta->isFile()); } if ($meta->isFile()) { return $this->storage->delete($meta->getPath()); } return $this->storage->deleteDirectory($meta->getPath()); }
[ "public", "function", "delete", "(", ")", "{", "$", "meta", "=", "$", "this", "->", "getMetaData", "(", ")", ";", "if", "(", "$", "meta", "->", "isImage", "(", ")", "||", "!", "$", "meta", "->", "isFile", "(", ")", ")", "{", "$", "service", "=", "new", "ThumbService", "(", "$", "this", "->", "package", ")", ";", "$", "service", "->", "delete", "(", "$", "meta", "->", "getPath", "(", ")", ",", "!", "$", "meta", "->", "isFile", "(", ")", ")", ";", "}", "if", "(", "$", "meta", "->", "isFile", "(", ")", ")", "{", "return", "$", "this", "->", "storage", "->", "delete", "(", "$", "meta", "->", "getPath", "(", ")", ")", ";", "}", "return", "$", "this", "->", "storage", "->", "deleteDirectory", "(", "$", "meta", "->", "getPath", "(", ")", ")", ";", "}" ]
Delete blob from storage. @return bool
[ "Delete", "blob", "from", "storage", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L115-L129
225,985
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.folderContent
public function folderContent() { $result = []; $path = $this->ensureUserPath($this->blob->path); $list = collect($this->storage->getDriver()->listContents($path)) ->pluck('path'); $exclude = (new ThumbService($this->package))->getSizes()->all(); $isExcluded = function ($path) use ($exclude) { $parts = explode('/', Str::normalizePath($path)); if (count($parts) > 0) { return array_key_exists($parts[0], $exclude); } return false; }; $list->each(function ($glob) use (&$result, $isExcluded) { if ($isExcluded($glob)) { // skip any thumbs dir and do not show it for users return; } $result[] = (new Blob($this->package)) ->setPath($glob) ->fullDetails(); }); return $result; }
php
public function folderContent() { $result = []; $path = $this->ensureUserPath($this->blob->path); $list = collect($this->storage->getDriver()->listContents($path)) ->pluck('path'); $exclude = (new ThumbService($this->package))->getSizes()->all(); $isExcluded = function ($path) use ($exclude) { $parts = explode('/', Str::normalizePath($path)); if (count($parts) > 0) { return array_key_exists($parts[0], $exclude); } return false; }; $list->each(function ($glob) use (&$result, $isExcluded) { if ($isExcluded($glob)) { // skip any thumbs dir and do not show it for users return; } $result[] = (new Blob($this->package)) ->setPath($glob) ->fullDetails(); }); return $result; }
[ "public", "function", "folderContent", "(", ")", "{", "$", "result", "=", "[", "]", ";", "$", "path", "=", "$", "this", "->", "ensureUserPath", "(", "$", "this", "->", "blob", "->", "path", ")", ";", "$", "list", "=", "collect", "(", "$", "this", "->", "storage", "->", "getDriver", "(", ")", "->", "listContents", "(", "$", "path", ")", ")", "->", "pluck", "(", "'path'", ")", ";", "$", "exclude", "=", "(", "new", "ThumbService", "(", "$", "this", "->", "package", ")", ")", "->", "getSizes", "(", ")", "->", "all", "(", ")", ";", "$", "isExcluded", "=", "function", "(", "$", "path", ")", "use", "(", "$", "exclude", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "Str", "::", "normalizePath", "(", "$", "path", ")", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "0", ")", "{", "return", "array_key_exists", "(", "$", "parts", "[", "0", "]", ",", "$", "exclude", ")", ";", "}", "return", "false", ";", "}", ";", "$", "list", "->", "each", "(", "function", "(", "$", "glob", ")", "use", "(", "&", "$", "result", ",", "$", "isExcluded", ")", "{", "if", "(", "$", "isExcluded", "(", "$", "glob", ")", ")", "{", "// skip any thumbs dir and do not show it for users", "return", ";", "}", "$", "result", "[", "]", "=", "(", "new", "Blob", "(", "$", "this", "->", "package", ")", ")", "->", "setPath", "(", "$", "glob", ")", "->", "fullDetails", "(", ")", ";", "}", ")", ";", "return", "$", "result", ";", "}" ]
Fetch folder content of the storage directory. @return array
[ "Fetch", "folder", "content", "of", "the", "storage", "directory", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L168-L198
225,986
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.blobExists
public function blobExists() { if ($this->blob->path . '' === '') { return true; } return $this->storage->exists($this->blob->path); }
php
public function blobExists() { if ($this->blob->path . '' === '') { return true; } return $this->storage->exists($this->blob->path); }
[ "public", "function", "blobExists", "(", ")", "{", "if", "(", "$", "this", "->", "blob", "->", "path", ".", "''", "===", "''", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "storage", "->", "exists", "(", "$", "this", "->", "blob", "->", "path", ")", ";", "}" ]
Determines is current blob path is existing in storage. @return bool
[ "Determines", "is", "current", "blob", "path", "is", "existing", "in", "storage", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L215-L222
225,987
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.isFile
public function isFile() { if ($this->blobExists()) { $metadata = $this->storage->getMetaData($this->blob->path); return $metadata['type'] === 'file'; } return false; }
php
public function isFile() { if ($this->blobExists()) { $metadata = $this->storage->getMetaData($this->blob->path); return $metadata['type'] === 'file'; } return false; }
[ "public", "function", "isFile", "(", ")", "{", "if", "(", "$", "this", "->", "blobExists", "(", ")", ")", "{", "$", "metadata", "=", "$", "this", "->", "storage", "->", "getMetaData", "(", "$", "this", "->", "blob", "->", "path", ")", ";", "return", "$", "metadata", "[", "'type'", "]", "===", "'file'", ";", "}", "return", "false", ";", "}" ]
Determines is the current blob of file type. @return bool
[ "Determines", "is", "the", "current", "blob", "of", "file", "type", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L228-L237
225,988
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.fileMimeType
public function fileMimeType() { try { $mimeType = $this->storage->mimeType($this->blob->path); } catch (\Exception $ex) { $ext = pathinfo($this->blob->path, PATHINFO_EXTENSION); $mimeType = BlobMetadata::guessMimeType($ext, !!$ext); } return $mimeType; }
php
public function fileMimeType() { try { $mimeType = $this->storage->mimeType($this->blob->path); } catch (\Exception $ex) { $ext = pathinfo($this->blob->path, PATHINFO_EXTENSION); $mimeType = BlobMetadata::guessMimeType($ext, !!$ext); } return $mimeType; }
[ "public", "function", "fileMimeType", "(", ")", "{", "try", "{", "$", "mimeType", "=", "$", "this", "->", "storage", "->", "mimeType", "(", "$", "this", "->", "blob", "->", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "ext", "=", "pathinfo", "(", "$", "this", "->", "blob", "->", "path", ",", "PATHINFO_EXTENSION", ")", ";", "$", "mimeType", "=", "BlobMetadata", "::", "guessMimeType", "(", "$", "ext", ",", "!", "!", "$", "ext", ")", ";", "}", "return", "$", "mimeType", ";", "}" ]
Get file mime type. @return string
[ "Get", "file", "mime", "type", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L243-L253
225,989
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.isSafe
public function isSafe($ext, $mime) { $unsafeExtensions = $this->package->config('block.extensions'); $unsafeMimes = $this->package->config('block.mimetypes'); $mimeSearch = function ($mimeValue) use ($mime) { return preg_match($mimeValue, $mime); }; if (in_array($ext, $unsafeExtensions)) { return false; } if (collect($unsafeMimes)->search($mimeSearch)) { return false; } return true; }
php
public function isSafe($ext, $mime) { $unsafeExtensions = $this->package->config('block.extensions'); $unsafeMimes = $this->package->config('block.mimetypes'); $mimeSearch = function ($mimeValue) use ($mime) { return preg_match($mimeValue, $mime); }; if (in_array($ext, $unsafeExtensions)) { return false; } if (collect($unsafeMimes)->search($mimeSearch)) { return false; } return true; }
[ "public", "function", "isSafe", "(", "$", "ext", ",", "$", "mime", ")", "{", "$", "unsafeExtensions", "=", "$", "this", "->", "package", "->", "config", "(", "'block.extensions'", ")", ";", "$", "unsafeMimes", "=", "$", "this", "->", "package", "->", "config", "(", "'block.mimetypes'", ")", ";", "$", "mimeSearch", "=", "function", "(", "$", "mimeValue", ")", "use", "(", "$", "mime", ")", "{", "return", "preg_match", "(", "$", "mimeValue", ",", "$", "mime", ")", ";", "}", ";", "if", "(", "in_array", "(", "$", "ext", ",", "$", "unsafeExtensions", ")", ")", "{", "return", "false", ";", "}", "if", "(", "collect", "(", "$", "unsafeMimes", ")", "->", "search", "(", "$", "mimeSearch", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determines is the file safe for upload. @param string $ext @param string $mime @return bool
[ "Determines", "is", "the", "file", "safe", "for", "upload", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L261-L278
225,990
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.getMetaData
public function getMetaData() { if (!$this->metadata) { $this->metadata = (new BlobMetadata())->init($this->blob->path); } return $this->metadata; }
php
public function getMetaData() { if (!$this->metadata) { $this->metadata = (new BlobMetadata())->init($this->blob->path); } return $this->metadata; }
[ "public", "function", "getMetaData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "metadata", ")", "{", "$", "this", "->", "metadata", "=", "(", "new", "BlobMetadata", "(", ")", ")", "->", "init", "(", "$", "this", "->", "blob", "->", "path", ")", ";", "}", "return", "$", "this", "->", "metadata", ";", "}" ]
Get blob meta data object. @return BlobMetadata
[ "Get", "blob", "meta", "data", "object", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L284-L291
225,991
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.fullDetails
public function fullDetails($reset = false) { return (new Blob($this->package)) ->setPath($this->blob->path) ->fullDetails($reset ? null : $this->getMetaData()); }
php
public function fullDetails($reset = false) { return (new Blob($this->package)) ->setPath($this->blob->path) ->fullDetails($reset ? null : $this->getMetaData()); }
[ "public", "function", "fullDetails", "(", "$", "reset", "=", "false", ")", "{", "return", "(", "new", "Blob", "(", "$", "this", "->", "package", ")", ")", "->", "setPath", "(", "$", "this", "->", "blob", "->", "path", ")", "->", "fullDetails", "(", "$", "reset", "?", "null", ":", "$", "this", "->", "getMetaData", "(", ")", ")", ";", "}" ]
Get full details of the current blob. @param bool $reset @return File|Folder
[ "Get", "full", "details", "of", "the", "current", "blob", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L298-L303
225,992
crip-laravel/filesys
src/Services/FilesysManager.php
FilesysManager.ensureUserPath
private function ensureUserPath(string $path): string { $userFolder = Str::normalizePath($this->package->config('user_folder')); if ($userFolder === '') { return $path; } if (starts_with($path, $userFolder)) { return $path; } return $userFolder . '/' . $path; }
php
private function ensureUserPath(string $path): string { $userFolder = Str::normalizePath($this->package->config('user_folder')); if ($userFolder === '') { return $path; } if (starts_with($path, $userFolder)) { return $path; } return $userFolder . '/' . $path; }
[ "private", "function", "ensureUserPath", "(", "string", "$", "path", ")", ":", "string", "{", "$", "userFolder", "=", "Str", "::", "normalizePath", "(", "$", "this", "->", "package", "->", "config", "(", "'user_folder'", ")", ")", ";", "if", "(", "$", "userFolder", "===", "''", ")", "{", "return", "$", "path", ";", "}", "if", "(", "starts_with", "(", "$", "path", ",", "$", "userFolder", ")", ")", "{", "return", "$", "path", ";", "}", "return", "$", "userFolder", ".", "'/'", ".", "$", "path", ";", "}" ]
Ensure that path contains prefix of user path; @param string $path @return string
[ "Ensure", "that", "path", "contains", "prefix", "of", "user", "path", ";" ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/FilesysManager.php#L369-L381
225,993
Techworker/ssml
src/Element/Custom.php
Custom.factory
public static function factory(string $name, array $attributes = []): Custom { $instance = new static(); $instance->name = $name; $instance->customAttributes = $attributes; return $instance; }
php
public static function factory(string $name, array $attributes = []): Custom { $instance = new static(); $instance->name = $name; $instance->customAttributes = $attributes; return $instance; }
[ "public", "static", "function", "factory", "(", "string", "$", "name", ",", "array", "$", "attributes", "=", "[", "]", ")", ":", "Custom", "{", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "instance", "->", "name", "=", "$", "name", ";", "$", "instance", "->", "customAttributes", "=", "$", "attributes", ";", "return", "$", "instance", ";", "}" ]
Creates a custom element with the given name and attributes. @param string $name The name of the element. @param array $attributes The attributes [key => value] @return Custom
[ "Creates", "a", "custom", "element", "with", "the", "given", "name", "and", "attributes", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Element/Custom.php#L37-L44
225,994
jagilpe/encryption-bundle
Crypt/CryptographyProvider.php
CryptographyProvider.getCipherMethod
private function getCipherMethod($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { $method = $this->settings['cipher_method'][$encType]; $supportedMethods = openssl_get_cipher_methods(); if (!in_array($method, $supportedMethods)) { throw new EncryptionException('Method '.$method.' not supported by openssl installation.'); } return $method; }
php
private function getCipherMethod($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { $method = $this->settings['cipher_method'][$encType]; $supportedMethods = openssl_get_cipher_methods(); if (!in_array($method, $supportedMethods)) { throw new EncryptionException('Method '.$method.' not supported by openssl installation.'); } return $method; }
[ "private", "function", "getCipherMethod", "(", "$", "encType", "=", "CryptographyProviderInterface", "::", "PROPERTY_ENCRYPTION", ")", "{", "$", "method", "=", "$", "this", "->", "settings", "[", "'cipher_method'", "]", "[", "$", "encType", "]", ";", "$", "supportedMethods", "=", "openssl_get_cipher_methods", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "method", ",", "$", "supportedMethods", ")", ")", "{", "throw", "new", "EncryptionException", "(", "'Method '", ".", "$", "method", ".", "' not supported by openssl installation.'", ")", ";", "}", "return", "$", "method", ";", "}" ]
Returns the cipher method corresponding to a determined element type @param string $encType @return string @throws EncryptionException
[ "Returns", "the", "cipher", "method", "corresponding", "to", "a", "determined", "element", "type" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/CryptographyProvider.php#L134-L144
225,995
jagilpe/encryption-bundle
Crypt/CryptographyProvider.php
CryptographyProvider.getSymmetricKeyLength
private function getSymmetricKeyLength($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { $cipherMethod = $this->getCipherMethod($encType); switch ($cipherMethod) { case 'AES-128-CBC': $length = 16; break; case 'AES-192-CBC': $length = 24; break; case 'AES-256-CBC': $length = 32; break; default: $length = 16; break; } return $length; }
php
private function getSymmetricKeyLength($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { $cipherMethod = $this->getCipherMethod($encType); switch ($cipherMethod) { case 'AES-128-CBC': $length = 16; break; case 'AES-192-CBC': $length = 24; break; case 'AES-256-CBC': $length = 32; break; default: $length = 16; break; } return $length; }
[ "private", "function", "getSymmetricKeyLength", "(", "$", "encType", "=", "CryptographyProviderInterface", "::", "PROPERTY_ENCRYPTION", ")", "{", "$", "cipherMethod", "=", "$", "this", "->", "getCipherMethod", "(", "$", "encType", ")", ";", "switch", "(", "$", "cipherMethod", ")", "{", "case", "'AES-128-CBC'", ":", "$", "length", "=", "16", ";", "break", ";", "case", "'AES-192-CBC'", ":", "$", "length", "=", "24", ";", "break", ";", "case", "'AES-256-CBC'", ":", "$", "length", "=", "32", ";", "break", ";", "default", ":", "$", "length", "=", "16", ";", "break", ";", "}", "return", "$", "length", ";", "}" ]
Returns the key length for the desired encryption method @param string $encType @return integer
[ "Returns", "the", "key", "length", "for", "the", "desired", "encryption", "method" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/CryptographyProvider.php#L153-L173
225,996
jagilpe/encryption-bundle
Crypt/CryptographyProvider.php
CryptographyProvider.getEncryptionOptions
private function getEncryptionOptions($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { switch ($encType) { case CryptographyProviderInterface::PROPERTY_ENCRYPTION: case CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION: return 0; case CryptographyProviderInterface::FILE_ENCRYPTION: return OPENSSL_RAW_DATA; default: throw new EncryptionException('Encryption type not supported: '.$encType); } }
php
private function getEncryptionOptions($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION) { switch ($encType) { case CryptographyProviderInterface::PROPERTY_ENCRYPTION: case CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION: return 0; case CryptographyProviderInterface::FILE_ENCRYPTION: return OPENSSL_RAW_DATA; default: throw new EncryptionException('Encryption type not supported: '.$encType); } }
[ "private", "function", "getEncryptionOptions", "(", "$", "encType", "=", "CryptographyProviderInterface", "::", "PROPERTY_ENCRYPTION", ")", "{", "switch", "(", "$", "encType", ")", "{", "case", "CryptographyProviderInterface", "::", "PROPERTY_ENCRYPTION", ":", "case", "CryptographyProviderInterface", "::", "PRIVATE_KEY_ENCRYPTION", ":", "return", "0", ";", "case", "CryptographyProviderInterface", "::", "FILE_ENCRYPTION", ":", "return", "OPENSSL_RAW_DATA", ";", "default", ":", "throw", "new", "EncryptionException", "(", "'Encryption type not supported: '", ".", "$", "encType", ")", ";", "}", "}" ]
Returns the options for the encryption depending on the encryption type @param string $encType @return int @throws EncryptionException
[ "Returns", "the", "options", "for", "the", "encryption", "depending", "on", "the", "encryption", "type" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/CryptographyProvider.php#L182-L193
225,997
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/AbstractClient.php
AbstractClient.response
public static function response($data, $type = self::FORMAT_XML) { if (is_string($data) && strlen($data) === 0) { return true; // Many operations return an empty string for success } switch ($type) { case static::FORMAT_XML: return AbstractResponse::fromXml($data); case static::FORMAT_JSON: return AbstractResponse::fromJson($data); } throw new InvalidArgumentException("Type must be 'xml' or 'json'"); }
php
public static function response($data, $type = self::FORMAT_XML) { if (is_string($data) && strlen($data) === 0) { return true; // Many operations return an empty string for success } switch ($type) { case static::FORMAT_XML: return AbstractResponse::fromXml($data); case static::FORMAT_JSON: return AbstractResponse::fromJson($data); } throw new InvalidArgumentException("Type must be 'xml' or 'json'"); }
[ "public", "static", "function", "response", "(", "$", "data", ",", "$", "type", "=", "self", "::", "FORMAT_XML", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", "&&", "strlen", "(", "$", "data", ")", "===", "0", ")", "{", "return", "true", ";", "// Many operations return an empty string for success", "}", "switch", "(", "$", "type", ")", "{", "case", "static", "::", "FORMAT_XML", ":", "return", "AbstractResponse", "::", "fromXml", "(", "$", "data", ")", ";", "case", "static", "::", "FORMAT_JSON", ":", "return", "AbstractResponse", "::", "fromJson", "(", "$", "data", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "\"Type must be 'xml' or 'json'\"", ")", ";", "}" ]
Parse a response into a response type @static @param string $data Response data to be parsed @param string $type = 'xml' Response format @return mixed Response object
[ "Parse", "a", "response", "into", "a", "response", "type" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/AbstractClient.php#L52-L64
225,998
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/AbstractClient.php
AbstractClient.get
public function get($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); if ($request) { $requestUri = $this->buildQuery($uri, $request->getQuery()); } else { $requestUri = $uri; } $http->setOption(CURLOPT_URL, $requestUri); return $http->execute(); }
php
public function get($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); if ($request) { $requestUri = $this->buildQuery($uri, $request->getQuery()); } else { $requestUri = $uri; } $http->setOption(CURLOPT_URL, $requestUri); return $http->execute(); }
[ "public", "function", "get", "(", "$", "uri", ",", "AbstractRequest", "$", "request", "=", "null", ")", "{", "$", "http", "=", "$", "this", "->", "getHttpClone", "(", ")", ";", "if", "(", "$", "request", ")", "{", "$", "requestUri", "=", "$", "this", "->", "buildQuery", "(", "$", "uri", ",", "$", "request", "->", "getQuery", "(", ")", ")", ";", "}", "else", "{", "$", "requestUri", "=", "$", "uri", ";", "}", "$", "http", "->", "setOption", "(", "CURLOPT_URL", ",", "$", "requestUri", ")", ";", "return", "$", "http", "->", "execute", "(", ")", ";", "}" ]
Execute a GET request against an API endpoint, optionally with a given Request object as parameters @param string $uri Endpoint URL @param AbstractRequest $request = null Request object for parameters @return string Response data
[ "Execute", "a", "GET", "request", "against", "an", "API", "endpoint", "optionally", "with", "a", "given", "Request", "object", "as", "parameters" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/AbstractClient.php#L74-L87
225,999
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/AbstractClient.php
AbstractClient.post
public function post($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); $http->setOption(CURLOPT_POST, true); $http->setOption(CURLOPT_URL, $uri); if ($request) { $http->setOption(CURLOPT_POSTFIELDS, $this->buildPostData($request->getQuery())); } return $http->execute(); }
php
public function post($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); $http->setOption(CURLOPT_POST, true); $http->setOption(CURLOPT_URL, $uri); if ($request) { $http->setOption(CURLOPT_POSTFIELDS, $this->buildPostData($request->getQuery())); } return $http->execute(); }
[ "public", "function", "post", "(", "$", "uri", ",", "AbstractRequest", "$", "request", "=", "null", ")", "{", "$", "http", "=", "$", "this", "->", "getHttpClone", "(", ")", ";", "$", "http", "->", "setOption", "(", "CURLOPT_POST", ",", "true", ")", ";", "$", "http", "->", "setOption", "(", "CURLOPT_URL", ",", "$", "uri", ")", ";", "if", "(", "$", "request", ")", "{", "$", "http", "->", "setOption", "(", "CURLOPT_POSTFIELDS", ",", "$", "this", "->", "buildPostData", "(", "$", "request", "->", "getQuery", "(", ")", ")", ")", ";", "}", "return", "$", "http", "->", "execute", "(", ")", ";", "}" ]
Execute a POST request against an API endpoint, optionally with a given Request object as parameters @param string $uri Endpoint URL @param AbstractRequest $request = null Request object for parameters @return string Response data
[ "Execute", "a", "POST", "request", "against", "an", "API", "endpoint", "optionally", "with", "a", "given", "Request", "object", "as", "parameters" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/AbstractClient.php#L97-L108