repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
thephpleague/uri-manipulations
src/Modifiers/Resolve.php
Resolve.resolvePathAndQuery
protected function resolvePathAndQuery(string $path, string $query): array { $components = ['path' => $path, 'query' => $query]; if ('' === $components['path']) { $components['path'] = $this->base_uri->getPath(); if ('' === $components['query']) { $components['query'] = $this->base_uri->getQuery(); } return $components; } if (0 !== strpos($components['path'], '/')) { $components['path'] = $this->mergePath($components['path']); } return $components; }
php
protected function resolvePathAndQuery(string $path, string $query): array { $components = ['path' => $path, 'query' => $query]; if ('' === $components['path']) { $components['path'] = $this->base_uri->getPath(); if ('' === $components['query']) { $components['query'] = $this->base_uri->getQuery(); } return $components; } if (0 !== strpos($components['path'], '/')) { $components['path'] = $this->mergePath($components['path']); } return $components; }
[ "protected", "function", "resolvePathAndQuery", "(", "string", "$", "path", ",", "string", "$", "query", ")", ":", "array", "{", "$", "components", "=", "[", "'path'", "=>", "$", "path", ",", "'query'", "=>", "$", "query", "]", ";", "if", "(", "''", ...
Resolve the URI for a Authority-less target URI @param string $path the target path component @param string $query the target query component @return string[]
[ "Resolve", "the", "URI", "for", "a", "Authority", "-", "less", "target", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Resolve.php#L96-L114
thephpleague/uri-manipulations
src/Modifiers/Resolve.php
Resolve.mergePath
protected function mergePath(string $path): string { $base_path = $this->base_uri->getPath(); if ('' !== $this->base_uri->getAuthority() && '' === $base_path) { return (string) $this->filterPath($path)->withLeadingSlash(); } if ('' !== $base_path) { $segments = explode('/', $base_path); array_pop($segments); $path = implode('/', $segments).'/'.$path; } return $path; }
php
protected function mergePath(string $path): string { $base_path = $this->base_uri->getPath(); if ('' !== $this->base_uri->getAuthority() && '' === $base_path) { return (string) $this->filterPath($path)->withLeadingSlash(); } if ('' !== $base_path) { $segments = explode('/', $base_path); array_pop($segments); $path = implode('/', $segments).'/'.$path; } return $path; }
[ "protected", "function", "mergePath", "(", "string", "$", "path", ")", ":", "string", "{", "$", "base_path", "=", "$", "this", "->", "base_uri", "->", "getPath", "(", ")", ";", "if", "(", "''", "!==", "$", "this", "->", "base_uri", "->", "getAuthority"...
Merging Relative URI path with Base URI path @param string $path @return string
[ "Merging", "Relative", "URI", "path", "with", "Base", "URI", "path" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Resolve.php#L123-L137
thephpleague/uri-manipulations
src/Modifiers/Resolve.php
Resolve.formatPath
protected function formatPath(string $path): string { $path = $this->filterPath($path)->withoutDotSegments(); if ('' !== $this->base_uri->getAuthority() && '' !== $path->__toString()) { $path = $path->withLeadingSlash(); } return (string) $path; }
php
protected function formatPath(string $path): string { $path = $this->filterPath($path)->withoutDotSegments(); if ('' !== $this->base_uri->getAuthority() && '' !== $path->__toString()) { $path = $path->withLeadingSlash(); } return (string) $path; }
[ "protected", "function", "formatPath", "(", "string", "$", "path", ")", ":", "string", "{", "$", "path", "=", "$", "this", "->", "filterPath", "(", "$", "path", ")", "->", "withoutDotSegments", "(", ")", ";", "if", "(", "''", "!==", "$", "this", "->"...
Format the resolved path @param string $path @return string
[ "Format", "the", "resolved", "path" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Resolve.php#L146-L154
thephpleague/uri-manipulations
src/Modifiers/AppendSegment.php
AppendSegment.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->append($this->segment); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->append($this->segment); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "append", "(", "$", "this", "->", "segment", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/AppendSegment.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/RegisterableDomain.php
RegisterableDomain.modifyHost
protected function modifyHost(string $str): string { return (string) $this->filterHost($str, $this->resolver)->withRegisterableDomain($this->label); }
php
protected function modifyHost(string $str): string { return (string) $this->filterHost($str, $this->resolver)->withRegisterableDomain($this->label); }
[ "protected", "function", "modifyHost", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterHost", "(", "$", "str", ",", "$", "this", "->", "resolver", ")", "->", "withRegisterableDomain", "(", "$", ...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/RegisterableDomain.php#L69-L72
thephpleague/uri-manipulations
src/Modifiers/AddBasePath.php
AddBasePath.modifyPath
protected function modifyPath(string $str): string { if ('' != $str && '/' !== $str[0]) { $str = '/'.$str; } if (0 === strpos($str, (string) $this->basepath)) { return $str; } return (string) $this->basepath->append($str); }
php
protected function modifyPath(string $str): string { if ('' != $str && '/' !== $str[0]) { $str = '/'.$str; } if (0 === strpos($str, (string) $this->basepath)) { return $str; } return (string) $this->basepath->append($str); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "if", "(", "''", "!=", "$", "str", "&&", "'/'", "!==", "$", "str", "[", "0", "]", ")", "{", "$", "str", "=", "'/'", ".", "$", "str", ";", "}", "if", "(...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/AddBasePath.php#L56-L67
thephpleague/uri-manipulations
src/Modifiers/Extension.php
Extension.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withExtension($this->extension); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withExtension($this->extension); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "withExtension", "(", "$", "this", "->", "extension", ")", ";", "}"...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Extension.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/PublicSuffix.php
PublicSuffix.modifyHost
protected function modifyHost(string $str): string { return (string) $this->filterHost($str, $this->resolver)->withPublicSuffix($this->label); }
php
protected function modifyHost(string $str): string { return (string) $this->filterHost($str, $this->resolver)->withPublicSuffix($this->label); }
[ "protected", "function", "modifyHost", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterHost", "(", "$", "str", ",", "$", "this", "->", "resolver", ")", "->", "withPublicSuffix", "(", "$", "thi...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/PublicSuffix.php#L69-L72
thephpleague/uri-manipulations
src/Modifiers/RemoveBasePath.php
RemoveBasePath.modifyPath
protected function modifyPath(string $str): string { if (in_array((string) $this->basepath, ['', '/'], true)) { return $str; } if ('' != $str && '/' !== $str[0]) { $str = '/'.$str; } if ('' == $str || 0 !== strpos($str, (string) $this->basepath)) { return $str; } return (string) $this->filterSegment($str)->withoutSegments($this->basepath->keys()); }
php
protected function modifyPath(string $str): string { if (in_array((string) $this->basepath, ['', '/'], true)) { return $str; } if ('' != $str && '/' !== $str[0]) { $str = '/'.$str; } if ('' == $str || 0 !== strpos($str, (string) $this->basepath)) { return $str; } return (string) $this->filterSegment($str)->withoutSegments($this->basepath->keys()); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "if", "(", "in_array", "(", "(", "string", ")", "$", "this", "->", "basepath", ",", "[", "''", ",", "'/'", "]", ",", "true", ")", ")", "{", "return", "$", ...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/RemoveBasePath.php#L56-L71
thephpleague/uri-manipulations
src/Modifiers/HostToUnicode.php
HostToUnicode.modifyHost
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->getContent(EncodingInterface::RFC3987_ENCODING); }
php
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->getContent(EncodingInterface::RFC3987_ENCODING); }
[ "protected", "function", "modifyHost", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterHost", "(", "$", "str", ")", "->", "getContent", "(", "EncodingInterface", "::", "RFC3987_ENCODING", ")", ";"...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/HostToUnicode.php#L39-L42
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.hostToAscii
protected function hostToAscii($uri) { static $modifier; if (null === $modifier) { $modifier = new HostToAscii(); } return $modifier->process($uri); }
php
protected function hostToAscii($uri) { static $modifier; if (null === $modifier) { $modifier = new HostToAscii(); } return $modifier->process($uri); }
[ "protected", "function", "hostToAscii", "(", "$", "uri", ")", "{", "static", "$", "modifier", ";", "if", "(", "null", "===", "$", "modifier", ")", "{", "$", "modifier", "=", "new", "HostToAscii", "(", ")", ";", "}", "return", "$", "modifier", "->", "...
Convert the Uri host component to its ascii version @param mixed $uri @return DeprecatedLeagueUriInterface|Psr7UriInterface|UriInterface
[ "Convert", "the", "Uri", "host", "component", "to", "its", "ascii", "version" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L58-L66
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.isRelativizable
protected function isRelativizable($payload): bool { $payload = $this->hostToAscii($payload); return $this->base_uri->getScheme() === $payload->getScheme() && $this->base_uri->getAuthority() === $payload->getAuthority() && !is_relative_path($payload); }
php
protected function isRelativizable($payload): bool { $payload = $this->hostToAscii($payload); return $this->base_uri->getScheme() === $payload->getScheme() && $this->base_uri->getAuthority() === $payload->getAuthority() && !is_relative_path($payload); }
[ "protected", "function", "isRelativizable", "(", "$", "payload", ")", ":", "bool", "{", "$", "payload", "=", "$", "this", "->", "hostToAscii", "(", "$", "payload", ")", ";", "return", "$", "this", "->", "base_uri", "->", "getScheme", "(", ")", "===", "...
Tell whether the submitted URI object can be relativize @param mixed $payload @return bool
[ "Tell", "whether", "the", "submitted", "URI", "object", "can", "be", "relativize" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L102-L109
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.relativizePath
protected function relativizePath(string $path): string { $base_segments = $this->getSegments($this->base_uri->getPath()); $target_segments = $this->getSegments($path); $target_basename = array_pop($target_segments); array_pop($base_segments); foreach ($base_segments as $offset => $segment) { if (!isset($target_segments[$offset]) || $segment !== $target_segments[$offset]) { break; } unset($base_segments[$offset], $target_segments[$offset]); } $target_segments[] = $target_basename; return $this->formatPath( str_repeat('../', count($base_segments)).implode('/', $target_segments) ); }
php
protected function relativizePath(string $path): string { $base_segments = $this->getSegments($this->base_uri->getPath()); $target_segments = $this->getSegments($path); $target_basename = array_pop($target_segments); array_pop($base_segments); foreach ($base_segments as $offset => $segment) { if (!isset($target_segments[$offset]) || $segment !== $target_segments[$offset]) { break; } unset($base_segments[$offset], $target_segments[$offset]); } $target_segments[] = $target_basename; return $this->formatPath( str_repeat('../', count($base_segments)).implode('/', $target_segments) ); }
[ "protected", "function", "relativizePath", "(", "string", "$", "path", ")", ":", "string", "{", "$", "base_segments", "=", "$", "this", "->", "getSegments", "(", "$", "this", "->", "base_uri", "->", "getPath", "(", ")", ")", ";", "$", "target_segments", ...
Relative the URI for a authority-less target URI @param string $path @return string
[ "Relative", "the", "URI", "for", "a", "authority", "-", "less", "target", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L118-L135
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.getSegments
protected function getSegments(string $path): array { if ('' !== $path && '/' === $path[0]) { $path = substr($path, 1); } return explode('/', $path); }
php
protected function getSegments(string $path): array { if ('' !== $path && '/' === $path[0]) { $path = substr($path, 1); } return explode('/', $path); }
[ "protected", "function", "getSegments", "(", "string", "$", "path", ")", ":", "array", "{", "if", "(", "''", "!==", "$", "path", "&&", "'/'", "===", "$", "path", "[", "0", "]", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "1", "...
returns the path segments @param string $path @return array
[ "returns", "the", "path", "segments" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L144-L151
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.formatPath
protected function formatPath(string $path): string { if ('' === $path) { $base_path = $this->base_uri->getPath(); return in_array($base_path, ['', '/'], true) ? $base_path : './'; } if (false === ($colon_pos = strpos($path, ':'))) { return $path; } $slash_pos = strpos($path, '/'); if (false === $slash_pos || $colon_pos < $slash_pos) { return "./$path"; } return $path; }
php
protected function formatPath(string $path): string { if ('' === $path) { $base_path = $this->base_uri->getPath(); return in_array($base_path, ['', '/'], true) ? $base_path : './'; } if (false === ($colon_pos = strpos($path, ':'))) { return $path; } $slash_pos = strpos($path, '/'); if (false === $slash_pos || $colon_pos < $slash_pos) { return "./$path"; } return $path; }
[ "protected", "function", "formatPath", "(", "string", "$", "path", ")", ":", "string", "{", "if", "(", "''", "===", "$", "path", ")", "{", "$", "base_path", "=", "$", "this", "->", "base_uri", "->", "getPath", "(", ")", ";", "return", "in_array", "("...
Formatting the path to keep a valid URI @param string $path @return string
[ "Formatting", "the", "path", "to", "keep", "a", "valid", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L160-L177
thephpleague/uri-manipulations
src/Modifiers/Relativize.php
Relativize.formatPathWithEmptyBaseQuery
protected function formatPathWithEmptyBaseQuery(string $path): string { $target_segments = $this->getSegments($path); $basename = end($target_segments); return '' === $basename ? './' : $basename; }
php
protected function formatPathWithEmptyBaseQuery(string $path): string { $target_segments = $this->getSegments($path); $basename = end($target_segments); return '' === $basename ? './' : $basename; }
[ "protected", "function", "formatPathWithEmptyBaseQuery", "(", "string", "$", "path", ")", ":", "string", "{", "$", "target_segments", "=", "$", "this", "->", "getSegments", "(", "$", "path", ")", ";", "$", "basename", "=", "end", "(", "$", "target_segments",...
Formatting the path to keep a resolvable URI @param string $path @return string
[ "Formatting", "the", "path", "to", "keep", "a", "resolvable", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Relativize.php#L186-L192
thephpleague/uri-manipulations
src/Modifiers/RemoveLabels.php
RemoveLabels.modifyHost
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->withoutLabels($this->keys); }
php
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->withoutLabels($this->keys); }
[ "protected", "function", "modifyHost", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterHost", "(", "$", "str", ")", "->", "withoutLabels", "(", "$", "this", "->", "keys", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/RemoveLabels.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/MergeQuery.php
MergeQuery.modifyQuery
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->merge($this->query); }
php
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->merge($this->query); }
[ "protected", "function", "modifyQuery", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterQuery", "(", "$", "str", ")", "->", "merge", "(", "$", "this", "->", "query", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/MergeQuery.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/RemoveQueryKeys.php
RemoveQueryKeys.modifyQuery
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->withoutPairs($this->keys); }
php
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->withoutPairs($this->keys); }
[ "protected", "function", "modifyQuery", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterQuery", "(", "$", "str", ")", "->", "withoutPairs", "(", "$", "this", "->", "keys", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/RemoveQueryKeys.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/AppendQuery.php
AppendQuery.modifyQuery
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->append($this->query); }
php
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->append($this->query); }
[ "protected", "function", "modifyQuery", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterQuery", "(", "$", "str", ")", "->", "append", "(", "$", "this", "->", "query", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/AppendQuery.php#L52-L55
thephpleague/uri-manipulations
src/Modifiers/RemoveSegments.php
RemoveSegments.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withoutSegments($this->keys); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withoutSegments($this->keys); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "withoutSegments", "(", "$", "this", "->", "keys", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/RemoveSegments.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/KsortQuery.php
KsortQuery.modifyQuery
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->ksort($this->sort); }
php
protected function modifyQuery(string $str): string { return (string) $this->filterQuery($str)->ksort($this->sort); }
[ "protected", "function", "modifyQuery", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterQuery", "(", "$", "str", ")", "->", "ksort", "(", "$", "this", "->", "sort", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/KsortQuery.php#L58-L61
thephpleague/uri-manipulations
src/Modifiers/ReplaceSegment.php
ReplaceSegment.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->replaceSegment($this->offset, $this->segment); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->replaceSegment($this->offset, $this->segment); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "replaceSegment", "(", "$", "this", "->", "offset", ",", "$", "this...
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/ReplaceSegment.php#L63-L66
thephpleague/uri-manipulations
src/Modifiers/Basename.php
Basename.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withBasename($this->basename); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withBasename($this->basename); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "withBasename", "(", "$", "this", "->", "basename", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Basename.php#L59-L62
thephpleague/uri-manipulations
src/Modifiers/Dirname.php
Dirname.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withDirname($this->dirname); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->withDirname($this->dirname); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "withDirname", "(", "$", "this", "->", "dirname", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Dirname.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/Exception.php
Exception.fromInvalidUri
public static function fromInvalidUri($uri) { return new self(sprintf('Expected data to be a valid URI object; received "%s"', is_object($uri) ? get_class($uri) : gettype($uri))); }
php
public static function fromInvalidUri($uri) { return new self(sprintf('Expected data to be a valid URI object; received "%s"', is_object($uri) ? get_class($uri) : gettype($uri))); }
[ "public", "static", "function", "fromInvalidUri", "(", "$", "uri", ")", "{", "return", "new", "self", "(", "sprintf", "(", "'Expected data to be a valid URI object; received \"%s\"'", ",", "is_object", "(", "$", "uri", ")", "?", "get_class", "(", "$", "uri", ")"...
New instance from invalid URI @param mixed $uri invalid uri @return self
[ "New", "instance", "from", "invalid", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Exception.php#L36-L39
thephpleague/uri-manipulations
src/Modifiers/Exception.php
Exception.fromInvalidInterface
public static function fromInvalidInterface(string $interface, $uri) { return new self(sprintf('The returned URI must be a "%s"; received "%s"', $interface, is_object($uri) ? get_class($uri) : gettype($uri))); }
php
public static function fromInvalidInterface(string $interface, $uri) { return new self(sprintf('The returned URI must be a "%s"; received "%s"', $interface, is_object($uri) ? get_class($uri) : gettype($uri))); }
[ "public", "static", "function", "fromInvalidInterface", "(", "string", "$", "interface", ",", "$", "uri", ")", "{", "return", "new", "self", "(", "sprintf", "(", "'The returned URI must be a \"%s\"; received \"%s\"'", ",", "$", "interface", ",", "is_object", "(", ...
New instance from invalid URI @param string $interface required interface @param mixed $uri invalid uri @return self
[ "New", "instance", "from", "invalid", "URI" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Exception.php#L49-L52
thephpleague/uri-manipulations
src/Modifiers/UriMiddlewareTrait.php
UriMiddlewareTrait.process
public function process($uri) { $interface = $this->getUriInterface($uri); $new_uri = $this->execute($uri); if ($new_uri instanceof $interface) { return $new_uri; } throw Exception::fromInvalidInterface($interface, $new_uri); }
php
public function process($uri) { $interface = $this->getUriInterface($uri); $new_uri = $this->execute($uri); if ($new_uri instanceof $interface) { return $new_uri; } throw Exception::fromInvalidInterface($interface, $new_uri); }
[ "public", "function", "process", "(", "$", "uri", ")", "{", "$", "interface", "=", "$", "this", "->", "getUriInterface", "(", "$", "uri", ")", ";", "$", "new_uri", "=", "$", "this", "->", "execute", "(", "$", "uri", ")", ";", "if", "(", "$", "new...
Process and return an Uri This method MUST retain the state of the submitted URI instance, and return an URI instance of the same type that contains the applied modifications. This method MUST be transparent when dealing with error and exceptions. It MUST not alter of silence them apart from validating its own parameters. @param Uri|UriInterface $uri @throws Exception If the submitted or the URI object is invalid @return Uri|UriInterface
[ "Process", "and", "return", "an", "Uri" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/UriMiddlewareTrait.php#L70-L79
thephpleague/uri-manipulations
src/Modifiers/UriMiddlewareTrait.php
UriMiddlewareTrait.getUriInterface
protected function getUriInterface($uri) { if ($uri instanceof UriInterface) { return UriInterface::class; } if ($uri instanceof Uri) { return Uri::class; } throw Exception::fromInvalidUri($uri); }
php
protected function getUriInterface($uri) { if ($uri instanceof UriInterface) { return UriInterface::class; } if ($uri instanceof Uri) { return Uri::class; } throw Exception::fromInvalidUri($uri); }
[ "protected", "function", "getUriInterface", "(", "$", "uri", ")", "{", "if", "(", "$", "uri", "instanceof", "UriInterface", ")", "{", "return", "UriInterface", "::", "class", ";", "}", "if", "(", "$", "uri", "instanceof", "Uri", ")", "{", "return", "Uri"...
Returns the URI object interface @param Uri|UriInterface $uri @throws Exception if the submitted URI object is invalid @return string
[ "Returns", "the", "URI", "object", "interface" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/UriMiddlewareTrait.php#L90-L101
thephpleague/uri-manipulations
src/Modifiers/UriMiddlewareTrait.php
UriMiddlewareTrait.filterString
protected function filterString(string $str): string { $invalid_chars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F"; if (strlen($str) !== strcspn($str, $invalid_chars)) { throw new Exception(sprintf('the submitted string `%s` contains invalid characters', $str)); } return $str; }
php
protected function filterString(string $str): string { $invalid_chars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F"; if (strlen($str) !== strcspn($str, $invalid_chars)) { throw new Exception(sprintf('the submitted string `%s` contains invalid characters', $str)); } return $str; }
[ "protected", "function", "filterString", "(", "string", "$", "str", ")", ":", "string", "{", "$", "invalid_chars", "=", "\"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1A\\x1B\\x1C\\x1D\\x1E\\x1F\\x7F...
validate a string @param mixed $str the value to evaluate as a string @throws Exception if the submitted data can not be converted to string @return string
[ "validate", "a", "string" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/UriMiddlewareTrait.php#L124-L132
thephpleague/uri-manipulations
src/Modifiers/UriMiddlewareTrait.php
UriMiddlewareTrait.filterHost
protected function filterHost(string $label, Rules $resolver = null): Host { return new Host($this->filterString($label), $resolver); }
php
protected function filterHost(string $label, Rules $resolver = null): Host { return new Host($this->filterString($label), $resolver); }
[ "protected", "function", "filterHost", "(", "string", "$", "label", ",", "Rules", "$", "resolver", "=", "null", ")", ":", "Host", "{", "return", "new", "Host", "(", "$", "this", "->", "filterString", "(", "$", "label", ")", ",", "$", "resolver", ")", ...
Filter and validate the host string @param string $label the data to validate @param null|Rules $resolver @return Host
[ "Filter", "and", "validate", "the", "host", "string" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/UriMiddlewareTrait.php#L142-L145
thephpleague/uri-manipulations
src/Modifiers/UriMiddlewareTrait.php
UriMiddlewareTrait.filterExtension
protected function filterExtension(string $extension): string { $extension = $this->filterString($extension); if (0 === strpos($extension, '.') || false !== strpos($extension, '/')) { throw new Exception( 'extension must be string sequence without a leading `.` and the path separator `/` characters' ); } return trim($extension); }
php
protected function filterExtension(string $extension): string { $extension = $this->filterString($extension); if (0 === strpos($extension, '.') || false !== strpos($extension, '/')) { throw new Exception( 'extension must be string sequence without a leading `.` and the path separator `/` characters' ); } return trim($extension); }
[ "protected", "function", "filterExtension", "(", "string", "$", "extension", ")", ":", "string", "{", "$", "extension", "=", "$", "this", "->", "filterString", "(", "$", "extension", ")", ";", "if", "(", "0", "===", "strpos", "(", "$", "extension", ",", ...
filter and validate the extension to use @param string $extension @throws Exception if the extension is not valid @return string
[ "filter", "and", "validate", "the", "extension", "to", "use" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/UriMiddlewareTrait.php#L240-L250
thephpleague/uri-manipulations
src/Modifiers/PrependSegment.php
PrependSegment.modifyPath
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->prepend($this->segment); }
php
protected function modifyPath(string $str): string { return (string) $this->filterSegment($str)->prepend($this->segment); }
[ "protected", "function", "modifyPath", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterSegment", "(", "$", "str", ")", "->", "prepend", "(", "$", "this", "->", "segment", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/PrependSegment.php#L54-L57
thephpleague/uri-manipulations
src/Modifiers/Formatter.php
Formatter.setEncoding
public function setEncoding(int $enc_type) { static $enc_type_list; if (null === $enc_type_list) { $enc_type_list = [ self::RFC1738_ENCODING => 1, self::RFC3986_ENCODING => 1, self::RFC3987_ENCODING => 1, self::NO_ENCODING => 1, ]; } if (!isset($enc_type_list[$enc_type])) { throw new InvalidArgumentException(sprintf('Unsupported or Unknown Encoding: %s', $enc_type)); } $this->enc_type = $enc_type; }
php
public function setEncoding(int $enc_type) { static $enc_type_list; if (null === $enc_type_list) { $enc_type_list = [ self::RFC1738_ENCODING => 1, self::RFC3986_ENCODING => 1, self::RFC3987_ENCODING => 1, self::NO_ENCODING => 1, ]; } if (!isset($enc_type_list[$enc_type])) { throw new InvalidArgumentException(sprintf('Unsupported or Unknown Encoding: %s', $enc_type)); } $this->enc_type = $enc_type; }
[ "public", "function", "setEncoding", "(", "int", "$", "enc_type", ")", "{", "static", "$", "enc_type_list", ";", "if", "(", "null", "===", "$", "enc_type_list", ")", "{", "$", "enc_type_list", "=", "[", "self", "::", "RFC1738_ENCODING", "=>", "1", ",", "...
Formatting encoding type @param int $enc_type a predefined constant value
[ "Formatting", "encoding", "type" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Formatter.php#L73-L90
thephpleague/uri-manipulations
src/Modifiers/Formatter.php
Formatter.setQuerySeparator
public function setQuerySeparator(string $separator) { $separator = filter_var($separator, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $this->query_separator = trim($separator); }
php
public function setQuerySeparator(string $separator) { $separator = filter_var($separator, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $this->query_separator = trim($separator); }
[ "public", "function", "setQuerySeparator", "(", "string", "$", "separator", ")", "{", "$", "separator", "=", "filter_var", "(", "$", "separator", ",", "FILTER_SANITIZE_STRING", ",", "FILTER_FLAG_STRIP_LOW", ")", ";", "$", "this", "->", "query_separator", "=", "t...
Query separator setter @param string $separator
[ "Query", "separator", "setter" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Formatter.php#L97-L102
thephpleague/uri-manipulations
src/Modifiers/Formatter.php
Formatter.formatUri
protected function formatUri($uri): string { $scheme = $uri->getScheme(); if ('' != $scheme) { $scheme = $scheme.':'; } $authority = null; $host = $uri->getHost(); if ('' != $host) { $user_info = $uri->getUserInfo(); if ('' != $user_info) { $authority .= (new UserInfo())->withContent($user_info)->getContent($this->enc_type).'@'; } $authority .= (new Host($host))->getContent($this->enc_type); $port = $uri->getPort(); if (null !== $port) { $authority .= ':'.$port; } } if (null !== $authority) { $authority = '//'.$authority; } $path = (new Path($uri->getPath()))->getContent($this->enc_type); if (null !== $authority && '' !== $path && '/' !== $path[0]) { $path = '/'.$path; } $query = $uri->getQuery(); if ('' != $query || $this->preserve_query) { $query = '?'.Uri\build_query(Uri\parse_query($query), $this->query_separator, $this->enc_type); } $fragment = $uri->getFragment(); if ('' != $fragment || $this->preserve_fragment) { $fragment = '#'.(new Fragment($fragment))->getContent($this->enc_type); } return $scheme.$authority.$path.$query.$fragment; }
php
protected function formatUri($uri): string { $scheme = $uri->getScheme(); if ('' != $scheme) { $scheme = $scheme.':'; } $authority = null; $host = $uri->getHost(); if ('' != $host) { $user_info = $uri->getUserInfo(); if ('' != $user_info) { $authority .= (new UserInfo())->withContent($user_info)->getContent($this->enc_type).'@'; } $authority .= (new Host($host))->getContent($this->enc_type); $port = $uri->getPort(); if (null !== $port) { $authority .= ':'.$port; } } if (null !== $authority) { $authority = '//'.$authority; } $path = (new Path($uri->getPath()))->getContent($this->enc_type); if (null !== $authority && '' !== $path && '/' !== $path[0]) { $path = '/'.$path; } $query = $uri->getQuery(); if ('' != $query || $this->preserve_query) { $query = '?'.Uri\build_query(Uri\parse_query($query), $this->query_separator, $this->enc_type); } $fragment = $uri->getFragment(); if ('' != $fragment || $this->preserve_fragment) { $fragment = '#'.(new Fragment($fragment))->getContent($this->enc_type); } return $scheme.$authority.$path.$query.$fragment; }
[ "protected", "function", "formatUri", "(", "$", "uri", ")", ":", "string", "{", "$", "scheme", "=", "$", "uri", "->", "getScheme", "(", ")", ";", "if", "(", "''", "!=", "$", "scheme", ")", "{", "$", "scheme", "=", "$", "scheme", ".", "':'", ";", ...
Format an Uri according to the Formatter properties @param DeprecatedLeagueUriInterface|Psr7UriInterface|UriInterface $uri @return string
[ "Format", "an", "Uri", "according", "to", "the", "Formatter", "properties" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/Formatter.php#L189-L230
thephpleague/uri-manipulations
src/Modifiers/PrependLabel.php
PrependLabel.modifyHost
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->prepend($this->label); }
php
protected function modifyHost(string $str): string { return (string) $this->filterHost($str)->prepend($this->label); }
[ "protected", "function", "modifyHost", "(", "string", "$", "str", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "filterHost", "(", "$", "str", ")", "->", "prepend", "(", "$", "this", "->", "label", ")", ";", "}" ]
Modify a URI part @param string $str the URI part string representation @return string the modified URI part string representation
[ "Modify", "a", "URI", "part" ]
train
https://github.com/thephpleague/uri-manipulations/blob/a9092d28abfca7db443871c84944f5e5c643c31b/src/Modifiers/PrependLabel.php#L54-L57
marc-mabe/php-enum
bench/EnumSet32Bench.php
EnumSet32Bench.init
public function init() { $this->values = Enum32::getValues(); $this->enumerators = Enum32::getEnumerators(); $this->emptySet = new EnumSet(Enum32::class); $this->fullSet = new EnumSet(Enum32::class, $this->enumerators); }
php
public function init() { $this->values = Enum32::getValues(); $this->enumerators = Enum32::getEnumerators(); $this->emptySet = new EnumSet(Enum32::class); $this->fullSet = new EnumSet(Enum32::class, $this->enumerators); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "values", "=", "Enum32", "::", "getValues", "(", ")", ";", "$", "this", "->", "enumerators", "=", "Enum32", "::", "getEnumerators", "(", ")", ";", "$", "this", "->", "emptySet", "=", "ne...
Will be called before every subject
[ "Will", "be", "called", "before", "every", "subject" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/bench/EnumSet32Bench.php#L20-L27
marc-mabe/php-enum
src/EnumSet.php
EnumSet.add
public function add($enumerator): void { $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
php
public function add($enumerator): void { $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
[ "public", "function", "add", "(", "$", "enumerator", ")", ":", "void", "{", "$", "this", "->", "{", "$", "this", "->", "fnDoSetBit", "}", "(", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOrdinal", ...
Adds an enumerator object or value @param Enum|null|bool|int|float|string|array $enumerator Enumerator object or value @return void @throws InvalidArgumentException On an invalid given enumerator
[ "Adds", "an", "enumerator", "object", "or", "value" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L119-L122
marc-mabe/php-enum
src/EnumSet.php
EnumSet.addIterable
public function addIterable(iterable $enumerators): void { $bitset = $this->bitset; try { foreach ($enumerators as $enumerator) { $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } } catch (\Throwable $e) { // reset all changes until error happened $this->bitset = $bitset; throw $e; } }
php
public function addIterable(iterable $enumerators): void { $bitset = $this->bitset; try { foreach ($enumerators as $enumerator) { $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } } catch (\Throwable $e) { // reset all changes until error happened $this->bitset = $bitset; throw $e; } }
[ "public", "function", "addIterable", "(", "iterable", "$", "enumerators", ")", ":", "void", "{", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "try", "{", "foreach", "(", "$", "enumerators", "as", "$", "enumerator", ")", "{", "$", "this", "->",...
Adds all enumerator objects or values of the given iterable @param iterable $enumerators Iterable list of enumerator objects or values @return void @throws InvalidArgumentException On an invalid given enumerator
[ "Adds", "all", "enumerator", "objects", "or", "values", "of", "the", "given", "iterable" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L130-L143
marc-mabe/php-enum
src/EnumSet.php
EnumSet.remove
public function remove($enumerator): void { $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
php
public function remove($enumerator): void { $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
[ "public", "function", "remove", "(", "$", "enumerator", ")", ":", "void", "{", "$", "this", "->", "{", "$", "this", "->", "fnDoUnsetBit", "}", "(", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOrdina...
Removes the given enumerator object or value @param Enum|null|bool|int|float|string|array $enumerator Enumerator object or value @return void @throws InvalidArgumentException On an invalid given enumerator
[ "Removes", "the", "given", "enumerator", "object", "or", "value" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L151-L154
marc-mabe/php-enum
src/EnumSet.php
EnumSet.removeIterable
public function removeIterable(iterable $enumerators): void { $bitset = $this->bitset; try { foreach ($enumerators as $enumerator) { $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } } catch (\Throwable $e) { // reset all changes until error happened $this->bitset = $bitset; throw $e; } }
php
public function removeIterable(iterable $enumerators): void { $bitset = $this->bitset; try { foreach ($enumerators as $enumerator) { $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } } catch (\Throwable $e) { // reset all changes until error happened $this->bitset = $bitset; throw $e; } }
[ "public", "function", "removeIterable", "(", "iterable", "$", "enumerators", ")", ":", "void", "{", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "try", "{", "foreach", "(", "$", "enumerators", "as", "$", "enumerator", ")", "{", "$", "this", "-...
Removes all enumerator objects or values of the given iterable @param iterable $enumerators Iterable list of enumerator objects or values @return void @throws InvalidArgumentException On an invalid given enumerator
[ "Removes", "all", "enumerator", "objects", "or", "values", "of", "the", "given", "iterable" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L190-L203
marc-mabe/php-enum
src/EnumSet.php
EnumSet.setUnion
public function setUnion(EnumSet $other): void { if ($this->enumeration !== $other->enumeration) { throw new InvalidArgumentException(\sprintf( 'Other should be of the same enumeration as this %s', $this->enumeration )); } $this->bitset = $this->bitset | $other->bitset; }
php
public function setUnion(EnumSet $other): void { if ($this->enumeration !== $other->enumeration) { throw new InvalidArgumentException(\sprintf( 'Other should be of the same enumeration as this %s', $this->enumeration )); } $this->bitset = $this->bitset | $other->bitset; }
[ "public", "function", "setUnion", "(", "EnumSet", "$", "other", ")", ":", "void", "{", "if", "(", "$", "this", "->", "enumeration", "!==", "$", "other", "->", "enumeration", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\\", "sprintf", "(", ...
Modify this set from both this and other (this | other) @param EnumSet $other EnumSet of the same enumeration to produce the union @return void @throws InvalidArgumentException If $other doesn't match the enumeration
[ "Modify", "this", "set", "from", "both", "this", "and", "other", "(", "this", "|", "other", ")" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L212-L222
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doSetBinaryBitsetLeBin
private function doSetBinaryBitsetLeBin($bitset): void { $size = \strlen($this->bitset); $sizeIn = \strlen($bitset); if ($sizeIn < $size) { // add "\0" if the given bitset is not long enough $bitset .= \str_repeat("\0", $size - $sizeIn); } elseif ($sizeIn > $size) { if (\ltrim(\substr($bitset, $size), "\0") !== '') { throw new InvalidArgumentException('out-of-range bits detected'); } $bitset = \substr($bitset, 0, $size); } // truncate out-of-range bits of last byte $lastByteMaxOrd = $this->enumerationCount % 8; if ($lastByteMaxOrd !== 0) { $lastByte = $bitset[-1]; $lastByteExpected = \chr((1 << $lastByteMaxOrd) - 1) & $lastByte; if ($lastByte !== $lastByteExpected) { throw new InvalidArgumentException('out-of-range bits detected'); } $this->bitset = \substr($bitset, 0, -1) . $lastByteExpected; } $this->bitset = $bitset; }
php
private function doSetBinaryBitsetLeBin($bitset): void { $size = \strlen($this->bitset); $sizeIn = \strlen($bitset); if ($sizeIn < $size) { // add "\0" if the given bitset is not long enough $bitset .= \str_repeat("\0", $size - $sizeIn); } elseif ($sizeIn > $size) { if (\ltrim(\substr($bitset, $size), "\0") !== '') { throw new InvalidArgumentException('out-of-range bits detected'); } $bitset = \substr($bitset, 0, $size); } // truncate out-of-range bits of last byte $lastByteMaxOrd = $this->enumerationCount % 8; if ($lastByteMaxOrd !== 0) { $lastByte = $bitset[-1]; $lastByteExpected = \chr((1 << $lastByteMaxOrd) - 1) & $lastByte; if ($lastByte !== $lastByteExpected) { throw new InvalidArgumentException('out-of-range bits detected'); } $this->bitset = \substr($bitset, 0, -1) . $lastByteExpected; } $this->bitset = $bitset; }
[ "private", "function", "doSetBinaryBitsetLeBin", "(", "$", "bitset", ")", ":", "void", "{", "$", "size", "=", "\\", "strlen", "(", "$", "this", "->", "bitset", ")", ";", "$", "sizeIn", "=", "\\", "strlen", "(", "$", "bitset", ")", ";", "if", "(", "...
Set binary bitset in little-endian order @param string $bitset @return void @throws InvalidArgumentException On out-of-range bits given as input bitset @see setBinaryBitsetLeBin() @see doSetBinaryBitsetLeInt()
[ "Set", "binary", "bitset", "in", "little", "-", "endian", "order" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L304-L332
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doSetBinaryBitsetLeInt
private function doSetBinaryBitsetLeInt($bitset): void { $len = \strlen($bitset); $int = 0; for ($i = 0; $i < $len; ++$i) { $ord = \ord($bitset[$i]); if ($ord && $i > \PHP_INT_SIZE - 1) { throw new InvalidArgumentException('out-of-range bits detected'); } $int |= $ord << (8 * $i); } if ($int & (~0 << $this->enumerationCount)) { throw new InvalidArgumentException('out-of-range bits detected'); } $this->bitset = $int; }
php
private function doSetBinaryBitsetLeInt($bitset): void { $len = \strlen($bitset); $int = 0; for ($i = 0; $i < $len; ++$i) { $ord = \ord($bitset[$i]); if ($ord && $i > \PHP_INT_SIZE - 1) { throw new InvalidArgumentException('out-of-range bits detected'); } $int |= $ord << (8 * $i); } if ($int & (~0 << $this->enumerationCount)) { throw new InvalidArgumentException('out-of-range bits detected'); } $this->bitset = $int; }
[ "private", "function", "doSetBinaryBitsetLeInt", "(", "$", "bitset", ")", ":", "void", "{", "$", "len", "=", "\\", "strlen", "(", "$", "bitset", ")", ";", "$", "int", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len"...
Set binary bitset in little-endian order @param string $bitset @return void @throws InvalidArgumentException On out-of-range bits given as input bitset @see setBinaryBitsetLeBin() @see doSetBinaryBitsetLeBin()
[ "Set", "binary", "bitset", "in", "little", "-", "endian", "order" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L343-L362
marc-mabe/php-enum
src/EnumSet.php
EnumSet.setBit
public function setBit(int $ordinal, bool $bit): void { if ($ordinal < 0 || $ordinal > $this->enumerationCount) { throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}"); } if ($bit) { $this->{$this->fnDoSetBit}($ordinal); } else { $this->{$this->fnDoUnsetBit}($ordinal); } }
php
public function setBit(int $ordinal, bool $bit): void { if ($ordinal < 0 || $ordinal > $this->enumerationCount) { throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}"); } if ($bit) { $this->{$this->fnDoSetBit}($ordinal); } else { $this->{$this->fnDoUnsetBit}($ordinal); } }
[ "public", "function", "setBit", "(", "int", "$", "ordinal", ",", "bool", "$", "bit", ")", ":", "void", "{", "if", "(", "$", "ordinal", "<", "0", "||", "$", "ordinal", ">", "$", "this", "->", "enumerationCount", ")", "{", "throw", "new", "InvalidArgum...
Set a bit at the given ordinal number @param int $ordinal Ordinal number of bit to set @param bool $bit The bit to set @return void @throws InvalidArgumentException If the given ordinal number is out-of-range @uses doSetBitBin() @uses doSetBitInt() @uses doUnsetBitBin() @uses doUnsetBitInt()
[ "Set", "a", "bit", "at", "the", "given", "ordinal", "number" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L388-L399
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doSetBitBin
private function doSetBitBin($ordinal): void { $byte = (int) ($ordinal / 8); $this->bitset[$byte] = $this->bitset[$byte] | \chr(1 << ($ordinal % 8)); }
php
private function doSetBitBin($ordinal): void { $byte = (int) ($ordinal / 8); $this->bitset[$byte] = $this->bitset[$byte] | \chr(1 << ($ordinal % 8)); }
[ "private", "function", "doSetBitBin", "(", "$", "ordinal", ")", ":", "void", "{", "$", "byte", "=", "(", "int", ")", "(", "$", "ordinal", "/", "8", ")", ";", "$", "this", "->", "bitset", "[", "$", "byte", "]", "=", "$", "this", "->", "bitset", ...
Set a bit at the given ordinal number. This is the binary bitset implementation. @param int $ordinal Ordinal number of bit to set @return void @see setBit() @see doSetBitInt()
[ "Set", "a", "bit", "at", "the", "given", "ordinal", "number", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L411-L415
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doUnsetBitBin
private function doUnsetBitBin($ordinal): void { $byte = (int) ($ordinal / 8); $this->bitset[$byte] = $this->bitset[$byte] & \chr(~(1 << ($ordinal % 8))); }
php
private function doUnsetBitBin($ordinal): void { $byte = (int) ($ordinal / 8); $this->bitset[$byte] = $this->bitset[$byte] & \chr(~(1 << ($ordinal % 8))); }
[ "private", "function", "doUnsetBitBin", "(", "$", "ordinal", ")", ":", "void", "{", "$", "byte", "=", "(", "int", ")", "(", "$", "ordinal", "/", "8", ")", ";", "$", "this", "->", "bitset", "[", "$", "byte", "]", "=", "$", "this", "->", "bitset", ...
Unset a bit at the given ordinal number. This is the binary bitset implementation. @param int $ordinal Ordinal number of bit to unset @return void @see setBit() @see doUnsetBitInt()
[ "Unset", "a", "bit", "at", "the", "given", "ordinal", "number", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L442-L446
marc-mabe/php-enum
src/EnumSet.php
EnumSet.with
public function with($enumerator): self { $clone = clone $this; $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); return $clone; }
php
public function with($enumerator): self { $clone = clone $this; $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); return $clone; }
[ "public", "function", "with", "(", "$", "enumerator", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "{", "$", "this", "->", "fnDoSetBit", "}", "(", "(", "$", "this", "->", "enumeration", ")", "::", "get", ...
Creates a new set with the given enumerator object or value added @param Enum|null|bool|int|float|string|array $enumerator Enumerator object or value @return static @throws InvalidArgumentException On an invalid given enumerator
[ "Creates", "a", "new", "set", "with", "the", "given", "enumerator", "object", "or", "value", "added" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L471-L476
marc-mabe/php-enum
src/EnumSet.php
EnumSet.withIterable
public function withIterable(iterable $enumerators): self { $clone = clone $this; foreach ($enumerators as $enumerator) { $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } return $clone; }
php
public function withIterable(iterable $enumerators): self { $clone = clone $this; foreach ($enumerators as $enumerator) { $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } return $clone; }
[ "public", "function", "withIterable", "(", "iterable", "$", "enumerators", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "foreach", "(", "$", "enumerators", "as", "$", "enumerator", ")", "{", "$", "clone", "->", "{", "$", "this",...
Creates a new set with the given enumeration objects or values added @param iterable $enumerators Iterable list of enumerator objects or values @return static @throws InvalidArgumentException On an invalid given enumerator
[ "Creates", "a", "new", "set", "with", "the", "given", "enumeration", "objects", "or", "values", "added" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L484-L491
marc-mabe/php-enum
src/EnumSet.php
EnumSet.without
public function without($enumerator): self { $clone = clone $this; $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); return $clone; }
php
public function without($enumerator): self { $clone = clone $this; $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); return $clone; }
[ "public", "function", "without", "(", "$", "enumerator", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "{", "$", "this", "->", "fnDoUnsetBit", "}", "(", "(", "$", "this", "->", "enumeration", ")", "::", "g...
Create a new set with the given enumerator object or value removed @param Enum|null|bool|int|float|string|array $enumerator Enumerator object or value @return static @throws InvalidArgumentException On an invalid given enumerator
[ "Create", "a", "new", "set", "with", "the", "given", "enumerator", "object", "or", "value", "removed" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L499-L504
marc-mabe/php-enum
src/EnumSet.php
EnumSet.withoutIterable
public function withoutIterable(iterable $enumerators): self { $clone = clone $this; foreach ($enumerators as $enumerator) { $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } return $clone; }
php
public function withoutIterable(iterable $enumerators): self { $clone = clone $this; foreach ($enumerators as $enumerator) { $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); } return $clone; }
[ "public", "function", "withoutIterable", "(", "iterable", "$", "enumerators", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "foreach", "(", "$", "enumerators", "as", "$", "enumerator", ")", "{", "$", "clone", "->", "{", "$", "thi...
Creates a new set with the given enumeration objects or values removed @param iterable $enumerators Iterable list of enumerator objects or values @return static @throws InvalidArgumentException On an invalid given enumerator
[ "Creates", "a", "new", "set", "with", "the", "given", "enumeration", "objects", "or", "values", "removed" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L512-L519
marc-mabe/php-enum
src/EnumSet.php
EnumSet.withBit
public function withBit(int $ordinal, bool $bit): self { $clone = clone $this; $clone->setBit($ordinal, $bit); return $clone; }
php
public function withBit(int $ordinal, bool $bit): self { $clone = clone $this; $clone->setBit($ordinal, $bit); return $clone; }
[ "public", "function", "withBit", "(", "int", "$", "ordinal", ",", "bool", "$", "bit", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "setBit", "(", "$", "ordinal", ",", "$", "bit", ")", ";", "return", "$"...
Create a new set with the bit at the given ordinal number set @param int $ordinal Ordinal number of bit to set @param bool $bit The bit to set @return static @throws InvalidArgumentException If the given ordinal number is out-of-range @uses doSetBitBin() @uses doSetBitInt() @uses doUnsetBitBin() @uses doUnsetBitInt()
[ "Create", "a", "new", "set", "with", "the", "bit", "at", "the", "given", "ordinal", "number", "set" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L679-L684
marc-mabe/php-enum
src/EnumSet.php
EnumSet.has
public function has($enumerator): bool { return $this->{$this->fnDoGetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
php
public function has($enumerator): bool { return $this->{$this->fnDoGetBit}(($this->enumeration)::get($enumerator)->getOrdinal()); }
[ "public", "function", "has", "(", "$", "enumerator", ")", ":", "bool", "{", "return", "$", "this", "->", "{", "$", "this", "->", "fnDoGetBit", "}", "(", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "ge...
Test if the given enumerator exists @param Enum|null|bool|int|float|string|array $enumerator @return bool
[ "Test", "if", "the", "given", "enumerator", "exists" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L693-L696
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doGetIteratorBin
private function doGetIteratorBin() { $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); for ($bitPos = 0; $bitPos < 8; ++$bitPos) { if ($ord & (1 << $bitPos)) { $ordinal = $bytePos * 8 + $bitPos; yield $ordinal => ($this->enumeration)::byOrdinal($ordinal); } } } }
php
private function doGetIteratorBin() { $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); for ($bitPos = 0; $bitPos < 8; ++$bitPos) { if ($ord & (1 << $bitPos)) { $ordinal = $bytePos * 8 + $bitPos; yield $ordinal => ($this->enumeration)::byOrdinal($ordinal); } } } }
[ "private", "function", "doGetIteratorBin", "(", ")", "{", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "$", "byteLen", "=", "\\", "strlen", "(", "$", "bitset", ")", ";", "for", "(", "$", "bytePos", "=", "0", ";", "$", "bytePos", "<", "$", ...
Get a new Iterator. This is the binary bitset implementation. @return Iterator @see getIterator() @see goGetIteratorInt()
[ "Get", "a", "new", "Iterator", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L732-L750
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doGetIteratorInt
private function doGetIteratorInt() { $count = $this->enumerationCount; $bitset = $this->bitset; for ($ordinal = 0; $ordinal < $count; ++$ordinal) { if ($bitset & (1 << $ordinal)) { yield $ordinal => ($this->enumeration)::byOrdinal($ordinal); } } }
php
private function doGetIteratorInt() { $count = $this->enumerationCount; $bitset = $this->bitset; for ($ordinal = 0; $ordinal < $count; ++$ordinal) { if ($bitset & (1 << $ordinal)) { yield $ordinal => ($this->enumeration)::byOrdinal($ordinal); } } }
[ "private", "function", "doGetIteratorInt", "(", ")", "{", "$", "count", "=", "$", "this", "->", "enumerationCount", ";", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "for", "(", "$", "ordinal", "=", "0", ";", "$", "ordinal", "<", "$", "count...
Get a new Iterator. This is the integer bitset implementation. @return Iterator @see getIterator() @see doGetIteratorBin()
[ "Get", "a", "new", "Iterator", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L761-L770
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doCountBin
private function doCountBin() { $count = 0; $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); if ($ord & 0b00000001) ++$count; if ($ord & 0b00000010) ++$count; if ($ord & 0b00000100) ++$count; if ($ord & 0b00001000) ++$count; if ($ord & 0b00010000) ++$count; if ($ord & 0b00100000) ++$count; if ($ord & 0b01000000) ++$count; if ($ord & 0b10000000) ++$count; } return $count; }
php
private function doCountBin() { $count = 0; $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); if ($ord & 0b00000001) ++$count; if ($ord & 0b00000010) ++$count; if ($ord & 0b00000100) ++$count; if ($ord & 0b00001000) ++$count; if ($ord & 0b00010000) ++$count; if ($ord & 0b00100000) ++$count; if ($ord & 0b01000000) ++$count; if ($ord & 0b10000000) ++$count; } return $count; }
[ "private", "function", "doCountBin", "(", ")", "{", "$", "count", "=", "0", ";", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "$", "byteLen", "=", "\\", "strlen", "(", "$", "bitset", ")", ";", "for", "(", "$", "bytePos", "=", "0", ";", ...
Count the number of elements. This is the binary bitset implementation. @return int @see count() @see doCountInt()
[ "Count", "the", "number", "of", "elements", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L795-L817
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doCountInt
private function doCountInt() { $count = 0; $bitset = $this->bitset; // PHP does not support right shift unsigned if ($bitset < 0) { $count = 1; $bitset = $bitset & \PHP_INT_MAX; } // iterate byte by byte and count set bits $phpIntBitSize = \PHP_INT_SIZE * 8; for ($bitPos = 0; $bitPos < $phpIntBitSize; $bitPos += 8) { $bitChk = 0xff << $bitPos; $byte = $bitset & $bitChk; if ($byte) { $byte = $byte >> $bitPos; if ($byte & 0b00000001) ++$count; if ($byte & 0b00000010) ++$count; if ($byte & 0b00000100) ++$count; if ($byte & 0b00001000) ++$count; if ($byte & 0b00010000) ++$count; if ($byte & 0b00100000) ++$count; if ($byte & 0b01000000) ++$count; if ($byte & 0b10000000) ++$count; } if ($bitset <= $bitChk) { break; } } return $count; }
php
private function doCountInt() { $count = 0; $bitset = $this->bitset; // PHP does not support right shift unsigned if ($bitset < 0) { $count = 1; $bitset = $bitset & \PHP_INT_MAX; } // iterate byte by byte and count set bits $phpIntBitSize = \PHP_INT_SIZE * 8; for ($bitPos = 0; $bitPos < $phpIntBitSize; $bitPos += 8) { $bitChk = 0xff << $bitPos; $byte = $bitset & $bitChk; if ($byte) { $byte = $byte >> $bitPos; if ($byte & 0b00000001) ++$count; if ($byte & 0b00000010) ++$count; if ($byte & 0b00000100) ++$count; if ($byte & 0b00001000) ++$count; if ($byte & 0b00010000) ++$count; if ($byte & 0b00100000) ++$count; if ($byte & 0b01000000) ++$count; if ($byte & 0b10000000) ++$count; } if ($bitset <= $bitChk) { break; } } return $count; }
[ "private", "function", "doCountInt", "(", ")", "{", "$", "count", "=", "0", ";", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "// PHP does not support right shift unsigned", "if", "(", "$", "bitset", "<", "0", ")", "{", "$", "count", "=", "1", ...
Count the number of elements. This is the integer bitset implementation. @return int @see count() @see doCountBin()
[ "Count", "the", "number", "of", "elements", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L828-L862
marc-mabe/php-enum
src/EnumSet.php
EnumSet.isEqual
public function isEqual(EnumSet $other): bool { return $this->enumeration === $other->enumeration && $this->bitset === $other->bitset; }
php
public function isEqual(EnumSet $other): bool { return $this->enumeration === $other->enumeration && $this->bitset === $other->bitset; }
[ "public", "function", "isEqual", "(", "EnumSet", "$", "other", ")", ":", "bool", "{", "return", "$", "this", "->", "enumeration", "===", "$", "other", "->", "enumeration", "&&", "$", "this", "->", "bitset", "===", "$", "other", "->", "bitset", ";", "}"...
Check if this EnumSet is the same as other @param EnumSet $other @return bool
[ "Check", "if", "this", "EnumSet", "is", "the", "same", "as", "other" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L869-L873
marc-mabe/php-enum
src/EnumSet.php
EnumSet.isSubset
public function isSubset(EnumSet $other): bool { return $this->enumeration === $other->enumeration && ($this->bitset & $other->bitset) === $this->bitset; }
php
public function isSubset(EnumSet $other): bool { return $this->enumeration === $other->enumeration && ($this->bitset & $other->bitset) === $this->bitset; }
[ "public", "function", "isSubset", "(", "EnumSet", "$", "other", ")", ":", "bool", "{", "return", "$", "this", "->", "enumeration", "===", "$", "other", "->", "enumeration", "&&", "(", "$", "this", "->", "bitset", "&", "$", "other", "->", "bitset", ")",...
Check if this EnumSet is a subset of other @param EnumSet $other @return bool
[ "Check", "if", "this", "EnumSet", "is", "a", "subset", "of", "other" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L880-L884
marc-mabe/php-enum
src/EnumSet.php
EnumSet.isSuperset
public function isSuperset(EnumSet $other): bool { return $this->enumeration === $other->enumeration && ($this->bitset | $other->bitset) === $this->bitset; }
php
public function isSuperset(EnumSet $other): bool { return $this->enumeration === $other->enumeration && ($this->bitset | $other->bitset) === $this->bitset; }
[ "public", "function", "isSuperset", "(", "EnumSet", "$", "other", ")", ":", "bool", "{", "return", "$", "this", "->", "enumeration", "===", "$", "other", "->", "enumeration", "&&", "(", "$", "this", "->", "bitset", "|", "$", "other", "->", "bitset", ")...
Check if this EnumSet is a superset of other @param EnumSet $other @return bool
[ "Check", "if", "this", "EnumSet", "is", "a", "superset", "of", "other" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L891-L895
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doGetOrdinalsBin
private function doGetOrdinalsBin() { $ordinals = []; $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); for ($bitPos = 0; $bitPos < 8; ++$bitPos) { if ($ord & (1 << $bitPos)) { $ordinals[] = $bytePos * 8 + $bitPos; } } } return $ordinals; }
php
private function doGetOrdinalsBin() { $ordinals = []; $bitset = $this->bitset; $byteLen = \strlen($bitset); for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) { if ($bitset[$bytePos] === "\0") { // fast skip null byte continue; } $ord = \ord($bitset[$bytePos]); for ($bitPos = 0; $bitPos < 8; ++$bitPos) { if ($ord & (1 << $bitPos)) { $ordinals[] = $bytePos * 8 + $bitPos; } } } return $ordinals; }
[ "private", "function", "doGetOrdinalsBin", "(", ")", "{", "$", "ordinals", "=", "[", "]", ";", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "$", "byteLen", "=", "\\", "strlen", "(", "$", "bitset", ")", ";", "for", "(", "$", "bytePos", "=",...
Get ordinal numbers of the defined enumerators as array. This is the binary bitset implementation. @return int[] @see getOrdinals() @see goGetOrdinalsInt()
[ "Get", "ordinal", "numbers", "of", "the", "defined", "enumerators", "as", "array", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L917-L936
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doGetOrdinalsInt
private function doGetOrdinalsInt() { $ordinals = []; $count = $this->enumerationCount; $bitset = $this->bitset; for ($ordinal = 0; $ordinal < $count; ++$ordinal) { if ($bitset & (1 << $ordinal)) { $ordinals[] = $ordinal; } } return $ordinals; }
php
private function doGetOrdinalsInt() { $ordinals = []; $count = $this->enumerationCount; $bitset = $this->bitset; for ($ordinal = 0; $ordinal < $count; ++$ordinal) { if ($bitset & (1 << $ordinal)) { $ordinals[] = $ordinal; } } return $ordinals; }
[ "private", "function", "doGetOrdinalsInt", "(", ")", "{", "$", "ordinals", "=", "[", "]", ";", "$", "count", "=", "$", "this", "->", "enumerationCount", ";", "$", "bitset", "=", "$", "this", "->", "bitset", ";", "for", "(", "$", "ordinal", "=", "0", ...
Get ordinal numbers of the defined enumerators as array. This is the integer bitset implementation. @return int[] @see getOrdinals() @see doGetOrdinalsBin()
[ "Get", "ordinal", "numbers", "of", "the", "defined", "enumerators", "as", "array", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L947-L958
marc-mabe/php-enum
src/EnumSet.php
EnumSet.getValues
public function getValues(): array { $enumeration = $this->enumeration; $values = []; foreach ($this->getOrdinals() as $ord) { $values[] = $enumeration::byOrdinal($ord)->getValue(); } return $values; }
php
public function getValues(): array { $enumeration = $this->enumeration; $values = []; foreach ($this->getOrdinals() as $ord) { $values[] = $enumeration::byOrdinal($ord)->getValue(); } return $values; }
[ "public", "function", "getValues", "(", ")", ":", "array", "{", "$", "enumeration", "=", "$", "this", "->", "enumeration", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOrdinals", "(", ")", "as", "$", "ord", ")", "{...
Get values of the defined enumerators as array @return mixed[]
[ "Get", "values", "of", "the", "defined", "enumerators", "as", "array" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L964-L972
marc-mabe/php-enum
src/EnumSet.php
EnumSet.getNames
public function getNames(): array { $enumeration = $this->enumeration; $names = []; foreach ($this->getOrdinals() as $ord) { $names[] = $enumeration::byOrdinal($ord)->getName(); } return $names; }
php
public function getNames(): array { $enumeration = $this->enumeration; $names = []; foreach ($this->getOrdinals() as $ord) { $names[] = $enumeration::byOrdinal($ord)->getName(); } return $names; }
[ "public", "function", "getNames", "(", ")", ":", "array", "{", "$", "enumeration", "=", "$", "this", "->", "enumeration", ";", "$", "names", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOrdinals", "(", ")", "as", "$", "ord", ")", "{",...
Get names of the defined enumerators as array @return string[]
[ "Get", "names", "of", "the", "defined", "enumerators", "as", "array" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L978-L986
marc-mabe/php-enum
src/EnumSet.php
EnumSet.getEnumerators
public function getEnumerators(): array { $enumeration = $this->enumeration; $enumerators = []; foreach ($this->getOrdinals() as $ord) { $enumerators[] = $enumeration::byOrdinal($ord); } return $enumerators; }
php
public function getEnumerators(): array { $enumeration = $this->enumeration; $enumerators = []; foreach ($this->getOrdinals() as $ord) { $enumerators[] = $enumeration::byOrdinal($ord); } return $enumerators; }
[ "public", "function", "getEnumerators", "(", ")", ":", "array", "{", "$", "enumeration", "=", "$", "this", "->", "enumeration", ";", "$", "enumerators", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOrdinals", "(", ")", "as", "$", "ord", ...
Get the defined enumerators as array @return Enum[]
[ "Get", "the", "defined", "enumerators", "as", "array" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L992-L1000
marc-mabe/php-enum
src/EnumSet.php
EnumSet.doGetBinaryBitsetLeInt
private function doGetBinaryBitsetLeInt() { $bin = \pack(\PHP_INT_SIZE === 8 ? 'P' : 'V', $this->bitset); return \substr($bin, 0, (int)\ceil($this->enumerationCount / 8)); }
php
private function doGetBinaryBitsetLeInt() { $bin = \pack(\PHP_INT_SIZE === 8 ? 'P' : 'V', $this->bitset); return \substr($bin, 0, (int)\ceil($this->enumerationCount / 8)); }
[ "private", "function", "doGetBinaryBitsetLeInt", "(", ")", "{", "$", "bin", "=", "\\", "pack", "(", "\\", "PHP_INT_SIZE", "===", "8", "?", "'P'", ":", "'V'", ",", "$", "this", "->", "bitset", ")", ";", "return", "\\", "substr", "(", "$", "bin", ",", ...
Get binary bitset in little-endian order. This is the integer bitset implementation. @return string @see getBinaryBitsetLe() @see doGetBinaryBitsetLeBin()
[ "Get", "binary", "bitset", "in", "little", "-", "endian", "order", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L1037-L1041
marc-mabe/php-enum
src/EnumSet.php
EnumSet.getBit
public function getBit(int $ordinal): bool { if ($ordinal < 0 || $ordinal > $this->enumerationCount) { throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}"); } return $this->{$this->fnDoGetBit}($ordinal); }
php
public function getBit(int $ordinal): bool { if ($ordinal < 0 || $ordinal > $this->enumerationCount) { throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}"); } return $this->{$this->fnDoGetBit}($ordinal); }
[ "public", "function", "getBit", "(", "int", "$", "ordinal", ")", ":", "bool", "{", "if", "(", "$", "ordinal", "<", "0", "||", "$", "ordinal", ">", "$", "this", "->", "enumerationCount", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Ordina...
Get a bit at the given ordinal number @param int $ordinal Ordinal number of bit to get @return bool @throws InvalidArgumentException If the given ordinal number is out-of-range @uses doGetBitBin() @uses doGetBitInt()
[ "Get", "a", "bit", "at", "the", "given", "ordinal", "number" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSet.php#L1062-L1069
marc-mabe/php-enum
src/Enum.php
Enum.getOrdinal
final public function getOrdinal() { if ($this->ordinal === null) { $ordinal = 0; $value = $this->value; foreach (self::detectConstants(static::class) as $constValue) { if ($value === $constValue) { break; } ++$ordinal; } $this->ordinal = $ordinal; } return $this->ordinal; }
php
final public function getOrdinal() { if ($this->ordinal === null) { $ordinal = 0; $value = $this->value; foreach (self::detectConstants(static::class) as $constValue) { if ($value === $constValue) { break; } ++$ordinal; } $this->ordinal = $ordinal; } return $this->ordinal; }
[ "final", "public", "function", "getOrdinal", "(", ")", "{", "if", "(", "$", "this", "->", "ordinal", "===", "null", ")", "{", "$", "ordinal", "=", "0", ";", "$", "value", "=", "$", "this", "->", "value", ";", "foreach", "(", "self", "::", "detectCo...
Get the ordinal number of the enumerator @return int
[ "Get", "the", "ordinal", "number", "of", "the", "enumerator" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L130-L146
marc-mabe/php-enum
src/Enum.php
Enum.is
final public function is($enumerator) { return $this === $enumerator || $this->value === $enumerator // The following additional conditions are required only because of the issue of serializable singletons || ($enumerator instanceof static && \get_class($enumerator) === static::class && $enumerator->value === $this->value ); }
php
final public function is($enumerator) { return $this === $enumerator || $this->value === $enumerator // The following additional conditions are required only because of the issue of serializable singletons || ($enumerator instanceof static && \get_class($enumerator) === static::class && $enumerator->value === $this->value ); }
[ "final", "public", "function", "is", "(", "$", "enumerator", ")", "{", "return", "$", "this", "===", "$", "enumerator", "||", "$", "this", "->", "value", "===", "$", "enumerator", "// The following additional conditions are required only because of the issue of serializ...
Compare this enumerator against another and check if it's the same. @param static|null|bool|int|float|string|array $enumerator An enumerator object or value @return bool
[ "Compare", "this", "enumerator", "against", "another", "and", "check", "if", "it", "s", "the", "same", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L154-L163
marc-mabe/php-enum
src/Enum.php
Enum.byValue
final public static function byValue($value) { if (!isset(self::$constants[static::class])) { self::detectConstants(static::class); } $name = \array_search($value, self::$constants[static::class], true); if ($name === false) { throw new InvalidArgumentException(sprintf( 'Unknown value %s for enumeration %s', \is_scalar($value) ? \var_export($value, true) : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)), static::class )); } if (!isset(self::$instances[static::class][$name])) { self::$instances[static::class][$name] = new static(self::$constants[static::class][$name]); } return self::$instances[static::class][$name]; }
php
final public static function byValue($value) { if (!isset(self::$constants[static::class])) { self::detectConstants(static::class); } $name = \array_search($value, self::$constants[static::class], true); if ($name === false) { throw new InvalidArgumentException(sprintf( 'Unknown value %s for enumeration %s', \is_scalar($value) ? \var_export($value, true) : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)), static::class )); } if (!isset(self::$instances[static::class][$name])) { self::$instances[static::class][$name] = new static(self::$constants[static::class][$name]); } return self::$instances[static::class][$name]; }
[ "final", "public", "static", "function", "byValue", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "constants", "[", "static", "::", "class", "]", ")", ")", "{", "self", "::", "detectConstants", "(", "static", "::", "cl...
Get an enumerator instance by the given value @param null|bool|int|float|string|array $value Enumerator value @return static @throws InvalidArgumentException On an unknwon or invalid value @throws LogicException On ambiguous constant values
[ "Get", "an", "enumerator", "instance", "by", "the", "given", "value" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L190-L212
marc-mabe/php-enum
src/Enum.php
Enum.byName
final public static function byName(string $name) { if (isset(self::$instances[static::class][$name])) { return self::$instances[static::class][$name]; } $const = static::class . "::{$name}"; if (!\defined($const)) { throw new InvalidArgumentException("{$const} not defined"); } return self::$instances[static::class][$name] = new static(\constant($const)); }
php
final public static function byName(string $name) { if (isset(self::$instances[static::class][$name])) { return self::$instances[static::class][$name]; } $const = static::class . "::{$name}"; if (!\defined($const)) { throw new InvalidArgumentException("{$const} not defined"); } return self::$instances[static::class][$name] = new static(\constant($const)); }
[ "final", "public", "static", "function", "byName", "(", "string", "$", "name", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "instances", "[", "static", "::", "class", "]", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", ...
Get an enumerator instance by the given name @param string $name The name of the enumerator @return static @throws InvalidArgumentException On an invalid or unknown name @throws LogicException On ambiguous values
[ "Get", "an", "enumerator", "instance", "by", "the", "given", "name" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L222-L234
marc-mabe/php-enum
src/Enum.php
Enum.byOrdinal
final public static function byOrdinal(int $ordinal) { if (!isset(self::$names[static::class])) { self::detectConstants(static::class); } if (!isset(self::$names[static::class][$ordinal])) { throw new InvalidArgumentException(\sprintf( 'Invalid ordinal number %s, must between 0 and %s', $ordinal, \count(self::$names[static::class]) - 1 )); } $name = self::$names[static::class][$ordinal]; if (isset(self::$instances[static::class][$name])) { return self::$instances[static::class][$name]; } return self::$instances[static::class][$name] = new static(self::$constants[static::class][$name], $ordinal); }
php
final public static function byOrdinal(int $ordinal) { if (!isset(self::$names[static::class])) { self::detectConstants(static::class); } if (!isset(self::$names[static::class][$ordinal])) { throw new InvalidArgumentException(\sprintf( 'Invalid ordinal number %s, must between 0 and %s', $ordinal, \count(self::$names[static::class]) - 1 )); } $name = self::$names[static::class][$ordinal]; if (isset(self::$instances[static::class][$name])) { return self::$instances[static::class][$name]; } return self::$instances[static::class][$name] = new static(self::$constants[static::class][$name], $ordinal); }
[ "final", "public", "static", "function", "byOrdinal", "(", "int", "$", "ordinal", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "names", "[", "static", "::", "class", "]", ")", ")", "{", "self", "::", "detectConstants", "(", "static", ":...
Get an enumeration instance by the given ordinal number @param int $ordinal The ordinal number of the enumerator @return static @throws InvalidArgumentException On an invalid ordinal number @throws LogicException On ambiguous values
[ "Get", "an", "enumeration", "instance", "by", "the", "given", "ordinal", "number" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L244-L264
marc-mabe/php-enum
src/Enum.php
Enum.detectConstants
private static function detectConstants($class) { if (!isset(self::$constants[$class])) { $reflection = new ReflectionClass($class); $constants = []; do { $scopeConstants = []; // Enumerators must be defined as public class constants foreach ($reflection->getReflectionConstants() as $reflConstant) { if ($reflConstant->isPublic()) { $scopeConstants[ $reflConstant->getName() ] = $reflConstant->getValue(); } } $constants = $scopeConstants + $constants; } while (($reflection = $reflection->getParentClass()) && $reflection->name !== __CLASS__); assert( self::noAmbiguousValues($constants), "Ambiguous enumerator values detected for {$class}" ); self::$constants[$class] = $constants; self::$names[$class] = \array_keys($constants); } return self::$constants[$class]; }
php
private static function detectConstants($class) { if (!isset(self::$constants[$class])) { $reflection = new ReflectionClass($class); $constants = []; do { $scopeConstants = []; // Enumerators must be defined as public class constants foreach ($reflection->getReflectionConstants() as $reflConstant) { if ($reflConstant->isPublic()) { $scopeConstants[ $reflConstant->getName() ] = $reflConstant->getValue(); } } $constants = $scopeConstants + $constants; } while (($reflection = $reflection->getParentClass()) && $reflection->name !== __CLASS__); assert( self::noAmbiguousValues($constants), "Ambiguous enumerator values detected for {$class}" ); self::$constants[$class] = $constants; self::$names[$class] = \array_keys($constants); } return self::$constants[$class]; }
[ "private", "static", "function", "detectConstants", "(", "$", "class", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "constants", "[", "$", "class", "]", ")", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "class", ...
Detect all public available constants of given enumeration class @param string $class @return array
[ "Detect", "all", "public", "available", "constants", "of", "given", "enumeration", "class" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L365-L393
marc-mabe/php-enum
src/Enum.php
Enum.noAmbiguousValues
private static function noAmbiguousValues($constants) { foreach ($constants as $value) { $names = \array_keys($constants, $value, true); if (\count($names) > 1) { return false; } } return true; }
php
private static function noAmbiguousValues($constants) { foreach ($constants as $value) { $names = \array_keys($constants, $value, true); if (\count($names) > 1) { return false; } } return true; }
[ "private", "static", "function", "noAmbiguousValues", "(", "$", "constants", ")", "{", "foreach", "(", "$", "constants", "as", "$", "value", ")", "{", "$", "names", "=", "\\", "array_keys", "(", "$", "constants", ",", "$", "value", ",", "true", ")", ";...
Test that the given constants does not contain ambiguous values @param array $constants @return bool
[ "Test", "that", "the", "given", "constants", "does", "not", "contain", "ambiguous", "values" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/Enum.php#L400-L410
marc-mabe/php-enum
bench/EnumBench.php
EnumBench.init
public function init() { $enumRefl = new ReflectionClass(Enum::class); $enumPropsRefl = $enumRefl->getProperties(ReflectionProperty::IS_STATIC); foreach ($enumPropsRefl as $enumPropRefl) { $enumPropRefl->setAccessible(true); $this->enumPropsRefl[$enumPropRefl->getName()] = $enumPropRefl; } $this->names = Enum66::getNames(); $this->values = Enum66::getValues(); $this->ordinals = Enum66::getOrdinals(); $this->enumerators = Enum66::getEnumerators(); }
php
public function init() { $enumRefl = new ReflectionClass(Enum::class); $enumPropsRefl = $enumRefl->getProperties(ReflectionProperty::IS_STATIC); foreach ($enumPropsRefl as $enumPropRefl) { $enumPropRefl->setAccessible(true); $this->enumPropsRefl[$enumPropRefl->getName()] = $enumPropRefl; } $this->names = Enum66::getNames(); $this->values = Enum66::getValues(); $this->ordinals = Enum66::getOrdinals(); $this->enumerators = Enum66::getEnumerators(); }
[ "public", "function", "init", "(", ")", "{", "$", "enumRefl", "=", "new", "ReflectionClass", "(", "Enum", "::", "class", ")", ";", "$", "enumPropsRefl", "=", "$", "enumRefl", "->", "getProperties", "(", "ReflectionProperty", "::", "IS_STATIC", ")", ";", "f...
Will be called before every subject
[ "Will", "be", "called", "before", "every", "subject" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/bench/EnumBench.php#L50-L63
marc-mabe/php-enum
src/EnumMap.php
EnumMap.add
public function add($enumerator, $value): void { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); $this->map[$ord] = $value; }
php
public function add($enumerator, $value): void { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); $this->map[$ord] = $value; }
[ "public", "function", "add", "(", "$", "enumerator", ",", "$", "value", ")", ":", "void", "{", "$", "ord", "=", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOrdinal", "(", ")", ";", "$", "this", ...
Adds the given enumerator (object or value) mapping to the specified data value. @param Enum|null|bool|int|float|string|array $enumerator @param mixed $value @throws InvalidArgumentException On an invalid given enumerator @see offsetSet()
[ "Adds", "the", "given", "enumerator", "(", "object", "or", "value", ")", "mapping", "to", "the", "specified", "data", "value", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L66-L70
marc-mabe/php-enum
src/EnumMap.php
EnumMap.addIterable
public function addIterable(iterable $map): void { $innerMap = $this->map; foreach ($map as $enumerator => $value) { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); $innerMap[$ord] = $value; } $this->map = $innerMap; }
php
public function addIterable(iterable $map): void { $innerMap = $this->map; foreach ($map as $enumerator => $value) { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); $innerMap[$ord] = $value; } $this->map = $innerMap; }
[ "public", "function", "addIterable", "(", "iterable", "$", "map", ")", ":", "void", "{", "$", "innerMap", "=", "$", "this", "->", "map", ";", "foreach", "(", "$", "map", "as", "$", "enumerator", "=>", "$", "value", ")", "{", "$", "ord", "=", "(", ...
Adds the given iterable, mapping enumerators (objects or values) to data values. @param iterable $map @throws InvalidArgumentException On an invalid given enumerator
[ "Adds", "the", "given", "iterable", "mapping", "enumerators", "(", "objects", "or", "values", ")", "to", "data", "values", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L77-L85
marc-mabe/php-enum
src/EnumMap.php
EnumMap.remove
public function remove($enumerator): void { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); unset($this->map[$ord]); }
php
public function remove($enumerator): void { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); unset($this->map[$ord]); }
[ "public", "function", "remove", "(", "$", "enumerator", ")", ":", "void", "{", "$", "ord", "=", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOrdinal", "(", ")", ";", "unset", "(", "$", "this", "->"...
Removes the given enumerator (object or value) mapping. @param Enum|null|bool|int|float|string|array $enumerator @throws InvalidArgumentException On an invalid given enumerator @see offsetUnset()
[ "Removes", "the", "given", "enumerator", "(", "object", "or", "value", ")", "mapping", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L93-L97
marc-mabe/php-enum
src/EnumMap.php
EnumMap.removeIterable
public function removeIterable(iterable $enumerators): void { $map = $this->map; foreach ($enumerators as $enumerator) { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); unset($map[$ord]); } $this->map = $map; }
php
public function removeIterable(iterable $enumerators): void { $map = $this->map; foreach ($enumerators as $enumerator) { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); unset($map[$ord]); } $this->map = $map; }
[ "public", "function", "removeIterable", "(", "iterable", "$", "enumerators", ")", ":", "void", "{", "$", "map", "=", "$", "this", "->", "map", ";", "foreach", "(", "$", "enumerators", "as", "$", "enumerator", ")", "{", "$", "ord", "=", "(", "$", "thi...
Removes the given iterable enumerator (object or value) mappings. @param iterable $enumerators @throws InvalidArgumentException On an invalid given enumerator
[ "Removes", "the", "given", "iterable", "enumerator", "(", "object", "or", "value", ")", "mappings", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L104-L113
marc-mabe/php-enum
src/EnumMap.php
EnumMap.get
public function get($enumerator) { $enumerator = ($this->enumeration)::get($enumerator); $ord = $enumerator->getOrdinal(); if (!\array_key_exists($ord, $this->map)) { throw new UnexpectedValueException(sprintf( 'Enumerator %s could not be found', \var_export($enumerator->getValue(), true) )); } return $this->map[$ord]; }
php
public function get($enumerator) { $enumerator = ($this->enumeration)::get($enumerator); $ord = $enumerator->getOrdinal(); if (!\array_key_exists($ord, $this->map)) { throw new UnexpectedValueException(sprintf( 'Enumerator %s could not be found', \var_export($enumerator->getValue(), true) )); } return $this->map[$ord]; }
[ "public", "function", "get", "(", "$", "enumerator", ")", "{", "$", "enumerator", "=", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", ";", "$", "ord", "=", "$", "enumerator", "->", "getOrdinal", "(", ")", ";", ...
Get the mapped data value of the given enumerator (object or value). @param Enum|null|bool|int|float|string|array $enumerator @return mixed @throws InvalidArgumentException On an invalid given enumerator @throws UnexpectedValueException If the given enumerator does not exist in this map @see offsetGet()
[ "Get", "the", "mapped", "data", "value", "of", "the", "given", "enumerator", "(", "object", "or", "value", ")", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L189-L201
marc-mabe/php-enum
src/EnumMap.php
EnumMap.search
public function search($value, bool $strict = false) { $ord = \array_search($value, $this->map, $strict); if ($ord !== false) { return ($this->enumeration)::byOrdinal($ord); } return null; }
php
public function search($value, bool $strict = false) { $ord = \array_search($value, $this->map, $strict); if ($ord !== false) { return ($this->enumeration)::byOrdinal($ord); } return null; }
[ "public", "function", "search", "(", "$", "value", ",", "bool", "$", "strict", "=", "false", ")", "{", "$", "ord", "=", "\\", "array_search", "(", "$", "value", ",", "$", "this", "->", "map", ",", "$", "strict", ")", ";", "if", "(", "$", "ord", ...
Search for the given data value. @param mixed $value @param bool $strict Use strict type comparison @return Enum|null The enumerator object of the first matching data value or NULL
[ "Search", "for", "the", "given", "data", "value", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L227-L235
marc-mabe/php-enum
src/EnumMap.php
EnumMap.has
public function has($enumerator): bool { try { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); return \array_key_exists($ord, $this->map); } catch (InvalidArgumentException $e) { // An invalid enumerator can't be contained in this map return false; } }
php
public function has($enumerator): bool { try { $ord = ($this->enumeration)::get($enumerator)->getOrdinal(); return \array_key_exists($ord, $this->map); } catch (InvalidArgumentException $e) { // An invalid enumerator can't be contained in this map return false; } }
[ "public", "function", "has", "(", "$", "enumerator", ")", ":", "bool", "{", "try", "{", "$", "ord", "=", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOrdinal", "(", ")", ";", "return", "\\", "array...
Test if the given enumerator key (object or value) exists. @param Enum|null|bool|int|float|string|array $enumerator @return bool @see offsetExists()
[ "Test", "if", "the", "given", "enumerator", "key", "(", "object", "or", "value", ")", "exists", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L243-L252
marc-mabe/php-enum
src/EnumMap.php
EnumMap.offsetExists
public function offsetExists($enumerator): bool { try { return isset($this->map[($this->enumeration)::get($enumerator)->getOrdinal()]); } catch (InvalidArgumentException $e) { // An invalid enumerator can't be an offset of this map return false; } }
php
public function offsetExists($enumerator): bool { try { return isset($this->map[($this->enumeration)::get($enumerator)->getOrdinal()]); } catch (InvalidArgumentException $e) { // An invalid enumerator can't be an offset of this map return false; } }
[ "public", "function", "offsetExists", "(", "$", "enumerator", ")", ":", "bool", "{", "try", "{", "return", "isset", "(", "$", "this", "->", "map", "[", "(", "$", "this", "->", "enumeration", ")", "::", "get", "(", "$", "enumerator", ")", "->", "getOr...
Test if the given enumerator key (object or value) exists and is not NULL @param Enum|null|bool|int|float|string|array $enumerator @return bool @see contains()
[ "Test", "if", "the", "given", "enumerator", "key", "(", "object", "or", "value", ")", "exists", "and", "is", "not", "NULL" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L275-L283
marc-mabe/php-enum
src/EnumMap.php
EnumMap.getIterator
public function getIterator(): Iterator { $map = $this->map; foreach ($map as $ordinal => $value) { yield ($this->enumeration)::byOrdinal($ordinal) => $value; } }
php
public function getIterator(): Iterator { $map = $this->map; foreach ($map as $ordinal => $value) { yield ($this->enumeration)::byOrdinal($ordinal) => $value; } }
[ "public", "function", "getIterator", "(", ")", ":", "Iterator", "{", "$", "map", "=", "$", "this", "->", "map", ";", "foreach", "(", "$", "map", "as", "$", "ordinal", "=>", "$", "value", ")", "{", "yield", "(", "$", "this", "->", "enumeration", ")"...
Get a new Iterator. @return Iterator Iterator<K extends Enum, V>
[ "Get", "a", "new", "Iterator", "." ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumMap.php#L333-L339
marc-mabe/php-enum
bench/EnumMapBench.php
EnumMapBench.init
public function init() { $this->values = Enum66::getValues(); $this->enumerators = Enum66::getEnumerators(); $this->emptyMap = new EnumMap(Enum66::class); $this->fullMap = new EnumMap(Enum66::class); foreach ($this->enumerators as $i => $enumerator) { $this->fullMap->offsetSet($enumerator, $i); } }
php
public function init() { $this->values = Enum66::getValues(); $this->enumerators = Enum66::getEnumerators(); $this->emptyMap = new EnumMap(Enum66::class); $this->fullMap = new EnumMap(Enum66::class); foreach ($this->enumerators as $i => $enumerator) { $this->fullMap->offsetSet($enumerator, $i); } }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "values", "=", "Enum66", "::", "getValues", "(", ")", ";", "$", "this", "->", "enumerators", "=", "Enum66", "::", "getEnumerators", "(", ")", ";", "$", "this", "->", "emptyMap", "=", "ne...
Will be called before every subject
[ "Will", "be", "called", "before", "every", "subject" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/bench/EnumMapBench.php#L44-L54
marc-mabe/php-enum
src/EnumSerializableTrait.php
EnumSerializableTrait.unserialize
public function unserialize($serialized): void { $value = \unserialize($serialized); $constants = self::getConstants(); $name = \array_search($value, $constants, true); if ($name === false) { $message = \is_scalar($value) ? 'Unknown value ' . \var_export($value, true) : 'Invalid value of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)); throw new RuntimeException($message); } $class = static::class; $enumerator = $this; $closure = function () use ($class, $name, $value, $enumerator) { if ($value !== null && $this->value !== null) { throw new LogicException('Do not call this directly - please use unserialize($enum) instead'); } $this->value = $value; if (!isset(self::$instances[$class][$name])) { self::$instances[$class][$name] = $enumerator; } }; $closure->bindTo($this, Enum::class)(); }
php
public function unserialize($serialized): void { $value = \unserialize($serialized); $constants = self::getConstants(); $name = \array_search($value, $constants, true); if ($name === false) { $message = \is_scalar($value) ? 'Unknown value ' . \var_export($value, true) : 'Invalid value of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)); throw new RuntimeException($message); } $class = static::class; $enumerator = $this; $closure = function () use ($class, $name, $value, $enumerator) { if ($value !== null && $this->value !== null) { throw new LogicException('Do not call this directly - please use unserialize($enum) instead'); } $this->value = $value; if (!isset(self::$instances[$class][$name])) { self::$instances[$class][$name] = $enumerator; } }; $closure->bindTo($this, Enum::class)(); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", ":", "void", "{", "$", "value", "=", "\\", "unserialize", "(", "$", "serialized", ")", ";", "$", "constants", "=", "self", "::", "getConstants", "(", ")", ";", "$", "name", "=", "\\", ...
Unserializes a given serialized value and push it into the current instance This will be called automatically on `unserialize()` if the enumeration implements the `Serializable` interface @param string $serialized @return void @throws RuntimeException On an unknown or invalid value @throws LogicException On changing numeration value by calling this directly
[ "Unserializes", "a", "given", "serialized", "value", "and", "push", "it", "into", "the", "current", "instance", "This", "will", "be", "called", "automatically", "on", "unserialize", "()", "if", "the", "enumeration", "implements", "the", "Serializable", "interface"...
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/src/EnumSerializableTrait.php#L49-L75
marc-mabe/php-enum
bench/EnumSet66Bench.php
EnumSet66Bench.init
public function init() { $this->values = Enum66::getValues(); $this->enumerators = Enum66::getEnumerators(); $this->emptySet = new EnumSet(Enum66::class); $this->fullSet = new EnumSet(Enum66::class, $this->enumerators); }
php
public function init() { $this->values = Enum66::getValues(); $this->enumerators = Enum66::getEnumerators(); $this->emptySet = new EnumSet(Enum66::class); $this->fullSet = new EnumSet(Enum66::class, $this->enumerators); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "values", "=", "Enum66", "::", "getValues", "(", ")", ";", "$", "this", "->", "enumerators", "=", "Enum66", "::", "getEnumerators", "(", ")", ";", "$", "this", "->", "emptySet", "=", "ne...
Will be called before every subject
[ "Will", "be", "called", "before", "every", "subject" ]
train
https://github.com/marc-mabe/php-enum/blob/3304afafc9e977e938824ed68e97683b3f152d2b/bench/EnumSet66Bench.php#L20-L27
artkonekt/menu
src/MenuServiceProvider.php
MenuServiceProvider.register
public function register() { $this->app->singleton('menu', function ($app) { return new Repository(); }); $this->app->singleton('konekt.menu.renderer.menu.ul', UlMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.menu.ol', OlMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.menu.div', DivMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.item.li', LiItemRenderer::class); $this->app->singleton('konekt.menu.renderer.item.div', DivItemRenderer::class); }
php
public function register() { $this->app->singleton('menu', function ($app) { return new Repository(); }); $this->app->singleton('konekt.menu.renderer.menu.ul', UlMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.menu.ol', OlMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.menu.div', DivMenuRenderer::class); $this->app->singleton('konekt.menu.renderer.item.li', LiItemRenderer::class); $this->app->singleton('konekt.menu.renderer.item.div', DivItemRenderer::class); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'menu'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Repository", "(", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", ...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/MenuServiceProvider.php#L36-L47
artkonekt/menu
src/ItemCollection.php
ItemCollection.addItem
public function addItem(Item $item) { if ($this->has($item->name)) { throw new DuplicateItemNameException( sprintf('An item with name `%s` already exists in the menu `%s`', $item->name, $item->menu->name ) ); } return $this->put($item->name, $item); }
php
public function addItem(Item $item) { if ($this->has($item->name)) { throw new DuplicateItemNameException( sprintf('An item with name `%s` already exists in the menu `%s`', $item->name, $item->menu->name ) ); } return $this->put($item->name, $item); }
[ "public", "function", "addItem", "(", "Item", "$", "item", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "item", "->", "name", ")", ")", "{", "throw", "new", "DuplicateItemNameException", "(", "sprintf", "(", "'An item with name `%s` already exist...
Add new Item to the collection. Performs check for name uniqueness @param Item $item @return $this @throws DuplicateItemNameException
[ "Add", "new", "Item", "to", "the", "collection", ".", "Performs", "check", "for", "name", "uniqueness" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L42-L53
artkonekt/menu
src/ItemCollection.php
ItemCollection.remove
public function remove($item) { $key = $item instanceof Item ? $item->name : $item; if ($this->has($key)) { $this->forget($key); return true; } return false; }
php
public function remove($item) { $key = $item instanceof Item ? $item->name : $item; if ($this->has($key)) { $this->forget($key); return true; } return false; }
[ "public", "function", "remove", "(", "$", "item", ")", "{", "$", "key", "=", "$", "item", "instanceof", "Item", "?", "$", "item", "->", "name", ":", "$", "item", ";", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "...
Remove an item from the list @param Item|string $item The item instance or name @return bool Returns true if the element has been removed, false otherwise
[ "Remove", "an", "item", "from", "the", "list" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L62-L72
artkonekt/menu
src/ItemCollection.php
ItemCollection.attr
public function attr(...$args) { $this->each(function ($item) use ($args) { $item->attr(...$args); }); return $this; }
php
public function attr(...$args) { $this->each(function ($item) use ($args) { $item->attr(...$args); }); return $this; }
[ "public", "function", "attr", "(", "...", "$", "args", ")", "{", "$", "this", "->", "each", "(", "function", "(", "$", "item", ")", "use", "(", "$", "args", ")", "{", "$", "item", "->", "attr", "(", "...", "$", "args", ")", ";", "}", ")", ";"...
Add attributes to a collection of items @return ItemCollection
[ "Add", "attributes", "to", "a", "collection", "of", "items" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L79-L86
artkonekt/menu
src/ItemCollection.php
ItemCollection.data
public function data(...$args) { $this->each(function ($item) use ($args) { $item->data(...$args); }); return $this; }
php
public function data(...$args) { $this->each(function ($item) use ($args) { $item->data(...$args); }); return $this; }
[ "public", "function", "data", "(", "...", "$", "args", ")", "{", "$", "this", "->", "each", "(", "function", "(", "$", "item", ")", "use", "(", "$", "args", ")", "{", "$", "item", "->", "data", "(", "...", "$", "args", ")", ";", "}", ")", ";"...
Add meta data to a collection of items @param array $args @return ItemCollection
[ "Add", "meta", "data", "to", "a", "collection", "of", "items" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L95-L102
artkonekt/menu
src/ItemCollection.php
ItemCollection.appendHtml
public function appendHtml($html) { $this->each(function ($item) use ($html) { $item->title .= $html; }); return $this; }
php
public function appendHtml($html) { $this->each(function ($item) use ($html) { $item->title .= $html; }); return $this; }
[ "public", "function", "appendHtml", "(", "$", "html", ")", "{", "$", "this", "->", "each", "(", "function", "(", "$", "item", ")", "use", "(", "$", "html", ")", "{", "$", "item", "->", "title", ".=", "$", "html", ";", "}", ")", ";", "return", "...
Appends text or HTML to a collection of items @param string @return ItemCollection
[ "Appends", "text", "or", "HTML", "to", "a", "collection", "of", "items" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L111-L118
artkonekt/menu
src/ItemCollection.php
ItemCollection.prependHtml
public function prependHtml($html) { $this->each(function ($item) use ($html) { $item->title = $html . $item->title; }); return $this; }
php
public function prependHtml($html) { $this->each(function ($item) use ($html) { $item->title = $html . $item->title; }); return $this; }
[ "public", "function", "prependHtml", "(", "$", "html", ")", "{", "$", "this", "->", "each", "(", "function", "(", "$", "item", ")", "use", "(", "$", "html", ")", "{", "$", "item", "->", "title", "=", "$", "html", ".", "$", "item", "->", "title", ...
Prepends text or HTML to a collection of items @param string $html @return ItemCollection
[ "Prepends", "text", "or", "HTML", "to", "a", "collection", "of", "items" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L127-L134
artkonekt/menu
src/ItemCollection.php
ItemCollection.filterByProperty
protected function filterByProperty($property, $value) { return $this->filter(function ($item) use ($property, $value) { if ($item->hasProperty($property)) { return $item->attr($property) == $value || $item->data($property) == $value; } return false; })->keyBy('name'); }
php
protected function filterByProperty($property, $value) { return $this->filter(function ($item) use ($property, $value) { if ($item->hasProperty($property)) { return $item->attr($property) == $value || $item->data($property) == $value; } return false; })->keyBy('name'); }
[ "protected", "function", "filterByProperty", "(", "$", "property", ",", "$", "value", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "item", ")", "use", "(", "$", "property", ",", "$", "value", ")", "{", "if", "(", "$", ...
@param $property @param $value @return static
[ "@param", "$property", "@param", "$value" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/ItemCollection.php#L201-L213
artkonekt/menu
src/Item.php
Item.addSubItem
public function addSubItem($name, $title, $options = []) { $options = is_array($options) ? $options : ['url' => $options]; $options['parent'] = $this; return $this->menu->addItem($name, $title, $options); }
php
public function addSubItem($name, $title, $options = []) { $options = is_array($options) ? $options : ['url' => $options]; $options['parent'] = $this; return $this->menu->addItem($name, $title, $options); }
[ "public", "function", "addSubItem", "(", "$", "name", ",", "$", "title", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "is_array", "(", "$", "options", ")", "?", "$", "options", ":", "[", "'url'", "=>", "$", "options", "]", "...
Creates a sub Item @param string $name @param string $title @param string|array $options @return Item
[ "Creates", "a", "sub", "Item" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/Item.php#L88-L94
artkonekt/menu
src/Item.php
Item.isAllowed
public function isAllowed(Authenticatable $user = null): bool { $user = $user ?: Auth::user(); foreach ($this->authorizationStack as $auth) { if (is_callable($auth)) { if (!$auth($user)) { return false; } } elseif ($user && $user->cannot($auth)) { return false; } } return true; }
php
public function isAllowed(Authenticatable $user = null): bool { $user = $user ?: Auth::user(); foreach ($this->authorizationStack as $auth) { if (is_callable($auth)) { if (!$auth($user)) { return false; } } elseif ($user && $user->cannot($auth)) { return false; } } return true; }
[ "public", "function", "isAllowed", "(", "Authenticatable", "$", "user", "=", "null", ")", ":", "bool", "{", "$", "user", "=", "$", "user", "?", ":", "Auth", "::", "user", "(", ")", ";", "foreach", "(", "$", "this", "->", "authorizationStack", "as", "...
Returns whether the menu item is allowed for the user @param Authenticatable $user In case no user is passed Auth::user() will be used @return bool
[ "Returns", "whether", "the", "menu", "item", "is", "allowed", "for", "the", "user" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/Item.php#L140-L155
artkonekt/menu
src/Item.php
Item.children
public function children() { return $this->menu->items->filter(function ($item) { return $item->hasParent() && $item->parent->name == $this->name; }); }
php
public function children() { return $this->menu->items->filter(function ($item) { return $item->hasParent() && $item->parent->name == $this->name; }); }
[ "public", "function", "children", "(", ")", "{", "return", "$", "this", "->", "menu", "->", "items", "->", "filter", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "hasParent", "(", ")", "&&", "$", "item", "->", "parent", ...
Returns children of the item @return \Konekt\Menu\ItemCollection
[ "Returns", "children", "of", "the", "item" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/Item.php#L196-L201
artkonekt/menu
src/Item.php
Item.childrenAllowed
public function childrenAllowed(Authenticatable $user = null) { return $this->children()->filter(function ($item) use ($user) { return $item->isAllowed($user); }); }
php
public function childrenAllowed(Authenticatable $user = null) { return $this->children()->filter(function ($item) use ($user) { return $item->isAllowed($user); }); }
[ "public", "function", "childrenAllowed", "(", "Authenticatable", "$", "user", "=", "null", ")", "{", "return", "$", "this", "->", "children", "(", ")", "->", "filter", "(", "function", "(", "$", "item", ")", "use", "(", "$", "user", ")", "{", "return",...
Returns allowed children of the item @return \Konekt\Menu\ItemCollection
[ "Returns", "allowed", "children", "of", "the", "item" ]
train
https://github.com/artkonekt/menu/blob/3b8649f41cce09c61bf84cfecc71727d41171dd3/src/Item.php#L208-L213