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
kriswallsmith/assetic
src/Assetic/AssetManager.php
AssetManager.set
public function set($name, AssetInterface $asset) { if (!ctype_alnum(str_replace('_', '', $name))) { throw new \InvalidArgumentException(sprintf('The name "%s" is invalid.', $name)); } $this->assets[$name] = $asset; }
php
public function set($name, AssetInterface $asset) { if (!ctype_alnum(str_replace('_', '', $name))) { throw new \InvalidArgumentException(sprintf('The name "%s" is invalid.', $name)); } $this->assets[$name] = $asset; }
[ "public", "function", "set", "(", "$", "name", ",", "AssetInterface", "$", "asset", ")", "{", "if", "(", "!", "ctype_alnum", "(", "str_replace", "(", "'_'", ",", "''", ",", "$", "name", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentExceptio...
Registers an asset to the current asset manager. @param string $name The asset name @param AssetInterface $asset The asset @throws \InvalidArgumentException If the asset name is invalid
[ "Registers", "an", "asset", "to", "the", "current", "asset", "manager", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/AssetManager.php#L63-L70
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.setLoader
public function setLoader($alias, FormulaLoaderInterface $loader) { $this->loaders[$alias] = $loader; $this->loaded = false; }
php
public function setLoader($alias, FormulaLoaderInterface $loader) { $this->loaders[$alias] = $loader; $this->loaded = false; }
[ "public", "function", "setLoader", "(", "$", "alias", ",", "FormulaLoaderInterface", "$", "loader", ")", "{", "$", "this", "->", "loaders", "[", "$", "alias", "]", "=", "$", "loader", ";", "$", "this", "->", "loaded", "=", "false", ";", "}" ]
Adds a loader to the asset manager. @param string $alias An alias for the loader @param FormulaLoaderInterface $loader A loader
[ "Adds", "a", "loader", "to", "the", "asset", "manager", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L59-L63
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.addResource
public function addResource(ResourceInterface $resource, $loader) { $this->resources[$loader][] = $resource; $this->loaded = false; }
php
public function addResource(ResourceInterface $resource, $loader) { $this->resources[$loader][] = $resource; $this->loaded = false; }
[ "public", "function", "addResource", "(", "ResourceInterface", "$", "resource", ",", "$", "loader", ")", "{", "$", "this", "->", "resources", "[", "$", "loader", "]", "[", "]", "=", "$", "resource", ";", "$", "this", "->", "loaded", "=", "false", ";", ...
Adds a resource to the asset manager. @param ResourceInterface $resource A resource @param string $loader The loader alias for this resource
[ "Adds", "a", "resource", "to", "the", "asset", "manager", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L71-L75
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.getResources
public function getResources() { $resources = array(); foreach ($this->resources as $r) { $resources = array_merge($resources, $r); } return $resources; }
php
public function getResources() { $resources = array(); foreach ($this->resources as $r) { $resources = array_merge($resources, $r); } return $resources; }
[ "public", "function", "getResources", "(", ")", "{", "$", "resources", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "resources", "as", "$", "r", ")", "{", "$", "resources", "=", "array_merge", "(", "$", "resources", ",", "$", "r", ...
Returns an array of resources. @return array An array of resources
[ "Returns", "an", "array", "of", "resources", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L82-L90
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.hasFormula
public function hasFormula($name) { if (!$this->loaded) { $this->load(); } return isset($this->formulae[$name]); }
php
public function hasFormula($name) { if (!$this->loaded) { $this->load(); } return isset($this->formulae[$name]); }
[ "public", "function", "hasFormula", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "loaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "formulae", "[", "$", "name", "]", ...
Checks for an asset formula. @param string $name An asset name @return Boolean If there is a formula
[ "Checks", "for", "an", "asset", "formula", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L99-L106
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.getFormula
public function getFormula($name) { if (!$this->loaded) { $this->load(); } if (!isset($this->formulae[$name])) { throw new \InvalidArgumentException(sprintf('There is no "%s" formula.', $name)); } return $this->formulae[$name]; }
php
public function getFormula($name) { if (!$this->loaded) { $this->load(); } if (!isset($this->formulae[$name])) { throw new \InvalidArgumentException(sprintf('There is no "%s" formula.', $name)); } return $this->formulae[$name]; }
[ "public", "function", "getFormula", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "loaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "formulae", "[", "$", "name",...
Returns an asset's formula. @param string $name An asset name @return array The formula @throws \InvalidArgumentException If there is no formula by that name
[ "Returns", "an", "asset", "s", "formula", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L117-L128
kriswallsmith/assetic
src/Assetic/Factory/LazyAssetManager.php
LazyAssetManager.load
public function load() { if ($this->loading) { return; } if ($diff = array_diff(array_keys($this->resources), array_keys($this->loaders))) { throw new \LogicException('The following loader(s) are not registered: '.implode(', ', $diff)); } $this->load...
php
public function load() { if ($this->loading) { return; } if ($diff = array_diff(array_keys($this->resources), array_keys($this->loaders))) { throw new \LogicException('The following loader(s) are not registered: '.implode(', ', $diff)); } $this->load...
[ "public", "function", "load", "(", ")", "{", "if", "(", "$", "this", "->", "loading", ")", "{", "return", ";", "}", "if", "(", "$", "diff", "=", "array_diff", "(", "array_keys", "(", "$", "this", "->", "resources", ")", ",", "array_keys", "(", "$",...
Loads formulae from resources. @throws \LogicException If a resource has been added to an invalid loader
[ "Loads", "formulae", "from", "resources", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/LazyAssetManager.php#L146-L166
kriswallsmith/assetic
src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php
AssetCollectionFilterIterator.accept
public function accept() { $asset = $this->getInnerIterator()->current(true); $duplicate = false; // check strict equality if (in_array($asset, $this->visited, true)) { $duplicate = true; } else { $this->visited[] = $asset; } // check...
php
public function accept() { $asset = $this->getInnerIterator()->current(true); $duplicate = false; // check strict equality if (in_array($asset, $this->visited, true)) { $duplicate = true; } else { $this->visited[] = $asset; } // check...
[ "public", "function", "accept", "(", ")", "{", "$", "asset", "=", "$", "this", "->", "getInnerIterator", "(", ")", "->", "current", "(", "true", ")", ";", "$", "duplicate", "=", "false", ";", "// check strict equality", "if", "(", "in_array", "(", "$", ...
Determines whether the current asset is a duplicate. De-duplication is performed based on either strict equality or by matching sources. @return Boolean Returns true if we have not seen this asset yet
[ "Determines", "whether", "the", "current", "asset", "is", "a", "duplicate", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php#L50-L75
kriswallsmith/assetic
src/Assetic/Util/FilesystemUtils.php
FilesystemUtils.removeDirectory
public static function removeDirectory($directory) { $inner = new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS); $outer = new \RecursiveIteratorIterator($inner, \RecursiveIteratorIterator::SELF_FIRST); // remove the files first foreach ($outer as $file) { ...
php
public static function removeDirectory($directory) { $inner = new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS); $outer = new \RecursiveIteratorIterator($inner, \RecursiveIteratorIterator::SELF_FIRST); // remove the files first foreach ($outer as $file) { ...
[ "public", "static", "function", "removeDirectory", "(", "$", "directory", ")", "{", "$", "inner", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "directory", ",", "\\", "FilesystemIterator", "::", "SKIP_DOTS", ")", ";", "$", "outer", "=", "new", "...
Recursively removes a directory from the filesystem.
[ "Recursively", "removes", "a", "directory", "from", "the", "filesystem", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/FilesystemUtils.php#L24-L47
kriswallsmith/assetic
src/Assetic/Util/FilesystemUtils.php
FilesystemUtils.createThrowAwayDirectory
public static function createThrowAwayDirectory($prefix) { $directory = self::getTemporaryDirectory().DIRECTORY_SEPARATOR.uniqid('assetic_'.$prefix); mkdir($directory); return $directory; }
php
public static function createThrowAwayDirectory($prefix) { $directory = self::getTemporaryDirectory().DIRECTORY_SEPARATOR.uniqid('assetic_'.$prefix); mkdir($directory); return $directory; }
[ "public", "static", "function", "createThrowAwayDirectory", "(", "$", "prefix", ")", "{", "$", "directory", "=", "self", "::", "getTemporaryDirectory", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", "'assetic_'", ".", "$", "prefix", ")", ";", "mkdir...
Creates a throw-away directory. This is not considered a "temporary" directory because it will not be automatically deleted at the end of the request or process. It must be deleted manually. @param string $prefix A prefix for the directory name @return string The directory path
[ "Creates", "a", "throw", "-", "away", "directory", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/FilesystemUtils.php#L60-L66
kriswallsmith/assetic
src/Assetic/Asset/GlobAsset.php
GlobAsset.initialize
private function initialize() { foreach ($this->globs as $glob) { $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues()); if (false !== $paths = glob($glob)) { foreach ($paths as $path) { if (is_file($path)) { ...
php
private function initialize() { foreach ($this->globs as $glob) { $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues()); if (false !== $paths = glob($glob)) { foreach ($paths as $path) { if (is_file($path)) { ...
[ "private", "function", "initialize", "(", ")", "{", "foreach", "(", "$", "this", "->", "globs", "as", "$", "glob", ")", "{", "$", "glob", "=", "VarUtils", "::", "resolve", "(", "$", "glob", ",", "$", "this", "->", "getVars", "(", ")", ",", "$", "...
Initializes the collection based on the glob(s) passed in.
[ "Initializes", "the", "collection", "based", "on", "the", "glob", "(", "s", ")", "passed", "in", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Asset/GlobAsset.php#L97-L114
kriswallsmith/assetic
src/Assetic/Extension/Twig/AsseticTokenParser.php
AsseticTokenParser.createBodyNode
protected function createBodyNode(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) { $reflector = new \ReflectionMethod($this, 'createNode'); if (__CLASS__ !== $reflector->getDeclaringClass()->name) { @...
php
protected function createBodyNode(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) { $reflector = new \ReflectionMethod($this, 'createNode'); if (__CLASS__ !== $reflector->getDeclaringClass()->name) { @...
[ "protected", "function", "createBodyNode", "(", "AssetInterface", "$", "asset", ",", "\\", "Twig_Node", "$", "body", ",", "array", "$", "inputs", ",", "array", "$", "filters", ",", "$", "name", ",", "array", "$", "attributes", "=", "array", "(", ")", ","...
@param AssetInterface $asset @param \Twig_Node $body @param array $inputs @param array $filters @param string $name @param array $attributes @param int $lineno @param string $tag @return \Twig_Node
[ "@param", "AssetInterface", "$asset", "@param", "\\", "Twig_Node", "$body", "@param", "array", "$inputs", "@param", "array", "$filters", "@param", "string", "$name", "@param", "array", "$attributes", "@param", "int", "$lineno", "@param", "string", "$tag" ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Extension/Twig/AsseticTokenParser.php#L161-L172
kriswallsmith/assetic
src/Assetic/Extension/Twig/AsseticTokenParser.php
AsseticTokenParser.createNode
protected function createNode(AssetInterface $asset, \Twig_NodeInterface $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) { @trigger_error(sprintf('The %s method is deprecated since 1.3 and will be removed in 2.0. Use createBodyNode instead.', __METHOD__), ...
php
protected function createNode(AssetInterface $asset, \Twig_NodeInterface $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) { @trigger_error(sprintf('The %s method is deprecated since 1.3 and will be removed in 2.0. Use createBodyNode instead.', __METHOD__), ...
[ "protected", "function", "createNode", "(", "AssetInterface", "$", "asset", ",", "\\", "Twig_NodeInterface", "$", "body", ",", "array", "$", "inputs", ",", "array", "$", "filters", ",", "$", "name", ",", "array", "$", "attributes", "=", "array", "(", ")", ...
@param AssetInterface $asset @param \Twig_NodeInterface $body @param array $inputs @param array $filters @param string $name @param array $attributes @param int $lineno @param string $tag @return \Twig_Node @deprecated since 1.3....
[ "@param", "AssetInterface", "$asset", "@param", "\\", "Twig_NodeInterface", "$body", "@param", "array", "$inputs", "@param", "array", "$filters", "@param", "string", "$name", "@param", "array", "$attributes", "@param", "int", "$lineno", "@param", "string", "$tag" ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Extension/Twig/AsseticTokenParser.php#L188-L197
kriswallsmith/assetic
src/Assetic/Asset/Iterator/AssetCollectionIterator.php
AssetCollectionIterator.current
public function current($raw = false) { $asset = current($this->assets); if ($raw) { return $asset; } // clone once if (!isset($this->clones[$asset])) { $clone = $this->clones[$asset] = clone $asset; // generate a target path based on as...
php
public function current($raw = false) { $asset = current($this->assets); if ($raw) { return $asset; } // clone once if (!isset($this->clones[$asset])) { $clone = $this->clones[$asset] = clone $asset; // generate a target path based on as...
[ "public", "function", "current", "(", "$", "raw", "=", "false", ")", "{", "$", "asset", "=", "current", "(", "$", "this", "->", "assets", ")", ";", "if", "(", "$", "raw", ")", "{", "return", "$", "asset", ";", "}", "// clone once", "if", "(", "!"...
Returns a copy of the current asset with filters and a target URL applied. @param Boolean $raw Returns the unmodified asset if true @return \Assetic\Asset\AssetInterface
[ "Returns", "a", "copy", "of", "the", "current", "asset", "with", "filters", "and", "a", "target", "URL", "applied", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Asset/Iterator/AssetCollectionIterator.php#L54-L82
kriswallsmith/assetic
src/Assetic/Filter/JSqueezeFilter.php
JSqueezeFilter.setSpecialVarRx
public function setSpecialVarRx($specialVarRx) { if (true === $specialVarRx) { $this->specialVarRx = $this->defaultRx; } else { $this->specialVarRx = $specialVarRx; } }
php
public function setSpecialVarRx($specialVarRx) { if (true === $specialVarRx) { $this->specialVarRx = $this->defaultRx; } else { $this->specialVarRx = $specialVarRx; } }
[ "public", "function", "setSpecialVarRx", "(", "$", "specialVarRx", ")", "{", "if", "(", "true", "===", "$", "specialVarRx", ")", "{", "$", "this", "->", "specialVarRx", "=", "$", "this", "->", "defaultRx", ";", "}", "else", "{", "$", "this", "->", "spe...
renaming with the default regex (for 1.x or 2.x)
[ "renaming", "with", "the", "default", "regex", "(", "for", "1", ".", "x", "or", "2", ".", "x", ")" ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Filter/JSqueezeFilter.php#L49-L56
kriswallsmith/assetic
src/Assetic/Filter/FilterCollection.php
FilterCollection.ensure
public function ensure(FilterInterface $filter) { if ($filter instanceof \Traversable) { foreach ($filter as $f) { $this->ensure($f); } } elseif (!in_array($filter, $this->filters, true)) { $this->filters[] = $filter; } }
php
public function ensure(FilterInterface $filter) { if ($filter instanceof \Traversable) { foreach ($filter as $f) { $this->ensure($f); } } elseif (!in_array($filter, $this->filters, true)) { $this->filters[] = $filter; } }
[ "public", "function", "ensure", "(", "FilterInterface", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "\\", "Traversable", ")", "{", "foreach", "(", "$", "filter", "as", "$", "f", ")", "{", "$", "this", "->", "ensure", "(", "$", "f...
Checks that the current collection contains the supplied filter. If the supplied filter is another filter collection, each of its filters will be checked.
[ "Checks", "that", "the", "current", "collection", "contains", "the", "supplied", "filter", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Filter/FilterCollection.php#L38-L47
kriswallsmith/assetic
src/Assetic/Asset/AssetCollection.php
AssetCollection.getLastModified
public function getLastModified() { if (!count($this->assets)) { return; } $mtime = 0; foreach ($this as $asset) { $assetMtime = $asset->getLastModified(); if ($assetMtime > $mtime) { $mtime = $assetMtime; } } ...
php
public function getLastModified() { if (!count($this->assets)) { return; } $mtime = 0; foreach ($this as $asset) { $assetMtime = $asset->getLastModified(); if ($assetMtime > $mtime) { $mtime = $assetMtime; } } ...
[ "public", "function", "getLastModified", "(", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "assets", ")", ")", "{", "return", ";", "}", "$", "mtime", "=", "0", ";", "foreach", "(", "$", "this", "as", "$", "asset", ")", "{", "$", "...
Returns the highest last-modified value of all assets in the current collection. @return integer|null A UNIX timestamp
[ "Returns", "the", "highest", "last", "-", "modified", "value", "of", "all", "assets", "in", "the", "current", "collection", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Asset/AssetCollection.php#L195-L210
kriswallsmith/assetic
src/Assetic/Extension/Twig/TwigFormulaLoader.php
TwigFormulaLoader.loadNode
private function loadNode(\Twig_Node $node) { $formulae = array(); if ($node instanceof AsseticNode) { $formulae[$node->getAttribute('name')] = array( $node->getAttribute('inputs'), $node->getAttribute('filters'), array( ...
php
private function loadNode(\Twig_Node $node) { $formulae = array(); if ($node instanceof AsseticNode) { $formulae[$node->getAttribute('name')] = array( $node->getAttribute('inputs'), $node->getAttribute('filters'), array( ...
[ "private", "function", "loadNode", "(", "\\", "Twig_Node", "$", "node", ")", "{", "$", "formulae", "=", "array", "(", ")", ";", "if", "(", "$", "node", "instanceof", "AsseticNode", ")", "{", "$", "formulae", "[", "$", "node", "->", "getAttribute", "(",...
Loads assets from the supplied node. @param \Twig_Node $node @return array An array of asset formulae indexed by name
[ "Loads", "assets", "from", "the", "supplied", "node", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Extension/Twig/TwigFormulaLoader.php#L57-L107
kriswallsmith/assetic
src/Assetic/Cache/ConfigCache.php
ConfigCache.set
public function set($resource, $value) { $path = $this->getSourcePath($resource); if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to create directory '.$dir); // @codeCove...
php
public function set($resource, $value) { $path = $this->getSourcePath($resource); if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to create directory '.$dir); // @codeCove...
[ "public", "function", "set", "(", "$", "resource", ",", "$", "value", ")", "{", "$", "path", "=", "$", "this", "->", "getSourcePath", "(", "$", "resource", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", "=", "dirname", "(", "$", "path", ")"...
Writes a value to a file. @param string $resource A cache key @param mixed $value A value to cache
[ "Writes", "a", "value", "to", "a", "file", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Cache/ConfigCache.php#L51-L66
kriswallsmith/assetic
src/Assetic/Cache/ConfigCache.php
ConfigCache.get
public function get($resource) { $path = $this->getSourcePath($resource); if (!file_exists($path)) { throw new \RuntimeException('There is no cached value for '.$resource); } return include $path; }
php
public function get($resource) { $path = $this->getSourcePath($resource); if (!file_exists($path)) { throw new \RuntimeException('There is no cached value for '.$resource); } return include $path; }
[ "public", "function", "get", "(", "$", "resource", ")", "{", "$", "path", "=", "$", "this", "->", "getSourcePath", "(", "$", "resource", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "RuntimeException...
Loads and returns the value for the supplied cache key. @param string $resource A cache key @return mixed The cached value
[ "Loads", "and", "returns", "the", "value", "for", "the", "supplied", "cache", "key", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Cache/ConfigCache.php#L75-L84
kriswallsmith/assetic
src/Assetic/Cache/ConfigCache.php
ConfigCache.getTimestamp
public function getTimestamp($resource) { $path = $this->getSourcePath($resource); if (!file_exists($path)) { throw new \RuntimeException('There is no cached value for '.$resource); } if (false === $mtime = @filemtime($path)) { // @codeCoverageIgnoreStart ...
php
public function getTimestamp($resource) { $path = $this->getSourcePath($resource); if (!file_exists($path)) { throw new \RuntimeException('There is no cached value for '.$resource); } if (false === $mtime = @filemtime($path)) { // @codeCoverageIgnoreStart ...
[ "public", "function", "getTimestamp", "(", "$", "resource", ")", "{", "$", "path", "=", "$", "this", "->", "getSourcePath", "(", "$", "resource", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Runtime...
Returns a timestamp for when the cache was created. @param string $resource A cache key @return integer A UNIX timestamp
[ "Returns", "a", "timestamp", "for", "when", "the", "cache", "was", "created", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Cache/ConfigCache.php#L93-L108
kriswallsmith/assetic
src/Assetic/Factory/Resource/CoalescingDirectoryResource.php
CoalescingDirectoryResource.getRelativeName
protected function getRelativeName(ResourceInterface $file, ResourceInterface $directory) { return substr((string) $file, strlen((string) $directory)); }
php
protected function getRelativeName(ResourceInterface $file, ResourceInterface $directory) { return substr((string) $file, strlen((string) $directory)); }
[ "protected", "function", "getRelativeName", "(", "ResourceInterface", "$", "file", ",", "ResourceInterface", "$", "directory", ")", "{", "return", "substr", "(", "(", "string", ")", "$", "file", ",", "strlen", "(", "(", "string", ")", "$", "directory", ")", ...
Returns the relative version of a filename. @param ResourceInterface $file The file @param ResourceInterface $directory The directory @return string The name to compare with files from other directories
[ "Returns", "the", "relative", "version", "of", "a", "filename", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php#L86-L89
kriswallsmith/assetic
src/Assetic/Factory/Resource/CoalescingDirectoryResource.php
CoalescingDirectoryResource.getFileResources
private function getFileResources() { $paths = array(); foreach ($this->directories as $directory) { foreach ($directory as $file) { $relative = $this->getRelativeName($file, $directory); if (!isset($paths[$relative])) { $paths[$relat...
php
private function getFileResources() { $paths = array(); foreach ($this->directories as $directory) { foreach ($directory as $file) { $relative = $this->getRelativeName($file, $directory); if (!isset($paths[$relative])) { $paths[$relat...
[ "private", "function", "getFileResources", "(", ")", "{", "$", "paths", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "directories", "as", "$", "directory", ")", "{", "foreach", "(", "$", "directory", "as", "$", "file", ")", "{", "$...
Performs the coalesce. @return array An array of file resources
[ "Performs", "the", "coalesce", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php#L96-L111
kriswallsmith/assetic
src/Assetic/Asset/AssetReference.php
AssetReference.callAsset
private function callAsset($method, $arguments = array()) { $asset = $this->resolve(); return call_user_func_array(array($asset, $method), $arguments); }
php
private function callAsset($method, $arguments = array()) { $asset = $this->resolve(); return call_user_func_array(array($asset, $method), $arguments); }
[ "private", "function", "callAsset", "(", "$", "method", ",", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "asset", "=", "$", "this", "->", "resolve", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "asset", ",", "...
private
[ "private" ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Asset/AssetReference.php#L134-L139
kriswallsmith/assetic
src/Assetic/Util/VarUtils.php
VarUtils.resolve
public static function resolve($template, array $vars, array $values) { $map = array(); foreach ($vars as $var) { if (false === strpos($template, '{'.$var.'}')) { continue; } if (!isset($values[$var])) { throw new \InvalidArgumentE...
php
public static function resolve($template, array $vars, array $values) { $map = array(); foreach ($vars as $var) { if (false === strpos($template, '{'.$var.'}')) { continue; } if (!isset($values[$var])) { throw new \InvalidArgumentE...
[ "public", "static", "function", "resolve", "(", "$", "template", ",", "array", "$", "vars", ",", "array", "$", "values", ")", "{", "$", "map", "=", "array", "(", ")", ";", "foreach", "(", "$", "vars", "as", "$", "var", ")", "{", "if", "(", "false...
Resolves variable placeholders. @param string $template A template string @param array $vars Variable names @param array $values Variable values @return string The resolved string @throws \InvalidArgumentException If there is a variable with no value
[ "Resolves", "variable", "placeholders", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/VarUtils.php#L32-L48
kriswallsmith/assetic
src/Assetic/Util/CssUtils.php
CssUtils.filterReferences
public static function filterReferences($content, $callback) { $content = static::filterUrls($content, $callback); $content = static::filterImports($content, $callback, false); $content = static::filterIEFilters($content, $callback); return $content; }
php
public static function filterReferences($content, $callback) { $content = static::filterUrls($content, $callback); $content = static::filterImports($content, $callback, false); $content = static::filterIEFilters($content, $callback); return $content; }
[ "public", "static", "function", "filterReferences", "(", "$", "content", ",", "$", "callback", ")", "{", "$", "content", "=", "static", "::", "filterUrls", "(", "$", "content", ",", "$", "callback", ")", ";", "$", "content", "=", "static", "::", "filterI...
Filters all references -- url() and "@import" -- through a callable. @param string $content The CSS @param callable $callback A PHP callable @return string The filtered CSS
[ "Filters", "all", "references", "--", "url", "()", "and", "@import", "--", "through", "a", "callable", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/CssUtils.php#L35-L42
kriswallsmith/assetic
src/Assetic/Util/CssUtils.php
CssUtils.filterUrls
public static function filterUrls($content, $callback) { $pattern = static::REGEX_URLS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern, $callback, $part); }); }
php
public static function filterUrls($content, $callback) { $pattern = static::REGEX_URLS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern, $callback, $part); }); }
[ "public", "static", "function", "filterUrls", "(", "$", "content", ",", "$", "callback", ")", "{", "$", "pattern", "=", "static", "::", "REGEX_URLS", ";", "return", "static", "::", "filterCommentless", "(", "$", "content", ",", "function", "(", "$", "part"...
Filters all CSS url()'s through a callable. @param string $content The CSS @param callable $callback A PHP callable @return string The filtered CSS
[ "Filters", "all", "CSS", "url", "()", "s", "through", "a", "callable", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/CssUtils.php#L52-L59
kriswallsmith/assetic
src/Assetic/Util/CssUtils.php
CssUtils.filterImports
public static function filterImports($content, $callback, $includeUrl = true) { $pattern = $includeUrl ? static::REGEX_IMPORTS : static::REGEX_IMPORTS_NO_URLS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern...
php
public static function filterImports($content, $callback, $includeUrl = true) { $pattern = $includeUrl ? static::REGEX_IMPORTS : static::REGEX_IMPORTS_NO_URLS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern...
[ "public", "static", "function", "filterImports", "(", "$", "content", ",", "$", "callback", ",", "$", "includeUrl", "=", "true", ")", "{", "$", "pattern", "=", "$", "includeUrl", "?", "static", "::", "REGEX_IMPORTS", ":", "static", "::", "REGEX_IMPORTS_NO_UR...
Filters all CSS imports through a callable. @param string $content The CSS @param callable $callback A PHP callable @param Boolean $includeUrl Whether to include url() in the pattern @return string The filtered CSS
[ "Filters", "all", "CSS", "imports", "through", "a", "callable", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/CssUtils.php#L70-L77
kriswallsmith/assetic
src/Assetic/Util/CssUtils.php
CssUtils.filterIEFilters
public static function filterIEFilters($content, $callback) { $pattern = static::REGEX_IE_FILTERS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern, $callback, $part); }); }
php
public static function filterIEFilters($content, $callback) { $pattern = static::REGEX_IE_FILTERS; return static::filterCommentless($content, function ($part) use (& $callback, $pattern) { return preg_replace_callback($pattern, $callback, $part); }); }
[ "public", "static", "function", "filterIEFilters", "(", "$", "content", ",", "$", "callback", ")", "{", "$", "pattern", "=", "static", "::", "REGEX_IE_FILTERS", ";", "return", "static", "::", "filterCommentless", "(", "$", "content", ",", "function", "(", "$...
Filters all IE filters (AlphaImageLoader filter) through a callable. @param string $content The CSS @param callable $callback A PHP callable @return string The filtered CSS
[ "Filters", "all", "IE", "filters", "(", "AlphaImageLoader", "filter", ")", "through", "a", "callable", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/CssUtils.php#L87-L94
kriswallsmith/assetic
src/Assetic/Util/CssUtils.php
CssUtils.filterCommentless
public static function filterCommentless($content, $callback) { $result = ''; foreach (preg_split(static::REGEX_COMMENTS, $content, -1, PREG_SPLIT_DELIM_CAPTURE) as $part) { if (!preg_match(static::REGEX_COMMENTS, $part, $match) || $part != $match[0]) { $part = call_user_...
php
public static function filterCommentless($content, $callback) { $result = ''; foreach (preg_split(static::REGEX_COMMENTS, $content, -1, PREG_SPLIT_DELIM_CAPTURE) as $part) { if (!preg_match(static::REGEX_COMMENTS, $part, $match) || $part != $match[0]) { $part = call_user_...
[ "public", "static", "function", "filterCommentless", "(", "$", "content", ",", "$", "callback", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "preg_split", "(", "static", "::", "REGEX_COMMENTS", ",", "$", "content", ",", "-", "1", ",", "PREG_S...
Filters each non-comment part through a callable. @param string $content The CSS @param callable $callback A PHP callable @return string The filtered CSS
[ "Filters", "each", "non", "-", "comment", "part", "through", "a", "callable", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Util/CssUtils.php#L104-L116
kriswallsmith/assetic
src/Assetic/Factory/AssetFactory.php
AssetFactory.parseInput
protected function parseInput($input, array $options = array()) { if ('@' == $input[0]) { return $this->createAssetReference(substr($input, 1)); } if (false !== strpos($input, '://') || 0 === strpos($input, '//')) { return $this->createHttpAsset($input, $options['var...
php
protected function parseInput($input, array $options = array()) { if ('@' == $input[0]) { return $this->createAssetReference(substr($input, 1)); } if (false !== strpos($input, '://') || 0 === strpos($input, '//')) { return $this->createHttpAsset($input, $options['var...
[ "protected", "function", "parseInput", "(", "$", "input", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "'@'", "==", "$", "input", "[", "0", "]", ")", "{", "return", "$", "this", "->", "createAssetReference", "(", "substr...
Parses an input string string into an asset. The input string can be one of the following: * A reference: If the string starts with an "at" sign it will be interpreted as a reference to an asset in the asset manager * An absolute URL: If the string contains "://" or starts with "//" it will be interpreted as an H...
[ "Parses", "an", "input", "string", "string", "into", "an", "asset", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/AssetFactory.php#L303-L330
kriswallsmith/assetic
src/Assetic/Factory/AssetFactory.php
AssetFactory.applyWorkers
private function applyWorkers(AssetCollectionInterface $asset) { foreach ($asset as $leaf) { foreach ($this->workers as $worker) { $retval = $worker->process($leaf, $this); if ($retval instanceof AssetInterface && $leaf !== $retval) { $asset->...
php
private function applyWorkers(AssetCollectionInterface $asset) { foreach ($asset as $leaf) { foreach ($this->workers as $worker) { $retval = $worker->process($leaf, $this); if ($retval instanceof AssetInterface && $leaf !== $retval) { $asset->...
[ "private", "function", "applyWorkers", "(", "AssetCollectionInterface", "$", "asset", ")", "{", "foreach", "(", "$", "asset", "as", "$", "leaf", ")", "{", "foreach", "(", "$", "this", "->", "workers", "as", "$", "worker", ")", "{", "$", "retval", "=", ...
Filters an asset collection through the factory workers. Each leaf asset will be processed first, followed by the asset collection itself. @param AssetCollectionInterface $asset An asset collection @return AssetCollectionInterface
[ "Filters", "an", "asset", "collection", "through", "the", "factory", "workers", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/AssetFactory.php#L380-L401
kriswallsmith/assetic
src/Assetic/Factory/AssetFactory.php
AssetFactory.findRootDir
private static function findRootDir($path, array $roots) { foreach ($roots as $root) { if (0 === strpos($path, $root)) { return $root; } } }
php
private static function findRootDir($path, array $roots) { foreach ($roots as $root) { if (0 === strpos($path, $root)) { return $root; } } }
[ "private", "static", "function", "findRootDir", "(", "$", "path", ",", "array", "$", "roots", ")", "{", "foreach", "(", "$", "roots", "as", "$", "root", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "path", ",", "$", "root", ")", ")", "{",...
Loops through the root directories and returns the first match. @param string $path An absolute path @param array $roots An array of root directories @return string|null The matching root directory, if found
[ "Loops", "through", "the", "root", "directories", "and", "returns", "the", "first", "match", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/AssetFactory.php#L416-L423
kriswallsmith/assetic
src/Assetic/Factory/Resource/DirectoryResource.php
DirectoryResource.getContent
public function getContent() { $content = array(); foreach ($this as $resource) { $content[] = $resource->getContent(); } return implode("\n", $content); }
php
public function getContent() { $content = array(); foreach ($this as $resource) { $content[] = $resource->getContent(); } return implode("\n", $content); }
[ "public", "function", "getContent", "(", ")", "{", "$", "content", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "resource", ")", "{", "$", "content", "[", "]", "=", "$", "resource", "->", "getContent", "(", ")", ";", "}", ...
Returns the combined content of all inner resources.
[ "Returns", "the", "combined", "content", "of", "all", "inner", "resources", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Factory/Resource/DirectoryResource.php#L58-L66
kriswallsmith/assetic
src/Assetic/Filter/Yui/BaseCompressorFilter.php
BaseCompressorFilter.compress
protected function compress($content, $type, $options = array()) { $pb = $this->createProcessBuilder(array($this->javaPath)); if (null !== $this->stackSize) { $pb->add('-Xss'.$this->stackSize); } $pb->add('-jar')->add($this->jarPath); foreach ($options as $opti...
php
protected function compress($content, $type, $options = array()) { $pb = $this->createProcessBuilder(array($this->javaPath)); if (null !== $this->stackSize) { $pb->add('-Xss'.$this->stackSize); } $pb->add('-jar')->add($this->jarPath); foreach ($options as $opti...
[ "protected", "function", "compress", "(", "$", "content", ",", "$", "type", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "pb", "=", "$", "this", "->", "createProcessBuilder", "(", "array", "(", "$", "this", "->", "javaPath", ")", ")", ...
Compresses a string. @param string $content The content to compress @param string $type The type of content, either "js" or "css" @param array $options An indexed array of additional options @return string The compressed content
[ "Compresses", "a", "string", "." ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Filter/Yui/BaseCompressorFilter.php#L67-L116
kriswallsmith/assetic
src/Assetic/Filter/CleanCssFilter.php
CleanCssFilter.filterDump
public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->cleanCssBin) : array($this->cleanCssBin)); if ($this->keepLineBreaks) { $pb->add('--keep-line-breaks'); } if ($thi...
php
public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->cleanCssBin) : array($this->cleanCssBin)); if ($this->keepLineBreaks) { $pb->add('--keep-line-breaks'); } if ($thi...
[ "public", "function", "filterDump", "(", "AssetInterface", "$", "asset", ")", "{", "$", "pb", "=", "$", "this", "->", "createProcessBuilder", "(", "$", "this", "->", "nodeBin", "?", "array", "(", "$", "this", "->", "nodeBin", ",", "$", "this", "->", "c...
Run the asset through CleanCss @see Assetic\Filter\FilterInterface::filterDump()
[ "Run", "the", "asset", "through", "CleanCss" ]
train
https://github.com/kriswallsmith/assetic/blob/e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1/src/Assetic/Filter/CleanCssFilter.php#L242-L342
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.addConstraints
public function addConstraints() { if (static::$constraints) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); //If the foreign key is an array (multi-column relationship), we adjust the query. if (is_array($this->foreignKey...
php
public function addConstraints() { if (static::$constraints) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); //If the foreign key is an array (multi-column relationship), we adjust the query. if (is_array($this->foreignKey...
[ "public", "function", "addConstraints", "(", ")", "{", "if", "(", "static", "::", "$", "constraints", ")", "{", "$", "foreignKey", "=", "$", "this", "->", "getForeignKeyName", "(", ")", ";", "$", "parentKeyValue", "=", "$", "this", "->", "getParentKey", ...
Set the base constraints on the relation query. @return void
[ "Set", "the", "base", "constraints", "on", "the", "relation", "query", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L16-L38
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.addEagerConstraints
public function addEagerConstraints(array $models) { $this->query->whereIn($this->foreignKey, $this->getKeys($models, $this->localKey)); }
php
public function addEagerConstraints(array $models) { $this->query->whereIn($this->foreignKey, $this->getKeys($models, $this->localKey)); }
[ "public", "function", "addEagerConstraints", "(", "array", "$", "models", ")", "{", "$", "this", "->", "query", "->", "whereIn", "(", "$", "this", "->", "foreignKey", ",", "$", "this", "->", "getKeys", "(", "$", "models", ",", "$", "this", "->", "local...
Set the constraints for an eager load of the relation. @param array $models @return void
[ "Set", "the", "constraints", "for", "an", "eager", "load", "of", "the", "relation", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L46-L49
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.getQualifiedParentKeyName
public function getQualifiedParentKeyName() { if (is_array($this->localKey)) { //Check for multi-columns relationship return array_map(function ($k) { return $this->parent->getTable().'.'.$k; }, $this->localKey); } else { return $this->parent->getT...
php
public function getQualifiedParentKeyName() { if (is_array($this->localKey)) { //Check for multi-columns relationship return array_map(function ($k) { return $this->parent->getTable().'.'.$k; }, $this->localKey); } else { return $this->parent->getT...
[ "public", "function", "getQualifiedParentKeyName", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "localKey", ")", ")", "{", "//Check for multi-columns relationship", "return", "array_map", "(", "function", "(", "$", "k", ")", "{", "return", "$"...
Get the fully qualified parent key name. @return string
[ "Get", "the", "fully", "qualified", "parent", "key", "name", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L56-L65
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.getForeignKeyName
public function getForeignKeyName() { $key = $this->getQualifiedForeignKeyName(); if (is_array($key)) { //Check for multi-columns relationship return array_map(function ($k) { $segments = explode('.', $k); return $segments[count($segments) - 1]; ...
php
public function getForeignKeyName() { $key = $this->getQualifiedForeignKeyName(); if (is_array($key)) { //Check for multi-columns relationship return array_map(function ($k) { $segments = explode('.', $k); return $segments[count($segments) - 1]; ...
[ "public", "function", "getForeignKeyName", "(", ")", "{", "$", "key", "=", "$", "this", "->", "getQualifiedForeignKeyName", "(", ")", ";", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "//Check for multi-columns relationship", "return", "array_map", "...
Get the plain foreign key. @return string
[ "Get", "the", "plain", "foreign", "key", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L72-L87
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.save
public function save(Model $model) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach ($foreignKey as $index => $key) { $model->setAttribute($key, $paren...
php
public function save(Model $model) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach ($foreignKey as $index => $key) { $model->setAttribute($key, $paren...
[ "public", "function", "save", "(", "Model", "$", "model", ")", "{", "$", "foreignKey", "=", "$", "this", "->", "getForeignKeyName", "(", ")", ";", "$", "parentKeyValue", "=", "$", "this", "->", "getParentKey", "(", ")", ";", "if", "(", "is_array", "(",...
Attach a model instance to the parent model. @param \Illuminate\Database\Eloquent\Model $model @return \Illuminate\Database\Eloquent\Model
[ "Attach", "a", "model", "instance", "to", "the", "parent", "model", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L95-L109
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.create
public function create(array $attributes = []) { return tap($this->related->newInstance($attributes), function ($instance) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relation...
php
public function create(array $attributes = []) { return tap($this->related->newInstance($attributes), function ($instance) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relation...
[ "public", "function", "create", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "return", "tap", "(", "$", "this", "->", "related", "->", "newInstance", "(", "$", "attributes", ")", ",", "function", "(", "$", "instance", ")", "{", "$", "for...
Create a new instance of the related model. @param array $attributes @return \Illuminate\Database\Eloquent\Model
[ "Create", "a", "new", "instance", "of", "the", "related", "model", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L117-L133
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.buildDictionary
protected function buildDictionary(Collection $results) { $dictionary = []; $foreign = $this->getForeignKeyName(); // First we will create a dictionary of models keyed by the foreign key of the // relationship as this will allow us to quickly access all of the related // mo...
php
protected function buildDictionary(Collection $results) { $dictionary = []; $foreign = $this->getForeignKeyName(); // First we will create a dictionary of models keyed by the foreign key of the // relationship as this will allow us to quickly access all of the related // mo...
[ "protected", "function", "buildDictionary", "(", "Collection", "$", "results", ")", "{", "$", "dictionary", "=", "[", "]", ";", "$", "foreign", "=", "$", "this", "->", "getForeignKeyName", "(", ")", ";", "// First we will create a dictionary of models keyed by the f...
Build model dictionary keyed by the relation's foreign key. @param \Illuminate\Database\Eloquent\Collection $results @return array
[ "Build", "model", "dictionary", "keyed", "by", "the", "relation", "s", "foreign", "key", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L195-L218
topclaudy/compoships
src/Database/Eloquent/Relations/HasOneOrMany.php
HasOneOrMany.setForeignAttributesForCreate
protected function setForeignAttributesForCreate(Model $model) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach ($foreignKey as $index => $key) { $model...
php
protected function setForeignAttributesForCreate(Model $model) { $foreignKey = $this->getForeignKeyName(); $parentKeyValue = $this->getParentKey(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach ($foreignKey as $index => $key) { $model...
[ "protected", "function", "setForeignAttributesForCreate", "(", "Model", "$", "model", ")", "{", "$", "foreignKey", "=", "$", "this", "->", "getForeignKeyName", "(", ")", ";", "$", "parentKeyValue", "=", "$", "this", "->", "getParentKey", "(", ")", ";", "if",...
Set the foreign ID for creating a related model. @param \Illuminate\Database\Eloquent\Model $model @return void
[ "Set", "the", "foreign", "ID", "for", "creating", "a", "related", "model", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOneOrMany.php#L226-L237
topclaudy/compoships
src/Database/Eloquent/Relations/HasOne.php
HasOne.getResults
public function getResults() { if (! is_array($this->getParentKey())) { if (is_null($this->getParentKey())) { return $this->getDefaultFor($this->parent); } } return $this->query->first() ?: $this->getDefaultFor($this->parent); }
php
public function getResults() { if (! is_array($this->getParentKey())) { if (is_null($this->getParentKey())) { return $this->getDefaultFor($this->parent); } } return $this->query->first() ?: $this->getDefaultFor($this->parent); }
[ "public", "function", "getResults", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "getParentKey", "(", ")", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "getParentKey", "(", ")", ")", ")", "{", "return", "$", ...
Get the results of the relationship. @return mixed
[ "Get", "the", "results", "of", "the", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOne.php#L18-L27
topclaudy/compoships
src/Database/Eloquent/Relations/HasOne.php
HasOne.getDefaultFor
protected function getDefaultFor(Model $model) { if (! $this->withDefault) { return; } $instance = $this->related->newInstance(); $foreignKey = $this->getForeignKeyName(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach (...
php
protected function getDefaultFor(Model $model) { if (! $this->withDefault) { return; } $instance = $this->related->newInstance(); $foreignKey = $this->getForeignKeyName(); if (is_array($foreignKey)) { //Check for multi-columns relationship foreach (...
[ "protected", "function", "getDefaultFor", "(", "Model", "$", "model", ")", "{", "if", "(", "!", "$", "this", "->", "withDefault", ")", "{", "return", ";", "}", "$", "instance", "=", "$", "this", "->", "related", "->", "newInstance", "(", ")", ";", "$...
Get the default value for this relation. @param \Illuminate\Database\Eloquent\Model $model @return \Illuminate\Database\Eloquent\Model|null
[ "Get", "the", "default", "value", "for", "this", "relation", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOne.php#L35-L62
topclaudy/compoships
src/Database/Eloquent/Relations/HasOne.php
HasOne.newRelatedInstanceFor
public function newRelatedInstanceFor(Model $parent) { $newInstance = $this->related->newInstance(); if (is_array($this->localKey)) { //Check for multi-columns relationship $foreignKey = $this->getForeignKeyName(); foreach ($this->localKey as $index => $key) { ...
php
public function newRelatedInstanceFor(Model $parent) { $newInstance = $this->related->newInstance(); if (is_array($this->localKey)) { //Check for multi-columns relationship $foreignKey = $this->getForeignKeyName(); foreach ($this->localKey as $index => $key) { ...
[ "public", "function", "newRelatedInstanceFor", "(", "Model", "$", "parent", ")", "{", "$", "newInstance", "=", "$", "this", "->", "related", "->", "newInstance", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "localKey", ")", ")", "{", "...
Make a new related instance for the given model. @param \Illuminate\Database\Eloquent\Model $parent @return \Illuminate\Database\Eloquent\Model
[ "Make", "a", "new", "related", "instance", "for", "the", "given", "model", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasOne.php#L99-L112
topclaudy/compoships
src/Database/Eloquent/Relations/HasMany.php
HasMany.getResults
public function getResults() { if (! is_array($this->getParentKey())) { return ! is_null($this->getParentKey()) ? $this->query->get() : $this->related->newCollection(); } return $this->query->get(); }
php
public function getResults() { if (! is_array($this->getParentKey())) { return ! is_null($this->getParentKey()) ? $this->query->get() : $this->related->newCollection(); } return $this->query->get(); }
[ "public", "function", "getResults", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "getParentKey", "(", ")", ")", ")", "{", "return", "!", "is_null", "(", "$", "this", "->", "getParentKey", "(", ")", ")", "?", "$", "this", "->",...
Get the results of the relationship. @return mixed
[ "Get", "the", "results", "of", "the", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/HasMany.php#L17-L24
topclaudy/compoships
src/Compoships.php
Compoships.newBaseQueryBuilder
protected function newBaseQueryBuilder() { $connection = $this->getConnection(); return new QueryBuilder($connection, $connection->getQueryGrammar(), $connection->getPostProcessor()); }
php
protected function newBaseQueryBuilder() { $connection = $this->getConnection(); return new QueryBuilder($connection, $connection->getQueryGrammar(), $connection->getPostProcessor()); }
[ "protected", "function", "newBaseQueryBuilder", "(", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "return", "new", "QueryBuilder", "(", "$", "connection", ",", "$", "connection", "->", "getQueryGrammar", "(", ")", ",",...
Configure Eloquent to use Compoships Query Builder @return \Awobaz\Compoships\Database\Query\Builder|static
[ "Configure", "Eloquent", "to", "use", "Compoships", "Query", "Builder" ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Compoships.php#L58-L63
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.getResults
public function getResults() { if (! is_array($this->foreignKey)) { if (is_null($this->child->{$this->foreignKey})) { return $this->getDefaultFor($this->parent); } } return $this->query->first() ?: $this->getDefaultFor($this->parent); }
php
public function getResults() { if (! is_array($this->foreignKey)) { if (is_null($this->child->{$this->foreignKey})) { return $this->getDefaultFor($this->parent); } } return $this->query->first() ?: $this->getDefaultFor($this->parent); }
[ "public", "function", "getResults", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "foreignKey", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "child", "->", "{", "$", "this", "->", "foreignKey", "}", ")", ")", ...
Get the results of the relationship. @return mixed
[ "Get", "the", "results", "of", "the", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L16-L25
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.addConstraints
public function addConstraints() { if (static::$constraints) { // For belongs to relationships, which are essentially the inverse of has one // or has many relationships, we need to actually query on the primary key // of the related models matching on the foreign key tha...
php
public function addConstraints() { if (static::$constraints) { // For belongs to relationships, which are essentially the inverse of has one // or has many relationships, we need to actually query on the primary key // of the related models matching on the foreign key tha...
[ "public", "function", "addConstraints", "(", ")", "{", "if", "(", "static", "::", "$", "constraints", ")", "{", "// For belongs to relationships, which are essentially the inverse of has one", "// or has many relationships, we need to actually query on the primary key", "// of the re...
Set the base constraints on the relation query. @return void
[ "Set", "the", "base", "constraints", "on", "the", "relation", "query", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L32-L51
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.addEagerConstraints
public function addEagerConstraints(array $models) { if (is_array($this->ownerKey)) { //Check for multi-columns relationship $keys = []; foreach ($this->ownerKey as $key) { $keys[] = $this->related->getTable().'.'.$key; } $this->query->whereI...
php
public function addEagerConstraints(array $models) { if (is_array($this->ownerKey)) { //Check for multi-columns relationship $keys = []; foreach ($this->ownerKey as $key) { $keys[] = $this->related->getTable().'.'.$key; } $this->query->whereI...
[ "public", "function", "addEagerConstraints", "(", "array", "$", "models", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "ownerKey", ")", ")", "{", "//Check for multi-columns relationship", "$", "keys", "=", "[", "]", ";", "foreach", "(", "$", "t...
Set the constraints for an eager load of the relation. @param array $models @return void
[ "Set", "the", "constraints", "for", "an", "eager", "load", "of", "the", "relation", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L59-L76
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.getEagerModelKeys
protected function getEagerModelKeys(array $models) { $keys = []; // First we need to gather all of the keys from the parent models so we know what // to query for via the eager loading query. We will add them to an array then // execute a "where in" statement to gather up all of th...
php
protected function getEagerModelKeys(array $models) { $keys = []; // First we need to gather all of the keys from the parent models so we know what // to query for via the eager loading query. We will add them to an array then // execute a "where in" statement to gather up all of th...
[ "protected", "function", "getEagerModelKeys", "(", "array", "$", "models", ")", "{", "$", "keys", "=", "[", "]", ";", "// First we need to gather all of the keys from the parent models so we know what", "// to query for via the eager loading query. We will add them to an array then",...
Gather the keys from an array of related models. @param array $models @return array
[ "Gather", "the", "keys", "from", "an", "array", "of", "related", "models", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L84-L113
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.getQualifiedForeignKey
public function getQualifiedForeignKey() { if (is_array($this->foreignKey)) { //Check for multi-columns relationship return array_map(function ($k) { return $this->child->getTable().'.'.$k; }, $this->foreignKey); } else { return $this->child->getTa...
php
public function getQualifiedForeignKey() { if (is_array($this->foreignKey)) { //Check for multi-columns relationship return array_map(function ($k) { return $this->child->getTable().'.'.$k; }, $this->foreignKey); } else { return $this->child->getTa...
[ "public", "function", "getQualifiedForeignKey", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "foreignKey", ")", ")", "{", "//Check for multi-columns relationship", "return", "array_map", "(", "function", "(", "$", "k", ")", "{", "return", "$",...
Get the fully qualified foreign key of the relationship. @return string
[ "Get", "the", "fully", "qualified", "foreign", "key", "of", "the", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L120-L129
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.getRelationExistenceQuery
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { if ($parentQuery->getQuery()->from == $query->getQuery()->from) { return $this->getRelationExistenceQueryForSelfRelation($query, $parentQuery, $columns); } $modelTable = $query->g...
php
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { if ($parentQuery->getQuery()->from == $query->getQuery()->from) { return $this->getRelationExistenceQueryForSelfRelation($query, $parentQuery, $columns); } $modelTable = $query->g...
[ "public", "function", "getRelationExistenceQuery", "(", "Builder", "$", "query", ",", "Builder", "$", "parentQuery", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "$", "parentQuery", "->", "getQuery", "(", ")", "->", "from", "==", "$", ...
Add the constraints for a relationship query. @param \Illuminate\Database\Eloquent\Builder $query @param \Illuminate\Database\Eloquent\Builder $parentQuery @param array|mixed $columns @return \Illuminate\Database\Eloquent\Builder
[ "Add", "the", "constraints", "for", "a", "relationship", "query", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L139-L155
topclaudy/compoships
src/Database/Eloquent/Relations/BelongsTo.php
BelongsTo.match
public function match(array $models, Collection $results, $relation) { $foreign = $this->foreignKey; $owner = $this->ownerKey; // First we will get to build a dictionary of the child models by their primary // key of the relationship, then we can easily match the children back onto...
php
public function match(array $models, Collection $results, $relation) { $foreign = $this->foreignKey; $owner = $this->ownerKey; // First we will get to build a dictionary of the child models by their primary // key of the relationship, then we can easily match the children back onto...
[ "public", "function", "match", "(", "array", "$", "models", ",", "Collection", "$", "results", ",", "$", "relation", ")", "{", "$", "foreign", "=", "$", "this", "->", "foreignKey", ";", "$", "owner", "=", "$", "this", "->", "ownerKey", ";", "// First w...
Match the eagerly loaded results to their parents. @param array $models @param \Illuminate\Database\Eloquent\Collection $results @param string $relation @return array
[ "Match", "the", "eagerly", "loaded", "results", "to", "their", "parents", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Relations/BelongsTo.php#L165-L208
topclaudy/compoships
src/Database/Eloquent/Concerns/HasRelationships.php
HasRelationships.getQualifiedKeyName
public function getQualifiedKeyName() { $keyName = $this->getKeyName(); if (is_array($keyName)) { //Check for multi-columns relationship $keys = []; foreach ($keyName as $key) { $keys[] = $this->getTable().$key; } return $keys; ...
php
public function getQualifiedKeyName() { $keyName = $this->getKeyName(); if (is_array($keyName)) { //Check for multi-columns relationship $keys = []; foreach ($keyName as $key) { $keys[] = $this->getTable().$key; } return $keys; ...
[ "public", "function", "getQualifiedKeyName", "(", ")", "{", "$", "keyName", "=", "$", "this", "->", "getKeyName", "(", ")", ";", "if", "(", "is_array", "(", "$", "keyName", ")", ")", "{", "//Check for multi-columns relationship", "$", "keys", "=", "[", "]"...
Get the table qualified key name. @return mixed
[ "Get", "the", "table", "qualified", "key", "name", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Concerns/HasRelationships.php#L19-L34
topclaudy/compoships
src/Database/Eloquent/Concerns/HasRelationships.php
HasRelationships.hasOne
public function hasOne($related, $foreignKey = null, $localKey = null) { if (is_array($foreignKey)) { //Check for multi-columns relationship $this->validateRelatedModel($related); } $instance = $this->newRelatedInstance($related); $foreignKey = $foreignKey ?: $this->get...
php
public function hasOne($related, $foreignKey = null, $localKey = null) { if (is_array($foreignKey)) { //Check for multi-columns relationship $this->validateRelatedModel($related); } $instance = $this->newRelatedInstance($related); $foreignKey = $foreignKey ?: $this->get...
[ "public", "function", "hasOne", "(", "$", "related", ",", "$", "foreignKey", "=", "null", ",", "$", "localKey", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "foreignKey", ")", ")", "{", "//Check for multi-columns relationship", "$", "this", "->"...
Define a one-to-one relationship. @param string $related @param string|array|null $foreignKey @param string|array|null $localKey @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne
[ "Define", "a", "one", "-", "to", "-", "one", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Concerns/HasRelationships.php#L44-L67
topclaudy/compoships
src/Database/Eloquent/Concerns/HasRelationships.php
HasRelationships.validateRelatedModel
private function validateRelatedModel($related) { $uses = class_uses_recursive($related); if (! array_key_exists('Awobaz\Compoships\Compoships', $uses) && ! is_subclass_of($related, 'Awobaz\Compoships\Database\Eloquent\Model')) { throw new InvalidUsageException("The rela...
php
private function validateRelatedModel($related) { $uses = class_uses_recursive($related); if (! array_key_exists('Awobaz\Compoships\Compoships', $uses) && ! is_subclass_of($related, 'Awobaz\Compoships\Database\Eloquent\Model')) { throw new InvalidUsageException("The rela...
[ "private", "function", "validateRelatedModel", "(", "$", "related", ")", "{", "$", "uses", "=", "class_uses_recursive", "(", "$", "related", ")", ";", "if", "(", "!", "array_key_exists", "(", "'Awobaz\\Compoships\\Compoships'", ",", "$", "uses", ")", "&&", "!"...
Validate the related model for Compoships compatibility @param $related @return void @throws InvalidUsageException
[ "Validate", "the", "related", "model", "for", "Compoships", "compatibility" ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Concerns/HasRelationships.php#L76-L84
topclaudy/compoships
src/Database/Eloquent/Concerns/HasRelationships.php
HasRelationships.belongsTo
public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null) { if (is_array($foreignKey)) { //Check for multi-columns relationship $this->validateRelatedModel($related); } // If no relation name was given, we will use this debug backtrace to extrac...
php
public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null) { if (is_array($foreignKey)) { //Check for multi-columns relationship $this->validateRelatedModel($related); } // If no relation name was given, we will use this debug backtrace to extrac...
[ "public", "function", "belongsTo", "(", "$", "related", ",", "$", "foreignKey", "=", "null", ",", "$", "ownerKey", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "foreignKey", ")", ")", "{", "//Check for mult...
Define an inverse one-to-one or many relationship. @param string $related @param string|array|null $foreignKey @param string|array|null $ownerKey @param string $relation @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
[ "Define", "an", "inverse", "one", "-", "to", "-", "one", "or", "many", "relationship", "." ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Concerns/HasRelationships.php#L128-L156
topclaudy/compoships
src/Database/Eloquent/Concerns/HasRelationships.php
HasRelationships.sanitizeKey
protected function sanitizeKey($instance, $foreignKey) { $grammar = $this->getConnection() ->getQueryGrammar(); return $grammar->isExpression($foreignKey) ? DB::raw($instance->getTable().'.'.$foreignKey) : $instance->getTable().'.'.$foreignKey; }
php
protected function sanitizeKey($instance, $foreignKey) { $grammar = $this->getConnection() ->getQueryGrammar(); return $grammar->isExpression($foreignKey) ? DB::raw($instance->getTable().'.'.$foreignKey) : $instance->getTable().'.'.$foreignKey; }
[ "protected", "function", "sanitizeKey", "(", "$", "instance", ",", "$", "foreignKey", ")", "{", "$", "grammar", "=", "$", "this", "->", "getConnection", "(", ")", "->", "getQueryGrammar", "(", ")", ";", "return", "$", "grammar", "->", "isExpression", "(", ...
Honor DB::raw instances @param string $instance @param string $foreignKey @return string|Expression
[ "Honor", "DB", "::", "raw", "instances" ]
train
https://github.com/topclaudy/compoships/blob/b63a7e5f6407c41326487f8d9b6030ee3d06f82c/src/Database/Eloquent/Concerns/HasRelationships.php#L165-L173
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.inSpan
public function inSpan(array $spanOptions, callable $callable, array $arguments = []) { $span = $this->startSpan($spanOptions + [ 'sameProcessAsParentSpan' => !empty($this->spans) ]); $scope = $this->withSpan($span); try { return call_user_func_array($callable...
php
public function inSpan(array $spanOptions, callable $callable, array $arguments = []) { $span = $this->startSpan($spanOptions + [ 'sameProcessAsParentSpan' => !empty($this->spans) ]); $scope = $this->withSpan($span); try { return call_user_func_array($callable...
[ "public", "function", "inSpan", "(", "array", "$", "spanOptions", ",", "callable", "$", "callable", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "span", "=", "$", "this", "->", "startSpan", "(", "$", "spanOptions", "+", "[", "'sameProc...
Instrument a callable by creating a Span that manages the startTime and endTime. @param array $spanOptions Options for the span. See <a href="../Span.html#method___construct">OpenCensus\Trace\Span::__construct()</a> @param callable $callable The callable to instrument. @param array $arguments [optional] Arguments for ...
[ "Instrument", "a", "callable", "by", "creating", "a", "Span", "that", "manages", "the", "startTime", "and", "endTime", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L67-L78
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.startSpan
public function startSpan(array $spanOptions = []) { $spanOptions += [ 'traceId' => $this->spanContext()->traceId(), 'parentSpanId' => $this->spanContext()->spanId(), 'startTime' => microtime(true) ]; return new Span($spanOptions); }
php
public function startSpan(array $spanOptions = []) { $spanOptions += [ 'traceId' => $this->spanContext()->traceId(), 'parentSpanId' => $this->spanContext()->spanId(), 'startTime' => microtime(true) ]; return new Span($spanOptions); }
[ "public", "function", "startSpan", "(", "array", "$", "spanOptions", "=", "[", "]", ")", "{", "$", "spanOptions", "+=", "[", "'traceId'", "=>", "$", "this", "->", "spanContext", "(", ")", "->", "traceId", "(", ")", ",", "'parentSpanId'", "=>", "$", "th...
Create a new Span. The start time is already set to the current time. The newly created span is not attached to the current context. @param array $spanOptions [optional] Options for the span. See <a href="../Span.html#method___construct">OpenCensus\Trace\Span::__construct()</a> @return Span
[ "Create", "a", "new", "Span", ".", "The", "start", "time", "is", "already", "set", "to", "the", "current", "time", ".", "The", "newly", "created", "span", "is", "not", "attached", "to", "the", "current", "context", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L88-L97
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.withSpan
public function withSpan(Span $span) { array_push($this->spans, $span); $prevContext = Context::current() ->withValues([ 'currentSpan' => $span, 'spanId' => $span->spanId() ]) ->attach(); $span->attach(); return new ...
php
public function withSpan(Span $span) { array_push($this->spans, $span); $prevContext = Context::current() ->withValues([ 'currentSpan' => $span, 'spanId' => $span->spanId() ]) ->attach(); $span->attach(); return new ...
[ "public", "function", "withSpan", "(", "Span", "$", "span", ")", "{", "array_push", "(", "$", "this", "->", "spans", ",", "$", "span", ")", ";", "$", "prevContext", "=", "Context", "::", "current", "(", ")", "->", "withValues", "(", "[", "'currentSpan'...
Attaches the provided span as the current span and returns a Scope object which must be closed. @param Span $span @return Scope
[ "Attaches", "the", "provided", "span", "as", "the", "current", "span", "and", "returns", "a", "Scope", "object", "which", "must", "be", "closed", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L106-L124
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.addAttribute
public function addAttribute($attribute, $value, $options = []) { $span = $this->getSpan($options); $span->addAttribute($attribute, $value); }
php
public function addAttribute($attribute, $value, $options = []) { $span = $this->getSpan($options); $span->addAttribute($attribute, $value); }
[ "public", "function", "addAttribute", "(", "$", "attribute", ",", "$", "value", ",", "$", "options", "=", "[", "]", ")", "{", "$", "span", "=", "$", "this", "->", "getSpan", "(", "$", "options", ")", ";", "$", "span", "->", "addAttribute", "(", "$"...
Add an attribute to the provided Span @param string $attribute @param string $value @param array $options [optional] Configuration options. @type Span $span The span to add the attribute to.
[ "Add", "an", "attribute", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L147-L151
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.addAnnotation
public function addAnnotation($description, $options = []) { $span = $this->getSpan($options); $span->addTimeEvent(new Annotation($description, $options)); }
php
public function addAnnotation($description, $options = []) { $span = $this->getSpan($options); $span->addTimeEvent(new Annotation($description, $options)); }
[ "public", "function", "addAnnotation", "(", "$", "description", ",", "$", "options", "=", "[", "]", ")", "{", "$", "span", "=", "$", "this", "->", "getSpan", "(", "$", "options", ")", ";", "$", "span", "->", "addTimeEvent", "(", "new", "Annotation", ...
Add an annotation to the provided Span @param string $description @param array $options [optional] Configuration options. @type Span $span The span to add the annotation to. @type array $attributes Attributes for this annotation. @type \DateTimeInterface|int|float $time The time of this event.
[ "Add", "an", "annotation", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L163-L167
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.addLink
public function addLink($traceId, $spanId, $options = []) { $span = $this->getSpan($options); $span->addLink(new Link($traceId, $spanId, $options)); }
php
public function addLink($traceId, $spanId, $options = []) { $span = $this->getSpan($options); $span->addLink(new Link($traceId, $spanId, $options)); }
[ "public", "function", "addLink", "(", "$", "traceId", ",", "$", "spanId", ",", "$", "options", "=", "[", "]", ")", "{", "$", "span", "=", "$", "this", "->", "getSpan", "(", "$", "options", ")", ";", "$", "span", "->", "addLink", "(", "new", "Link...
Add a link to the provided Span @param string $traceId @param string $spanId @param array $options [optional] Configuration options. @type Span $span The span to add the link to. @type string $type The relationship of the current span relative to the linked span: child, parent, or unspecified. @type array $attributes...
[ "Add", "a", "link", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L182-L186
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.addMessageEvent
public function addMessageEvent($type, $id, $options = []) { $span = $this->getSpan($options); $span->addTimeEvent(new MessageEvent($type, $id, $options)); }
php
public function addMessageEvent($type, $id, $options = []) { $span = $this->getSpan($options); $span->addTimeEvent(new MessageEvent($type, $id, $options)); }
[ "public", "function", "addMessageEvent", "(", "$", "type", ",", "$", "id", ",", "$", "options", "=", "[", "]", ")", "{", "$", "span", "=", "$", "this", "->", "getSpan", "(", "$", "options", ")", ";", "$", "span", "->", "addTimeEvent", "(", "new", ...
Add an message event to the provided Span @param string $type @param string $id @param array $options [optional] Configuration options. @type Span $span The span to add the message event to. @type int $uncompressedSize The number of uncompressed bytes sent or received. @type int $compressedSize The number of compress...
[ "Add", "an", "message", "event", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L203-L207
census-instrumentation/opencensus-php
src/Trace/Tracer/ContextTracer.php
ContextTracer.spanContext
public function spanContext() { $context = Context::current(); return new SpanContext( $context->value('traceId'), $context->value('spanId'), $context->value('enabled'), $context->value('fromHeader') ); }
php
public function spanContext() { $context = Context::current(); return new SpanContext( $context->value('traceId'), $context->value('spanId'), $context->value('enabled'), $context->value('fromHeader') ); }
[ "public", "function", "spanContext", "(", ")", "{", "$", "context", "=", "Context", "::", "current", "(", ")", ";", "return", "new", "SpanContext", "(", "$", "context", "->", "value", "(", "'traceId'", ")", ",", "$", "context", "->", "value", "(", "'sp...
Returns the current SpanContext @return SpanContext
[ "Returns", "the", "current", "SpanContext" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer/ContextTracer.php#L214-L223
census-instrumentation/opencensus-php
src/Trace/Integrations/Eloquent.php
Eloquent.load
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load Eloquent integrations.', E_USER_WARNING); return; } // public function getModels($columns = ['*']) opencensus_trace_method(Builder::cla...
php
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load Eloquent integrations.', E_USER_WARNING); return; } // public function getModels($columns = ['*']) opencensus_trace_method(Builder::cla...
[ "public", "static", "function", "load", "(", ")", "{", "if", "(", "!", "extension_loaded", "(", "'opencensus'", ")", ")", "{", "trigger_error", "(", "'opencensus extension required to load Eloquent integrations.'", ",", "E_USER_WARNING", ")", ";", "return", ";", "}"...
Static method to add instrumentation to Eloquent ORM calls
[ "Static", "method", "to", "add", "instrumentation", "to", "Eloquent", "ORM", "calls" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Eloquent.php#L39-L86
census-instrumentation/opencensus-php
src/Trace/Integrations/Mysql.php
Mysql.load
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load mysqli integrations.', E_USER_WARNING); return; } // mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT...
php
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load mysqli integrations.', E_USER_WARNING); return; } // mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT...
[ "public", "static", "function", "load", "(", ")", "{", "if", "(", "!", "extension_loaded", "(", "'opencensus'", ")", ")", "{", "trigger_error", "(", "'opencensus extension required to load mysqli integrations.'", ",", "E_USER_WARNING", ")", ";", "return", ";", "}", ...
Static method to add instrumentation to mysql requests
[ "Static", "method", "to", "add", "instrumentation", "to", "mysql", "requests" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Mysql.php#L37-L139
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.start
public static function start(ExporterInterface $reporter, array $options = []) { $sampler = array_key_exists('sampler', $options) ? $options['sampler'] : new AlwaysSampleSampler(); unset($options['sampler']); $propagator = array_key_exists('propagator', $options) ...
php
public static function start(ExporterInterface $reporter, array $options = []) { $sampler = array_key_exists('sampler', $options) ? $options['sampler'] : new AlwaysSampleSampler(); unset($options['sampler']); $propagator = array_key_exists('propagator', $options) ...
[ "public", "static", "function", "start", "(", "ExporterInterface", "$", "reporter", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "sampler", "=", "array_key_exists", "(", "'sampler'", ",", "$", "options", ")", "?", "$", "options", "[", "'sa...
Start a new trace session for this request. You should call this as early as possible for the most accurate results. @param ExporterInterface $reporter @param array $options Configuration options. See <a href="Span.html#method___construct">OpenCensus\Trace\Span::__construct()</a> for the other available options. @typ...
[ "Start", "a", "new", "trace", "session", "for", "this", "request", ".", "You", "should", "call", "this", "as", "early", "as", "possible", "for", "the", "most", "accurate", "results", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L120-L133
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.inSpan
public static function inSpan(array $spanOptions, callable $callable, array $arguments = []) { if (!isset(self::$instance)) { return call_user_func_array($callable, $arguments); } return self::$instance->inSpan($spanOptions, $callable, $arguments); }
php
public static function inSpan(array $spanOptions, callable $callable, array $arguments = []) { if (!isset(self::$instance)) { return call_user_func_array($callable, $arguments); } return self::$instance->inSpan($spanOptions, $callable, $arguments); }
[ "public", "static", "function", "inSpan", "(", "array", "$", "spanOptions", ",", "callable", "$", "callable", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return...
Instrument a callable by creating a Span that manages the startTime and endTime. If an exception is thrown while executing the callable, the exception will be caught, the span will be closed, and the exception will be re-thrown. Example: ``` // Instrumenting code as a closure Tracer::inSpan(['name' => 'some-closure'],...
[ "Instrument", "a", "callable", "by", "creating", "a", "Span", "that", "manages", "the", "startTime", "and", "endTime", ".", "If", "an", "exception", "is", "thrown", "while", "executing", "the", "callable", "the", "exception", "will", "be", "caught", "the", "...
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L162-L168
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.startSpan
public static function startSpan(array $spanOptions = []) { if (!isset(self::$instance)) { return new Span(); } return self::$instance->startSpan($spanOptions); }
php
public static function startSpan(array $spanOptions = []) { if (!isset(self::$instance)) { return new Span(); } return self::$instance->startSpan($spanOptions); }
[ "public", "static", "function", "startSpan", "(", "array", "$", "spanOptions", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", "new", "Span", "(", ")", ";", "}", "return", "self", "::",...
Explicitly start a new Span. You will need to attach the span and handle any thrown exceptions. Example: ``` $span = Tracer::startSpan(['name' => 'expensive-operation']); $scope = Tracer::withSpan($span); try { // do something expensive } catch (\Exception $e) { } finally { $scope->close(); } ``` @param array $spanOp...
[ "Explicitly", "start", "a", "new", "Span", ".", "You", "will", "need", "to", "attach", "the", "span", "and", "handle", "any", "thrown", "exceptions", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L190-L196
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.withSpan
public static function withSpan(Span $span) { if (!isset(self::$instance)) { return new Scope(function () { }); } return self::$instance->withSpan($span); }
php
public static function withSpan(Span $span) { if (!isset(self::$instance)) { return new Scope(function () { }); } return self::$instance->withSpan($span); }
[ "public", "static", "function", "withSpan", "(", "Span", "$", "span", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", "new", "Scope", "(", "function", "(", ")", "{", "}", ")", ";", "}", "return", "s...
Attaches the provided span as the current span and returns a Scope object which must be closed. Example: ``` $span = Tracer::startSpan(['name' => 'expensive-operation']); $scope = Tracer::withSpan($span); try { // do something expensive } finally { $scope->close(); } ``` @param Span $span @return Scope
[ "Attaches", "the", "provided", "span", "as", "the", "current", "span", "and", "returns", "a", "Scope", "object", "which", "must", "be", "closed", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L216-L223
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.addAttribute
public static function addAttribute($attribute, $value, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addAttribute($attribute, $value, $options); }
php
public static function addAttribute($attribute, $value, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addAttribute($attribute, $value, $options); }
[ "public", "static", "function", "addAttribute", "(", "$", "attribute", ",", "$", "value", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", ";", "}", "return", "self"...
Add an attribute to the provided Span @param string $attribute @param string $value @param array $options [optional] Configuration options. @type Span $span The span to add the attribute to.
[ "Add", "an", "attribute", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L234-L240
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.addAnnotation
public static function addAnnotation($description, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addAnnotation($description, $options); }
php
public static function addAnnotation($description, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addAnnotation($description, $options); }
[ "public", "static", "function", "addAnnotation", "(", "$", "description", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", ";", "}", "return", "self", "::", "$", "in...
Add an annotation to the provided Span @param string $description @param array $options [optional] Configuration options. @type Span $span The span to add the annotation to. @type array $attributes Attributes for this annotation. @type \DateTimeInterface|int|float $time The time of this event.
[ "Add", "an", "annotation", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L252-L258
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.addLink
public static function addLink($traceId, $spanId, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addLink($traceId, $spanId, $options); }
php
public static function addLink($traceId, $spanId, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addLink($traceId, $spanId, $options); }
[ "public", "static", "function", "addLink", "(", "$", "traceId", ",", "$", "spanId", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", ";", "}", "return", "self", ":...
Add a link to the provided Span @param string $traceId @param string $spanId @param array $options [optional] Configuration options. @type Span $span The span to add the link to. @type string $type The relationship of the current span relative to the linked span: child, parent, or unspecified. @type array $attributes...
[ "Add", "a", "link", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L273-L279
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.addMessageEvent
public static function addMessageEvent($type, $id, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addMessageEvent($type, $id, $options); }
php
public static function addMessageEvent($type, $id, $options = []) { if (!isset(self::$instance)) { return; } return self::$instance->addMessageEvent($type, $id, $options); }
[ "public", "static", "function", "addMessageEvent", "(", "$", "type", ",", "$", "id", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", ";", "}", "return", "self", "...
Add an message event to the provided Span @param string $type @param string $id @param array $options [optional] Configuration options. @type Span $span The span to add the message event to. @type int $uncompressedSize The number of uncompressed bytes sent or received. @type int $compressedSize The number of compress...
[ "Add", "an", "message", "event", "to", "the", "provided", "Span" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L296-L302
census-instrumentation/opencensus-php
src/Trace/Tracer.php
Tracer.spanContext
public static function spanContext() { if (!isset(self::$instance)) { return new SpanContext(null, null, false); } return self::$instance->tracer()->spanContext(); }
php
public static function spanContext() { if (!isset(self::$instance)) { return new SpanContext(null, null, false); } return self::$instance->tracer()->spanContext(); }
[ "public", "static", "function", "spanContext", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "return", "new", "SpanContext", "(", "null", ",", "null", ",", "false", ")", ";", "}", "return", "self", "::", ...
Returns the current span context. @return SpanContext
[ "Returns", "the", "current", "span", "context", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Tracer.php#L309-L315
census-instrumentation/opencensus-php
src/Trace/DateFormatTrait.php
DateFormatTrait.formatDate
private function formatDate($when = null) { if (!$when) { // now $when = $this->formatFloatTimeToDate(microtime(true)); } elseif (is_numeric($when)) { $when = $this->formatFloatTimeToDate($when); } elseif (!$when instanceof \DateTimeInterface) { ...
php
private function formatDate($when = null) { if (!$when) { // now $when = $this->formatFloatTimeToDate(microtime(true)); } elseif (is_numeric($when)) { $when = $this->formatFloatTimeToDate($when); } elseif (!$when instanceof \DateTimeInterface) { ...
[ "private", "function", "formatDate", "(", "$", "when", "=", "null", ")", "{", "if", "(", "!", "$", "when", ")", "{", "// now", "$", "when", "=", "$", "this", "->", "formatFloatTimeToDate", "(", "microtime", "(", "true", ")", ")", ";", "}", "elseif", ...
Handles parsing a \DateTimeInterface object from a provided timestamp. @param \DateTimeInterface|int|float $when [optional] The end time of this span. **Defaults to** now. If provided as an int or float, it is expected to be a Unix timestamp. @return \DateTimeInterface @throws \InvalidArgumentException
[ "Handles", "parsing", "a", "\\", "DateTimeInterface", "object", "from", "a", "provided", "timestamp", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/DateFormatTrait.php#L33-L45
census-instrumentation/opencensus-php
src/Utils/VarintTrait.php
VarintTrait.encodeUnsigned
public static function encodeUnsigned(string &$buf, int $x): int { $offset = $i = strlen($buf); while ($x >= 0x80) { $buf[$i++] = chr($x | 0x80); $x >>= 7; } $buf[$i++] = chr($x); return $i - $offset; }
php
public static function encodeUnsigned(string &$buf, int $x): int { $offset = $i = strlen($buf); while ($x >= 0x80) { $buf[$i++] = chr($x | 0x80); $x >>= 7; } $buf[$i++] = chr($x); return $i - $offset; }
[ "public", "static", "function", "encodeUnsigned", "(", "string", "&", "$", "buf", ",", "int", "$", "x", ")", ":", "int", "{", "$", "offset", "=", "$", "i", "=", "strlen", "(", "$", "buf", ")", ";", "while", "(", "$", "x", ">=", "0x80", ")", "{"...
Varint encode as unsigned integer. @param string $buf bytestring to hold varint encoding of $x. @param int $x the unsigned integer to varint encode. @return int number of bytes written to buf.
[ "Varint", "encode", "as", "unsigned", "integer", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Utils/VarintTrait.php#L33-L42
census-instrumentation/opencensus-php
src/Utils/VarintTrait.php
VarintTrait.encodeSigned
public static function encodeSigned(string &$buf, int $x): int { $ux = $x << 1; if ($x < 0) { $ux = ~$ux; } return self::encodeUnsigned($buf, $ux); }
php
public static function encodeSigned(string &$buf, int $x): int { $ux = $x << 1; if ($x < 0) { $ux = ~$ux; } return self::encodeUnsigned($buf, $ux); }
[ "public", "static", "function", "encodeSigned", "(", "string", "&", "$", "buf", ",", "int", "$", "x", ")", ":", "int", "{", "$", "ux", "=", "$", "x", "<<", "1", ";", "if", "(", "$", "x", "<", "0", ")", "{", "$", "ux", "=", "~", "$", "ux", ...
Varint encode as signed integer. @param string $buf bytestring to hold varint encoding of $x. @param int $x the signed integer to varint encode. @return int number of bytes written to buf.
[ "Varint", "encode", "as", "signed", "integer", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Utils/VarintTrait.php#L51-L58
census-instrumentation/opencensus-php
src/Utils/VarintTrait.php
VarintTrait.decodeUnsigned
public static function decodeUnsigned(string $buf, int &$x): int { $x = 0; $s = 0; for ($i = 0; $i < strlen($buf); $i++) { $b = ord($buf[$i]); if ($b < 0x80) { if ($i > 9 || $i == 9 && $b > 1) { // overflow $x = ...
php
public static function decodeUnsigned(string $buf, int &$x): int { $x = 0; $s = 0; for ($i = 0; $i < strlen($buf); $i++) { $b = ord($buf[$i]); if ($b < 0x80) { if ($i > 9 || $i == 9 && $b > 1) { // overflow $x = ...
[ "public", "static", "function", "decodeUnsigned", "(", "string", "$", "buf", ",", "int", "&", "$", "x", ")", ":", "int", "{", "$", "x", "=", "0", ";", "$", "s", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(...
Varint decode an unsigned integer. @param string $buf bytestring holding varint encoding. @param int $x integer to receive the decoded value. @return int number of bytes read from buf.
[ "Varint", "decode", "an", "unsigned", "integer", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Utils/VarintTrait.php#L67-L87
census-instrumentation/opencensus-php
src/Utils/VarintTrait.php
VarintTrait.decodeSigned
public static function decodeSigned(string $buf, int &$x): int { $ux = 0; $cnt = self::decodeUnsigned($buf, $ux); $x = $ux >> 1; if ($ux&1 != 0) { $x = ~$x; } return $cnt; }
php
public static function decodeSigned(string $buf, int &$x): int { $ux = 0; $cnt = self::decodeUnsigned($buf, $ux); $x = $ux >> 1; if ($ux&1 != 0) { $x = ~$x; } return $cnt; }
[ "public", "static", "function", "decodeSigned", "(", "string", "$", "buf", ",", "int", "&", "$", "x", ")", ":", "int", "{", "$", "ux", "=", "0", ";", "$", "cnt", "=", "self", "::", "decodeUnsigned", "(", "$", "buf", ",", "$", "ux", ")", ";", "$...
Varint decode a signed integer. @param string $buf bytestring holding varint encoding. @param int $x integer to receive the decoded value. @return int number of bytes read from buf.
[ "Varint", "decode", "a", "signed", "integer", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Utils/VarintTrait.php#L96-L105
census-instrumentation/opencensus-php
src/Trace/Integrations/Memcached.php
Memcached.load
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load Memcached integrations.', E_USER_WARNING); return; } // bool Memcached::add ( string $key , mixed $value [, int $expiration ] ) opencen...
php
public static function load() { if (!extension_loaded('opencensus')) { trigger_error('opencensus extension required to load Memcached integrations.', E_USER_WARNING); return; } // bool Memcached::add ( string $key , mixed $value [, int $expiration ] ) opencen...
[ "public", "static", "function", "load", "(", ")", "{", "if", "(", "!", "extension_loaded", "(", "'opencensus'", ")", ")", "{", "trigger_error", "(", "'opencensus extension required to load Memcached integrations.'", ",", "E_USER_WARNING", ")", ";", "return", ";", "}...
Static method to add instrumentation to memcache requests
[ "Static", "method", "to", "add", "instrumentation", "to", "memcache", "requests" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Memcached.php#L37-L121
census-instrumentation/opencensus-php
src/Trace/Integrations/Memcached.php
Memcached.handleAttributes
public static function handleAttributes($memcached, $keyOrKeys) { $key = is_array($keyOrKeys) ? implode(",", $keyOrKeys) : $keyOrKeys; return [ 'attributes' => ['key' => $key], 'kind' => Span::KIND_CLIENT ]; }
php
public static function handleAttributes($memcached, $keyOrKeys) { $key = is_array($keyOrKeys) ? implode(",", $keyOrKeys) : $keyOrKeys; return [ 'attributes' => ['key' => $key], 'kind' => Span::KIND_CLIENT ]; }
[ "public", "static", "function", "handleAttributes", "(", "$", "memcached", ",", "$", "keyOrKeys", ")", "{", "$", "key", "=", "is_array", "(", "$", "keyOrKeys", ")", "?", "implode", "(", "\",\"", ",", "$", "keyOrKeys", ")", ":", "$", "keyOrKeys", ";", "...
Handle converting the key or keys provided to a Memcache function into a comma-separated attribute @internal @param \Memcached $memcached @param array|string $keyOrKeys The key or keys to operate on @return array @access private
[ "Handle", "converting", "the", "key", "or", "keys", "provided", "to", "a", "Memcache", "function", "into", "a", "comma", "-", "separated", "attribute" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Memcached.php#L133-L140
census-instrumentation/opencensus-php
src/Trace/Integrations/Memcached.php
Memcached.handleAttributesByKey
public static function handleAttributesByKey($memcached, $serverKey, $keyOrKeys) { $key = is_array($keyOrKeys) ? implode(",", $keyOrKeys) : $keyOrKeys; return [ 'attributes' => [ 'serverKey' => $serverKey, 'key' => $key ], 'kind' =>...
php
public static function handleAttributesByKey($memcached, $serverKey, $keyOrKeys) { $key = is_array($keyOrKeys) ? implode(",", $keyOrKeys) : $keyOrKeys; return [ 'attributes' => [ 'serverKey' => $serverKey, 'key' => $key ], 'kind' =>...
[ "public", "static", "function", "handleAttributesByKey", "(", "$", "memcached", ",", "$", "serverKey", ",", "$", "keyOrKeys", ")", "{", "$", "key", "=", "is_array", "(", "$", "keyOrKeys", ")", "?", "implode", "(", "\",\"", ",", "$", "keyOrKeys", ")", ":"...
Handle converting the key or keys provided to a Memcache function into a comma-separated attribute @internal @param \Memcached $memcached @param string $serverKey The key identifying the server to store the value on or retrieve it from. @param array|string $keyOrKeys The key or keys to operate on @return array @acces...
[ "Handle", "converting", "the", "key", "or", "keys", "provided", "to", "a", "Memcache", "function", "into", "a", "comma", "-", "separated", "attribute" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Memcached.php#L153-L163
census-instrumentation/opencensus-php
src/Trace/Integrations/Memcached.php
Memcached.handleCasByKey
public static function handleCasByKey($memcached, $casToken, $serverKey, $key) { return [ 'attributes' => [ 'casToken' => $casToken, 'serverKey' => $serverKey, 'key' => $key ], 'kind' => Span::KIND_CLIENT ]; }
php
public static function handleCasByKey($memcached, $casToken, $serverKey, $key) { return [ 'attributes' => [ 'casToken' => $casToken, 'serverKey' => $serverKey, 'key' => $key ], 'kind' => Span::KIND_CLIENT ]; }
[ "public", "static", "function", "handleCasByKey", "(", "$", "memcached", ",", "$", "casToken", ",", "$", "serverKey", ",", "$", "key", ")", "{", "return", "[", "'attributes'", "=>", "[", "'casToken'", "=>", "$", "casToken", ",", "'serverKey'", "=>", "$", ...
Handle converting the key and check and set token to attributes @internal @param \Memcached $memcached @param string $casToken The check and set token. Unique value associated with the existing item. Generated by memcache. @param string $serverKey The key identifying the server to store the value on or retrieve it fro...
[ "Handle", "converting", "the", "key", "and", "check", "and", "set", "token", "to", "attributes" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Memcached.php#L201-L211
census-instrumentation/opencensus-php
src/Trace/Integrations/Memcached.php
Memcached.handleSetMultiByKey
public static function handleSetMultiByKey($memcached, $serverKey, $items) { return [ 'attributes' => [ 'serverKey' => $serverKey, 'key' => implode(',', array_keys($items)) ], 'kind' => Span::KIND_CLIENT ]; }
php
public static function handleSetMultiByKey($memcached, $serverKey, $items) { return [ 'attributes' => [ 'serverKey' => $serverKey, 'key' => implode(',', array_keys($items)) ], 'kind' => Span::KIND_CLIENT ]; }
[ "public", "static", "function", "handleSetMultiByKey", "(", "$", "memcached", ",", "$", "serverKey", ",", "$", "items", ")", "{", "return", "[", "'attributes'", "=>", "[", "'serverKey'", "=>", "$", "serverKey", ",", "'key'", "=>", "implode", "(", "','", ",...
Extract key attribute from a setMulti command @internal @param \Memcached $memcached @param string $serverKey The key identifying the server to store the value on or retrieve it from. @param array $items The items being set in memcached. @return array @access private
[ "Extract", "key", "attribute", "from", "a", "setMulti", "command" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Integrations/Memcached.php#L242-L251
census-instrumentation/opencensus-php
src/Stats/MeasurementMap.php
MeasurementMap.putAttachment
public function putAttachment(string $key, string $value): MeasurementInterface { $this->attachments[$key] = $value; return $this; }
php
public function putAttachment(string $key, string $value): MeasurementInterface { $this->attachments[$key] = $value; return $this; }
[ "public", "function", "putAttachment", "(", "string", "$", "key", ",", "string", "$", "value", ")", ":", "MeasurementInterface", "{", "$", "this", "->", "attachments", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add an Exemplar Attachment to our map. If the key already exists, the existing Attachment in the map will be overriden with the new value. @param string $key The Attachment key. @param string $value The Attachment value. @return MeasurementInterface
[ "Add", "an", "Exemplar", "Attachment", "to", "our", "map", ".", "If", "the", "key", "already", "exists", "the", "existing", "Attachment", "in", "the", "map", "will", "be", "overriden", "with", "the", "new", "value", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Stats/MeasurementMap.php#L54-L58
census-instrumentation/opencensus-php
src/Stats/MeasurementMap.php
MeasurementMap.record
public function record(Context $ctx = null, TagContext $tags = null): bool { // without measurements we can bail out immediately if (count($this->measurements) === 0) { return true; } if ($ctx === null) { $ctx = Context::current(); } // clone ...
php
public function record(Context $ctx = null, TagContext $tags = null): bool { // without measurements we can bail out immediately if (count($this->measurements) === 0) { return true; } if ($ctx === null) { $ctx = Context::current(); } // clone ...
[ "public", "function", "record", "(", "Context", "$", "ctx", "=", "null", ",", "TagContext", "$", "tags", "=", "null", ")", ":", "bool", "{", "// without measurements we can bail out immediately", "if", "(", "count", "(", "$", "this", "->", "measurements", ")",...
Record the Measurements, Attachments and Tags found in the map. If Context is not explicitly provided, the current Context is used. If a TagContext object is explicitly provided, all tags found are inserted into the TagContext object found in Context. If a Tag with the same key already exists in the implicit TagContext...
[ "Record", "the", "Measurements", "Attachments", "and", "Tags", "found", "in", "the", "map", ".", "If", "Context", "is", "not", "explicitly", "provided", "the", "current", "Context", "is", "used", ".", "If", "a", "TagContext", "object", "is", "explicitly", "p...
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Stats/MeasurementMap.php#L72-L92
census-instrumentation/opencensus-php
src/Trace/Propagator/BinaryFormatter.php
BinaryFormatter.deserialize
public function deserialize($bin) { $data = @unpack('Cversion/Cfield0/H32traceId/Cfield1/H16spanId/Cfield2/Coptions', $bin); if ($data === false) { trigger_error('Invalid binary format for SpanContext', E_USER_WARNING); return new SpanContext(); } $enabled = !...
php
public function deserialize($bin) { $data = @unpack('Cversion/Cfield0/H32traceId/Cfield1/H16spanId/Cfield2/Coptions', $bin); if ($data === false) { trigger_error('Invalid binary format for SpanContext', E_USER_WARNING); return new SpanContext(); } $enabled = !...
[ "public", "function", "deserialize", "(", "$", "bin", ")", "{", "$", "data", "=", "@", "unpack", "(", "'Cversion/Cfield0/H32traceId/Cfield1/H16spanId/Cfield2/Coptions'", ",", "$", "bin", ")", ";", "if", "(", "$", "data", "===", "false", ")", "{", "trigger_erro...
Generate a SpanContext object from the Trace Context header @param string $header @return SpanContext
[ "Generate", "a", "SpanContext", "object", "from", "the", "Trace", "Context", "header" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Propagator/BinaryFormatter.php#L40-L52
census-instrumentation/opencensus-php
src/Trace/Propagator/BinaryFormatter.php
BinaryFormatter.serialize
public function serialize(SpanContext $context) { $spanHex = str_pad($context->spanId(), 16, "0", STR_PAD_LEFT); $traceOptions = $context->enabled() ? self::OPTION_ENABLED : 0; return pack("CCH*CH*CC", 0, 0, $context->traceId(), 1, $spanHex, 2, $traceOptions); }
php
public function serialize(SpanContext $context) { $spanHex = str_pad($context->spanId(), 16, "0", STR_PAD_LEFT); $traceOptions = $context->enabled() ? self::OPTION_ENABLED : 0; return pack("CCH*CH*CC", 0, 0, $context->traceId(), 1, $spanHex, 2, $traceOptions); }
[ "public", "function", "serialize", "(", "SpanContext", "$", "context", ")", "{", "$", "spanHex", "=", "str_pad", "(", "$", "context", "->", "spanId", "(", ")", ",", "16", ",", "\"0\"", ",", "STR_PAD_LEFT", ")", ";", "$", "traceOptions", "=", "$", "cont...
Convert a SpanContext to header string @param SpanContext $context @return string
[ "Convert", "a", "SpanContext", "to", "header", "string" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/Propagator/BinaryFormatter.php#L60-L65
census-instrumentation/opencensus-php
src/Trace/SpanData.php
SpanData.stackTraceHashId
public function stackTraceHashId() { if (!isset($this->stackTraceHashId)) { // take the lower 16 digits of the md5 $md5 = md5(serialize($this->stackTrace)); $this->stackTraceHashId = substr($md5, 16); } return $this->stackTraceHashId; }
php
public function stackTraceHashId() { if (!isset($this->stackTraceHashId)) { // take the lower 16 digits of the md5 $md5 = md5(serialize($this->stackTrace)); $this->stackTraceHashId = substr($md5, 16); } return $this->stackTraceHashId; }
[ "public", "function", "stackTraceHashId", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stackTraceHashId", ")", ")", "{", "// take the lower 16 digits of the md5", "$", "md5", "=", "md5", "(", "serialize", "(", "$", "this", "->", "stackTra...
Return a hash id for this span's stackTrace in hexadecimal @return string
[ "Return", "a", "hash", "id", "for", "this", "span", "s", "stackTrace", "in", "hexadecimal" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Trace/SpanData.php#L319-L327
census-instrumentation/opencensus-php
src/Stats/Stats.php
Stats.getInstance
public static function getInstance(): Stats { if (self::$instance instanceof Stats) { return self::$instance; } self::$instance = new Stats(); self::$instance->exporter = new NoopExporter(); return self::$instance; }
php
public static function getInstance(): Stats { if (self::$instance instanceof Stats) { return self::$instance; } self::$instance = new Stats(); self::$instance->exporter = new NoopExporter(); return self::$instance; }
[ "public", "static", "function", "getInstance", "(", ")", ":", "Stats", "{", "if", "(", "self", "::", "$", "instance", "instanceof", "Stats", ")", "{", "return", "self", "::", "$", "instance", ";", "}", "self", "::", "$", "instance", "=", "new", "Stats"...
Retrieve Stats instance. @return Stats
[ "Retrieve", "Stats", "instance", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Stats/Stats.php#L91-L100
census-instrumentation/opencensus-php
src/Core/DaemonClient.php
DaemonClient.init
public static function init(array $options = []): DaemonClient { if (self::$instance instanceof DaemonClient) { return self::$instance; } if (array_key_exists('maxSendTime', $options) && is_float($options['maxSendTime'])) { $maxSendTime = $options['maxSendTime']; ...
php
public static function init(array $options = []): DaemonClient { if (self::$instance instanceof DaemonClient) { return self::$instance; } if (array_key_exists('maxSendTime', $options) && is_float($options['maxSendTime'])) { $maxSendTime = $options['maxSendTime']; ...
[ "public", "static", "function", "init", "(", "array", "$", "options", "=", "[", "]", ")", ":", "DaemonClient", "{", "if", "(", "self", "::", "$", "instance", "instanceof", "DaemonClient", ")", "{", "return", "self", "::", "$", "instance", ";", "}", "if...
Initialize our DaemonClient for Stats and/or Trace reporting to the OpenCensus PHP Daemon service. @param array $options Configuration options. @type string $socketPath Path of the Unix socket to communicate over. @type float $maxSendTime The maximum send time for a message payload in seconds. @throws \Exception Thro...
[ "Initialize", "our", "DaemonClient", "for", "Stats", "and", "/", "or", "Trace", "reporting", "to", "the", "OpenCensus", "PHP", "Daemon", "service", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Core/DaemonClient.php#L145-L187
census-instrumentation/opencensus-php
src/Core/DaemonClient.php
DaemonClient.send
final private function send(string $type, string $msg = ''): bool { if ($this->useExtension) { return opencensus_core_send_to_daemonclient(ord($type), $msg); } $start = microtime(true); $maxEnd = $start + $this->maxSendTime; $buf = self::START_OF_MSG . $type; ...
php
final private function send(string $type, string $msg = ''): bool { if ($this->useExtension) { return opencensus_core_send_to_daemonclient(ord($type), $msg); } $start = microtime(true); $maxEnd = $start + $this->maxSendTime; $buf = self::START_OF_MSG . $type; ...
[ "final", "private", "function", "send", "(", "string", "$", "type", ",", "string", "$", "msg", "=", "''", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "useExtension", ")", "{", "return", "opencensus_core_send_to_daemonclient", "(", "ord", "(", "$...
Send message to daemon Message layout: MSG_PREFIX : 32 bit (0 value to aide in recovery from message truncation) MESSAGE_TYPE: byte SEQUENCE_NR : varint PROCESS_ID : varint THREAD_ID : varint (0 in most PHP deployments - (ZTS disabled)) START_TIME : float (measured in microseconds, 32 or 64 bit depending on env.)...
[ "Send", "message", "to", "daemon" ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Core/DaemonClient.php#L342-L373
census-instrumentation/opencensus-php
src/Core/DaemonClient.php
DaemonClient.encodeString
final private static function encodeString(string $data): string { $buf = ''; self::encodeUnsigned($buf, strlen($data)); return $buf . $data; }
php
final private static function encodeString(string $data): string { $buf = ''; self::encodeUnsigned($buf, strlen($data)); return $buf . $data; }
[ "final", "private", "static", "function", "encodeString", "(", "string", "$", "data", ")", ":", "string", "{", "$", "buf", "=", "''", ";", "self", "::", "encodeUnsigned", "(", "$", "buf", ",", "strlen", "(", "$", "data", ")", ")", ";", "return", "$",...
Encodes message payload by prefixing the message length as unsigned varint. @param string $data The message payload to prefix. @return string returns The unsigned varint length prefixed payload.
[ "Encodes", "message", "payload", "by", "prefixing", "the", "message", "length", "as", "unsigned", "varint", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Core/DaemonClient.php#L381-L386
census-instrumentation/opencensus-php
src/Tags/TagValue.php
TagValue.create
public static function create(string $value): TagValue { if (strlen($value) > self::MAX_LENGTH || !self::isPrintable($value)) { throw new \Exception("Invalid TagValue: $value"); } return new self($value); }
php
public static function create(string $value): TagValue { if (strlen($value) > self::MAX_LENGTH || !self::isPrintable($value)) { throw new \Exception("Invalid TagValue: $value"); } return new self($value); }
[ "public", "static", "function", "create", "(", "string", "$", "value", ")", ":", "TagValue", "{", "if", "(", "strlen", "(", "$", "value", ")", ">", "self", "::", "MAX_LENGTH", "||", "!", "self", "::", "isPrintable", "(", "$", "value", ")", ")", "{", ...
Constructs a TagValue with the given string payload. The name must meet the following requirements: <ol> <li>It cannot be longer than TagValue::MAX_LENGTH <li>It can only contain printable ASCII characters. </ol> @param string $value the value payload. @return TagValue @throws \Exception if name is not valid.
[ "Constructs", "a", "TagValue", "with", "the", "given", "string", "payload", "." ]
train
https://github.com/census-instrumentation/opencensus-php/blob/1327147dc2ea99c06df01db4daa8c4ab2656514d/src/Tags/TagValue.php#L54-L60