repository_name
string
func_path_in_repository
string
func_name
string
whole_func_string
string
language
string
func_code_string
string
func_code_tokens
list
func_documentation_string
string
func_documentation_tokens
list
split_name
string
func_code_url
string
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readCircularStringText
private function readCircularStringText(WKTParser $parser, CoordinateSystem $cs) : CircularString { $points = $this->readMultiPoint($parser, $cs); return new CircularString($cs, ...$points); }
php
private function readCircularStringText(WKTParser $parser, CoordinateSystem $cs) : CircularString { $points = $this->readMultiPoint($parser, $cs); return new CircularString($cs, ...$points); }
[ "private", "function", "readCircularStringText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "CircularString", "{", "$", "points", "=", "$", "this", "->", "readMultiPoint", "(", "$", "parser", ",", "$", "cs", ")", ";", "r...
(x y, ...) @param WKTParser $parser @param CoordinateSystem $cs @return CircularString
[ "(", "x", "y", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L250-L255
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readCompoundCurveText
private function readCompoundCurveText(WKTParser $parser, CoordinateSystem $cs) : CompoundCurve { $parser->matchOpener(); $curves = []; do { if ($parser->isNextOpenerOrWord()) { $curves[] = $this->readLineStringText($parser, $cs); } else { $curves[] = $this->readGeometry($parser, $cs->SRID()); } $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new CompoundCurve($cs, ...$curves); }
php
private function readCompoundCurveText(WKTParser $parser, CoordinateSystem $cs) : CompoundCurve { $parser->matchOpener(); $curves = []; do { if ($parser->isNextOpenerOrWord()) { $curves[] = $this->readLineStringText($parser, $cs); } else { $curves[] = $this->readGeometry($parser, $cs->SRID()); } $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new CompoundCurve($cs, ...$curves); }
[ "private", "function", "readCompoundCurveText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "CompoundCurve", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "curves", "=", "[", "]", ";", "do", "{", "if", "(...
@param WKTParser $parser @param CoordinateSystem $cs @return CompoundCurve
[ "@param", "WKTParser", "$parser", "@param", "CoordinateSystem", "$cs" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L263-L279
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readMultiPointText
private function readMultiPointText(WKTParser $parser, CoordinateSystem $cs) : MultiPoint { $points = $this->readMultiPoint($parser, $cs); return new MultiPoint($cs, ...$points); }
php
private function readMultiPointText(WKTParser $parser, CoordinateSystem $cs) : MultiPoint { $points = $this->readMultiPoint($parser, $cs); return new MultiPoint($cs, ...$points); }
[ "private", "function", "readMultiPointText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "MultiPoint", "{", "$", "points", "=", "$", "this", "->", "readMultiPoint", "(", "$", "parser", ",", "$", "cs", ")", ";", "return", ...
(x y, ...) @param WKTParser $parser @param CoordinateSystem $cs @return MultiPoint
[ "(", "x", "y", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L289-L294
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readMultiLineString
private function readMultiLineString(WKTParser $parser, CoordinateSystem $cs) : array { $parser->matchOpener(); $lineStrings = []; do { $lineStrings[] = $this->readLineStringText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return $lineStrings; }
php
private function readMultiLineString(WKTParser $parser, CoordinateSystem $cs) : array { $parser->matchOpener(); $lineStrings = []; do { $lineStrings[] = $this->readLineStringText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return $lineStrings; }
[ "private", "function", "readMultiLineString", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "array", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "lineStrings", "=", "[", "]", ";", "do", "{", "$", "lineStr...
((x y, ...), ...) @param WKTParser $parser @param CoordinateSystem $cs @return LineString[]
[ "((", "x", "y", "...", ")", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L304-L315
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readPolygonText
private function readPolygonText(WKTParser $parser, CoordinateSystem $cs) : Polygon { $rings = $this->readMultiLineString($parser, $cs); return new Polygon($cs, ...$rings); }
php
private function readPolygonText(WKTParser $parser, CoordinateSystem $cs) : Polygon { $rings = $this->readMultiLineString($parser, $cs); return new Polygon($cs, ...$rings); }
[ "private", "function", "readPolygonText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "Polygon", "{", "$", "rings", "=", "$", "this", "->", "readMultiLineString", "(", "$", "parser", ",", "$", "cs", ")", ";", "return", ...
((x y, ...), ...) @param WKTParser $parser @param CoordinateSystem $cs @return Polygon
[ "((", "x", "y", "...", ")", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L325-L330
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readCurvePolygonText
private function readCurvePolygonText(WKTParser $parser, CoordinateSystem $cs) : CurvePolygon { $parser->matchOpener(); $curves = []; do { if ($parser->isNextOpenerOrWord()) { $curves[] = $this->readLineStringText($parser, $cs); } else { $curves[] = $this->readGeometry($parser, $cs->SRID()); } $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new CurvePolygon($cs, ...$curves); }
php
private function readCurvePolygonText(WKTParser $parser, CoordinateSystem $cs) : CurvePolygon { $parser->matchOpener(); $curves = []; do { if ($parser->isNextOpenerOrWord()) { $curves[] = $this->readLineStringText($parser, $cs); } else { $curves[] = $this->readGeometry($parser, $cs->SRID()); } $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new CurvePolygon($cs, ...$curves); }
[ "private", "function", "readCurvePolygonText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "CurvePolygon", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "curves", "=", "[", "]", ";", "do", "{", "if", "(",...
@param WKTParser $parser @param CoordinateSystem $cs @return CurvePolygon
[ "@param", "WKTParser", "$parser", "@param", "CoordinateSystem", "$cs" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L338-L354
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readTriangleText
private function readTriangleText(WKTParser $parser, CoordinateSystem $cs) : Triangle { $rings = $this->readMultiLineString($parser, $cs); return new Triangle($cs, ...$rings); }
php
private function readTriangleText(WKTParser $parser, CoordinateSystem $cs) : Triangle { $rings = $this->readMultiLineString($parser, $cs); return new Triangle($cs, ...$rings); }
[ "private", "function", "readTriangleText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "Triangle", "{", "$", "rings", "=", "$", "this", "->", "readMultiLineString", "(", "$", "parser", ",", "$", "cs", ")", ";", "return", ...
((x y, ...), ...) @param WKTParser $parser @param CoordinateSystem $cs @return Triangle
[ "((", "x", "y", "...", ")", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L364-L369
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readMultiLineStringText
private function readMultiLineStringText(WKTParser $parser, CoordinateSystem $cs) : MultiLineString { $lineStrings = $this->readMultiLineString($parser, $cs); return new MultiLineString($cs, ...$lineStrings); }
php
private function readMultiLineStringText(WKTParser $parser, CoordinateSystem $cs) : MultiLineString { $lineStrings = $this->readMultiLineString($parser, $cs); return new MultiLineString($cs, ...$lineStrings); }
[ "private", "function", "readMultiLineStringText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "MultiLineString", "{", "$", "lineStrings", "=", "$", "this", "->", "readMultiLineString", "(", "$", "parser", ",", "$", "cs", ")",...
((x y, ...), ...) @param WKTParser $parser @param CoordinateSystem $cs @return MultiLineString
[ "((", "x", "y", "...", ")", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L379-L384
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readMultiPolygonText
private function readMultiPolygonText(WKTParser $parser, CoordinateSystem $cs) : MultiPolygon { $parser->matchOpener(); $polygons = []; do { $polygons[] = $this->readPolygonText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new MultiPolygon($cs, ...$polygons); }
php
private function readMultiPolygonText(WKTParser $parser, CoordinateSystem $cs) : MultiPolygon { $parser->matchOpener(); $polygons = []; do { $polygons[] = $this->readPolygonText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new MultiPolygon($cs, ...$polygons); }
[ "private", "function", "readMultiPolygonText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "MultiPolygon", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "polygons", "=", "[", "]", ";", "do", "{", "$", "po...
(((x y, ...), ...), ...) @param WKTParser $parser @param CoordinateSystem $cs @return MultiPolygon
[ "(((", "x", "y", "...", ")", "...", ")", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L394-L405
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readGeometryCollectionText
private function readGeometryCollectionText(WKTParser $parser, CoordinateSystem $cs) : GeometryCollection { $parser->matchOpener(); $geometries = []; do { $geometries[] = $this->readGeometry($parser, $cs->SRID()); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new GeometryCollection($cs, ...$geometries); }
php
private function readGeometryCollectionText(WKTParser $parser, CoordinateSystem $cs) : GeometryCollection { $parser->matchOpener(); $geometries = []; do { $geometries[] = $this->readGeometry($parser, $cs->SRID()); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new GeometryCollection($cs, ...$geometries); }
[ "private", "function", "readGeometryCollectionText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "GeometryCollection", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "geometries", "=", "[", "]", ";", "do", "{"...
@param WKTParser $parser @param CoordinateSystem $cs @return GeometryCollection
[ "@param", "WKTParser", "$parser", "@param", "CoordinateSystem", "$cs" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L413-L424
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readPolyhedralSurfaceText
private function readPolyhedralSurfaceText(WKTParser $parser, CoordinateSystem $cs) : PolyhedralSurface { $parser->matchOpener(); $patches = []; do { $patches[] = $this->readPolygonText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new PolyhedralSurface($cs, ...$patches); }
php
private function readPolyhedralSurfaceText(WKTParser $parser, CoordinateSystem $cs) : PolyhedralSurface { $parser->matchOpener(); $patches = []; do { $patches[] = $this->readPolygonText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new PolyhedralSurface($cs, ...$patches); }
[ "private", "function", "readPolyhedralSurfaceText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "PolyhedralSurface", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "patches", "=", "[", "]", ";", "do", "{", "...
@param WKTParser $parser @param CoordinateSystem $cs @return PolyhedralSurface
[ "@param", "WKTParser", "$parser", "@param", "CoordinateSystem", "$cs" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L432-L443
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readTINText
private function readTINText(WKTParser $parser, CoordinateSystem $cs) : TIN { $parser->matchOpener(); $patches = []; do { $patches[] = $this->readTriangleText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new TIN($cs, ...$patches); }
php
private function readTINText(WKTParser $parser, CoordinateSystem $cs) : TIN { $parser->matchOpener(); $patches = []; do { $patches[] = $this->readTriangleText($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return new TIN($cs, ...$patches); }
[ "private", "function", "readTINText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "TIN", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "patches", "=", "[", "]", ";", "do", "{", "$", "patches", "[", "]...
@param WKTParser $parser @param CoordinateSystem $cs @return TIN
[ "@param", "WKTParser", "$parser", "@param", "CoordinateSystem", "$cs" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L451-L462
brick/geo
src/LineString.php
LineString.of
public static function of(Point $point1, Point ...$pointN) : LineString { return new LineString($point1->coordinateSystem(), $point1, ...$pointN); }
php
public static function of(Point $point1, Point ...$pointN) : LineString { return new LineString($point1->coordinateSystem(), $point1, ...$pointN); }
[ "public", "static", "function", "of", "(", "Point", "$", "point1", ",", "Point", "...", "$", "pointN", ")", ":", "LineString", "{", "return", "new", "LineString", "(", "$", "point1", "->", "coordinateSystem", "(", ")", ",", "$", "point1", ",", "...", "...
Creates a non-empty LineString composed of the given points. @param Point $point1 The first point. @param Point ...$pointN The subsequent points. @return LineString @throws InvalidGeometryException If only one point was given. @throws CoordinateSystemException If the points use different coordinate systems.
[ "Creates", "a", "non", "-", "empty", "LineString", "composed", "of", "the", "given", "points", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/LineString.php#L71-L74
brick/geo
src/LineString.php
LineString.rectangle
public static function rectangle(Point $a, Point $b) : LineString { $cs = $a->coordinateSystem(); if ($cs != $b->coordinateSystem()) { // by-value comparison. throw CoordinateSystemException::dimensionalityMix($a, $b); } if ($cs->coordinateDimension() !== 2) { throw new CoordinateSystemException(__METHOD__ . ' expects 2D points.'); } $x1 = min($a->x(), $b->x()); $x2 = max($a->x(), $b->x()); $y1 = min($a->y(), $b->y()); $y2 = max($a->y(), $b->y()); $p1 = new Point($cs, $x1, $y1); $p2 = new Point($cs, $x2, $y1); $p3 = new Point($cs, $x2, $y2); $p4 = new Point($cs, $x1, $y2); return new LineString($cs, $p1, $p2, $p3, $p4, $p1); }
php
public static function rectangle(Point $a, Point $b) : LineString { $cs = $a->coordinateSystem(); if ($cs != $b->coordinateSystem()) { // by-value comparison. throw CoordinateSystemException::dimensionalityMix($a, $b); } if ($cs->coordinateDimension() !== 2) { throw new CoordinateSystemException(__METHOD__ . ' expects 2D points.'); } $x1 = min($a->x(), $b->x()); $x2 = max($a->x(), $b->x()); $y1 = min($a->y(), $b->y()); $y2 = max($a->y(), $b->y()); $p1 = new Point($cs, $x1, $y1); $p2 = new Point($cs, $x2, $y1); $p3 = new Point($cs, $x2, $y2); $p4 = new Point($cs, $x1, $y2); return new LineString($cs, $p1, $p2, $p3, $p4, $p1); }
[ "public", "static", "function", "rectangle", "(", "Point", "$", "a", ",", "Point", "$", "b", ")", ":", "LineString", "{", "$", "cs", "=", "$", "a", "->", "coordinateSystem", "(", ")", ";", "if", "(", "$", "cs", "!=", "$", "b", "->", "coordinateSyst...
Creates a rectangle out of two 2D corner points. The result is a linear ring (closed and simple). @param Point $a @param Point $b @return LineString @throws CoordinateSystemException If the points use different coordinate systems, or are not 2D.
[ "Creates", "a", "rectangle", "out", "of", "two", "2D", "corner", "points", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/LineString.php#L88-L112
brick/geo
src/Proxy/CompoundCurveProxy.php
CompoundCurveProxy.numCurves
public function numCurves() : int { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->numCurves(); }
php
public function numCurves() : int { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->numCurves(); }
[ "public", "function", "numCurves", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "proxyGeometry", "===", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "$", "this", "->", "proxyGeometry", "->", "numCurves", "(",...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CompoundCurveProxy.php#L181-L188
brick/geo
src/IO/WKTParser.php
WKTParser.scan
private function scan(string $wkt) : void { $regex = $this->getRegex(); $regex[] = '\s+'; $regex[] = '(.+?)'; $regex = '/' . implode('|', $regex) . '/i'; preg_match_all($regex, $wkt, $matches, PREG_SET_ORDER); foreach ($matches as $index => $match) { foreach ($match as $key => $value) { if ($key === 0) { continue; } if ($value !== '') { $this->tokens[$index] = [$key, $value]; } } } ksort($this->tokens); reset($this->tokens); }
php
private function scan(string $wkt) : void { $regex = $this->getRegex(); $regex[] = '\s+'; $regex[] = '(.+?)'; $regex = '/' . implode('|', $regex) . '/i'; preg_match_all($regex, $wkt, $matches, PREG_SET_ORDER); foreach ($matches as $index => $match) { foreach ($match as $key => $value) { if ($key === 0) { continue; } if ($value !== '') { $this->tokens[$index] = [$key, $value]; } } } ksort($this->tokens); reset($this->tokens); }
[ "private", "function", "scan", "(", "string", "$", "wkt", ")", ":", "void", "{", "$", "regex", "=", "$", "this", "->", "getRegex", "(", ")", ";", "$", "regex", "[", "]", "=", "'\\s+'", ";", "$", "regex", "[", "]", "=", "'(.+?)'", ";", "$", "reg...
@param string $wkt @return void
[ "@param", "string", "$wkt" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L53-L77
brick/geo
src/IO/WKTParser.php
WKTParser.matchOpener
public function matchOpener() : void { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected '(' but encountered end of stream"); } if ($token[1] !== '(') { throw new GeometryIOException("Expected '(' but encountered '" . $token[1] . "'"); } }
php
public function matchOpener() : void { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected '(' but encountered end of stream"); } if ($token[1] !== '(') { throw new GeometryIOException("Expected '(' but encountered '" . $token[1] . "'"); } }
[ "public", "function", "matchOpener", "(", ")", ":", "void", "{", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ";", "if", "(", "$", "token", "===", "null", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected '(' but encountered...
@return void @throws GeometryIOException
[ "@return", "void" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L100-L110
brick/geo
src/IO/WKTParser.php
WKTParser.matchCloser
public function matchCloser() : void { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected ')' but encountered end of stream"); } if ($token[1] !== ')') { throw new GeometryIOException("Expected ')' but encountered '" . $token[1] . "'"); } }
php
public function matchCloser() : void { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected ')' but encountered end of stream"); } if ($token[1] !== ')') { throw new GeometryIOException("Expected ')' but encountered '" . $token[1] . "'"); } }
[ "public", "function", "matchCloser", "(", ")", ":", "void", "{", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ";", "if", "(", "$", "token", "===", "null", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected ')' but encountered...
@return void @throws GeometryIOException
[ "@return", "void" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L117-L127
brick/geo
src/IO/WKTParser.php
WKTParser.getNextWord
public function getNextWord() : string { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected word but encountered end of stream"); } if ($token[0] !== static::T_WORD) { throw new GeometryIOException("Expected word but encountered '" . $token[1] . "'"); } return $token[1]; }
php
public function getNextWord() : string { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected word but encountered end of stream"); } if ($token[0] !== static::T_WORD) { throw new GeometryIOException("Expected word but encountered '" . $token[1] . "'"); } return $token[1]; }
[ "public", "function", "getNextWord", "(", ")", ":", "string", "{", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ";", "if", "(", "$", "token", "===", "null", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected word but encounte...
@return string @throws GeometryIOException
[ "@return", "string" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L134-L146
brick/geo
src/IO/WKTParser.php
WKTParser.isNextOpenerOrWord
public function isNextOpenerOrWord() : bool { $token = current($this->tokens); if ($token === false) { throw new GeometryIOException("Expected '(' or word but encountered end of stream"); } if ($token[1] === '(') { return true; } if ($token[0] === static::T_WORD) { return false; } throw new GeometryIOException("Expected '(' or word but encountered '" . $token[1] . "'"); }
php
public function isNextOpenerOrWord() : bool { $token = current($this->tokens); if ($token === false) { throw new GeometryIOException("Expected '(' or word but encountered end of stream"); } if ($token[1] === '(') { return true; } if ($token[0] === static::T_WORD) { return false; } throw new GeometryIOException("Expected '(' or word but encountered '" . $token[1] . "'"); }
[ "public", "function", "isNextOpenerOrWord", "(", ")", ":", "bool", "{", "$", "token", "=", "current", "(", "$", "this", "->", "tokens", ")", ";", "if", "(", "$", "token", "===", "false", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected '...
Returns whether the next token is an opener or a word. @return bool True if the next token is an opener, false if it is a word. @throws GeometryIOException If the next token is not an opener or a word, or if there is no next token.
[ "Returns", "whether", "the", "next", "token", "is", "an", "opener", "or", "a", "word", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L174-L191
brick/geo
src/IO/WKTParser.php
WKTParser.getNextNumber
public function getNextNumber() : float { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected number but encountered end of stream"); } if ($token[0] !== static::T_NUMBER) { throw new GeometryIOException("Expected number but encountered '" . $token[1] . "'"); } return (float) $token[1]; }
php
public function getNextNumber() : float { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected number but encountered end of stream"); } if ($token[0] !== static::T_NUMBER) { throw new GeometryIOException("Expected number but encountered '" . $token[1] . "'"); } return (float) $token[1]; }
[ "public", "function", "getNextNumber", "(", ")", ":", "float", "{", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ";", "if", "(", "$", "token", "===", "null", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected number but encou...
@return float @throws GeometryIOException
[ "@return", "float" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L198-L210
brick/geo
src/IO/WKTParser.php
WKTParser.getNextCloserOrComma
public function getNextCloserOrComma() : string { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected ')' or ',' but encountered end of stream"); } if ($token[1] !== ')' && $token[1] !== ',') { throw new GeometryIOException("Expected ')' or ',' but encountered '" . $token[1] . "'"); } return $token[1]; }
php
public function getNextCloserOrComma() : string { $token = $this->nextToken(); if ($token === null) { throw new GeometryIOException("Expected ')' or ',' but encountered end of stream"); } if ($token[1] !== ')' && $token[1] !== ',') { throw new GeometryIOException("Expected ')' or ',' but encountered '" . $token[1] . "'"); } return $token[1]; }
[ "public", "function", "getNextCloserOrComma", "(", ")", ":", "string", "{", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ";", "if", "(", "$", "token", "===", "null", ")", "{", "throw", "new", "GeometryIOException", "(", "\"Expected ')' or '...
@return string @throws GeometryIOException
[ "@return", "string" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTParser.php#L217-L229
linkorb/etcd-php
src/Client.php
Client.setRoot
public function setRoot($root) { if (strpos($root, '/') !== 0) { $root = '/' . $root; } $this->root = rtrim($root, '/'); return $this; }
php
public function setRoot($root) { if (strpos($root, '/') !== 0) { $root = '/' . $root; } $this->root = rtrim($root, '/'); return $this; }
[ "public", "function", "setRoot", "(", "$", "root", ")", "{", "if", "(", "strpos", "(", "$", "root", ",", "'/'", ")", "!==", "0", ")", "{", "$", "root", "=", "'/'", ".", "$", "root", ";", "}", "$", "this", "->", "root", "=", "rtrim", "(", "$",...
Set the default root directory. the default is `/` If the root is others e.g. /linkorb when you set new key, or set dir, all of the key is under the root e.g. <code> $client->setRoot('/linkorb'); $client->set('key1, 'value1'); // the new key is /linkorb/key1 </code> @param string $root @return Client
[ "Set", "the", "default", "root", "directory", ".", "the", "default", "is", "/", "If", "the", "root", "is", "others", "e", ".", "g", ".", "/", "linkorb", "when", "you", "set", "new", "key", "or", "set", "dir", "all", "of", "the", "key", "is", "under...
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L74-L81
linkorb/etcd-php
src/Client.php
Client.buildKeyUri
private function buildKeyUri($key) { if (strpos($key, '/') !== 0) { $key = '/' . $key; } $uri = '/' . $this->apiversion . '/keys' . $this->root . $key; return $uri; }
php
private function buildKeyUri($key) { if (strpos($key, '/') !== 0) { $key = '/' . $key; } $uri = '/' . $this->apiversion . '/keys' . $this->root . $key; return $uri; }
[ "private", "function", "buildKeyUri", "(", "$", "key", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'/'", ")", "!==", "0", ")", "{", "$", "key", "=", "'/'", ".", "$", "key", ";", "}", "$", "uri", "=", "'/'", ".", "$", "this", "->", ...
Build key space operations @param string $key @return string
[ "Build", "key", "space", "operations" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L88-L95
linkorb/etcd-php
src/Client.php
Client.getVersion
public function getVersion($uri) { $response = $this->guzzleclient->get($uri); $data = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } return $data; }
php
public function getVersion($uri) { $response = $this->guzzleclient->get($uri); $data = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } return $data; }
[ "public", "function", "getVersion", "(", "$", "uri", ")", "{", "$", "response", "=", "$", "this", "->", "guzzleclient", "->", "get", "(", "$", "uri", ")", ";", "$", "data", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "...
get server version @param string $uri @return mixed
[ "get", "server", "version" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L103-L111
linkorb/etcd-php
src/Client.php
Client.set
public function set($key, $value, $ttl = null, $condition = array()) { $data = array('value' => $value); if ($ttl) { $data['ttl'] = $ttl; } try { $response = $this->guzzleclient->put($this->buildKeyUri($key), array( 'query' => $condition, 'form_params' => $data )); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } return $body; }
php
public function set($key, $value, $ttl = null, $condition = array()) { $data = array('value' => $value); if ($ttl) { $data['ttl'] = $ttl; } try { $response = $this->guzzleclient->put($this->buildKeyUri($key), array( 'query' => $condition, 'form_params' => $data )); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } return $body; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ",", "$", "condition", "=", "array", "(", ")", ")", "{", "$", "data", "=", "array", "(", "'value'", "=>", "$", "value", ")", ";", "if", "(", "$", "...
Set the value of a key @param string $key @param string $value @param int $ttl @param array $condition @return stdClass
[ "Set", "the", "value", "of", "a", "key" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L121-L142
linkorb/etcd-php
src/Client.php
Client.getNode
public function getNode($key, array $query = array()) { try { $response = $this->guzzleclient->get( $this->buildKeyUri($key), array( 'query' => $query ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body['node']; }
php
public function getNode($key, array $query = array()) { try { $response = $this->guzzleclient->get( $this->buildKeyUri($key), array( 'query' => $query ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body['node']; }
[ "public", "function", "getNode", "(", "$", "key", ",", "array", "$", "query", "=", "array", "(", ")", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "guzzleclient", "->", "get", "(", "$", "this", "->", "buildKeyUri", "(", "$", "key"...
Retrieve the value of a key @param string $key @param array $query the extra query params @return array @throws KeyNotFoundException
[ "Retrieve", "the", "value", "of", "a", "key" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L151-L171
linkorb/etcd-php
src/Client.php
Client.mk
public function mk($key, $value, $ttl = 0) { $body = $request = $this->set( $key, $value, $ttl, array('prevExist' => 'false') ); if (isset($body['errorCode'])) { throw new KeyExistsException($body['message'], $body['errorCode']); } return $body; }
php
public function mk($key, $value, $ttl = 0) { $body = $request = $this->set( $key, $value, $ttl, array('prevExist' => 'false') ); if (isset($body['errorCode'])) { throw new KeyExistsException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "mk", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "$", "body", "=", "$", "request", "=", "$", "this", "->", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", ",", "array", "(", "'...
make a new key with a given value @param string $key @param string $value @param int $ttl @return array $body @throws KeyExistsException
[ "make", "a", "new", "key", "with", "a", "given", "value" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L199-L213
linkorb/etcd-php
src/Client.php
Client.mkdir
public function mkdir($key, $ttl = 0) { $data = array('dir' => 'true'); if ($ttl) { $data['ttl'] = $ttl; } try { $response = $this->guzzleclient->put( $this->buildKeyUri($key), array( 'query' => array('prevExist' => 'false'), 'form_params' => $data ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyExistsException($body['message'], $body['errorCode']); } return $body; }
php
public function mkdir($key, $ttl = 0) { $data = array('dir' => 'true'); if ($ttl) { $data['ttl'] = $ttl; } try { $response = $this->guzzleclient->put( $this->buildKeyUri($key), array( 'query' => array('prevExist' => 'false'), 'form_params' => $data ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyExistsException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "mkdir", "(", "$", "key", ",", "$", "ttl", "=", "0", ")", "{", "$", "data", "=", "array", "(", "'dir'", "=>", "'true'", ")", ";", "if", "(", "$", "ttl", ")", "{", "$", "data", "[", "'ttl'", "]", "=", "$", "ttl", ";", "...
make a new directory @param string $key @param int $ttl @return array $body @throws KeyExistsException
[ "make", "a", "new", "directory" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L223-L250
linkorb/etcd-php
src/Client.php
Client.update
public function update($key, $value, $ttl = 0, $condition = array()) { $extra = array('prevExist' => 'true'); if ($condition) { $extra = array_merge($extra, $condition); } $body = $this->set($key, $value, $ttl, $extra); if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body; }
php
public function update($key, $value, $ttl = 0, $condition = array()) { $extra = array('prevExist' => 'true'); if ($condition) { $extra = array_merge($extra, $condition); } $body = $this->set($key, $value, $ttl, $extra); if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "update", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "0", ",", "$", "condition", "=", "array", "(", ")", ")", "{", "$", "extra", "=", "array", "(", "'prevExist'", "=>", "'true'", ")", ";", "if", "(", "$", "c...
Update an existing key with a given value. @param strint $key @param string $value @param int $ttl @param array $condition The extra condition for updating @return array $body @throws KeyNotFoundException
[ "Update", "an", "existing", "key", "with", "a", "given", "value", "." ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L262-L274
linkorb/etcd-php
src/Client.php
Client.updateDir
public function updateDir($key, $ttl) { if (!$ttl) { throw new EtcdException('TTL is required', 204); } $condition = array( 'dir' => 'true', 'prevExist' => 'true' ); $response = $this->guzzleclient->put( $this->buildKeyUri($key), array( 'query' => $condition, 'form_params' => array( 'ttl' => (int)$ttl ) ) ); $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
php
public function updateDir($key, $ttl) { if (!$ttl) { throw new EtcdException('TTL is required', 204); } $condition = array( 'dir' => 'true', 'prevExist' => 'true' ); $response = $this->guzzleclient->put( $this->buildKeyUri($key), array( 'query' => $condition, 'form_params' => array( 'ttl' => (int)$ttl ) ) ); $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "updateDir", "(", "$", "key", ",", "$", "ttl", ")", "{", "if", "(", "!", "$", "ttl", ")", "{", "throw", "new", "EtcdException", "(", "'TTL is required'", ",", "204", ")", ";", "}", "$", "condition", "=", "array", "(", "'dir'", ...
Update directory @param string $key @param int $ttl @return array $body @throws EtcdException
[ "Update", "directory" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L283-L312
linkorb/etcd-php
src/Client.php
Client.rm
public function rm($key) { try { $response = $this->guzzleclient->delete($this->buildKeyUri($key)); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
php
public function rm($key) { try { $response = $this->guzzleclient->delete($this->buildKeyUri($key)); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "rm", "(", "$", "key", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "guzzleclient", "->", "delete", "(", "$", "this", "->", "buildKeyUri", "(", "$", "key", ")", ")", ";", "}", "catch", "(", "BadResponseExceptio...
remove a key @param string $key @return array|stdClass @throws EtcdException
[ "remove", "a", "key" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L321-L338
linkorb/etcd-php
src/Client.php
Client.rmdir
public function rmdir($key, $recursive = false) { $query = array('dir' => 'true'); if ($recursive === true) { $query['recursive'] = 'true'; } try { $response = $this->guzzleclient->delete( $this->buildKeyUri($key), array( 'query' => $query ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
php
public function rmdir($key, $recursive = false) { $query = array('dir' => 'true'); if ($recursive === true) { $query['recursive'] = 'true'; } try { $response = $this->guzzleclient->delete( $this->buildKeyUri($key), array( 'query' => $query ) ); } catch (BadResponseException $e) { $response = $e->getResponse(); } $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new EtcdException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "rmdir", "(", "$", "key", ",", "$", "recursive", "=", "false", ")", "{", "$", "query", "=", "array", "(", "'dir'", "=>", "'true'", ")", ";", "if", "(", "$", "recursive", "===", "true", ")", "{", "$", "query", "[", "'recursive'...
Removes the key if it is directory @param string $key @param boolean $recursive @return mixed @throws EtcdException
[ "Removes", "the", "key", "if", "it", "is", "directory" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L347-L374
linkorb/etcd-php
src/Client.php
Client.listDir
public function listDir($key = '/', $recursive = false) { $query = array(); if ($recursive === true) { $query['recursive'] = 'true'; } $response = $this->guzzleclient->get( $this->buildKeyUri($key), array( 'query' => $query ) ); $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body; }
php
public function listDir($key = '/', $recursive = false) { $query = array(); if ($recursive === true) { $query['recursive'] = 'true'; } $response = $this->guzzleclient->get( $this->buildKeyUri($key), array( 'query' => $query ) ); $body = json_decode($response->getBody(), true); if (JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error()); } if (isset($body['errorCode'])) { throw new KeyNotFoundException($body['message'], $body['errorCode']); } return $body; }
[ "public", "function", "listDir", "(", "$", "key", "=", "'/'", ",", "$", "recursive", "=", "false", ")", "{", "$", "query", "=", "array", "(", ")", ";", "if", "(", "$", "recursive", "===", "true", ")", "{", "$", "query", "[", "'recursive'", "]", "...
Retrieve a directory @param string $key @param boolean $recursive @return mixed @throws KeyNotFoundException
[ "Retrieve", "a", "directory" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L383-L405
linkorb/etcd-php
src/Client.php
Client.ls
public function ls($key = '/', $recursive = false) { $this->values = array(); $this->dirs = array(); try { $data = $this->listDir($key, $recursive); } catch (EtcdException $e) { throw $e; } $iterator = new RecursiveArrayIterator($data); return $this->traversalDir($iterator); }
php
public function ls($key = '/', $recursive = false) { $this->values = array(); $this->dirs = array(); try { $data = $this->listDir($key, $recursive); } catch (EtcdException $e) { throw $e; } $iterator = new RecursiveArrayIterator($data); return $this->traversalDir($iterator); }
[ "public", "function", "ls", "(", "$", "key", "=", "'/'", ",", "$", "recursive", "=", "false", ")", "{", "$", "this", "->", "values", "=", "array", "(", ")", ";", "$", "this", "->", "dirs", "=", "array", "(", ")", ";", "try", "{", "$", "data", ...
Retrieve a directories key @param string $key @param boolean $recursive @return array @throws EtcdException
[ "Retrieve", "a", "directories", "key" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L414-L427
linkorb/etcd-php
src/Client.php
Client.traversalDir
private function traversalDir(RecursiveArrayIterator $iterator) { $key = ''; while ($iterator->valid()) { if ($iterator->hasChildren()) { $this->traversalDir($iterator->getChildren()); } else { if ($iterator->key() == 'key' && ($iterator->current() != '/')) { $this->dirs[] = $key = $iterator->current(); } if ($iterator->key() == 'value') { $this->values[$key] = $iterator->current(); } } $iterator->next(); } return $this->dirs; }
php
private function traversalDir(RecursiveArrayIterator $iterator) { $key = ''; while ($iterator->valid()) { if ($iterator->hasChildren()) { $this->traversalDir($iterator->getChildren()); } else { if ($iterator->key() == 'key' && ($iterator->current() != '/')) { $this->dirs[] = $key = $iterator->current(); } if ($iterator->key() == 'value') { $this->values[$key] = $iterator->current(); } } $iterator->next(); } return $this->dirs; }
[ "private", "function", "traversalDir", "(", "RecursiveArrayIterator", "$", "iterator", ")", "{", "$", "key", "=", "''", ";", "while", "(", "$", "iterator", "->", "valid", "(", ")", ")", "{", "if", "(", "$", "iterator", "->", "hasChildren", "(", ")", ")...
Traversal the directory to get the keys. @param RecursiveArrayIterator $iterator @return array
[ "Traversal", "the", "directory", "to", "get", "the", "keys", "." ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L439-L457
linkorb/etcd-php
src/Client.php
Client.getKeysValue
public function getKeysValue($root = '/', $recursive = true, $key = null) { $this->ls($root, $recursive); if (isset($this->values[$key])) { return $this->values[$key]; } return $this->values; }
php
public function getKeysValue($root = '/', $recursive = true, $key = null) { $this->ls($root, $recursive); if (isset($this->values[$key])) { return $this->values[$key]; } return $this->values; }
[ "public", "function", "getKeysValue", "(", "$", "root", "=", "'/'", ",", "$", "recursive", "=", "true", ",", "$", "key", "=", "null", ")", "{", "$", "this", "->", "ls", "(", "$", "root", ",", "$", "recursive", ")", ";", "if", "(", "isset", "(", ...
Get all key-value pair that the key is not directory. @param string $key @param boolean $recursive @param string $key @return array
[ "Get", "all", "key", "-", "value", "pair", "that", "the", "key", "is", "not", "directory", "." ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L466-L473
linkorb/etcd-php
src/Client.php
Client.mkdirWithInOrderKey
public function mkdirWithInOrderKey($dir, $ttl = 0) { $data = array( 'dir' => 'true' ); if ($ttl) { $data['ttl'] = $ttl; } $request = $this->guzzleclient->post( $this->buildKeyUri($dir), null, $data ); $response = $request->send(); $body = $response->json(); return $body; }
php
public function mkdirWithInOrderKey($dir, $ttl = 0) { $data = array( 'dir' => 'true' ); if ($ttl) { $data['ttl'] = $ttl; } $request = $this->guzzleclient->post( $this->buildKeyUri($dir), null, $data ); $response = $request->send(); $body = $response->json(); return $body; }
[ "public", "function", "mkdirWithInOrderKey", "(", "$", "dir", ",", "$", "ttl", "=", "0", ")", "{", "$", "data", "=", "array", "(", "'dir'", "=>", "'true'", ")", ";", "if", "(", "$", "ttl", ")", "{", "$", "data", "[", "'ttl'", "]", "=", "$", "tt...
create a new directory with auto generated id @param string $dir @param int $ttl @return array $body
[ "create", "a", "new", "directory", "with", "auto", "generated", "id" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L482-L501
linkorb/etcd-php
src/Client.php
Client.setWithInOrderKey
public function setWithInOrderKey($dir, $value, $ttl = 0, $condition = array()) { $data = array('value' => $value); if ($ttl) { $data['ttl'] = $ttl; } $request = $this->guzzleclient->post($this->buildKeyUri($dir), null, $data, array( 'query' => $condition )); $response = $request->send(); $body = $response->json(); return $body; }
php
public function setWithInOrderKey($dir, $value, $ttl = 0, $condition = array()) { $data = array('value' => $value); if ($ttl) { $data['ttl'] = $ttl; } $request = $this->guzzleclient->post($this->buildKeyUri($dir), null, $data, array( 'query' => $condition )); $response = $request->send(); $body = $response->json(); return $body; }
[ "public", "function", "setWithInOrderKey", "(", "$", "dir", ",", "$", "value", ",", "$", "ttl", "=", "0", ",", "$", "condition", "=", "array", "(", ")", ")", "{", "$", "data", "=", "array", "(", "'value'", "=>", "$", "value", ")", ";", "if", "(",...
create a new key in a directory with auto generated id @param string $dir @param string $value @param int $ttl @param array $condition @return array $body
[ "create", "a", "new", "key", "in", "a", "directory", "with", "auto", "generated", "id" ]
train
https://github.com/linkorb/etcd-php/blob/bb17b4f84b44cd18ef36e93f8d13c05714430fc2/src/Client.php#L512-L526
FaCuZ/laravel-theme
src/Commands/WidgetGeneratorCommand.php
WidgetGeneratorCommand.handle
public function handle() { // Widget class name is camel case. $widgetClassName = ucfirst($this->getWidgetName()); // Widget class file is camel with php extension. $widgetClassFile = $widgetClassName.'.php'; // CamelCase for template. $widgetClassTpl = lcfirst($this->getWidgetName()); // Get class template. $widgetClassTemplate = $this->getTemplate('widgetClass'); // Default create not on a global. $watch = 'false'; // If not specific a theme, not a global also return an error. if ($this->option('global') === false and ! $this->argument('theme')){ return $this->error('Please specific a theme name or use option -g to create as a global widget.'); } $theme_path = base_path($this->config->get('theme.themeDir').'/'.$this->getTheme()); if (is_dir($theme_path) === false){ return $this->error('The theme "'.$this->getTheme().'" does not exist.'); } // Create as a global use -g. if ($this->option('global') === true){ $watch = 'true'; } $widgetNamespace = $this->config->get('theme.namespaces.widget'); // Prepare class template. $widgetClassTemplate = preg_replace( array('|\{widgetNamespace\}|', '|\{widgetClass\}|', '|\{widgetTemplate\}|', '|\{watch\}|'), array($widgetNamespace, $widgetClassName, $widgetClassTpl, $watch), $widgetClassTemplate ); // Create widget directory. if (!$this->files->isDirectory(app_path().'/Widgets')){ $this->files->makeDirectory(app_path().'/Widgets', 0777, true); } // Widget class already exists. if ($this->files->exists(app_path().'/Widgets/'.$widgetClassFile)){ return $this->error('Widget "'.$this->getWidgetName().'" is already exists.'); } // Create class file. $this->files->put(app_path().'/Widgets/'.$widgetClassFile, $widgetClassTemplate); // Make file example. $this->makeFile('widgets/'.$widgetClassTpl.'.blade.php', $this->getTemplate('widget.blade')); $this->info('Widget "'.$this->getWidgetName().'" has been created.'); }
php
public function handle() { // Widget class name is camel case. $widgetClassName = ucfirst($this->getWidgetName()); // Widget class file is camel with php extension. $widgetClassFile = $widgetClassName.'.php'; // CamelCase for template. $widgetClassTpl = lcfirst($this->getWidgetName()); // Get class template. $widgetClassTemplate = $this->getTemplate('widgetClass'); // Default create not on a global. $watch = 'false'; // If not specific a theme, not a global also return an error. if ($this->option('global') === false and ! $this->argument('theme')){ return $this->error('Please specific a theme name or use option -g to create as a global widget.'); } $theme_path = base_path($this->config->get('theme.themeDir').'/'.$this->getTheme()); if (is_dir($theme_path) === false){ return $this->error('The theme "'.$this->getTheme().'" does not exist.'); } // Create as a global use -g. if ($this->option('global') === true){ $watch = 'true'; } $widgetNamespace = $this->config->get('theme.namespaces.widget'); // Prepare class template. $widgetClassTemplate = preg_replace( array('|\{widgetNamespace\}|', '|\{widgetClass\}|', '|\{widgetTemplate\}|', '|\{watch\}|'), array($widgetNamespace, $widgetClassName, $widgetClassTpl, $watch), $widgetClassTemplate ); // Create widget directory. if (!$this->files->isDirectory(app_path().'/Widgets')){ $this->files->makeDirectory(app_path().'/Widgets', 0777, true); } // Widget class already exists. if ($this->files->exists(app_path().'/Widgets/'.$widgetClassFile)){ return $this->error('Widget "'.$this->getWidgetName().'" is already exists.'); } // Create class file. $this->files->put(app_path().'/Widgets/'.$widgetClassFile, $widgetClassTemplate); // Make file example. $this->makeFile('widgets/'.$widgetClassTpl.'.blade.php', $this->getTemplate('widget.blade')); $this->info('Widget "'.$this->getWidgetName().'" has been created.'); }
[ "public", "function", "handle", "(", ")", "{", "// Widget class name is camel case.", "$", "widgetClassName", "=", "ucfirst", "(", "$", "this", "->", "getWidgetName", "(", ")", ")", ";", "// Widget class file is camel with php extension.", "$", "widgetClassFile", "=", ...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/WidgetGeneratorCommand.php#L67-L126
FaCuZ/laravel-theme
src/Manifest.php
Manifest.getJsonContents
public function getJsonContents() { $default = []; $path = $this->getJsonPath(); if ($this->files->exists($path)) { $contents = $this->files->get($path); return json_decode($contents, true); } else { throw new UnknownFileException("The theme must have a valid theme.json manifest file."); } }
php
public function getJsonContents() { $default = []; $path = $this->getJsonPath(); if ($this->files->exists($path)) { $contents = $this->files->get($path); return json_decode($contents, true); } else { throw new UnknownFileException("The theme must have a valid theme.json manifest file."); } }
[ "public", "function", "getJsonContents", "(", ")", "{", "$", "default", "=", "[", "]", ";", "$", "path", "=", "$", "this", "->", "getJsonPath", "(", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "path", ")", ")", "{",...
Get theme JSON content as an array. @return array|mixed
[ "Get", "theme", "JSON", "content", "as", "an", "array", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Manifest.php#L58-L71
FaCuZ/laravel-theme
src/Manifest.php
Manifest.setJsonContents
protected function setJsonContents(array $content) { $content = json_encode($content, JSON_PRETTY_PRINT); return $this->files->put($this->getJsonPath(), $content); }
php
protected function setJsonContents(array $content) { $content = json_encode($content, JSON_PRETTY_PRINT); return $this->files->put($this->getJsonPath(), $content); }
[ "protected", "function", "setJsonContents", "(", "array", "$", "content", ")", "{", "$", "content", "=", "json_encode", "(", "$", "content", ",", "JSON_PRETTY_PRINT", ")", ";", "return", "$", "this", "->", "files", "->", "put", "(", "$", "this", "->", "g...
Set theme manifest JSON content property value. @param array $content @return integer
[ "Set", "theme", "manifest", "JSON", "content", "property", "value", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Manifest.php#L79-L85
FaCuZ/laravel-theme
src/Manifest.php
Manifest.setProperty
public function setProperty($key, $value) { $content = $this->getJsonContents(); if (count($content)) { if (isset($content[$key])) { unset($content[$key]); } $content[$key] = $value; $this->setJsonContents($content); return true; } return false; }
php
public function setProperty($key, $value) { $content = $this->getJsonContents(); if (count($content)) { if (isset($content[$key])) { unset($content[$key]); } $content[$key] = $value; $this->setJsonContents($content); return true; } return false; }
[ "public", "function", "setProperty", "(", "$", "key", ",", "$", "value", ")", "{", "$", "content", "=", "$", "this", "->", "getJsonContents", "(", ")", ";", "if", "(", "count", "(", "$", "content", ")", ")", "{", "if", "(", "isset", "(", "$", "co...
Set a theme manifest key value. @param string $key @param mixed $value @return bool
[ "Set", "a", "theme", "manifest", "key", "value", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Manifest.php#L106-L124
FaCuZ/laravel-theme
src/Commands/ThemeGeneratorCommand.php
ThemeGeneratorCommand.handle
public function handle() { if ($this->files->isDirectory($this->getPath(null))){ return $this->error('Theme "'.$this->getTheme().'" is already exists.'); } $this->makeDirs([ 'assets/css', 'assets/js', 'assets/img', 'layouts', 'partials/sections', 'views', 'widgets', ]); $this->makeFiles([ 'layout.blade.php' => 'layouts/', 'header.blade.php' => 'partials/', 'footer.blade.php' => 'partials/', 'main.blade.php' => 'partials/sections/', 'index.blade.php' => 'views/', 'style.css' => 'assets/css/', 'script.js' => 'assets/js/', 'theme.json' => '', 'gulpfile.js' => '', 'config.php' => '' ]); $this->info('Theme "'.$this->getTheme().'" has been created.'); }
php
public function handle() { if ($this->files->isDirectory($this->getPath(null))){ return $this->error('Theme "'.$this->getTheme().'" is already exists.'); } $this->makeDirs([ 'assets/css', 'assets/js', 'assets/img', 'layouts', 'partials/sections', 'views', 'widgets', ]); $this->makeFiles([ 'layout.blade.php' => 'layouts/', 'header.blade.php' => 'partials/', 'footer.blade.php' => 'partials/', 'main.blade.php' => 'partials/sections/', 'index.blade.php' => 'views/', 'style.css' => 'assets/css/', 'script.js' => 'assets/js/', 'theme.json' => '', 'gulpfile.js' => '', 'config.php' => '' ]); $this->info('Theme "'.$this->getTheme().'" has been created.'); }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "this", "->", "getPath", "(", "null", ")", ")", ")", "{", "return", "$", "this", "->", "error", "(", "'Theme \"'", ".", "$", "this"...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeGeneratorCommand.php#L60-L90
FaCuZ/laravel-theme
src/Commands/ThemeGeneratorCommand.php
ThemeGeneratorCommand.makeDirs
protected function makeDirs($directory) { foreach ($directory as $path) { if (!$this->files->isDirectory($this->getPath($path))){ $this->files->makeDirectory($this->getPath($path), 0777, true); } } }
php
protected function makeDirs($directory) { foreach ($directory as $path) { if (!$this->files->isDirectory($this->getPath($path))){ $this->files->makeDirectory($this->getPath($path), 0777, true); } } }
[ "protected", "function", "makeDirs", "(", "$", "directory", ")", "{", "foreach", "(", "$", "directory", "as", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "this", "->", "getPath", "(", "$", "path",...
Make directory. @param array $directory @return void
[ "Make", "directory", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeGeneratorCommand.php#L98-L105
FaCuZ/laravel-theme
src/Commands/ThemeGeneratorCommand.php
ThemeGeneratorCommand.makeFiles
protected function makeFiles($files) { foreach ($files as $file => $to) { $template = $this->getTemplate($file); $path = $to.$file; if (!$this->files->exists($this->getPath($path))){ $file_path = $this->getPath($path); $facade = $this->option('facade'); if (!is_null($facade)){ $template = preg_replace('/Theme(\.|::)/', $facade.'$1', $template); } $this->files->put($file_path, $template); if(substr($file_path, -10) == 'theme.json'){ $this->files->chmod($file_path, 0666); } } } }
php
protected function makeFiles($files) { foreach ($files as $file => $to) { $template = $this->getTemplate($file); $path = $to.$file; if (!$this->files->exists($this->getPath($path))){ $file_path = $this->getPath($path); $facade = $this->option('facade'); if (!is_null($facade)){ $template = preg_replace('/Theme(\.|::)/', $facade.'$1', $template); } $this->files->put($file_path, $template); if(substr($file_path, -10) == 'theme.json'){ $this->files->chmod($file_path, 0666); } } } }
[ "protected", "function", "makeFiles", "(", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", "=>", "$", "to", ")", "{", "$", "template", "=", "$", "this", "->", "getTemplate", "(", "$", "file", ")", ";", "$", "path", "=", "...
Make file. @param string $file @param string $to @return void
[ "Make", "file", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeGeneratorCommand.php#L114-L138
FaCuZ/laravel-theme
src/Commands/ThemeGeneratorCommand.php
ThemeGeneratorCommand.getOptions
protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path), array('facade', null, InputOption::VALUE_OPTIONAL, 'Facade name.', null), ); }
php
protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path), array('facade', null, InputOption::VALUE_OPTIONAL, 'Facade name.', null), ); }
[ "protected", "function", "getOptions", "(", ")", "{", "$", "path", "=", "base_path", "(", "$", "this", "->", "config", "->", "get", "(", "'theme.themeDir'", ")", ")", ";", "return", "array", "(", "array", "(", "'path'", ",", "null", ",", "InputOption", ...
Get the console command options. @return array
[ "Get", "the", "console", "command", "options", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeGeneratorCommand.php#L193-L201
FaCuZ/laravel-theme
src/Theme.php
Theme.view
public function view($view, $args = []){ if(is_array($view)) { if(isset($view['theme'])) $this->theme($view['theme']); if(isset($view['layout'])) $this->layout($view['layout']); if(isset($view['cookie'])) $this->withCookie($view['cookie']); $statusCode = (isset($view['statusCode'])) ? $view['statusCode'] : 200; if(empty($args)) if(isset($view['args'])) $args = $view['args']; $view = $view['view']; } $this->uses($this->theme)->layout($this->layout); return $this->watch($view, $args)->render(); }
php
public function view($view, $args = []){ if(is_array($view)) { if(isset($view['theme'])) $this->theme($view['theme']); if(isset($view['layout'])) $this->layout($view['layout']); if(isset($view['cookie'])) $this->withCookie($view['cookie']); $statusCode = (isset($view['statusCode'])) ? $view['statusCode'] : 200; if(empty($args)) if(isset($view['args'])) $args = $view['args']; $view = $view['view']; } $this->uses($this->theme)->layout($this->layout); return $this->watch($view, $args)->render(); }
[ "public", "function", "view", "(", "$", "view", ",", "$", "args", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "view", ")", ")", "{", "if", "(", "isset", "(", "$", "view", "[", "'theme'", "]", ")", ")", "$", "this", "->", "theme"...
Get a view @return View
[ "Get", "a", "view" ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L221-L238
FaCuZ/laravel-theme
src/Theme.php
Theme.info
public function info($property = null, $value = null) { $info = $this->manifest; $info->setThemePath($this->getThemePath()); if($value && $property){ $info->setProperty($property, $value); return $value; } else { if($property){ return $info->getProperty($property); } return $info->getJsonContents(); } }
php
public function info($property = null, $value = null) { $info = $this->manifest; $info->setThemePath($this->getThemePath()); if($value && $property){ $info->setProperty($property, $value); return $value; } else { if($property){ return $info->getProperty($property); } return $info->getJsonContents(); } }
[ "public", "function", "info", "(", "$", "property", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "info", "=", "$", "this", "->", "manifest", ";", "$", "info", "->", "setThemePath", "(", "$", "this", "->", "getThemePath", "(", ")", ")...
Get or set data on manifest. @return Collection
[ "Get", "or", "set", "data", "on", "manifest", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L246-L260
FaCuZ/laravel-theme
src/Theme.php
Theme.all
public function all() { $themes = []; if ($this->files->exists($path)) { $scannedThemes = $this->files->directories($path); foreach ($scannedThemes as $theme) { $themes[] = basename($theme); } } return new Collection($themes); }
php
public function all() { $themes = []; if ($this->files->exists($path)) { $scannedThemes = $this->files->directories($path); foreach ($scannedThemes as $theme) { $themes[] = basename($theme); } } return new Collection($themes); }
[ "public", "function", "all", "(", ")", "{", "$", "themes", "=", "[", "]", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "path", ")", ")", "{", "$", "scannedThemes", "=", "$", "this", "->", "files", "->", "directories", "("...
Get all themes. @return Collection
[ "Get", "all", "themes", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L267-L278
FaCuZ/laravel-theme
src/Theme.php
Theme.partial
public function partial($view, $args = array()) { $partialDir = $this->getThemeNamespace('partials'); return $this->loadPartial($view, $partialDir, $args); }
php
public function partial($view, $args = array()) { $partialDir = $this->getThemeNamespace('partials'); return $this->loadPartial($view, $partialDir, $args); }
[ "public", "function", "partial", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "partialDir", "=", "$", "this", "->", "getThemeNamespace", "(", "'partials'", ")", ";", "return", "$", "this", "->", "loadPartial", "(", "$", ...
Set up a partial. @param string $view @param array $args @throws UnknownPartialFileException @return mixed
[ "Set", "up", "a", "partial", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L718-L723
FaCuZ/laravel-theme
src/Theme.php
Theme.watchPartial
public function watchPartial($view, $args = array()) { try { return $this->partial($view, $args); } catch (UnknownPartialFileException $e) { return $this->loadPartial($view, 'partials', $args); } }
php
public function watchPartial($view, $args = array()) { try { return $this->partial($view, $args); } catch (UnknownPartialFileException $e) { return $this->loadPartial($view, 'partials', $args); } }
[ "public", "function", "watchPartial", "(", "$", "view", ",", "$", "args", "=", "array", "(", ")", ")", "{", "try", "{", "return", "$", "this", "->", "partial", "(", "$", "view", ",", "$", "args", ")", ";", "}", "catch", "(", "UnknownPartialFileExcept...
Watch and set up a partial from anywhere. This method will first try to load the partial from current theme. If partial is not found in theme then it loads it from app (i.e. app/views/partials) @param string $view @param array $args @throws UnknownPartialFileException @return mixed
[ "Watch", "and", "set", "up", "a", "partial", "from", "anywhere", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L774-L781
FaCuZ/laravel-theme
src/Theme.php
Theme.partialComposer
public function partialComposer($view, $callback, $layout = null) { if (! is_array($view)) { $view = array($view); } // Partial path with namespace. $path = $this->getThemeNamespace('partials'); // This code support partialWithLayout. if (! is_null($layout)) { $path = $path.'.'.$layout; } $view = array_map(function($v) use ($path) { return $path.'.'.$v; }, $view); $this->view->composer($view, $callback); }
php
public function partialComposer($view, $callback, $layout = null) { if (! is_array($view)) { $view = array($view); } // Partial path with namespace. $path = $this->getThemeNamespace('partials'); // This code support partialWithLayout. if (! is_null($layout)) { $path = $path.'.'.$layout; } $view = array_map(function($v) use ($path) { return $path.'.'.$v; }, $view); $this->view->composer($view, $callback); }
[ "public", "function", "partialComposer", "(", "$", "view", ",", "$", "callback", ",", "$", "layout", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "view", ")", ")", "{", "$", "view", "=", "array", "(", "$", "view", ")", ";", "}", ...
Hook a partial before rendering. @param mixed $view @param closure $callback @return void
[ "Hook", "a", "partial", "before", "rendering", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L829-L848
FaCuZ/laravel-theme
src/Theme.php
Theme.location
public function location($realpath = false) { try { if ($this->view->exists($this->content)) { return ($realpath) ? $this->view->getFinder()->find($this->content) : $this->content; } } catch (\InvalidArgumentException $e) { return null; } }
php
public function location($realpath = false) { try { if ($this->view->exists($this->content)) { return ($realpath) ? $this->view->getFinder()->find($this->content) : $this->content; } } catch (\InvalidArgumentException $e) { return null; } }
[ "public", "function", "location", "(", "$", "realpath", "=", "false", ")", "{", "try", "{", "if", "(", "$", "this", "->", "view", "->", "exists", "(", "$", "this", "->", "content", ")", ")", "{", "return", "(", "$", "realpath", ")", "?", "$", "th...
Find view location. @param boolean $realpath @return string
[ "Find", "view", "location", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Theme.php#L1162-L1171
FaCuZ/laravel-theme
src/ThemeServiceProvider.php
ThemeServiceProvider.boot
public function boot(Router $router) { $configPath = __DIR__.'/../config/theme.php'; // Publish config. $this->publishes([$configPath => config_path('theme.php')], 'config'); $router->aliasMiddleware('theme', Middleware\ThemeLoader::class); // Register blade directives: $this->addToBlade(['dd', 'dd(%s);']); $this->addToBlade(['dv', 'dd(get_defined_vars()[%s]);', 'dd(get_defined_vars()["__data"]);']); $this->addToBlade(['d', 'dump(%s);']); $this->addToBlade(['get', 'Theme::get(%s);']); $this->addToBlade(['getIfHas', 'Theme::has(%1$s) ? Theme::get(%1$s) : ""']); $this->addToBlade(['partial', 'Theme::partial(%s);']); $this->addToBlade(['sections', 'Theme::partial("sections.".%s);']); $this->addToBlade(['content', null, 'Theme::content();']); $this->addToBlade(['asset', 'Theme::asset()->absUrl(%s);']); $this->addToBlade(['protect', 'protectEmail(%s);']); $this->addToBlade(['styles', 'Theme::asset()->container(%s)->styles();', 'Theme::asset()->styles();']); $this->addToBlade(['scripts', 'Theme::asset()->container(%s)->scripts();', 'Theme::asset()->scripts();']); $this->addToBlade(['widget', 'Theme::widget(%s)->render();']); }
php
public function boot(Router $router) { $configPath = __DIR__.'/../config/theme.php'; // Publish config. $this->publishes([$configPath => config_path('theme.php')], 'config'); $router->aliasMiddleware('theme', Middleware\ThemeLoader::class); // Register blade directives: $this->addToBlade(['dd', 'dd(%s);']); $this->addToBlade(['dv', 'dd(get_defined_vars()[%s]);', 'dd(get_defined_vars()["__data"]);']); $this->addToBlade(['d', 'dump(%s);']); $this->addToBlade(['get', 'Theme::get(%s);']); $this->addToBlade(['getIfHas', 'Theme::has(%1$s) ? Theme::get(%1$s) : ""']); $this->addToBlade(['partial', 'Theme::partial(%s);']); $this->addToBlade(['sections', 'Theme::partial("sections.".%s);']); $this->addToBlade(['content', null, 'Theme::content();']); $this->addToBlade(['asset', 'Theme::asset()->absUrl(%s);']); $this->addToBlade(['protect', 'protectEmail(%s);']); $this->addToBlade(['styles', 'Theme::asset()->container(%s)->styles();', 'Theme::asset()->styles();']); $this->addToBlade(['scripts', 'Theme::asset()->container(%s)->scripts();', 'Theme::asset()->scripts();']); $this->addToBlade(['widget', 'Theme::widget(%s)->render();']); }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "$", "configPath", "=", "__DIR__", ".", "'/../config/theme.php'", ";", "// Publish config.\r", "$", "this", "->", "publishes", "(", "[", "$", "configPath", "=>", "config_path", "(", "'theme....
Bootstrap the application events. @param \Illuminate\Routing\Router $router @return void
[ "Bootstrap", "the", "application", "events", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/ThemeServiceProvider.php#L22-L52
FaCuZ/laravel-theme
src/ThemeServiceProvider.php
ThemeServiceProvider.register
public function register() { $configPath = __DIR__.'/../config/theme.php'; // Merge config to allow user overwrite. $this->mergeConfigFrom($configPath, 'theme'); $app = $this->app; // Register providers: $this->registerAsset(); $this->registerTheme(); $this->registerWidget(); $this->registerBreadcrumb(); $this->registerManifest(); // Register commands: $this->registerThemeGenerator(); $this->registerWidgetGenerator(); $this->registerThemeList(); $this->registerThemeDuplicate(); $this->registerThemeDestroy(); // Assign commands: $this->commands( 'theme.create', 'theme.widget', 'theme.list', 'theme.duplicate', 'theme.destroy' ); }
php
public function register() { $configPath = __DIR__.'/../config/theme.php'; // Merge config to allow user overwrite. $this->mergeConfigFrom($configPath, 'theme'); $app = $this->app; // Register providers: $this->registerAsset(); $this->registerTheme(); $this->registerWidget(); $this->registerBreadcrumb(); $this->registerManifest(); // Register commands: $this->registerThemeGenerator(); $this->registerWidgetGenerator(); $this->registerThemeList(); $this->registerThemeDuplicate(); $this->registerThemeDestroy(); // Assign commands: $this->commands( 'theme.create', 'theme.widget', 'theme.list', 'theme.duplicate', 'theme.destroy' ); }
[ "public", "function", "register", "(", ")", "{", "$", "configPath", "=", "__DIR__", ".", "'/../config/theme.php'", ";", "// Merge config to allow user overwrite.\r", "$", "this", "->", "mergeConfigFrom", "(", "$", "configPath", ",", "'theme'", ")", ";", "$", "app"...
Register service provider. @return void
[ "Register", "service", "provider", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/ThemeServiceProvider.php#L59-L91
FaCuZ/laravel-theme
src/ThemeServiceProvider.php
ThemeServiceProvider.registerTheme
public function registerTheme() { $this->app->singleton('theme', function($app) { return new Theme($app['config'], $app['events'], $app['view'], $app['asset'], $app['files'], $app['breadcrumb'], $app['manifest']); }); $this->app->alias('theme', 'Facuz\Theme\Contracts\Theme'); }
php
public function registerTheme() { $this->app->singleton('theme', function($app) { return new Theme($app['config'], $app['events'], $app['view'], $app['asset'], $app['files'], $app['breadcrumb'], $app['manifest']); }); $this->app->alias('theme', 'Facuz\Theme\Contracts\Theme'); }
[ "public", "function", "registerTheme", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'theme'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Theme", "(", "$", "app", "[", "'config'", "]", ",", "$", "app", "[", "'...
Register theme provider. @return void
[ "Register", "theme", "provider", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/ThemeServiceProvider.php#L127-L135
FaCuZ/laravel-theme
src/Commands/ThemeDuplicateCommand.php
ThemeDuplicateCommand.handle
public function handle() { $theme = strtolower($this->argument('name')); $new_theme = strtolower($this->argument('new-name')); $theme_path = $this->getPath($theme); $new_theme_path = $this->getPath($new_theme); if(!$this->files->isDirectory($theme_path)){ return $this->error('Theme "'.$theme.'" does not exist.'); } if($this->files->isDirectory($new_theme_path)){ return $this->error('Theme "'.$new_theme.'" is already exists.'); } $this->files->copyDirectory($theme_path, $new_theme_path); $this->info('Theme "'.$new_theme.'" has been created.'); }
php
public function handle() { $theme = strtolower($this->argument('name')); $new_theme = strtolower($this->argument('new-name')); $theme_path = $this->getPath($theme); $new_theme_path = $this->getPath($new_theme); if(!$this->files->isDirectory($theme_path)){ return $this->error('Theme "'.$theme.'" does not exist.'); } if($this->files->isDirectory($new_theme_path)){ return $this->error('Theme "'.$new_theme.'" is already exists.'); } $this->files->copyDirectory($theme_path, $new_theme_path); $this->info('Theme "'.$new_theme.'" has been created.'); }
[ "public", "function", "handle", "(", ")", "{", "$", "theme", "=", "strtolower", "(", "$", "this", "->", "argument", "(", "'name'", ")", ")", ";", "$", "new_theme", "=", "strtolower", "(", "$", "this", "->", "argument", "(", "'new-name'", ")", ")", ";...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeDuplicateCommand.php#L60-L79
FaCuZ/laravel-theme
src/Commands/ThemeDuplicateCommand.php
ThemeDuplicateCommand.getPath
protected function getPath($theme, $file = null) { $rootPath = $this->option('path'); return $rootPath.'/'.$theme.'/' . $file; }
php
protected function getPath($theme, $file = null) { $rootPath = $this->option('path'); return $rootPath.'/'.$theme.'/' . $file; }
[ "protected", "function", "getPath", "(", "$", "theme", ",", "$", "file", "=", "null", ")", "{", "$", "rootPath", "=", "$", "this", "->", "option", "(", "'path'", ")", ";", "return", "$", "rootPath", ".", "'/'", ".", "$", "theme", ".", "'/'", ".", ...
Get root writable path. @param string $path @return string
[ "Get", "root", "writable", "path", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeDuplicateCommand.php#L88-L93
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.url
public function url($uri, $secure = null) { // If path is full, so we just return. if (preg_match('#^http|//:#', $uri)) { return $uri; } $path = $this->getCurrentPath().$uri; if(substr($path, 0, 6)=='public') $path = substr($path, 7); return $this->configAssetUrl($path, $secure); }
php
public function url($uri, $secure = null) { // If path is full, so we just return. if (preg_match('#^http|//:#', $uri)) { return $uri; } $path = $this->getCurrentPath().$uri; if(substr($path, 0, 6)=='public') $path = substr($path, 7); return $this->configAssetUrl($path, $secure); }
[ "public", "function", "url", "(", "$", "uri", ",", "$", "secure", "=", "null", ")", "{", "// If path is full, so we just return.", "if", "(", "preg_match", "(", "'#^http|//:#'", ",", "$", "uri", ")", ")", "{", "return", "$", "uri", ";", "}", "$", "path",...
Return asset path with current theme path. @param string $uri @param boolean $secure @return string
[ "Return", "asset", "path", "with", "current", "theme", "path", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L124-L137
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.absUrl
public function absUrl($uri, $secure = null) { $source = $this->url($uri, $secure); if(substr($source, 0, 7)=='/public') $source = substr($source, 7); return url($source); }
php
public function absUrl($uri, $secure = null) { $source = $this->url($uri, $secure); if(substr($source, 0, 7)=='/public') $source = substr($source, 7); return url($source); }
[ "public", "function", "absUrl", "(", "$", "uri", ",", "$", "secure", "=", "null", ")", "{", "$", "source", "=", "$", "this", "->", "url", "(", "$", "uri", ",", "$", "secure", ")", ";", "if", "(", "substr", "(", "$", "source", ",", "0", ",", "...
Return asset absolute path with current theme path. @param string $uri @param boolean $secure @return string
[ "Return", "asset", "absolute", "path", "with", "current", "theme", "path", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L147-L155
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.added
protected function added($name, $source, $dependencies = array(), $attributes = array()) { if (is_array($source)) { foreach ($source as $path) { $name = $name.'-'.md5($path); $this->added($name, $path, $dependencies, $attributes); } } else { $type = (pathinfo(parse_url($source, PHP_URL_PATH), PATHINFO_EXTENSION) == 'css') ? 'style' : 'script'; // Remove unnecessary slashes from internal path. if ( ! preg_match('|^//|', $source)) { $source = ltrim($source, '/'); } return $this->$type($name, $source, $dependencies, $attributes); } }
php
protected function added($name, $source, $dependencies = array(), $attributes = array()) { if (is_array($source)) { foreach ($source as $path) { $name = $name.'-'.md5($path); $this->added($name, $path, $dependencies, $attributes); } } else { $type = (pathinfo(parse_url($source, PHP_URL_PATH), PATHINFO_EXTENSION) == 'css') ? 'style' : 'script'; // Remove unnecessary slashes from internal path. if ( ! preg_match('|^//|', $source)) { $source = ltrim($source, '/'); } return $this->$type($name, $source, $dependencies, $attributes); } }
[ "protected", "function", "added", "(", "$", "name", ",", "$", "source", ",", "$", "dependencies", "=", "array", "(", ")", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "source", ")", ")", "{", "foreach",...
Add an asset to the container. The extension of the asset source will be used to determine the type of asset being registered (CSS or JavaScript). When using a non-standard extension, the style/script methods may be used to register assets. <code> // Add an asset to the container Asset::container()->add('jquery', 'js/jquery.js'); // Add an asset that has dependencies on other assets Asset::add('jquery', 'js/jquery.js', 'jquery-ui'); // Add an asset that should have attributes applied to its tags Asset::add('jquery', 'js/jquery.js', null, array('defer')); </code> @param string $name @param string $source @param array $dependencies @param array $attributes @return AssetContainer
[ "Add", "an", "asset", "to", "the", "container", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L182-L205
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.add
public function add($name, $source = null, $dependencies = array(), $attributes = array()) { if(!is_array($name)) { if(!isset($source)) throw new \ErrorException("Missing argument 2 for Facuz\Theme\AssetContainer::add()", 1); return $this->added($name, $source, $dependencies, $attributes); } foreach ($name as $array) { if(count($array) < 2) throw new \ErrorException("Missing value 2 of the array for Facuz\Theme\AssetContainer::add()", 1); $container = $array[0]; $source = $array[1]; $dependencies = isset($array[2]) ? $array[2] : []; $attributes = isset($array[3]) ? $array[3] : []; $this->add($container, $source, $dependencies, $attributes); } $this->usePath(false); }
php
public function add($name, $source = null, $dependencies = array(), $attributes = array()) { if(!is_array($name)) { if(!isset($source)) throw new \ErrorException("Missing argument 2 for Facuz\Theme\AssetContainer::add()", 1); return $this->added($name, $source, $dependencies, $attributes); } foreach ($name as $array) { if(count($array) < 2) throw new \ErrorException("Missing value 2 of the array for Facuz\Theme\AssetContainer::add()", 1); $container = $array[0]; $source = $array[1]; $dependencies = isset($array[2]) ? $array[2] : []; $attributes = isset($array[3]) ? $array[3] : []; $this->add($container, $source, $dependencies, $attributes); } $this->usePath(false); }
[ "public", "function", "add", "(", "$", "name", ",", "$", "source", "=", "null", ",", "$", "dependencies", "=", "array", "(", ")", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "name", ")", ")", ...
Alias add an asset to container. @param string $name @param string $source @param array $dependencies @param array $attributes @return AssetContainer
[ "Alias", "add", "an", "asset", "to", "container", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L216-L235
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.script
public function script($name, $source, $dependencies = array(), $attributes = array()) { // Prepaend path to theme. if ($this->isUsePath()) { $source = $this->evaluatePath($this->getCurrentPath().$source); } $this->register('script', $name, $source, $dependencies, $attributes); return $this; }
php
public function script($name, $source, $dependencies = array(), $attributes = array()) { // Prepaend path to theme. if ($this->isUsePath()) { $source = $this->evaluatePath($this->getCurrentPath().$source); } $this->register('script', $name, $source, $dependencies, $attributes); return $this; }
[ "public", "function", "script", "(", "$", "name", ",", "$", "source", ",", "$", "dependencies", "=", "array", "(", ")", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "// Prepaend path to theme.", "if", "(", "$", "this", "->", "isUsePath", "...
Add a JavaScript file to the registered assets. @param string $name @param string $source @param array $dependencies @param array $attributes @return AssetContainer
[ "Add", "a", "JavaScript", "file", "to", "the", "registered", "assets", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L347-L357
FaCuZ/laravel-theme
src/AssetContainer.php
AssetContainer.html
public function html($group, $source, $attributes) { $result = substr($source, 0, 7); if($result=='/public') $source = substr($source, 7); $source = url($source); switch ($group) { case 'script' : $attributes['src'] = $source; return '<script'.$this->attributes($attributes).'></script>'.PHP_EOL; case 'style' : $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'); $attributes = $attributes + $defaults; $attributes['href'] = $source; return '<link'.$this->attributes($attributes).'>'.PHP_EOL; } }
php
public function html($group, $source, $attributes) { $result = substr($source, 0, 7); if($result=='/public') $source = substr($source, 7); $source = url($source); switch ($group) { case 'script' : $attributes['src'] = $source; return '<script'.$this->attributes($attributes).'></script>'.PHP_EOL; case 'style' : $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'); $attributes = $attributes + $defaults; $attributes['href'] = $source; return '<link'.$this->attributes($attributes).'>'.PHP_EOL; } }
[ "public", "function", "html", "(", "$", "group", ",", "$", "source", ",", "$", "attributes", ")", "{", "$", "result", "=", "substr", "(", "$", "source", ",", "0", ",", "7", ")", ";", "if", "(", "$", "result", "==", "'/public'", ")", "$", "source"...
Render asset as HTML. @param string $group @param mixed $source @param array $attributes @return string
[ "Render", "asset", "as", "HTML", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/AssetContainer.php#L532-L555
FaCuZ/laravel-theme
src/Commands/ThemeListCommand.php
ThemeListCommand.handle
public function handle() { $themes = []; $empty = true; $path = $this->option('path'); if ($this->files->exists($path)) { $scannedThemes = $this->files->directories($path); foreach ($scannedThemes as $key => $theme) { $themes[] = array($key+1, basename($theme)); $empty = false; } } $headers = ['#', 'Theme name']; if(!$empty){ $this->table($headers, $themes); } else { $this->info("No themes installed"); } }
php
public function handle() { $themes = []; $empty = true; $path = $this->option('path'); if ($this->files->exists($path)) { $scannedThemes = $this->files->directories($path); foreach ($scannedThemes as $key => $theme) { $themes[] = array($key+1, basename($theme)); $empty = false; } } $headers = ['#', 'Theme name']; if(!$empty){ $this->table($headers, $themes); } else { $this->info("No themes installed"); } }
[ "public", "function", "handle", "(", ")", "{", "$", "themes", "=", "[", "]", ";", "$", "empty", "=", "true", ";", "$", "path", "=", "$", "this", "->", "option", "(", "'path'", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "("...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Commands/ThemeListCommand.php#L62-L84
FaCuZ/laravel-theme
src/Middleware/ThemeLoader.php
ThemeLoader.handle
public function handle($request, Closure $next, $theme = null, $layout = null) { if(isset($theme)) Theme::uses($theme); if(isset($layout)) Theme::layout($layout); return $next($request); /* $response = $next($request); $originalContent = $response->getOriginalContent(); if(!is_string($originalContent)) { $view_name = $originalContent->getName(); $data = $originalContent->getData(); } else { $view_name = $response->exception->getTrace()[0]['args'][0]; } return $theme->scope($view_name, $data)->render(); */ }
php
public function handle($request, Closure $next, $theme = null, $layout = null) { if(isset($theme)) Theme::uses($theme); if(isset($layout)) Theme::layout($layout); return $next($request); /* $response = $next($request); $originalContent = $response->getOriginalContent(); if(!is_string($originalContent)) { $view_name = $originalContent->getName(); $data = $originalContent->getData(); } else { $view_name = $response->exception->getTrace()[0]['args'][0]; } return $theme->scope($view_name, $data)->render(); */ }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ",", "$", "theme", "=", "null", ",", "$", "layout", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "theme", ")", ")", "Theme", "::", "uses", "(", "$", "theme"...
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @param String $theme @param String $layout @return mixed
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/FaCuZ/laravel-theme/blob/2447113dcb2bb952ef8621473e1bb8b1a62b44f4/src/Middleware/ThemeLoader.php#L16-L39
laravel-admin-extensions/config
database/migrations/2017_07_17_040159_create_config_table.php
CreateConfigTable.up
public function up() { $connection = config('admin.database.connection') ?: config('database.default'); $table = config('admin.extensions.config.table', 'admin_config'); Schema::connection($connection)->create($table, function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('value'); $table->text('description')->nullable(); $table->timestamps(); }); }
php
public function up() { $connection = config('admin.database.connection') ?: config('database.default'); $table = config('admin.extensions.config.table', 'admin_config'); Schema::connection($connection)->create($table, function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('value'); $table->text('description')->nullable(); $table->timestamps(); }); }
[ "public", "function", "up", "(", ")", "{", "$", "connection", "=", "config", "(", "'admin.database.connection'", ")", "?", ":", "config", "(", "'database.default'", ")", ";", "$", "table", "=", "config", "(", "'admin.extensions.config.table'", ",", "'admin_confi...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/laravel-admin-extensions/config/blob/183b7974725eec7c4845a442a248c5f847599a89/database/migrations/2017_07_17_040159_create_config_table.php#L14-L27
goshippo/shippo-php-client
lib/Shippo/Object.php
Shippo_Object.scopedConstructFrom
public static function scopedConstructFrom($class, $values, $apiKey = null) { $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey); $obj->refreshFrom($values, $apiKey); return $obj; }
php
public static function scopedConstructFrom($class, $values, $apiKey = null) { $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey); $obj->refreshFrom($values, $apiKey); return $obj; }
[ "public", "static", "function", "scopedConstructFrom", "(", "$", "class", ",", "$", "values", ",", "$", "apiKey", "=", "null", ")", "{", "$", "obj", "=", "new", "$", "class", "(", "isset", "(", "$", "values", "[", "'id'", "]", ")", "?", "$", "value...
This unfortunately needs to be public to be used in Util.php @param string $class @param array $values @param string|null $apiKey @return Shippo_Object The object constructed from the given values.
[ "This", "unfortunately", "needs", "to", "be", "public", "to", "be", "used", "in", "Util", ".", "php" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Object.php#L132-L137
goshippo/shippo-php-client
lib/Shippo/Object.php
Shippo_Object.refreshFrom
public function refreshFrom($values, $apiKey, $partial = false) { $this->_apiKey = $apiKey; // Wipe old state before setting new. This is useful for e.g. updating a // customer, where there is no persistent card parameter. Mark those values // which don't persist as transient if ($partial) { $removed = new Shippo_Util_Set(); } else { $removed = array_diff(array_keys($this->_values), array_keys($values)); } foreach ($removed as $k) { if (self::$permanentAttributes->includes($k)) continue; unset($this->$k); } foreach ($values as $k => $v) { if (self::$permanentAttributes->includes($k) && isset($this[$k])) continue; if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) { $this->_values[$k] = Shippo_Object::scopedConstructFrom('Shippo_AttachedObject', $v, $apiKey); } else { $this->_values[$k] = Shippo_Util::convertToShippoObject($v, $apiKey); } $this->_transientValues->discard($k); $this->_unsavedValues->discard($k); } }
php
public function refreshFrom($values, $apiKey, $partial = false) { $this->_apiKey = $apiKey; // Wipe old state before setting new. This is useful for e.g. updating a // customer, where there is no persistent card parameter. Mark those values // which don't persist as transient if ($partial) { $removed = new Shippo_Util_Set(); } else { $removed = array_diff(array_keys($this->_values), array_keys($values)); } foreach ($removed as $k) { if (self::$permanentAttributes->includes($k)) continue; unset($this->$k); } foreach ($values as $k => $v) { if (self::$permanentAttributes->includes($k) && isset($this[$k])) continue; if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) { $this->_values[$k] = Shippo_Object::scopedConstructFrom('Shippo_AttachedObject', $v, $apiKey); } else { $this->_values[$k] = Shippo_Util::convertToShippoObject($v, $apiKey); } $this->_transientValues->discard($k); $this->_unsavedValues->discard($k); } }
[ "public", "function", "refreshFrom", "(", "$", "values", ",", "$", "apiKey", ",", "$", "partial", "=", "false", ")", "{", "$", "this", "->", "_apiKey", "=", "$", "apiKey", ";", "// Wipe old state before setting new. This is useful for e.g. updating a", "// customer...
Refreshes this object using the provided values. @param array $values @param string $apiKey @param boolean $partial Defaults to false.
[ "Refreshes", "this", "object", "using", "the", "provided", "values", "." ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Object.php#L158-L190
goshippo/shippo-php-client
lib/Shippo/Object.php
Shippo_Object._lsb
protected function _lsb($method) { $class = get_class($this); $args = array_slice(func_get_args(), 1); return call_user_func_array(array( $class, $method ), $args); }
php
protected function _lsb($method) { $class = get_class($this); $args = array_slice(func_get_args(), 1); return call_user_func_array(array( $class, $method ), $args); }
[ "protected", "function", "_lsb", "(", "$", "method", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "$", "args", "=", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "call_user_func_array", "(", "arra...
Pretend to have late static bindings, even in PHP 5.2
[ "Pretend", "to", "have", "late", "static", "bindings", "even", "in", "PHP", "5", ".", "2" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Object.php#L219-L227
goshippo/shippo-php-client
lib/Shippo/CustomsDeclaration.php
Shippo_CustomsDeclaration.create
public static function create($params = null, $apiKey = null) { $class = get_class(); return self::_scopedCreate($class, $params, $apiKey); }
php
public static function create($params = null, $apiKey = null) { $class = get_class(); return self::_scopedCreate($class, $params, $apiKey); }
[ "public", "static", "function", "create", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "return", "self", "::", "_scopedCreate", "(", "$", "class", ",", "$", "params", ",", ...
@param array|null $params @param string|null $apiKey @return Shippo_CustomsDeclaration Create a customs declaration.
[ "@param", "array|null", "$params", "@param", "string|null", "$apiKey" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/CustomsDeclaration.php#L23-L27
goshippo/shippo-php-client
lib/Shippo/CustomsDeclaration.php
Shippo_CustomsDeclaration.all
public static function all($params = null, $apiKey = null) { $class = get_class(); return self::_scopedAll($class, $params, $apiKey); }
php
public static function all($params = null, $apiKey = null) { $class = get_class(); return self::_scopedAll($class, $params, $apiKey); }
[ "public", "static", "function", "all", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "return", "self", "::", "_scopedAll", "(", "$", "class", ",", "$", "params", ",", "$",...
@param array|null $params @return Shippo_All Get all the customs declarations.
[ "@param", "array|null", "$params" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/CustomsDeclaration.php#L45-L49
goshippo/shippo-php-client
lib/Shippo/Batch.php
Shippo_Batch.add
public static function add($id, $params = null, $apiKey = null) { $class = get_class(); return self::_scopedAddBatch($class, $id, $params, $apiKey); }
php
public static function add($id, $params = null, $apiKey = null) { $class = get_class(); return self::_scopedAddBatch($class, $id, $params, $apiKey); }
[ "public", "static", "function", "add", "(", "$", "id", ",", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "return", "self", "::", "_scopedAddBatch", "(", "$", "class", ",", "$"...
@param string $id @param array|null $params @param string|null $apiKey @return Shippo_Add Adds shipments to a batch
[ "@param", "string", "$id", "@param", "array|null", "$params", "@param", "string|null", "$apiKey" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Batch.php#L48-L52
goshippo/shippo-php-client
lib/Shippo/Batch.php
Shippo_Batch.remove
public static function remove($id, $params = null, $apiKey = null) { $class = get_class(); return self::_scopedRemoveBatch($class, $id, $params, $apiKey); }
php
public static function remove($id, $params = null, $apiKey = null) { $class = get_class(); return self::_scopedRemoveBatch($class, $id, $params, $apiKey); }
[ "public", "static", "function", "remove", "(", "$", "id", ",", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "return", "self", "::", "_scopedRemoveBatch", "(", "$", "class", ",",...
@param string $id @param array|null $params @param string|null $apiKey @return Shippo_Remove Removes shipments from a batch
[ "@param", "string", "$id", "@param", "array|null", "$params", "@param", "string|null", "$apiKey" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Batch.php#L61-L65
goshippo/shippo-php-client
lib/Shippo/Util.php
Shippo_Util.convertShippoObjectToArray
public static function convertShippoObjectToArray($values) { $results = array(); foreach ($values as $k => $v) { // FIXME: this is an encapsulation violation if ($k[0] == '_') { continue; } if ($v instanceof Shippo_Object) { $results[$k] = $v->__toArray(true); } else if (is_array($v)) { $results[$k] = self::convertShippoObjectToArray($v); } else { $results[$k] = $v; } } return $results; }
php
public static function convertShippoObjectToArray($values) { $results = array(); foreach ($values as $k => $v) { // FIXME: this is an encapsulation violation if ($k[0] == '_') { continue; } if ($v instanceof Shippo_Object) { $results[$k] = $v->__toArray(true); } else if (is_array($v)) { $results[$k] = self::convertShippoObjectToArray($v); } else { $results[$k] = $v; } } return $results; }
[ "public", "static", "function", "convertShippoObjectToArray", "(", "$", "values", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "k", "=>", "$", "v", ")", "{", "// FIXME: this is an encapsulation violation", ...
Recursively converts the PHP Shippo object to an array. @param array $values The PHP Shippo object to convert. @return array
[ "Recursively", "converts", "the", "PHP", "Shippo", "object", "to", "an", "array", "." ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Util.php#L30-L47
goshippo/shippo-php-client
lib/Shippo/Util.php
Shippo_Util.convertToShippoObject
public static function convertToShippoObject($resp, $apiKey) { // TODO: Have API Return Object: Type in order to cast properly $types = array( 'QUOTE' => 'Shippo_Address' ); if (self::isList($resp)) { $mapped = array(); foreach ($resp as $i) array_push($mapped, self::convertToShippoObject($i, $apiKey)); return $mapped; } else if (is_array($resp)) { if (isset($resp['object_purpose']) && is_string($resp['object_purpose']) && isset($types[$resp['object_purpose']])) { $class = $types[$resp['object_purpose']]; } else { $class = 'Shippo_Object'; } return Shippo_Object::scopedConstructFrom($class, $resp, $apiKey); } else { return $resp; } }
php
public static function convertToShippoObject($resp, $apiKey) { // TODO: Have API Return Object: Type in order to cast properly $types = array( 'QUOTE' => 'Shippo_Address' ); if (self::isList($resp)) { $mapped = array(); foreach ($resp as $i) array_push($mapped, self::convertToShippoObject($i, $apiKey)); return $mapped; } else if (is_array($resp)) { if (isset($resp['object_purpose']) && is_string($resp['object_purpose']) && isset($types[$resp['object_purpose']])) { $class = $types[$resp['object_purpose']]; } else { $class = 'Shippo_Object'; } return Shippo_Object::scopedConstructFrom($class, $resp, $apiKey); } else { return $resp; } }
[ "public", "static", "function", "convertToShippoObject", "(", "$", "resp", ",", "$", "apiKey", ")", "{", "// TODO: Have API Return Object: Type in order to cast properly", "$", "types", "=", "array", "(", "'QUOTE'", "=>", "'Shippo_Address'", ")", ";", "if", "(", "se...
Converts a response from the Shippo API to the corresponding PHP object. @param array $resp The response from the Shippo API. @param string $apiKey @return Shippo_Object|array
[ "Converts", "a", "response", "from", "the", "Shippo", "API", "to", "the", "corresponding", "PHP", "object", "." ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Util.php#L56-L77
goshippo/shippo-php-client
lib/Shippo/Util.php
Shippo_Util.utf8
public static function utf8($value) { if (is_string($value) && mb_detect_encoding($value, "UTF-8", TRUE) != "UTF-8") { return utf8_encode($value); } else { return $value; } }
php
public static function utf8($value) { if (is_string($value) && mb_detect_encoding($value, "UTF-8", TRUE) != "UTF-8") { return utf8_encode($value); } else { return $value; } }
[ "public", "static", "function", "utf8", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", "&&", "mb_detect_encoding", "(", "$", "value", ",", "\"UTF-8\"", ",", "TRUE", ")", "!=", "\"UTF-8\"", ")", "{", "return", "utf8_encode", ...
@param string|mixed $value A string to UTF8-encode. @returns string|mixed The UTF8-encoded string, or the object passed in if it wasn't a string.
[ "@param", "string|mixed", "$value", "A", "string", "to", "UTF8", "-", "encode", "." ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Util.php#L85-L92
goshippo/shippo-php-client
lib/Shippo/Track.php
Shippo_Track.get_status
public static function get_status($params = null, $apiKey = null) { $class = get_class(); $id = $params['id']; return self::_scopedGetStatus($class, $id, $params, $apiKey); }
php
public static function get_status($params = null, $apiKey = null) { $class = get_class(); $id = $params['id']; return self::_scopedGetStatus($class, $id, $params, $apiKey); }
[ "public", "static", "function", "get_status", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "return", "self", "::", ...
@param array|null $params @param string|null $apiKey @return Shippo_Get_Status Get the tracking status of a Shipment.
[ "@param", "array|null", "$params", "@param", "string|null", "$apiKey" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Track.php#L35-L40
goshippo/shippo-php-client
lib/Shippo/Shipment.php
Shippo_Shipment.get_shipping_rates
public static function get_shipping_rates($params = null, $apiKey = null) { $class = get_class(); $id = $params['id']; return self::_scopedGet($class, $id, $params, $apiKey = null); }
php
public static function get_shipping_rates($params = null, $apiKey = null) { $class = get_class(); $id = $params['id']; return self::_scopedGet($class, $id, $params, $apiKey = null); }
[ "public", "static", "function", "get_shipping_rates", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "return", "self", ...
@param array|null $params @param string|null $apiKey @return Shippo_Get_Shipping_Rates Get the rates for a Shipment.
[ "@param", "array|null", "$params", "@param", "string|null", "$apiKey" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/Shipment.php#L47-L52
goshippo/shippo-php-client
lib/Shippo/CarrierAccount.php
Shippo_CarrierAccount.update
public static function update($id, $params, $apiKey = null) { $class = get_class(); return self::_scopedUpdate($class, $id, $params, $apiKey); }
php
public static function update($id, $params, $apiKey = null) { $class = get_class(); return self::_scopedUpdate($class, $id, $params, $apiKey); }
[ "public", "static", "function", "update", "(", "$", "id", ",", "$", "params", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "return", "self", "::", "_scopedUpdate", "(", "$", "class", ",", "$", "id", ",",...
@param id of the CarrierAccount to be updated @return Shippo_Retrieve Get a customs item.
[ "@param", "id", "of", "the", "CarrierAccount", "to", "be", "updated" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/CarrierAccount.php#L56-L60
goshippo/shippo-php-client
lib/Shippo/ApiRequestor.php
Shippo_ApiRequestor.handleApiError
public function handleApiError($rbody, $rcode, $resp) { // Array is not currently being returned by API, making the below N/A // if (!is_array($resp) || !isset($resp['error'])) { // $msg = "Invalid response object from API: $rbody " // ."(HTTP response code was $rcode)"; // throw new Shippo_ApiError($msg, $rcode, $rbody, $resp); // } $msg = "message not set"; $param = "parameters not set"; $code = "code not set"; // Temporary setting of msg to rbody $msg = $rbody; // Parameters necessary for error code construction are not provided // $error = $resp['error']; // $msg = isset($error['message']) ? $error['message'] : null; // $param = isset($error['param']) ? $error['param'] : null; // $code = isset($error['code']) ? $error['code'] : null; switch ($rcode) { case 400: throw new Shippo_InvalidRequestError($msg, $param, $rcode, $rbody, $resp); case 404: throw new Shippo_InvalidRequestError($msg, $param, $rcode, $rbody, $resp); case 401: throw new Shippo_AuthenticationError($msg, $rcode, $rbody, $resp); default: throw new Shippo_ApiError($msg, $rcode, $rbody, $resp); } }
php
public function handleApiError($rbody, $rcode, $resp) { // Array is not currently being returned by API, making the below N/A // if (!is_array($resp) || !isset($resp['error'])) { // $msg = "Invalid response object from API: $rbody " // ."(HTTP response code was $rcode)"; // throw new Shippo_ApiError($msg, $rcode, $rbody, $resp); // } $msg = "message not set"; $param = "parameters not set"; $code = "code not set"; // Temporary setting of msg to rbody $msg = $rbody; // Parameters necessary for error code construction are not provided // $error = $resp['error']; // $msg = isset($error['message']) ? $error['message'] : null; // $param = isset($error['param']) ? $error['param'] : null; // $code = isset($error['code']) ? $error['code'] : null; switch ($rcode) { case 400: throw new Shippo_InvalidRequestError($msg, $param, $rcode, $rbody, $resp); case 404: throw new Shippo_InvalidRequestError($msg, $param, $rcode, $rbody, $resp); case 401: throw new Shippo_AuthenticationError($msg, $rcode, $rbody, $resp); default: throw new Shippo_ApiError($msg, $rcode, $rbody, $resp); } }
[ "public", "function", "handleApiError", "(", "$", "rbody", ",", "$", "rcode", ",", "$", "resp", ")", "{", "// Array is not currently being returned by API, making the below N/A ", "// if (!is_array($resp) || !isset($resp['error'])) {", "// $msg = \"Invalid response object from API:...
@param string $rbody A JSON string. @param int $rcode @param array $resp @throws Shippo_InvalidRequestError if the error is caused by the user. @throws Shippo_AuthenticationError if the error is caused by a lack of permissions. @throws Shippo_ApiError otherwise.
[ "@param", "string", "$rbody", "A", "JSON", "string", ".", "@param", "int", "$rcode", "@param", "array", "$resp" ]
train
https://github.com/goshippo/shippo-php-client/blob/e4b577a0f45675db5df54e14877a2a9f463dfcad/lib/Shippo/ApiRequestor.php#L76-L108
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.delete
public function delete() { if ($this->_id) { try { $this->_connection->delete($this->url() . '/' . $this->_id, []); return true; } catch (Exception $e) { } } return false; }
php
public function delete() { if ($this->_id) { try { $this->_connection->delete($this->url() . '/' . $this->_id, []); return true; } catch (Exception $e) { } } return false; }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "_id", ")", "{", "try", "{", "$", "this", "->", "_connection", "->", "delete", "(", "$", "this", "->", "url", "(", ")", ".", "'/'", ".", "$", "this", "->", "_id", ",",...
Explicitly delete the cursor This might issue an HTTP DELETE request to inform the server about the deletion. @throws Exception @return bool - true if the server acknowledged the deletion request, false otherwise
[ "Explicitly", "delete", "the", "cursor" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L243-L255
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.getCount
public function getCount() { if ($this->_count !== null) { return $this->_count; } while ($this->_hasMore) { $this->fetchOutstanding(); } return $this->_length; }
php
public function getCount() { if ($this->_count !== null) { return $this->_count; } while ($this->_hasMore) { $this->fetchOutstanding(); } return $this->_length; }
[ "public", "function", "getCount", "(", ")", "{", "if", "(", "$", "this", "->", "_count", "!==", "null", ")", "{", "return", "$", "this", "->", "_count", ";", "}", "while", "(", "$", "this", "->", "_hasMore", ")", "{", "$", "this", "->", "fetchOutst...
Get the total number of results in the cursor This might issue additional HTTP requests to fetch any outstanding results from the server @throws Exception @return int - total number of results
[ "Get", "the", "total", "number", "of", "results", "in", "the", "cursor" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L267-L278
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.valid
public function valid() { if ($this->_position <= $this->_length - 1) { // we have more results than the current position is return true; } if (!$this->_hasMore || !$this->_id) { // we don't have more results, but the cursor is exhausted return false; } // need to fetch additional results from the server $this->fetchOutstanding(); return ($this->_position <= $this->_length - 1); }
php
public function valid() { if ($this->_position <= $this->_length - 1) { // we have more results than the current position is return true; } if (!$this->_hasMore || !$this->_id) { // we don't have more results, but the cursor is exhausted return false; } // need to fetch additional results from the server $this->fetchOutstanding(); return ($this->_position <= $this->_length - 1); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "$", "this", "->", "_position", "<=", "$", "this", "->", "_length", "-", "1", ")", "{", "// we have more results than the current position is", "return", "true", ";", "}", "if", "(", "!", "$", "this"...
Check if cursor can be advanced further, necessary for Iterator This might issue additional HTTP requests to fetch any outstanding results from the server @throws Exception @return bool - true if the cursor can be advanced further, false if cursor is at end
[ "Check", "if", "cursor", "can", "be", "advanced", "further", "necessary", "for", "Iterator" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L374-L390
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.add
private function add(array $data) { foreach ($this->sanitize($data) as $row) { if (!is_array($row) || (isset($this->_options[self::ENTRY_FLAT]) && $this->_options[self::ENTRY_FLAT])) { $this->addFlatFromArray($row); } else { if (!isset($this->_options['objectType'])) { $this->addDocumentsFromArray($row); } else { switch ($this->_options['objectType']) { case 'edge' : $this->addEdgesFromArray($row); break; case 'vertex' : $this->addVerticesFromArray($row); break; case 'path' : $this->addPathsFromArray($row); break; case 'shortestPath' : $this->addShortestPathFromArray($row); break; case 'distanceTo' : $this->addDistanceToFromArray($row); break; case 'commonNeighbors' : $this->addCommonNeighborsFromArray($row); break; case 'commonProperties' : $this->addCommonPropertiesFromArray($row); break; case 'figure' : $this->addFigureFromArray($row); break; default : $this->addDocumentsFromArray($row); break; } } } } }
php
private function add(array $data) { foreach ($this->sanitize($data) as $row) { if (!is_array($row) || (isset($this->_options[self::ENTRY_FLAT]) && $this->_options[self::ENTRY_FLAT])) { $this->addFlatFromArray($row); } else { if (!isset($this->_options['objectType'])) { $this->addDocumentsFromArray($row); } else { switch ($this->_options['objectType']) { case 'edge' : $this->addEdgesFromArray($row); break; case 'vertex' : $this->addVerticesFromArray($row); break; case 'path' : $this->addPathsFromArray($row); break; case 'shortestPath' : $this->addShortestPathFromArray($row); break; case 'distanceTo' : $this->addDistanceToFromArray($row); break; case 'commonNeighbors' : $this->addCommonNeighborsFromArray($row); break; case 'commonProperties' : $this->addCommonPropertiesFromArray($row); break; case 'figure' : $this->addFigureFromArray($row); break; default : $this->addDocumentsFromArray($row); break; } } } } }
[ "private", "function", "add", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "sanitize", "(", "$", "data", ")", "as", "$", "row", ")", "{", "if", "(", "!", "is_array", "(", "$", "row", ")", "||", "(", "isset", "(", "$",...
Create an array of results from the input array @param array $data - incoming result @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "results", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L401-L442
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addDocumentsFromArray
private function addDocumentsFromArray(array $data) { $_documentClass = $this->_documentClass; $this->_result[] = $_documentClass::createFromArray($data, $this->_options); }
php
private function addDocumentsFromArray(array $data) { $_documentClass = $this->_documentClass; $this->_result[] = $_documentClass::createFromArray($data, $this->_options); }
[ "private", "function", "addDocumentsFromArray", "(", "array", "$", "data", ")", "{", "$", "_documentClass", "=", "$", "this", "->", "_documentClass", ";", "$", "this", "->", "_result", "[", "]", "=", "$", "_documentClass", "::", "createFromArray", "(", "$", ...
Create an array of documents from the input array @param array $data - array of incoming "document" arrays @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "documents", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L466-L471
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addPathsFromArray
private function addPathsFromArray(array $data) { $_documentClass = $this->_documentClass; $_edgeClass = $this->_edgeClass; $entry = [ 'vertices' => [], 'edges' => [], 'source' => $_documentClass::createFromArray($data['source'], $this->_options), 'destination' => $_documentClass::createFromArray($data['destination'], $this->_options), ]; foreach ($data['vertices'] as $v) { $entry['vertices'][] = $_documentClass::createFromArray($v, $this->_options); } foreach ($data['edges'] as $v) { $entry['edges'][] = $_edgeClass::createFromArray($v, $this->_options); } $this->_result[] = $entry; }
php
private function addPathsFromArray(array $data) { $_documentClass = $this->_documentClass; $_edgeClass = $this->_edgeClass; $entry = [ 'vertices' => [], 'edges' => [], 'source' => $_documentClass::createFromArray($data['source'], $this->_options), 'destination' => $_documentClass::createFromArray($data['destination'], $this->_options), ]; foreach ($data['vertices'] as $v) { $entry['vertices'][] = $_documentClass::createFromArray($v, $this->_options); } foreach ($data['edges'] as $v) { $entry['edges'][] = $_edgeClass::createFromArray($v, $this->_options); } $this->_result[] = $entry; }
[ "private", "function", "addPathsFromArray", "(", "array", "$", "data", ")", "{", "$", "_documentClass", "=", "$", "this", "->", "_documentClass", ";", "$", "_edgeClass", "=", "$", "this", "->", "_edgeClass", ";", "$", "entry", "=", "[", "'vertices'", "=>",...
Create an array of paths from the input array @param array $data - array of incoming "paths" arrays @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "paths", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L481-L499
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addCommonNeighborsFromArray
private function addCommonNeighborsFromArray(array $data) { $_documentClass = $this->_documentClass; $left = $data['left']; $right = $data['right']; if (!isset($this->_result[$left])) { $this->_result[$left] = []; } if (!isset($this->_result[$left][$right])) { $this->_result[$left][$right] = []; } foreach ($data['neighbors'] as $neighbor) { $this->_result[$left][$right][] = $_documentClass::createFromArray($neighbor); } }
php
private function addCommonNeighborsFromArray(array $data) { $_documentClass = $this->_documentClass; $left = $data['left']; $right = $data['right']; if (!isset($this->_result[$left])) { $this->_result[$left] = []; } if (!isset($this->_result[$left][$right])) { $this->_result[$left][$right] = []; } foreach ($data['neighbors'] as $neighbor) { $this->_result[$left][$right][] = $_documentClass::createFromArray($neighbor); } }
[ "private", "function", "addCommonNeighborsFromArray", "(", "array", "$", "data", ")", "{", "$", "_documentClass", "=", "$", "this", "->", "_documentClass", ";", "$", "left", "=", "$", "data", "[", "'left'", "]", ";", "$", "right", "=", "$", "data", "[", ...
Create an array of common neighbors from the input array @param array $data - array of incoming "paths" arrays @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "common", "neighbors", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L571-L588
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addCommonPropertiesFromArray
private function addCommonPropertiesFromArray(array $data) { $k = array_keys($data); $k = $k[0]; $this->_result[$k] = []; foreach ($data[$k] as $c) { $id = $c['_id']; unset($c['_id']); $this->_result[$k][$id] = $c; } }
php
private function addCommonPropertiesFromArray(array $data) { $k = array_keys($data); $k = $k[0]; $this->_result[$k] = []; foreach ($data[$k] as $c) { $id = $c['_id']; unset($c['_id']); $this->_result[$k][$id] = $c; } }
[ "private", "function", "addCommonPropertiesFromArray", "(", "array", "$", "data", ")", "{", "$", "k", "=", "array_keys", "(", "$", "data", ")", ";", "$", "k", "=", "$", "k", "[", "0", "]", ";", "$", "this", "->", "_result", "[", "$", "k", "]", "=...
Create an array of common properties from the input array @param array $data - array of incoming "paths" arrays @return void
[ "Create", "an", "array", "of", "common", "properties", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L597-L607
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addEdgesFromArray
private function addEdgesFromArray(array $data) { $_edgeClass = $this->_edgeClass; $this->_result[] = $_edgeClass::createFromArray($data, $this->_options); }
php
private function addEdgesFromArray(array $data) { $_edgeClass = $this->_edgeClass; $this->_result[] = $_edgeClass::createFromArray($data, $this->_options); }
[ "private", "function", "addEdgesFromArray", "(", "array", "$", "data", ")", "{", "$", "_edgeClass", "=", "$", "this", "->", "_edgeClass", ";", "$", "this", "->", "_result", "[", "]", "=", "$", "_edgeClass", "::", "createFromArray", "(", "$", "data", ",",...
Create an array of Edges from the input array @param array $data - array of incoming "edge" arrays @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "Edges", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L629-L634
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.addVerticesFromArray
private function addVerticesFromArray(array $data) { $_documentClass = $this->_documentClass; $this->_result[] = $_documentClass::createFromArray($data, $this->_options); }
php
private function addVerticesFromArray(array $data) { $_documentClass = $this->_documentClass; $this->_result[] = $_documentClass::createFromArray($data, $this->_options); }
[ "private", "function", "addVerticesFromArray", "(", "array", "$", "data", ")", "{", "$", "_documentClass", "=", "$", "this", "->", "_documentClass", ";", "$", "this", "->", "_result", "[", "]", "=", "$", "_documentClass", "::", "createFromArray", "(", "$", ...
Create an array of Vertex from the input array @param array $data - array of incoming "vertex" arrays @return void @throws \ArangoDBClient\ClientException
[ "Create", "an", "array", "of", "Vertex", "from", "the", "input", "array" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L645-L650
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.sanitize
private function sanitize(array $rows) { $_documentClass = $this->_documentClass; if (isset($this->_options[self::ENTRY_SANITIZE]) && $this->_options[self::ENTRY_SANITIZE]) { foreach ($rows as $key => $value) { if (is_array($value) && isset($value[$_documentClass::ENTRY_ID])) { unset($rows[$key][$_documentClass::ENTRY_ID]); } if (is_array($value) && isset($value[$_documentClass::ENTRY_REV])) { unset($rows[$key][$_documentClass::ENTRY_REV]); } } } return $rows; }
php
private function sanitize(array $rows) { $_documentClass = $this->_documentClass; if (isset($this->_options[self::ENTRY_SANITIZE]) && $this->_options[self::ENTRY_SANITIZE]) { foreach ($rows as $key => $value) { if (is_array($value) && isset($value[$_documentClass::ENTRY_ID])) { unset($rows[$key][$_documentClass::ENTRY_ID]); } if (is_array($value) && isset($value[$_documentClass::ENTRY_REV])) { unset($rows[$key][$_documentClass::ENTRY_REV]); } } } return $rows; }
[ "private", "function", "sanitize", "(", "array", "$", "rows", ")", "{", "$", "_documentClass", "=", "$", "this", "->", "_documentClass", ";", "if", "(", "isset", "(", "$", "this", "->", "_options", "[", "self", "::", "ENTRY_SANITIZE", "]", ")", "&&", "...
Sanitize the result set rows This will remove the _id and _rev attributes from the results if the "sanitize" option is set @param array $rows - array of rows to be sanitized @return array - sanitized rows
[ "Sanitize", "the", "result", "set", "rows" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L663-L681
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.fetchOutstanding
private function fetchOutstanding() { // continuation $response = $this->_connection->put($this->url() . '/' . $this->_id, '', []); ++$this->_fetches; $data = $response->getJson(); $this->_hasMore = (bool) $data[self::ENTRY_HASMORE]; $this->add($data[self::ENTRY_RESULT]); if (!$this->_hasMore) { // we have fetched the complete result set and can unset the id now $this->_id = null; } $this->updateLength(); }
php
private function fetchOutstanding() { // continuation $response = $this->_connection->put($this->url() . '/' . $this->_id, '', []); ++$this->_fetches; $data = $response->getJson(); $this->_hasMore = (bool) $data[self::ENTRY_HASMORE]; $this->add($data[self::ENTRY_RESULT]); if (!$this->_hasMore) { // we have fetched the complete result set and can unset the id now $this->_id = null; } $this->updateLength(); }
[ "private", "function", "fetchOutstanding", "(", ")", "{", "// continuation", "$", "response", "=", "$", "this", "->", "_connection", "->", "put", "(", "$", "this", "->", "url", "(", ")", ".", "'/'", ".", "$", "this", "->", "_id", ",", "''", ",", "[",...
Fetch outstanding results from the server @throws Exception @return void
[ "Fetch", "outstanding", "results", "from", "the", "server" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L690-L707
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.url
private function url() { if (isset($this->_options[self::ENTRY_BASEURL])) { return $this->_options[self::ENTRY_BASEURL]; } // this is the fallback return Urls::URL_CURSOR; }
php
private function url() { if (isset($this->_options[self::ENTRY_BASEURL])) { return $this->_options[self::ENTRY_BASEURL]; } // this is the fallback return Urls::URL_CURSOR; }
[ "private", "function", "url", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_options", "[", "self", "::", "ENTRY_BASEURL", "]", ")", ")", "{", "return", "$", "this", "->", "_options", "[", "self", "::", "ENTRY_BASEURL", "]", ";", "}", ...
Return the base URL for the cursor @return string
[ "Return", "the", "base", "URL", "for", "the", "cursor" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L726-L734
arangodb/arangodb-php
lib/ArangoDBClient/Cursor.php
Cursor.getStatValue
private function getStatValue($name) { if (isset($this->_extra[self::ENTRY_STATS][$name])) { return $this->_extra[self::ENTRY_STATS][$name]; } return 0; }
php
private function getStatValue($name) { if (isset($this->_extra[self::ENTRY_STATS][$name])) { return $this->_extra[self::ENTRY_STATS][$name]; } return 0; }
[ "private", "function", "getStatValue", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_extra", "[", "self", "::", "ENTRY_STATS", "]", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "_extra", "[", "self"...
Get a statistical figure value from the query result @param string $name - name of figure to return @return int
[ "Get", "a", "statistical", "figure", "value", "from", "the", "query", "result" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/lib/ArangoDBClient/Cursor.php#L743-L750
arangodb/arangodb-php
examples/customDocumentClass.php
AbstractEntity.setInternalKey
public function setInternalKey($key) { parent::setInternalKey($key); if (empty($this->_id)) { $this->_id = $this->_collectionName . '/' . $key; } }
php
public function setInternalKey($key) { parent::setInternalKey($key); if (empty($this->_id)) { $this->_id = $this->_collectionName . '/' . $key; } }
[ "public", "function", "setInternalKey", "(", "$", "key", ")", "{", "parent", "::", "setInternalKey", "(", "$", "key", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "_id", ")", ")", "{", "$", "this", "->", "_id", "=", "$", "this", "->", "_...
Sets internal key (eg. when using in forms). @param string $key
[ "Sets", "internal", "key", "(", "eg", ".", "when", "using", "in", "forms", ")", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/examples/customDocumentClass.php#L48-L54
arangodb/arangodb-php
examples/customDocumentClass.php
AbstractCollection.findOneByExample
public function findOneByExample($example) { $cursor = $this->byExample($this->_collectionName, $example); if ($cursor->getCount() > 0) { /* @var $document AbstractEntity */ $document = $cursor->getAll()[0]; $document->setIsNew(false); return $document; } return false; }
php
public function findOneByExample($example) { $cursor = $this->byExample($this->_collectionName, $example); if ($cursor->getCount() > 0) { /* @var $document AbstractEntity */ $document = $cursor->getAll()[0]; $document->setIsNew(false); return $document; } return false; }
[ "public", "function", "findOneByExample", "(", "$", "example", ")", "{", "$", "cursor", "=", "$", "this", "->", "byExample", "(", "$", "this", "->", "_collectionName", ",", "$", "example", ")", ";", "if", "(", "$", "cursor", "->", "getCount", "(", ")",...
Find by Example. @param array $example @return AbstractEntity|bool
[ "Find", "by", "Example", "." ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/examples/customDocumentClass.php#L179-L191
arangodb/arangodb-php
examples/customDocumentClass.php
AbstractCollection.findOneById
public function findOneById($id) { try { return $this->_documentHandler->getById($this->_collectionName, $id); } catch (ServerException $e) { if ($e->getServerMessage() === 'document not found') { return null; } throw $e; } }
php
public function findOneById($id) { try { return $this->_documentHandler->getById($this->_collectionName, $id); } catch (ServerException $e) { if ($e->getServerMessage() === 'document not found') { return null; } throw $e; } }
[ "public", "function", "findOneById", "(", "$", "id", ")", "{", "try", "{", "return", "$", "this", "->", "_documentHandler", "->", "getById", "(", "$", "this", "->", "_collectionName", ",", "$", "id", ")", ";", "}", "catch", "(", "ServerException", "$", ...
Gets one document by given ID @param string|int $id @return AbstractEntity|null @throws ServerException
[ "Gets", "one", "document", "by", "given", "ID" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/examples/customDocumentClass.php#L201-L211
arangodb/arangodb-php
examples/customDocumentClass.php
AbstractCollection.store
public function store($document) { if (is_null($document->get('_dateCreated'))) { $document->set('_dateCreated', date('Y-m-d H:i:s')); } $document->set('_dateUpdated', date('Y-m-d H:i:s')); if ($document->getIsNew()) { if (method_exists($document, 'onCreate')) { $document->onCreate(); } return $this->_documentHandler->save($this->_collectionName, $document); } else { if (method_exists($document, 'onUpdate')) { $document->onUpdate(); } return $this->_documentHandler->replace($document); } }
php
public function store($document) { if (is_null($document->get('_dateCreated'))) { $document->set('_dateCreated', date('Y-m-d H:i:s')); } $document->set('_dateUpdated', date('Y-m-d H:i:s')); if ($document->getIsNew()) { if (method_exists($document, 'onCreate')) { $document->onCreate(); } return $this->_documentHandler->save($this->_collectionName, $document); } else { if (method_exists($document, 'onUpdate')) { $document->onUpdate(); } return $this->_documentHandler->replace($document); } }
[ "public", "function", "store", "(", "$", "document", ")", "{", "if", "(", "is_null", "(", "$", "document", "->", "get", "(", "'_dateCreated'", ")", ")", ")", "{", "$", "document", "->", "set", "(", "'_dateCreated'", ",", "date", "(", "'Y-m-d H:i:s'", "...
Store a document to a collection {@inheritDoc} @param AbstractEntity $document @return mixed
[ "Store", "a", "document", "to", "a", "collection" ]
train
https://github.com/arangodb/arangodb-php/blob/89fac3fc9ab21ec8cf0a5dc35118abfaa3d49b02/examples/customDocumentClass.php#L233-L253