id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
41,700
grohiro/laravel-camelcase-json
src/CamelCaseJsonResponseFactory.php
CamelCaseJsonResponseFactory.encodeArray
public function encodeArray($array) { $newArray = []; foreach ($array as $key => $val) { $newArray[\camel_case($key)] = $this->encodeJson($val); } return $newArray; }
php
public function encodeArray($array) { $newArray = []; foreach ($array as $key => $val) { $newArray[\camel_case($key)] = $this->encodeJson($val); } return $newArray; }
[ "public", "function", "encodeArray", "(", "$", "array", ")", "{", "$", "newArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "newArray", "[", "\\", "camel_case", "(", "$", "key", ")", "]"...
Encode an array
[ "Encode", "an", "array" ]
9659d3c418c835864648f3ba1c2c42d2769a543c
https://github.com/grohiro/laravel-camelcase-json/blob/9659d3c418c835864648f3ba1c2c42d2769a543c/src/CamelCaseJsonResponseFactory.php#L51-L58
41,701
php-middleware/request-id
src/RequestDecorator.php
RequestDecorator.decorate
public function decorate(RequestInterface $request) { return $request->withHeader($this->headerName, $this->requestIdProvider->getRequestId()); }
php
public function decorate(RequestInterface $request) { return $request->withHeader($this->headerName, $this->requestIdProvider->getRequestId()); }
[ "public", "function", "decorate", "(", "RequestInterface", "$", "request", ")", "{", "return", "$", "request", "->", "withHeader", "(", "$", "this", "->", "headerName", ",", "$", "this", "->", "requestIdProvider", "->", "getRequestId", "(", ")", ")", ";", ...
Adds request id to request and return new instance @param RequestInterface $request @return RequestInterface
[ "Adds", "request", "id", "to", "request", "and", "return", "new", "instance" ]
3936e46a3b533e78125651734fe189be1d94d4d2
https://github.com/php-middleware/request-id/blob/3936e46a3b533e78125651734fe189be1d94d4d2/src/RequestDecorator.php#L25-L28
41,702
adam-paterson/oauth2-slack
src/Provider/Slack.php
Slack.getResourceOwnerDetailsUrl
public function getResourceOwnerDetailsUrl(AccessToken $token) { $authorizedUser = $this->getAuthorizedUser($token); $params = [ 'token' => $token->getToken(), 'user' => $authorizedUser->getId() ]; return 'https://slack.com/api/users.info?'.http_build_query($params); }
php
public function getResourceOwnerDetailsUrl(AccessToken $token) { $authorizedUser = $this->getAuthorizedUser($token); $params = [ 'token' => $token->getToken(), 'user' => $authorizedUser->getId() ]; return 'https://slack.com/api/users.info?'.http_build_query($params); }
[ "public", "function", "getResourceOwnerDetailsUrl", "(", "AccessToken", "$", "token", ")", "{", "$", "authorizedUser", "=", "$", "this", "->", "getAuthorizedUser", "(", "$", "token", ")", ";", "$", "params", "=", "[", "'token'", "=>", "$", "token", "->", "...
Returns the URL for requesting the resource owner's details. @param AccessToken $token @return string
[ "Returns", "the", "URL", "for", "requesting", "the", "resource", "owner", "s", "details", "." ]
f0b4a409c018c9b9623a9377baea14ac36fbb9e9
https://github.com/adam-paterson/oauth2-slack/blob/f0b4a409c018c9b9623a9377baea14ac36fbb9e9/src/Provider/Slack.php#L49-L59
41,703
Elao/PhpEnums
src/FlaggedEnum.php
FlaggedEnum.getBitmask
private static function getBitmask(): int { $enumType = static::class; if (!isset(self::$masks[$enumType])) { $mask = 0; foreach (static::values() as $flag) { if ($flag < 1 || ($flag > 1 && ($flag % 2) !== 0)) { throw new LogicException(sprintf( 'Possible value %s of the enumeration "%s" is not a bit flag.', json_encode($flag), static::class )); } $mask |= $flag; } self::$masks[$enumType] = $mask; } return self::$masks[$enumType]; }
php
private static function getBitmask(): int { $enumType = static::class; if (!isset(self::$masks[$enumType])) { $mask = 0; foreach (static::values() as $flag) { if ($flag < 1 || ($flag > 1 && ($flag % 2) !== 0)) { throw new LogicException(sprintf( 'Possible value %s of the enumeration "%s" is not a bit flag.', json_encode($flag), static::class )); } $mask |= $flag; } self::$masks[$enumType] = $mask; } return self::$masks[$enumType]; }
[ "private", "static", "function", "getBitmask", "(", ")", ":", "int", "{", "$", "enumType", "=", "static", "::", "class", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "masks", "[", "$", "enumType", "]", ")", ")", "{", "$", "mask", "=", "0...
Gets an integer value of the possible flags for enumeration. @throws LogicException If the possibles values are not valid bit flags @return int
[ "Gets", "an", "integer", "value", "of", "the", "possible", "flags", "for", "enumeration", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/FlaggedEnum.php#L111-L131
41,704
Elao/PhpEnums
src/FlaggedEnum.php
FlaggedEnum.getFlags
public function getFlags(): array { if ($this->flags === null) { $this->flags = []; foreach (static::values() as $flag) { if ($this->hasFlag($flag)) { $this->flags[] = $flag; } } } return $this->flags; }
php
public function getFlags(): array { if ($this->flags === null) { $this->flags = []; foreach (static::values() as $flag) { if ($this->hasFlag($flag)) { $this->flags[] = $flag; } } } return $this->flags; }
[ "public", "function", "getFlags", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "flags", "===", "null", ")", "{", "$", "this", "->", "flags", "=", "[", "]", ";", "foreach", "(", "static", "::", "values", "(", ")", "as", "$", "flag", ...
Gets an array of bit flags of the value. @return array
[ "Gets", "an", "array", "of", "bit", "flags", "of", "the", "value", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/FlaggedEnum.php#L148-L160
41,705
Elao/PhpEnums
src/FlaggedEnum.php
FlaggedEnum.hasFlag
public function hasFlag(int $bitFlag): bool { if ($bitFlag >= 1) { return $bitFlag === ($bitFlag & $this->value); } return false; }
php
public function hasFlag(int $bitFlag): bool { if ($bitFlag >= 1) { return $bitFlag === ($bitFlag & $this->value); } return false; }
[ "public", "function", "hasFlag", "(", "int", "$", "bitFlag", ")", ":", "bool", "{", "if", "(", "$", "bitFlag", ">=", "1", ")", "{", "return", "$", "bitFlag", "===", "(", "$", "bitFlag", "&", "$", "this", "->", "value", ")", ";", "}", "return", "f...
Determines whether the specified flag is set in a numeric value. @param int $bitFlag The bit flag or bit flags @return bool True if the bit flag or bit flags are also set in the current instance; otherwise, false
[ "Determines", "whether", "the", "specified", "flag", "is", "set", "in", "a", "numeric", "value", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/FlaggedEnum.php#L169-L176
41,706
Elao/PhpEnums
src/FlaggedEnum.php
FlaggedEnum.withFlags
public function withFlags(int $flags): self { if (!static::accepts($flags)) { throw new InvalidValueException($flags, static::class); } return static::get($this->value | $flags); }
php
public function withFlags(int $flags): self { if (!static::accepts($flags)) { throw new InvalidValueException($flags, static::class); } return static::get($this->value | $flags); }
[ "public", "function", "withFlags", "(", "int", "$", "flags", ")", ":", "self", "{", "if", "(", "!", "static", "::", "accepts", "(", "$", "flags", ")", ")", "{", "throw", "new", "InvalidValueException", "(", "$", "flags", ",", "static", "::", "class", ...
Computes a new value with given flags, and returns the corresponding instance. @param int $flags The bit flag or bit flags @throws InvalidValueException When $flags is not acceptable for this enumeration type @return static The enum instance for computed value
[ "Computes", "a", "new", "value", "with", "given", "flags", "and", "returns", "the", "corresponding", "instance", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/FlaggedEnum.php#L187-L194
41,707
Elao/PhpEnums
src/Bridge/Symfony/Form/DataTransformer/ValueToEnumTransformer.php
ValueToEnumTransformer.transform
public function transform($value) { if ($value === null) { return null; } if (!$value instanceof $this->enumClass) { throw new TransformationFailedException(sprintf( 'Expected instance of "%s". Got "%s".', $this->enumClass, \is_object($value) ? \get_class($value) : \gettype($value) )); } return $value->getValue(); }
php
public function transform($value) { if ($value === null) { return null; } if (!$value instanceof $this->enumClass) { throw new TransformationFailedException(sprintf( 'Expected instance of "%s". Got "%s".', $this->enumClass, \is_object($value) ? \get_class($value) : \gettype($value) )); } return $value->getValue(); }
[ "public", "function", "transform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "value", "instanceof", "$", "this", "->", "enumClass", ")", "{", "throw", "new", "Tra...
Transforms EnumInterface object to a raw enumerated value. @param EnumInterface|null $value EnumInterface instance @throws TransformationFailedException When the transformation fails @return int|string|null Value of EnumInterface
[ "Transforms", "EnumInterface", "object", "to", "a", "raw", "enumerated", "value", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/Bridge/Symfony/Form/DataTransformer/ValueToEnumTransformer.php#L49-L64
41,708
Elao/PhpEnums
src/Bridge/Symfony/Form/DataTransformer/ValueToEnumTransformer.php
ValueToEnumTransformer.reverseTransform
public function reverseTransform($value) { if ($value === null) { return null; } try { return $this->enumClass::get($value); } catch (InvalidValueException $exception) { throw new TransformationFailedException($exception->getMessage(), $exception->getCode(), $exception); } }
php
public function reverseTransform($value) { if ($value === null) { return null; } try { return $this->enumClass::get($value); } catch (InvalidValueException $exception) { throw new TransformationFailedException($exception->getMessage(), $exception->getCode(), $exception); } }
[ "public", "function", "reverseTransform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", "null", ";", "}", "try", "{", "return", "$", "this", "->", "enumClass", "::", "get", "(", "$", "value", ")", ";", "}"...
Transforms a raw enumerated value to an enumeration instance. @param int|string|null $value Value accepted by EnumInterface @throws TransformationFailedException When the transformation fails @return EnumInterface|null A single EnumInterface instance or null
[ "Transforms", "a", "raw", "enumerated", "value", "to", "an", "enumeration", "instance", "." ]
7fae338102f868a070326a9cda3cbd0a9615ebaf
https://github.com/Elao/PhpEnums/blob/7fae338102f868a070326a9cda3cbd0a9615ebaf/src/Bridge/Symfony/Form/DataTransformer/ValueToEnumTransformer.php#L75-L86
41,709
loveorigami/yii2-plugins-system
src/components/View.php
View.doBody
public function doBody() { if ($this->hasEventHandlers(self::EVENT_DO_BODY)) { $event = new ViewEvent([ 'content' => $this->_body, ]); $this->trigger(self::EVENT_DO_BODY, $event); $this->_body = $event->content; } }
php
public function doBody() { if ($this->hasEventHandlers(self::EVENT_DO_BODY)) { $event = new ViewEvent([ 'content' => $this->_body, ]); $this->trigger(self::EVENT_DO_BODY, $event); $this->_body = $event->content; } }
[ "public", "function", "doBody", "(", ")", "{", "if", "(", "$", "this", "->", "hasEventHandlers", "(", "self", "::", "EVENT_DO_BODY", ")", ")", "{", "$", "event", "=", "new", "ViewEvent", "(", "[", "'content'", "=>", "$", "this", "->", "_body", ",", "...
Content manipulation. Need for correct replacement shortcodes
[ "Content", "manipulation", ".", "Need", "for", "correct", "replacement", "shortcodes" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/components/View.php#L28-L37
41,710
loveorigami/yii2-plugins-system
src/controllers/EventController.php
EventController.actionCreate
public function actionCreate() { $model = new Event(); $model->plugin_id = Plugin::EVENTS_CORE; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); } else { return $this->render('create', [ 'model' => $model, ]); } }
php
public function actionCreate() { $model = new Event(); $model->plugin_id = Plugin::EVENTS_CORE; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); } else { return $this->render('create', [ 'model' => $model, ]); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "Event", "(", ")", ";", "$", "model", "->", "plugin_id", "=", "Plugin", "::", "EVENTS_CORE", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "-...
Creates a new Event model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "Event", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/controllers/EventController.php#L62-L74
41,711
loveorigami/yii2-plugins-system
src/shortcodes/ShortcodeParser.php
ShortcodeParser.addIgnoreBlocks
public function addIgnoreBlocks($blocks) { if (is_array($blocks)) { foreach ($blocks as $openTag => $closeTag) { $this->addIgnoreBlock($openTag, $closeTag); } } }
php
public function addIgnoreBlocks($blocks) { if (is_array($blocks)) { foreach ($blocks as $openTag => $closeTag) { $this->addIgnoreBlock($openTag, $closeTag); } } }
[ "public", "function", "addIgnoreBlocks", "(", "$", "blocks", ")", "{", "if", "(", "is_array", "(", "$", "blocks", ")", ")", "{", "foreach", "(", "$", "blocks", "as", "$", "openTag", "=>", "$", "closeTag", ")", "{", "$", "this", "->", "addIgnoreBlock", ...
Add ignore blocks from array @param array $blocks
[ "Add", "ignore", "blocks", "from", "array" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/shortcodes/ShortcodeParser.php#L32-L39
41,712
loveorigami/yii2-plugins-system
src/shortcodes/ShortcodeParser.php
ShortcodeParser.hasShortcode
public function hasShortcode($content, $tag) { if (false === strpos($content, '[')) { return false; } if ($this->existsShortcode($tag)) { return true; } preg_match_all($this->shortcodeRegex(), $content, $matches, PREG_SET_ORDER); if (empty($matches)) { return false; } foreach ($matches as $shortcode) { if ($tag === $shortcode[2]) { return true; } } return false; }
php
public function hasShortcode($content, $tag) { if (false === strpos($content, '[')) { return false; } if ($this->existsShortcode($tag)) { return true; } preg_match_all($this->shortcodeRegex(), $content, $matches, PREG_SET_ORDER); if (empty($matches)) { return false; } foreach ($matches as $shortcode) { if ($tag === $shortcode[2]) { return true; } } return false; }
[ "public", "function", "hasShortcode", "(", "$", "content", ",", "$", "tag", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "content", ",", "'['", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "existsShortcode", ...
Tests whether content has a particular shortcode @param $content @param $tag @return bool
[ "Tests", "whether", "content", "has", "a", "particular", "shortcode" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/shortcodes/ShortcodeParser.php#L151-L174
41,713
loveorigami/yii2-plugins-system
src/shortcodes/ShortcodeParser.php
ShortcodeParser.doShortcode
public function doShortcode($content) { if (false === strpos($content, '[')) { return $content; } if (empty($this->_shortcodes) || !is_array($this->_shortcodes)) return $content; /** * Clear content from ignore blocks */ $pattern = $this->getIgnorePattern(); $content = preg_replace_callback("~$pattern~isu", ['self', '_stack'], $content); /** * parse nested */ $content = $this->parseContent($content); /** * Replase shorcodes in content */ $content = strtr($content, self::_stack()); return $content; }
php
public function doShortcode($content) { if (false === strpos($content, '[')) { return $content; } if (empty($this->_shortcodes) || !is_array($this->_shortcodes)) return $content; /** * Clear content from ignore blocks */ $pattern = $this->getIgnorePattern(); $content = preg_replace_callback("~$pattern~isu", ['self', '_stack'], $content); /** * parse nested */ $content = $this->parseContent($content); /** * Replase shorcodes in content */ $content = strtr($content, self::_stack()); return $content; }
[ "public", "function", "doShortcode", "(", "$", "content", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "content", ",", "'['", ")", ")", "{", "return", "$", "content", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "_shortcodes", ...
Parse shortcodes in given content @param string $content Content to parse for shortcodes @return string
[ "Parse", "shortcodes", "in", "given", "content" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/shortcodes/ShortcodeParser.php#L181-L207
41,714
loveorigami/yii2-plugins-system
src/shortcodes/ShortcodeParser.php
ShortcodeParser.parseContent
protected function parseContent($content) { $content = preg_replace_callback($this->shortcodeRegex(), [$this, 'doShortcodeTag'], $content); if (!$this->isFinishedParse()) { $content = $this->parseContent($content); } return $content; }
php
protected function parseContent($content) { $content = preg_replace_callback($this->shortcodeRegex(), [$this, 'doShortcodeTag'], $content); if (!$this->isFinishedParse()) { $content = $this->parseContent($content); } return $content; }
[ "protected", "function", "parseContent", "(", "$", "content", ")", "{", "$", "content", "=", "preg_replace_callback", "(", "$", "this", "->", "shortcodeRegex", "(", ")", ",", "[", "$", "this", ",", "'doShortcodeTag'", "]", ",", "$", "content", ")", ";", ...
parse nested shortcodes @param $content @return string
[ "parse", "nested", "shortcodes" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/shortcodes/ShortcodeParser.php#L214-L221
41,715
loveorigami/yii2-plugins-system
src/shortcodes/ShortcodeParser.php
ShortcodeParser.getShortcodesFromContent
public function getShortcodesFromContent($content) { $content = $this->getContentWithoutIgnoreBlocks($content); if (false === strpos($content, '[')) { return []; } $result = []; $regex = "\[([A-Za-z_]+[^\ \]]+)"; preg_match_all('/' . $regex . '/', $content, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $match) { $result[$match] = $match; } } if ($result) { return array_keys($result); } return $result; }
php
public function getShortcodesFromContent($content) { $content = $this->getContentWithoutIgnoreBlocks($content); if (false === strpos($content, '[')) { return []; } $result = []; $regex = "\[([A-Za-z_]+[^\ \]]+)"; preg_match_all('/' . $regex . '/', $content, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $match) { $result[$match] = $match; } } if ($result) { return array_keys($result); } return $result; }
[ "public", "function", "getShortcodesFromContent", "(", "$", "content", ")", "{", "$", "content", "=", "$", "this", "->", "getContentWithoutIgnoreBlocks", "(", "$", "content", ")", ";", "if", "(", "false", "===", "strpos", "(", "$", "content", ",", "'['", "...
Get the list of all shortcodes found in given content @param string $content Content to process @return array
[ "Get", "the", "list", "of", "all", "shortcodes", "found", "in", "given", "content" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/shortcodes/ShortcodeParser.php#L305-L329
41,716
loveorigami/yii2-plugins-system
src/repositories/PluginDirRepository.php
PluginDirRepository.populate
protected function populate() { ClassHelper::getAllClasses($this->_dirs, function ($class) { foreach ($this->_methods as $type) { /** @var BasePlugin|BaseShortcode $class */ if (is_callable([$class, $type])) { $this->_data[] = $this->getInfo($class, $type); return $class; } } return null; }); }
php
protected function populate() { ClassHelper::getAllClasses($this->_dirs, function ($class) { foreach ($this->_methods as $type) { /** @var BasePlugin|BaseShortcode $class */ if (is_callable([$class, $type])) { $this->_data[] = $this->getInfo($class, $type); return $class; } } return null; }); }
[ "protected", "function", "populate", "(", ")", "{", "ClassHelper", "::", "getAllClasses", "(", "$", "this", "->", "_dirs", ",", "function", "(", "$", "class", ")", "{", "foreach", "(", "$", "this", "->", "_methods", "as", "$", "type", ")", "{", "/** @v...
populate pool storage
[ "populate", "pool", "storage" ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/repositories/PluginDirRepository.php#L30-L42
41,717
loveorigami/yii2-plugins-system
src/helpers/ShortcodesHelper.php
ShortcodesHelper.shortcodeRegex
public static function shortcodeRegex($shortcodes, $as_key = true) { if (!is_array($shortcodes)) { $shortcodes = (array)$shortcodes; $as_key = false; } $keys = ($as_key) ? array_keys($shortcodes) : $shortcodes; $tagRegex = join('|', array_map('preg_quote', $keys)); return '/' . '\\[' // Opening bracket . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] . "($tagRegex)" // 2: Shortcode name . '(?![\\w-])' // Not followed by word character or hyphen . '(' // 3: Unroll the loop: Inside the opening shortcode tag . '[^\\]\\/]*' // Not a closing bracket or forward slash . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket . '[^\\]\\/]*' // Not a closing bracket or forward slash . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag ... . '\\]' // ... and closing bracket . '|' . '\\]' // Closing bracket . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags . '[^\\[]*+' // Not an opening bracket . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag . '[^\\[]*+' // Not an opening bracket . ')*+' . ')' . '\\[\\/\\2\\]' // Closing shortcode tag . ')?' . ')' . '(\\]?)' // 6: Optional second closing brocket for escaping shortcodes: [[tag]] . '/s'; }
php
public static function shortcodeRegex($shortcodes, $as_key = true) { if (!is_array($shortcodes)) { $shortcodes = (array)$shortcodes; $as_key = false; } $keys = ($as_key) ? array_keys($shortcodes) : $shortcodes; $tagRegex = join('|', array_map('preg_quote', $keys)); return '/' . '\\[' // Opening bracket . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] . "($tagRegex)" // 2: Shortcode name . '(?![\\w-])' // Not followed by word character or hyphen . '(' // 3: Unroll the loop: Inside the opening shortcode tag . '[^\\]\\/]*' // Not a closing bracket or forward slash . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket . '[^\\]\\/]*' // Not a closing bracket or forward slash . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag ... . '\\]' // ... and closing bracket . '|' . '\\]' // Closing bracket . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags . '[^\\[]*+' // Not an opening bracket . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag . '[^\\[]*+' // Not an opening bracket . ')*+' . ')' . '\\[\\/\\2\\]' // Closing shortcode tag . ')?' . ')' . '(\\]?)' // 6: Optional second closing brocket for escaping shortcodes: [[tag]] . '/s'; }
[ "public", "static", "function", "shortcodeRegex", "(", "$", "shortcodes", ",", "$", "as_key", "=", "true", ")", "{", "if", "(", "!", "is_array", "(", "$", "shortcodes", ")", ")", "{", "$", "shortcodes", "=", "(", "array", ")", "$", "shortcodes", ";", ...
Retrieve the shortcode regular expression for searching. The regular expression combines the shortcode tags in the regular expression in a regex class. The regular expression contains 6 different sub matches to help with parsing. 1 - An extra [ to allow for escaping shortcodes with double [[]] 2 - The shortcode name 3 - The shortcode argument list 4 - The self closing / 5 - The content of a shortcode when it wraps some content. 6 - An extra ] to allow for escaping shortcodes with double [[]] @param $shortcodes @param bool $as_key @return string The shortcode search regular expression
[ "Retrieve", "the", "shortcode", "regular", "expression", "for", "searching", ".", "The", "regular", "expression", "combines", "the", "shortcode", "tags", "in", "the", "regular", "expression", "in", "a", "regex", "class", "." ]
9f2d926237910b5ff24d2c6e0993a7f3ba4607f1
https://github.com/loveorigami/yii2-plugins-system/blob/9f2d926237910b5ff24d2c6e0993a7f3ba4607f1/src/helpers/ShortcodesHelper.php#L70-L109
41,718
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.loadFromFile
public function loadFromFile(&$ShapeFile, &$SHPFile, &$DBFFile) { $this->ShapeFile = $ShapeFile; $this->SHPFile = $SHPFile; $this->DBFFile = $DBFFile; $this->_loadHeaders(); /* No header read */ if ($this->read == 0) { return; } switch ($this->shapeType) { case 0: $this->_loadNullRecord(); break; case 1: $this->_loadPointRecord(); break; case 21: $this->_loadPointMRecord(); break; case 11: $this->_loadPointZRecord(); break; case 3: $this->_loadPolyLineRecord(); break; case 23: $this->_loadPolyLineMRecord(); break; case 13: $this->_loadPolyLineZRecord(); break; case 5: $this->_loadPolygonRecord(); break; case 25: $this->_loadPolygonMRecord(); break; case 15: $this->_loadPolygonZRecord(); break; case 8: $this->_loadMultiPointRecord(); break; case 28: $this->_loadMultiPointMRecord(); break; case 18: $this->_loadMultiPointZRecord(); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } /* We need to skip rest of the record */ while ($this->read < $this->size) { $this->_loadData('V', 4); } /* Check if we didn't read too much */ if ($this->read != $this->size) { $this->setError(sprintf('Failed to parse record, read=%d, size=%d', $this->read, $this->size)); } if (ShapeFile::supportsDbase() && isset($this->DBFFile)) { $this->_loadDBFData(); } }
php
public function loadFromFile(&$ShapeFile, &$SHPFile, &$DBFFile) { $this->ShapeFile = $ShapeFile; $this->SHPFile = $SHPFile; $this->DBFFile = $DBFFile; $this->_loadHeaders(); /* No header read */ if ($this->read == 0) { return; } switch ($this->shapeType) { case 0: $this->_loadNullRecord(); break; case 1: $this->_loadPointRecord(); break; case 21: $this->_loadPointMRecord(); break; case 11: $this->_loadPointZRecord(); break; case 3: $this->_loadPolyLineRecord(); break; case 23: $this->_loadPolyLineMRecord(); break; case 13: $this->_loadPolyLineZRecord(); break; case 5: $this->_loadPolygonRecord(); break; case 25: $this->_loadPolygonMRecord(); break; case 15: $this->_loadPolygonZRecord(); break; case 8: $this->_loadMultiPointRecord(); break; case 28: $this->_loadMultiPointMRecord(); break; case 18: $this->_loadMultiPointZRecord(); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } /* We need to skip rest of the record */ while ($this->read < $this->size) { $this->_loadData('V', 4); } /* Check if we didn't read too much */ if ($this->read != $this->size) { $this->setError(sprintf('Failed to parse record, read=%d, size=%d', $this->read, $this->size)); } if (ShapeFile::supportsDbase() && isset($this->DBFFile)) { $this->_loadDBFData(); } }
[ "public", "function", "loadFromFile", "(", "&", "$", "ShapeFile", ",", "&", "$", "SHPFile", ",", "&", "$", "DBFFile", ")", "{", "$", "this", "->", "ShapeFile", "=", "$", "ShapeFile", ";", "$", "this", "->", "SHPFile", "=", "$", "SHPFile", ";", "$", ...
Loads record from files. @param ShapeFile $ShapeFile @param file &$SHPFile Opened SHP file @param file &$DBFFile Opened DBF file
[ "Loads", "record", "from", "files", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L61-L131
41,719
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.saveToFile
public function saveToFile(&$SHPFile, &$DBFFile, $recordNumber) { $this->SHPFile = $SHPFile; $this->DBFFile = $DBFFile; $this->recordNumber = $recordNumber; $this->_saveHeaders(); switch ($this->shapeType) { case 0: // Nothing to save break; case 1: $this->_savePointRecord(); break; case 21: $this->_savePointMRecord(); break; case 11: $this->_savePointZRecord(); break; case 3: $this->_savePolyLineRecord(); break; case 23: $this->_savePolyLineMRecord(); break; case 13: $this->_savePolyLineZRecord(); break; case 5: $this->_savePolygonRecord(); break; case 25: $this->_savePolygonMRecord(); break; case 15: $this->_savePolygonZRecord(); break; case 8: $this->_saveMultiPointRecord(); break; case 28: $this->_saveMultiPointMRecord(); break; case 18: $this->_saveMultiPointZRecord(); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } if (ShapeFile::supportsDbase() && ! is_null($this->DBFFile)) { $this->_saveDBFData(); } }
php
public function saveToFile(&$SHPFile, &$DBFFile, $recordNumber) { $this->SHPFile = $SHPFile; $this->DBFFile = $DBFFile; $this->recordNumber = $recordNumber; $this->_saveHeaders(); switch ($this->shapeType) { case 0: // Nothing to save break; case 1: $this->_savePointRecord(); break; case 21: $this->_savePointMRecord(); break; case 11: $this->_savePointZRecord(); break; case 3: $this->_savePolyLineRecord(); break; case 23: $this->_savePolyLineMRecord(); break; case 13: $this->_savePolyLineZRecord(); break; case 5: $this->_savePolygonRecord(); break; case 25: $this->_savePolygonMRecord(); break; case 15: $this->_savePolygonZRecord(); break; case 8: $this->_saveMultiPointRecord(); break; case 28: $this->_saveMultiPointMRecord(); break; case 18: $this->_saveMultiPointZRecord(); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } if (ShapeFile::supportsDbase() && ! is_null($this->DBFFile)) { $this->_saveDBFData(); } }
[ "public", "function", "saveToFile", "(", "&", "$", "SHPFile", ",", "&", "$", "DBFFile", ",", "$", "recordNumber", ")", "{", "$", "this", "->", "SHPFile", "=", "$", "SHPFile", ";", "$", "this", "->", "DBFFile", "=", "$", "DBFFile", ";", "$", "this", ...
Saves record to files. @param file &$SHPFile Opened SHP file @param file &$DBFFile Opened DBF file @param int $recordNumber Record number
[ "Saves", "record", "to", "files", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L140-L194
41,720
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.updateDBFInfo
public function updateDBFInfo($header) { $tmp = $this->DBFData; unset($this->DBFData); $this->DBFData = []; foreach ($header as $value) { $this->DBFData[$value[0]] = (isset($tmp[$value[0]])) ? $tmp[$value[0]] : ''; } }
php
public function updateDBFInfo($header) { $tmp = $this->DBFData; unset($this->DBFData); $this->DBFData = []; foreach ($header as $value) { $this->DBFData[$value[0]] = (isset($tmp[$value[0]])) ? $tmp[$value[0]] : ''; } }
[ "public", "function", "updateDBFInfo", "(", "$", "header", ")", "{", "$", "tmp", "=", "$", "this", "->", "DBFData", ";", "unset", "(", "$", "this", "->", "DBFData", ")", ";", "$", "this", "->", "DBFData", "=", "[", "]", ";", "foreach", "(", "$", ...
Updates DBF data to match header. @param array $header DBF structure header
[ "Updates", "DBF", "data", "to", "match", "header", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L201-L209
41,721
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord._loadHeaders
private function _loadHeaders() { $this->shapeType = false; $this->recordNumber = $this->_loadData('N', 4); if ($this->recordNumber === false) { return; } // We read the length of the record $this->size = $this->_loadData('N', 4); if ($this->size === false) { return; } $this->size = $this->size * 2 + 8; $this->shapeType = $this->_loadData('V', 4); }
php
private function _loadHeaders() { $this->shapeType = false; $this->recordNumber = $this->_loadData('N', 4); if ($this->recordNumber === false) { return; } // We read the length of the record $this->size = $this->_loadData('N', 4); if ($this->size === false) { return; } $this->size = $this->size * 2 + 8; $this->shapeType = $this->_loadData('V', 4); }
[ "private", "function", "_loadHeaders", "(", ")", "{", "$", "this", "->", "shapeType", "=", "false", ";", "$", "this", "->", "recordNumber", "=", "$", "this", "->", "_loadData", "(", "'N'", ",", "4", ")", ";", "if", "(", "$", "this", "->", "recordNumb...
Loads metadata header from a file.
[ "Loads", "metadata", "header", "from", "a", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L233-L247
41,722
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord._saveHeaders
private function _saveHeaders() { fwrite($this->SHPFile, pack('N', $this->recordNumber)); fwrite($this->SHPFile, pack('N', $this->getContentLength())); fwrite($this->SHPFile, pack('V', $this->shapeType)); }
php
private function _saveHeaders() { fwrite($this->SHPFile, pack('N', $this->recordNumber)); fwrite($this->SHPFile, pack('N', $this->getContentLength())); fwrite($this->SHPFile, pack('V', $this->shapeType)); }
[ "private", "function", "_saveHeaders", "(", ")", "{", "fwrite", "(", "$", "this", "->", "SHPFile", ",", "pack", "(", "'N'", ",", "$", "this", "->", "recordNumber", ")", ")", ";", "fwrite", "(", "$", "this", "->", "SHPFile", ",", "pack", "(", "'N'", ...
Saves metadata header to a file.
[ "Saves", "metadata", "header", "to", "a", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L252-L257
41,723
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord._adjustPoint
private function _adjustPoint($point) { $type = $this->shapeType / 10; if ($type >= 2) { $point = $this->_fixPoint($point, 'm'); } elseif ($type >= 1) { $point = $this->_fixPoint($point, 'z'); $point = $this->_fixPoint($point, 'm'); } return $point; }
php
private function _adjustPoint($point) { $type = $this->shapeType / 10; if ($type >= 2) { $point = $this->_fixPoint($point, 'm'); } elseif ($type >= 1) { $point = $this->_fixPoint($point, 'z'); $point = $this->_fixPoint($point, 'm'); } return $point; }
[ "private", "function", "_adjustPoint", "(", "$", "point", ")", "{", "$", "type", "=", "$", "this", "->", "shapeType", "/", "10", ";", "if", "(", "$", "type", ">=", "2", ")", "{", "$", "point", "=", "$", "this", "->", "_fixPoint", "(", "$", "point...
Adjust point and bounding box when adding point. @param array $point Point data @return array Fixed point data
[ "Adjust", "point", "and", "bounding", "box", "when", "adding", "point", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L628-L639
41,724
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.addPoint
public function addPoint($point, $partIndex = 0) { $point = $this->_adjustPoint($point); switch ($this->shapeType) { case 0: //Don't add anything return; case 1: case 11: case 21: //Substitutes the value of the current point $this->SHPData = $point; break; case 3: case 5: case 13: case 15: case 23: case 25: //Adds a new point to the selected part $this->SHPData['parts'][$partIndex]['points'][] = $point; $this->SHPData['numparts'] = count($this->SHPData['parts']); $this->SHPData['numpoints'] = 1 + (isset($this->SHPData['numpoints']) ? $this->SHPData['numpoints'] : 0); break; case 8: case 18: case 28: //Adds a new point $this->SHPData['points'][] = $point; $this->SHPData['numpoints'] = 1 + (isset($this->SHPData['numpoints']) ? $this->SHPData['numpoints'] : 0); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); return; } $this->_adjustBBox($point); }
php
public function addPoint($point, $partIndex = 0) { $point = $this->_adjustPoint($point); switch ($this->shapeType) { case 0: //Don't add anything return; case 1: case 11: case 21: //Substitutes the value of the current point $this->SHPData = $point; break; case 3: case 5: case 13: case 15: case 23: case 25: //Adds a new point to the selected part $this->SHPData['parts'][$partIndex]['points'][] = $point; $this->SHPData['numparts'] = count($this->SHPData['parts']); $this->SHPData['numpoints'] = 1 + (isset($this->SHPData['numpoints']) ? $this->SHPData['numpoints'] : 0); break; case 8: case 18: case 28: //Adds a new point $this->SHPData['points'][] = $point; $this->SHPData['numpoints'] = 1 + (isset($this->SHPData['numpoints']) ? $this->SHPData['numpoints'] : 0); break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); return; } $this->_adjustBBox($point); }
[ "public", "function", "addPoint", "(", "$", "point", ",", "$", "partIndex", "=", "0", ")", "{", "$", "point", "=", "$", "this", "->", "_adjustPoint", "(", "$", "point", ")", ";", "switch", "(", "$", "this", "->", "shapeType", ")", "{", "case", "0",...
Adds point to a record. @param array $point Point data @param int $partIndex Part index
[ "Adds", "point", "to", "a", "record", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L647-L684
41,725
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.deletePoint
public function deletePoint($pointIndex = 0, $partIndex = 0) { switch ($this->shapeType) { case 0: //Don't delete anything break; case 1: case 11: case 21: //Sets the value of the point to zero $this->SHPData['x'] = 0.0; $this->SHPData['y'] = 0.0; if (in_array($this->shapeType, [11, 21])) { $this->SHPData['m'] = 0.0; } if (in_array($this->shapeType, [11])) { $this->SHPData['z'] = 0.0; } break; case 3: case 5: case 13: case 15: case 23: case 25: //Deletes the point from the selected part, if exists if (isset($this->SHPData['parts'][$partIndex]) && isset($this->SHPData['parts'][$partIndex]['points'][$pointIndex])) { $count = count($this->SHPData['parts'][$partIndex]['points']) - 1; for ($i = $pointIndex; $i < $count; ++$i) { $this->SHPData['parts'][$partIndex]['points'][$i] = $this->SHPData['parts'][$partIndex]['points'][$i + 1]; } unset($this->SHPData['parts'][$partIndex]['points'][count($this->SHPData['parts'][$partIndex]['points']) - 1]); $this->SHPData['numparts'] = count($this->SHPData['parts']); --$this->SHPData['numpoints']; } break; case 8: case 18: case 28: //Deletes the point, if exists if (isset($this->SHPData['points'][$pointIndex])) { $count = count($this->SHPData['points']) - 1; for ($i = $pointIndex; $i < $count; ++$i) { $this->SHPData['points'][$i] = $this->SHPData['points'][$i + 1]; } unset($this->SHPData['points'][count($this->SHPData['points']) - 1]); --$this->SHPData['numpoints']; } break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } }
php
public function deletePoint($pointIndex = 0, $partIndex = 0) { switch ($this->shapeType) { case 0: //Don't delete anything break; case 1: case 11: case 21: //Sets the value of the point to zero $this->SHPData['x'] = 0.0; $this->SHPData['y'] = 0.0; if (in_array($this->shapeType, [11, 21])) { $this->SHPData['m'] = 0.0; } if (in_array($this->shapeType, [11])) { $this->SHPData['z'] = 0.0; } break; case 3: case 5: case 13: case 15: case 23: case 25: //Deletes the point from the selected part, if exists if (isset($this->SHPData['parts'][$partIndex]) && isset($this->SHPData['parts'][$partIndex]['points'][$pointIndex])) { $count = count($this->SHPData['parts'][$partIndex]['points']) - 1; for ($i = $pointIndex; $i < $count; ++$i) { $this->SHPData['parts'][$partIndex]['points'][$i] = $this->SHPData['parts'][$partIndex]['points'][$i + 1]; } unset($this->SHPData['parts'][$partIndex]['points'][count($this->SHPData['parts'][$partIndex]['points']) - 1]); $this->SHPData['numparts'] = count($this->SHPData['parts']); --$this->SHPData['numpoints']; } break; case 8: case 18: case 28: //Deletes the point, if exists if (isset($this->SHPData['points'][$pointIndex])) { $count = count($this->SHPData['points']) - 1; for ($i = $pointIndex; $i < $count; ++$i) { $this->SHPData['points'][$i] = $this->SHPData['points'][$i + 1]; } unset($this->SHPData['points'][count($this->SHPData['points']) - 1]); --$this->SHPData['numpoints']; } break; default: $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } }
[ "public", "function", "deletePoint", "(", "$", "pointIndex", "=", "0", ",", "$", "partIndex", "=", "0", ")", "{", "switch", "(", "$", "this", "->", "shapeType", ")", "{", "case", "0", ":", "//Don't delete anything", "break", ";", "case", "1", ":", "cas...
Deletes point from a record. @param int $pointIndex Point index @param int $partIndex Part index
[ "Deletes", "point", "from", "a", "record", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L692-L747
41,726
phpmyadmin/shapefile
src/ShapeRecord.php
ShapeRecord.getContentLength
public function getContentLength() { // The content length for a record is the length of the record contents section measured in 16-bit words. // one coordinate makes 4 16-bit words (64 bit double) switch ($this->shapeType) { case 0: $result = 0; break; case 1: $result = 10; break; case 21: $result = 10 + 4; break; case 11: $result = 10 + 8; break; case 3: case 5: $count = count($this->SHPData['parts']); $result = 22 + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += 8 * count($this->SHPData['parts'][$i]['points']); } break; case 23: case 25: $count = count($this->SHPData['parts']); $result = 22 + (2 * 4) + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += (8 + 4) * count($this->SHPData['parts'][$i]['points']); } break; case 13: case 15: $count = count($this->SHPData['parts']); $result = 22 + (4 * 4) + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += (8 + 8) * count($this->SHPData['parts'][$i]['points']); } break; case 8: $result = 20 + 8 * count($this->SHPData['points']); break; case 28: $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData['points']); break; case 18: $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData['points']); break; default: $result = false; $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } return $result; }
php
public function getContentLength() { // The content length for a record is the length of the record contents section measured in 16-bit words. // one coordinate makes 4 16-bit words (64 bit double) switch ($this->shapeType) { case 0: $result = 0; break; case 1: $result = 10; break; case 21: $result = 10 + 4; break; case 11: $result = 10 + 8; break; case 3: case 5: $count = count($this->SHPData['parts']); $result = 22 + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += 8 * count($this->SHPData['parts'][$i]['points']); } break; case 23: case 25: $count = count($this->SHPData['parts']); $result = 22 + (2 * 4) + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += (8 + 4) * count($this->SHPData['parts'][$i]['points']); } break; case 13: case 15: $count = count($this->SHPData['parts']); $result = 22 + (4 * 4) + 2 * $count; for ($i = 0; $i < $count; ++$i) { $result += (8 + 8) * count($this->SHPData['parts'][$i]['points']); } break; case 8: $result = 20 + 8 * count($this->SHPData['points']); break; case 28: $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData['points']); break; case 18: $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData['points']); break; default: $result = false; $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)); break; } return $result; }
[ "public", "function", "getContentLength", "(", ")", "{", "// The content length for a record is the length of the record contents section measured in 16-bit words.", "// one coordinate makes 4 16-bit words (64 bit double)", "switch", "(", "$", "this", "->", "shapeType", ")", "{", "ca...
Returns length of content. @return int
[ "Returns", "length", "of", "content", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeRecord.php#L754-L811
41,727
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.saveToFile
public function saveToFile($FileName = null) { if (! is_null($FileName)) { $this->FileName = $FileName; } if (($this->_openSHPFile(true)) && ($this->_openSHXFile(true)) && ($this->_createDBFFile())) { $this->_saveHeaders(); $this->_saveRecords(); $this->_closeSHPFile(); $this->_closeSHXFile(); $this->_closeDBFFile(); } else { return false; } }
php
public function saveToFile($FileName = null) { if (! is_null($FileName)) { $this->FileName = $FileName; } if (($this->_openSHPFile(true)) && ($this->_openSHXFile(true)) && ($this->_createDBFFile())) { $this->_saveHeaders(); $this->_saveRecords(); $this->_closeSHPFile(); $this->_closeSHXFile(); $this->_closeDBFFile(); } else { return false; } }
[ "public", "function", "saveToFile", "(", "$", "FileName", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "FileName", ")", ")", "{", "$", "this", "->", "FileName", "=", "$", "FileName", ";", "}", "if", "(", "(", "$", "this", "->", "_o...
Saves shapefile. @param string|null $FileName Name of file, otherwise existing is used
[ "Saves", "shapefile", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L127-L142
41,728
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.updateBBox
private function updateBBox($type, $data) { $min = $type . 'min'; $max = $type . 'max'; if (! isset($this->boundingBox[$min]) || $this->boundingBox[$min] == 0.0 || ($this->boundingBox[$min] > $data[$min])) { $this->boundingBox[$min] = $data[$min]; } if (! isset($this->boundingBox[$max]) || $this->boundingBox[$max] == 0.0 || ($this->boundingBox[$max] < $data[$max])) { $this->boundingBox[$max] = $data[$max]; } }
php
private function updateBBox($type, $data) { $min = $type . 'min'; $max = $type . 'max'; if (! isset($this->boundingBox[$min]) || $this->boundingBox[$min] == 0.0 || ($this->boundingBox[$min] > $data[$min])) { $this->boundingBox[$min] = $data[$min]; } if (! isset($this->boundingBox[$max]) || $this->boundingBox[$max] == 0.0 || ($this->boundingBox[$max] < $data[$max])) { $this->boundingBox[$max] = $data[$max]; } }
[ "private", "function", "updateBBox", "(", "$", "type", ",", "$", "data", ")", "{", "$", "min", "=", "$", "type", ".", "'min'", ";", "$", "max", "=", "$", "type", ".", "'max'", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "boundingBox", ...
Updates bounding box based on SHPData. @param string $type Type of box @param array $data ShapeRecord SHPData
[ "Updates", "bounding", "box", "based", "on", "SHPData", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L162-L173
41,729
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.addRecord
public function addRecord($record) { if ((isset($this->DBFHeader)) && (is_array($this->DBFHeader))) { $record->updateDBFInfo($this->DBFHeader); } $this->fileLength += ($record->getContentLength() + 4); $this->records[] = $record; $this->records[count($this->records) - 1]->recordNumber = count($this->records); $this->updateBBox('x', $record->SHPData); $this->updateBBox('y', $record->SHPData); if (in_array($this->shapeType, [11, 13, 15, 18, 21, 23, 25, 28])) { $this->updateBBox('m', $record->SHPData); } if (in_array($this->shapeType, [11, 13, 15, 18])) { $this->updateBBox('z', $record->SHPData); } return count($this->records) - 1; }
php
public function addRecord($record) { if ((isset($this->DBFHeader)) && (is_array($this->DBFHeader))) { $record->updateDBFInfo($this->DBFHeader); } $this->fileLength += ($record->getContentLength() + 4); $this->records[] = $record; $this->records[count($this->records) - 1]->recordNumber = count($this->records); $this->updateBBox('x', $record->SHPData); $this->updateBBox('y', $record->SHPData); if (in_array($this->shapeType, [11, 13, 15, 18, 21, 23, 25, 28])) { $this->updateBBox('m', $record->SHPData); } if (in_array($this->shapeType, [11, 13, 15, 18])) { $this->updateBBox('z', $record->SHPData); } return count($this->records) - 1; }
[ "public", "function", "addRecord", "(", "$", "record", ")", "{", "if", "(", "(", "isset", "(", "$", "this", "->", "DBFHeader", ")", ")", "&&", "(", "is_array", "(", "$", "this", "->", "DBFHeader", ")", ")", ")", "{", "$", "record", "->", "updateDBF...
Adds record to shape file. @param ShapeRecord $record @return int Number of added record
[ "Adds", "record", "to", "shape", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L182-L204
41,730
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.deleteRecord
public function deleteRecord($index) { if (isset($this->records[$index])) { $this->fileLength -= ($this->records[$index]->getContentLength() + 4); $count = count($this->records) - 1; for ($i = $index; $i < $count; ++$i) { $this->records[$i] = $this->records[$i + 1]; } unset($this->records[count($this->records) - 1]); $this->_deleteRecordFromDBF($index); } }
php
public function deleteRecord($index) { if (isset($this->records[$index])) { $this->fileLength -= ($this->records[$index]->getContentLength() + 4); $count = count($this->records) - 1; for ($i = $index; $i < $count; ++$i) { $this->records[$i] = $this->records[$i + 1]; } unset($this->records[count($this->records) - 1]); $this->_deleteRecordFromDBF($index); } }
[ "public", "function", "deleteRecord", "(", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "records", "[", "$", "index", "]", ")", ")", "{", "$", "this", "->", "fileLength", "-=", "(", "$", "this", "->", "records", "[", "$", "...
Deletes record from shapefile. @param int $index
[ "Deletes", "record", "from", "shapefile", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L211-L222
41,731
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.setDBFHeader
public function setDBFHeader($header) { $this->DBFHeader = $header; $count = count($this->records); for ($i = 0; $i < $count; ++$i) { $this->records[$i]->updateDBFInfo($header); } }
php
public function setDBFHeader($header) { $this->DBFHeader = $header; $count = count($this->records); for ($i = 0; $i < $count; ++$i) { $this->records[$i]->updateDBFInfo($header); } }
[ "public", "function", "setDBFHeader", "(", "$", "header", ")", "{", "$", "this", "->", "DBFHeader", "=", "$", "header", ";", "$", "count", "=", "count", "(", "$", "this", "->", "records", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", ...
Changes array defining fields in DBF file, used in dbase_create call. @param array $header An array of arrays, each array describing the format of one field of the database. Each field consists of a name, a character indicating the field type, and optionally, a length, a precision and a nullable flag.
[ "Changes", "array", "defining", "fields", "in", "DBF", "file", "used", "in", "dbase_create", "call", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L243-L251
41,732
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile.getIndexFromDBFData
public function getIndexFromDBFData($field, $value) { foreach ($this->records as $index => $record) { if (isset($record->DBFData[$field]) && (trim(strtoupper($record->DBFData[$field])) == strtoupper($value)) ) { return $index; } } return -1; }
php
public function getIndexFromDBFData($field, $value) { foreach ($this->records as $index => $record) { if (isset($record->DBFData[$field]) && (trim(strtoupper($record->DBFData[$field])) == strtoupper($value)) ) { return $index; } } return -1; }
[ "public", "function", "getIndexFromDBFData", "(", "$", "field", ",", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "records", "as", "$", "index", "=>", "$", "record", ")", "{", "if", "(", "isset", "(", "$", "record", "->", "DBFData", "["...
Lookups value in the DBF file and returs index. @param string $field Field to match @param mixed $value Value to match @return int
[ "Lookups", "value", "in", "the", "DBF", "file", "and", "returs", "index", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L261-L272
41,733
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._loadDBFHeader
private function _loadDBFHeader() { $DBFFile = fopen($this->_getFilename('.dbf'), 'r'); $result = []; $i = 1; $inHeader = true; while ($inHeader) { if (! feof($DBFFile)) { $buff32 = fread($DBFFile, 32); if ($i > 1) { if (substr($buff32, 0, 1) == chr(13)) { $inHeader = false; } else { $pos = strpos(substr($buff32, 0, 10), chr(0)); $pos = ($pos == 0 ? 10 : $pos); $fieldName = substr($buff32, 0, $pos); $fieldType = substr($buff32, 11, 1); $fieldLen = ord(substr($buff32, 16, 1)); $fieldDec = ord(substr($buff32, 17, 1)); array_push($result, [$fieldName, $fieldType, $fieldLen, $fieldDec]); } } ++$i; } else { $inHeader = false; } } fclose($DBFFile); return $result; }
php
private function _loadDBFHeader() { $DBFFile = fopen($this->_getFilename('.dbf'), 'r'); $result = []; $i = 1; $inHeader = true; while ($inHeader) { if (! feof($DBFFile)) { $buff32 = fread($DBFFile, 32); if ($i > 1) { if (substr($buff32, 0, 1) == chr(13)) { $inHeader = false; } else { $pos = strpos(substr($buff32, 0, 10), chr(0)); $pos = ($pos == 0 ? 10 : $pos); $fieldName = substr($buff32, 0, $pos); $fieldType = substr($buff32, 11, 1); $fieldLen = ord(substr($buff32, 16, 1)); $fieldDec = ord(substr($buff32, 17, 1)); array_push($result, [$fieldName, $fieldType, $fieldLen, $fieldDec]); } } ++$i; } else { $inHeader = false; } } fclose($DBFFile); return $result; }
[ "private", "function", "_loadDBFHeader", "(", ")", "{", "$", "DBFFile", "=", "fopen", "(", "$", "this", "->", "_getFilename", "(", "'.dbf'", ")", ",", "'r'", ")", ";", "$", "result", "=", "[", "]", ";", "$", "i", "=", "1", ";", "$", "inHeader", "...
Loads DBF metadata.
[ "Loads", "DBF", "metadata", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L277-L312
41,734
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._deleteRecordFromDBF
private function _deleteRecordFromDBF($index) { if ($this->DBFFile !== null && @dbase_delete_record($this->DBFFile, $index)) { dbase_pack($this->DBFFile); } }
php
private function _deleteRecordFromDBF($index) { if ($this->DBFFile !== null && @dbase_delete_record($this->DBFFile, $index)) { dbase_pack($this->DBFFile); } }
[ "private", "function", "_deleteRecordFromDBF", "(", "$", "index", ")", "{", "if", "(", "$", "this", "->", "DBFFile", "!==", "null", "&&", "@", "dbase_delete_record", "(", "$", "this", "->", "DBFFile", ",", "$", "index", ")", ")", "{", "dbase_pack", "(", ...
Deletes record from the DBF file. @param int $index
[ "Deletes", "record", "from", "the", "DBF", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L319-L324
41,735
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._loadHeaders
private function _loadHeaders() { if (Util::loadData('N', $this->readSHP(4)) != self::MAGIC) { $this->setError('Not a SHP file (file code mismatch)'); return false; } /* Skip 20 unused bytes */ $this->readSHP(20); $this->fileLength = Util::loadData('N', $this->readSHP(4)); /* We currently ignore version */ $this->readSHP(4); $this->shapeType = Util::loadData('V', $this->readSHP(4)); $this->boundingBox = []; $this->boundingBox['xmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['ymin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['xmax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['ymax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['zmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['zmax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['mmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['mmax'] = Util::loadData('d', $this->readSHP(8)); if (self::supportsDbase()) { $this->DBFHeader = $this->_loadDBFHeader(); } return true; }
php
private function _loadHeaders() { if (Util::loadData('N', $this->readSHP(4)) != self::MAGIC) { $this->setError('Not a SHP file (file code mismatch)'); return false; } /* Skip 20 unused bytes */ $this->readSHP(20); $this->fileLength = Util::loadData('N', $this->readSHP(4)); /* We currently ignore version */ $this->readSHP(4); $this->shapeType = Util::loadData('V', $this->readSHP(4)); $this->boundingBox = []; $this->boundingBox['xmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['ymin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['xmax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['ymax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['zmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['zmax'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['mmin'] = Util::loadData('d', $this->readSHP(8)); $this->boundingBox['mmax'] = Util::loadData('d', $this->readSHP(8)); if (self::supportsDbase()) { $this->DBFHeader = $this->_loadDBFHeader(); } return true; }
[ "private", "function", "_loadHeaders", "(", ")", "{", "if", "(", "Util", "::", "loadData", "(", "'N'", ",", "$", "this", "->", "readSHP", "(", "4", ")", ")", "!=", "self", "::", "MAGIC", ")", "{", "$", "this", "->", "setError", "(", "'Not a SHP file ...
Loads SHP file metadata. @return bool
[ "Loads", "SHP", "file", "metadata", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L331-L364
41,736
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._saveBBoxRecord
private function _saveBBoxRecord($file, $type) { fwrite($file, Util::packDouble( isset($this->boundingBox[$type]) ? $this->boundingBox[$type] : 0 )); }
php
private function _saveBBoxRecord($file, $type) { fwrite($file, Util::packDouble( isset($this->boundingBox[$type]) ? $this->boundingBox[$type] : 0 )); }
[ "private", "function", "_saveBBoxRecord", "(", "$", "file", ",", "$", "type", ")", "{", "fwrite", "(", "$", "file", ",", "Util", "::", "packDouble", "(", "isset", "(", "$", "this", "->", "boundingBox", "[", "$", "type", "]", ")", "?", "$", "this", ...
Saves bounding box record, possibly using 0 instead of not set values. @param file $file File object @param string $type Bounding box dimension (eg. xmax, mmin...)
[ "Saves", "bounding", "box", "record", "possibly", "using", "0", "instead", "of", "not", "set", "values", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L372-L377
41,737
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._saveBBox
private function _saveBBox($file) { $this->_saveBBoxRecord($file, 'xmin'); $this->_saveBBoxRecord($file, 'ymin'); $this->_saveBBoxRecord($file, 'xmax'); $this->_saveBBoxRecord($file, 'ymax'); $this->_saveBBoxRecord($file, 'zmin'); $this->_saveBBoxRecord($file, 'zmax'); $this->_saveBBoxRecord($file, 'mmin'); $this->_saveBBoxRecord($file, 'mmax'); }
php
private function _saveBBox($file) { $this->_saveBBoxRecord($file, 'xmin'); $this->_saveBBoxRecord($file, 'ymin'); $this->_saveBBoxRecord($file, 'xmax'); $this->_saveBBoxRecord($file, 'ymax'); $this->_saveBBoxRecord($file, 'zmin'); $this->_saveBBoxRecord($file, 'zmax'); $this->_saveBBoxRecord($file, 'mmin'); $this->_saveBBoxRecord($file, 'mmax'); }
[ "private", "function", "_saveBBox", "(", "$", "file", ")", "{", "$", "this", "->", "_saveBBoxRecord", "(", "$", "file", ",", "'xmin'", ")", ";", "$", "this", "->", "_saveBBoxRecord", "(", "$", "file", ",", "'ymin'", ")", ";", "$", "this", "->", "_sav...
Saves bounding box to a file. @param file $file File object
[ "Saves", "bounding", "box", "to", "a", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L384-L394
41,738
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._saveHeaders
private function _saveHeaders() { fwrite($this->SHPFile, pack('NNNNNN', self::MAGIC, 0, 0, 0, 0, 0)); fwrite($this->SHPFile, pack('N', $this->fileLength)); fwrite($this->SHPFile, pack('V', 1000)); fwrite($this->SHPFile, pack('V', $this->shapeType)); $this->_saveBBox($this->SHPFile); fwrite($this->SHXFile, pack('NNNNNN', self::MAGIC, 0, 0, 0, 0, 0)); fwrite($this->SHXFile, pack('N', 50 + 4 * count($this->records))); fwrite($this->SHXFile, pack('V', 1000)); fwrite($this->SHXFile, pack('V', $this->shapeType)); $this->_saveBBox($this->SHXFile); }
php
private function _saveHeaders() { fwrite($this->SHPFile, pack('NNNNNN', self::MAGIC, 0, 0, 0, 0, 0)); fwrite($this->SHPFile, pack('N', $this->fileLength)); fwrite($this->SHPFile, pack('V', 1000)); fwrite($this->SHPFile, pack('V', $this->shapeType)); $this->_saveBBox($this->SHPFile); fwrite($this->SHXFile, pack('NNNNNN', self::MAGIC, 0, 0, 0, 0, 0)); fwrite($this->SHXFile, pack('N', 50 + 4 * count($this->records))); fwrite($this->SHXFile, pack('V', 1000)); fwrite($this->SHXFile, pack('V', $this->shapeType)); $this->_saveBBox($this->SHXFile); }
[ "private", "function", "_saveHeaders", "(", ")", "{", "fwrite", "(", "$", "this", "->", "SHPFile", ",", "pack", "(", "'NNNNNN'", ",", "self", "::", "MAGIC", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ")", ")", ";", "fwrite", "(", "$", "t...
Saves SHP and SHX file metadata.
[ "Saves", "SHP", "and", "SHX", "file", "metadata", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L399-L412
41,739
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._saveRecords
private function _saveRecords() { $offset = 50; if (is_array($this->records) && (count($this->records) > 0)) { foreach ($this->records as $index => $record) { //Save the record to the .shp file $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1); //Save the record to the .shx file fwrite($this->SHXFile, pack('N', $offset)); fwrite($this->SHXFile, pack('N', $record->getContentLength())); $offset += (4 + $record->getContentLength()); } } }
php
private function _saveRecords() { $offset = 50; if (is_array($this->records) && (count($this->records) > 0)) { foreach ($this->records as $index => $record) { //Save the record to the .shp file $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1); //Save the record to the .shx file fwrite($this->SHXFile, pack('N', $offset)); fwrite($this->SHXFile, pack('N', $record->getContentLength())); $offset += (4 + $record->getContentLength()); } } }
[ "private", "function", "_saveRecords", "(", ")", "{", "$", "offset", "=", "50", ";", "if", "(", "is_array", "(", "$", "this", "->", "records", ")", "&&", "(", "count", "(", "$", "this", "->", "records", ")", ">", "0", ")", ")", "{", "foreach", "(...
Saves records to SHP and SHX files.
[ "Saves", "records", "to", "SHP", "and", "SHX", "files", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L443-L457
41,740
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._openFile
private function _openFile($toWrite, $extension, $name) { $shp_name = $this->_getFilename($extension); $result = @fopen($shp_name, ($toWrite ? 'wb+' : 'rb')); if (! $result) { $this->setError(sprintf('It wasn\'t possible to open the %s file "%s"', $name, $shp_name)); return false; } return $result; }
php
private function _openFile($toWrite, $extension, $name) { $shp_name = $this->_getFilename($extension); $result = @fopen($shp_name, ($toWrite ? 'wb+' : 'rb')); if (! $result) { $this->setError(sprintf('It wasn\'t possible to open the %s file "%s"', $name, $shp_name)); return false; } return $result; }
[ "private", "function", "_openFile", "(", "$", "toWrite", ",", "$", "extension", ",", "$", "name", ")", "{", "$", "shp_name", "=", "$", "this", "->", "_getFilename", "(", "$", "extension", ")", ";", "$", "result", "=", "@", "fopen", "(", "$", "shp_nam...
Generic interface to open files. @param bool $toWrite Whether file should be opened for writing @param string $extension File extension @param string $name Verbose file name to report errors @return file|false File handle
[ "Generic", "interface", "to", "open", "files", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L468-L479
41,741
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._openSHPFile
private function _openSHPFile($toWrite = false) { $this->SHPFile = $this->_openFile($toWrite, '.shp', 'Shape'); if (! $this->SHPFile) { return false; } return true; }
php
private function _openSHPFile($toWrite = false) { $this->SHPFile = $this->_openFile($toWrite, '.shp', 'Shape'); if (! $this->SHPFile) { return false; } return true; }
[ "private", "function", "_openSHPFile", "(", "$", "toWrite", "=", "false", ")", "{", "$", "this", "->", "SHPFile", "=", "$", "this", "->", "_openFile", "(", "$", "toWrite", ",", "'.shp'", ",", "'Shape'", ")", ";", "if", "(", "!", "$", "this", "->", ...
Opens SHP file. @param bool $toWrite Whether file should be opened for writing @return bool
[ "Opens", "SHP", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L488-L496
41,742
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._openSHXFile
private function _openSHXFile($toWrite = false) { $this->SHXFile = $this->_openFile($toWrite, '.shx', 'Index'); if (! $this->SHXFile) { return false; } return true; }
php
private function _openSHXFile($toWrite = false) { $this->SHXFile = $this->_openFile($toWrite, '.shx', 'Index'); if (! $this->SHXFile) { return false; } return true; }
[ "private", "function", "_openSHXFile", "(", "$", "toWrite", "=", "false", ")", "{", "$", "this", "->", "SHXFile", "=", "$", "this", "->", "_openFile", "(", "$", "toWrite", ",", "'.shx'", ",", "'Index'", ")", ";", "if", "(", "!", "$", "this", "->", ...
Opens SHX file. @param bool $toWrite Whether file should be opened for writing @return bool
[ "Opens", "SHX", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L516-L524
41,743
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._createDBFFile
private function _createDBFFile() { if (! self::supportsDbase() || ! is_array($this->DBFHeader) || count($this->DBFHeader) == 0) { $this->DBFFile = null; return true; } $dbf_name = $this->_getFilename('.dbf'); /* Unlink existing file */ if (file_exists($dbf_name)) { unlink($dbf_name); } /* Create new file */ $this->DBFFile = @dbase_create($dbf_name, $this->DBFHeader); if ($this->DBFFile === false) { $this->setError(sprintf('It wasn\'t possible to create the DBase file "%s"', $dbf_name)); return false; } return true; }
php
private function _createDBFFile() { if (! self::supportsDbase() || ! is_array($this->DBFHeader) || count($this->DBFHeader) == 0) { $this->DBFFile = null; return true; } $dbf_name = $this->_getFilename('.dbf'); /* Unlink existing file */ if (file_exists($dbf_name)) { unlink($dbf_name); } /* Create new file */ $this->DBFFile = @dbase_create($dbf_name, $this->DBFHeader); if ($this->DBFFile === false) { $this->setError(sprintf('It wasn\'t possible to create the DBase file "%s"', $dbf_name)); return false; } return true; }
[ "private", "function", "_createDBFFile", "(", ")", "{", "if", "(", "!", "self", "::", "supportsDbase", "(", ")", "||", "!", "is_array", "(", "$", "this", "->", "DBFHeader", ")", "||", "count", "(", "$", "this", "->", "DBFHeader", ")", "==", "0", ")",...
Creates DBF file. @return bool
[ "Creates", "DBF", "file", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L542-L565
41,744
phpmyadmin/shapefile
src/ShapeFile.php
ShapeFile._openDBFFile
private function _openDBFFile() { if (! self::supportsDbase()) { $this->DBFFile = null; return true; } $dbf_name = $this->_getFilename('.dbf'); if (is_readable($dbf_name)) { $this->DBFFile = @dbase_open($dbf_name, 0); if (! $this->DBFFile) { $this->setError(sprintf('It wasn\'t possible to open the DBase file "%s"', $dbf_name)); return false; } } else { $this->setError(sprintf('It wasn\'t possible to find the DBase file "%s"', $dbf_name)); return false; } return true; }
php
private function _openDBFFile() { if (! self::supportsDbase()) { $this->DBFFile = null; return true; } $dbf_name = $this->_getFilename('.dbf'); if (is_readable($dbf_name)) { $this->DBFFile = @dbase_open($dbf_name, 0); if (! $this->DBFFile) { $this->setError(sprintf('It wasn\'t possible to open the DBase file "%s"', $dbf_name)); return false; } } else { $this->setError(sprintf('It wasn\'t possible to find the DBase file "%s"', $dbf_name)); return false; } return true; }
[ "private", "function", "_openDBFFile", "(", ")", "{", "if", "(", "!", "self", "::", "supportsDbase", "(", ")", ")", "{", "$", "this", "->", "DBFFile", "=", "null", ";", "return", "true", ";", "}", "$", "dbf_name", "=", "$", "this", "->", "_getFilenam...
Loads DBF file if supported. @return bool
[ "Loads", "DBF", "file", "if", "supported", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/ShapeFile.php#L572-L594
41,745
phpmyadmin/shapefile
src/Util.php
Util.swap
public static function swap($binValue) { $result = $binValue[strlen($binValue) - 1]; for ($i = strlen($binValue) - 2; $i >= 0; --$i) { $result .= $binValue[$i]; } return $result; }
php
public static function swap($binValue) { $result = $binValue[strlen($binValue) - 1]; for ($i = strlen($binValue) - 2; $i >= 0; --$i) { $result .= $binValue[$i]; } return $result; }
[ "public", "static", "function", "swap", "(", "$", "binValue", ")", "{", "$", "result", "=", "$", "binValue", "[", "strlen", "(", "$", "binValue", ")", "-", "1", "]", ";", "for", "(", "$", "i", "=", "strlen", "(", "$", "binValue", ")", "-", "2", ...
Changes endianity. @param string $binValue Binary value @return string
[ "Changes", "endianity", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/Util.php#L72-L80
41,746
phpmyadmin/shapefile
src/Util.php
Util.packDouble
public static function packDouble($value) { $bin = pack('d', (float) $value); if (is_null(self::$little_endian)) { self::$little_endian = (pack('L', 1) == pack('V', 1)); } if (self::$little_endian) { return $bin; } return self::swap($bin); }
php
public static function packDouble($value) { $bin = pack('d', (float) $value); if (is_null(self::$little_endian)) { self::$little_endian = (pack('L', 1) == pack('V', 1)); } if (self::$little_endian) { return $bin; } return self::swap($bin); }
[ "public", "static", "function", "packDouble", "(", "$", "value", ")", "{", "$", "bin", "=", "pack", "(", "'d'", ",", "(", "float", ")", "$", "value", ")", ";", "if", "(", "is_null", "(", "self", "::", "$", "little_endian", ")", ")", "{", "self", ...
Encodes double value to correct endianity. @param float $value Value to pack @return string
[ "Encodes", "double", "value", "to", "correct", "endianity", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/Util.php#L89-L102
41,747
phpmyadmin/shapefile
src/Util.php
Util.nameShape
public static function nameShape($type) { if (isset(self::$shape_names[$type])) { return self::$shape_names[$type]; } return sprintf('Shape %d', $type); }
php
public static function nameShape($type) { if (isset(self::$shape_names[$type])) { return self::$shape_names[$type]; } return sprintf('Shape %d', $type); }
[ "public", "static", "function", "nameShape", "(", "$", "type", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "shape_names", "[", "$", "type", "]", ")", ")", "{", "return", "self", "::", "$", "shape_names", "[", "$", "type", "]", ";", "}", ...
Returns shape name. @param int $type @return string
[ "Returns", "shape", "name", "." ]
f4f359b58ea3065ea85e3aa3bb8b677a24861363
https://github.com/phpmyadmin/shapefile/blob/f4f359b58ea3065ea85e3aa3bb8b677a24861363/src/Util.php#L111-L118
41,748
phpab/phpab
src/Storage/Adapter/Cookie.php
Cookie.parseExistingCookie
protected function parseExistingCookie() { if (is_array($this->data)) { return; } $cookiesContent = filter_input_array(INPUT_COOKIE); if (empty($cookiesContent) || !array_key_exists($this->cookieName, $cookiesContent)) { $this->data = []; return; } $deserializedCookie = json_decode($cookiesContent[$this->cookieName], true); if (is_null($deserializedCookie)) { $this->data = []; return; } $this->data = $deserializedCookie; }
php
protected function parseExistingCookie() { if (is_array($this->data)) { return; } $cookiesContent = filter_input_array(INPUT_COOKIE); if (empty($cookiesContent) || !array_key_exists($this->cookieName, $cookiesContent)) { $this->data = []; return; } $deserializedCookie = json_decode($cookiesContent[$this->cookieName], true); if (is_null($deserializedCookie)) { $this->data = []; return; } $this->data = $deserializedCookie; }
[ "protected", "function", "parseExistingCookie", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "data", ")", ")", "{", "return", ";", "}", "$", "cookiesContent", "=", "filter_input_array", "(", "INPUT_COOKIE", ")", ";", "if", "(", "empty", ...
Parses any previous cookie and stores it internally
[ "Parses", "any", "previous", "cookie", "and", "stores", "it", "internally" ]
2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf
https://github.com/phpab/phpab/blob/2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf/src/Storage/Adapter/Cookie.php#L65-L86
41,749
phpab/phpab
src/Engine/Engine.php
Engine.activateVariant
private function activateVariant(Bag $bag, VariantInterface $variant) { $this->dispatcher->dispatch('phpab.participation.variant_run', [$this, $bag, $variant]); $variant->run(); }
php
private function activateVariant(Bag $bag, VariantInterface $variant) { $this->dispatcher->dispatch('phpab.participation.variant_run', [$this, $bag, $variant]); $variant->run(); }
[ "private", "function", "activateVariant", "(", "Bag", "$", "bag", ",", "VariantInterface", "$", "variant", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'phpab.participation.variant_run'", ",", "[", "$", "this", ",", "$", "bag", ",", "$"...
Runs the Variant and dispatches subscriptions @param Bag $bag @param VariantInterface $variant
[ "Runs", "the", "Variant", "and", "dispatches", "subscriptions" ]
2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf
https://github.com/phpab/phpab/blob/2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf/src/Engine/Engine.php#L237-L242
41,750
phpab/phpab
src/Participation/Manager.php
Manager.getParticipatingVariant
public function getParticipatingVariant($test) { $test = $test instanceof TestInterface ? $test->getIdentifier() : $test; if ($this->storage->has($test)) { return $this->storage->get($test); } return null; }
php
public function getParticipatingVariant($test) { $test = $test instanceof TestInterface ? $test->getIdentifier() : $test; if ($this->storage->has($test)) { return $this->storage->get($test); } return null; }
[ "public", "function", "getParticipatingVariant", "(", "$", "test", ")", "{", "$", "test", "=", "$", "test", "instanceof", "TestInterface", "?", "$", "test", "->", "getIdentifier", "(", ")", ":", "$", "test", ";", "if", "(", "$", "this", "->", "storage", ...
Gets the variant the user is participating in for the given test. @param TestInterface|string $test The identifier of the test to get the variant for. @return string|null Returns the identifier of the variant or null if not participating.
[ "Gets", "the", "variant", "the", "user", "is", "participating", "in", "for", "the", "given", "test", "." ]
2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf
https://github.com/phpab/phpab/blob/2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf/src/Participation/Manager.php#L46-L55
41,751
phpab/phpab
src/Event/Dispatcher.php
Dispatcher.addSubscriber
public function addSubscriber(SubscriberInterface $subscriber) { foreach ($subscriber->getSubscribedEvents() as $eventName => $callable) { $this->addListener($eventName, $callable); } }
php
public function addSubscriber(SubscriberInterface $subscriber) { foreach ($subscriber->getSubscribedEvents() as $eventName => $callable) { $this->addListener($eventName, $callable); } }
[ "public", "function", "addSubscriber", "(", "SubscriberInterface", "$", "subscriber", ")", "{", "foreach", "(", "$", "subscriber", "->", "getSubscribedEvents", "(", ")", "as", "$", "eventName", "=>", "$", "callable", ")", "{", "$", "this", "->", "addListener",...
Adds a subscriber to this dispatcher which in its turn adds all the subscribed events. @param SubscriberInterface $subscriber The subscriber which can subscribe to multiple events
[ "Adds", "a", "subscriber", "to", "this", "dispatcher", "which", "in", "its", "turn", "adds", "all", "the", "subscribed", "events", "." ]
2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf
https://github.com/phpab/phpab/blob/2ba5bbc61cadedc8a611780f3b8a3a7ffb8ee0cf/src/Event/Dispatcher.php#L45-L50
41,752
eko/GoogleTranslateBundle
Translate/Method.php
Method.startProfiling
protected function startProfiling($name, $query, $source = null, $target = null) { if ($this->stopwatch instanceof Stopwatch) { $this->profiles[$this->counter] = [ 'query' => urldecode($query), 'source' => $source, 'target' => $target, 'duration' => null, 'memory_start' => memory_get_usage(true), 'memory_end' => null, 'memory_peak' => null, ]; return $this->stopwatch->start($name); } }
php
protected function startProfiling($name, $query, $source = null, $target = null) { if ($this->stopwatch instanceof Stopwatch) { $this->profiles[$this->counter] = [ 'query' => urldecode($query), 'source' => $source, 'target' => $target, 'duration' => null, 'memory_start' => memory_get_usage(true), 'memory_end' => null, 'memory_peak' => null, ]; return $this->stopwatch->start($name); } }
[ "protected", "function", "startProfiling", "(", "$", "name", ",", "$", "query", ",", "$", "source", "=", "null", ",", "$", "target", "=", "null", ")", "{", "if", "(", "$", "this", "->", "stopwatch", "instanceof", "Stopwatch", ")", "{", "$", "this", "...
Starts profiling. @param string $name Method name @param string $query Query text @param string $source Source language @param string $target Target language @return StopwatchEvent
[ "Starts", "profiling", "." ]
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/Translate/Method.php#L100-L115
41,753
eko/GoogleTranslateBundle
DependencyInjection/EkoGoogleTranslateExtension.php
EkoGoogleTranslateExtension.loadProfilerCollector
protected function loadProfilerCollector(ContainerBuilder $container, XmlFileLoader $loader) { if ($container->getParameter('kernel.debug')) { $loader->load('collector.xml'); $services = $container->findTaggedServiceIds('eko.google_translate.method'); $identifiers = array_keys($services); foreach ($identifiers as $identifier) { $serviceDefinition = $container->getDefinition($identifier); $serviceDefinition->addArgument(new Reference('debug.stopwatch')); $container->setDefinition($identifier, $serviceDefinition); } } }
php
protected function loadProfilerCollector(ContainerBuilder $container, XmlFileLoader $loader) { if ($container->getParameter('kernel.debug')) { $loader->load('collector.xml'); $services = $container->findTaggedServiceIds('eko.google_translate.method'); $identifiers = array_keys($services); foreach ($identifiers as $identifier) { $serviceDefinition = $container->getDefinition($identifier); $serviceDefinition->addArgument(new Reference('debug.stopwatch')); $container->setDefinition($identifier, $serviceDefinition); } } }
[ "protected", "function", "loadProfilerCollector", "(", "ContainerBuilder", "$", "container", ",", "XmlFileLoader", "$", "loader", ")", "{", "if", "(", "$", "container", "->", "getParameter", "(", "'kernel.debug'", ")", ")", "{", "$", "loader", "->", "load", "(...
Loads profiler collector for correct environments. @param ContainerBuilder $container Symfony dependency injection container @param XmlFileLoader $loader XML file loader
[ "Loads", "profiler", "collector", "for", "correct", "environments", "." ]
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/DependencyInjection/EkoGoogleTranslateExtension.php#L49-L64
41,754
eko/GoogleTranslateBundle
Translate/Method/Translator.php
Translator.translate
public function translate($query, $target, $source = null, $economic = false, $plainText = false) { if (!is_array($query)) { return $this->handle($query, $target, $source, $plainText); } if ($economic) { $results = $this->handle(implode(self::ECONOMIC_DELIMITER, $query), $target, $source, $plainText); $results = explode(self::ECONOMIC_DELIMITER, $results); return array_map('trim', $results); } $results = []; foreach ($query as $item) { $results[] = $this->handle($item, $target, $source, $plainText); } return $results; }
php
public function translate($query, $target, $source = null, $economic = false, $plainText = false) { if (!is_array($query)) { return $this->handle($query, $target, $source, $plainText); } if ($economic) { $results = $this->handle(implode(self::ECONOMIC_DELIMITER, $query), $target, $source, $plainText); $results = explode(self::ECONOMIC_DELIMITER, $results); return array_map('trim', $results); } $results = []; foreach ($query as $item) { $results[] = $this->handle($item, $target, $source, $plainText); } return $results; }
[ "public", "function", "translate", "(", "$", "query", ",", "$", "target", ",", "$", "source", "=", "null", ",", "$", "economic", "=", "false", ",", "$", "plainText", "=", "false", ")", "{", "if", "(", "!", "is_array", "(", "$", "query", ")", ")", ...
Translates given string in given target language from a source language via the Google Translate API. If source language is not defined, it use detector method to detect string language. @param string|array $query A query string to translate @param string $target A target language @param string $source A source language @param bool $economic Enable the economic mode? (only 1 request) @param bool $plainText The source (and response) are plain text @return array|string
[ "Translates", "given", "string", "in", "given", "target", "language", "from", "a", "source", "language", "via", "the", "Google", "Translate", "API", ".", "If", "source", "language", "is", "not", "defined", "it", "use", "detector", "method", "to", "detect", "...
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/Translate/Method/Translator.php#L87-L107
41,755
eko/GoogleTranslateBundle
Translate/Method/Translator.php
Translator.handle
protected function handle($query, $target, $source = null, $plainText = false) { if (null === $source) { $source = $this->getDetector()->detect($query); } // Split up the query if it is too long. See MAXIMUM_TEXT_SIZE description for more info. { $queryArray = []; $remainingQuery = $query; while (strlen($remainingQuery) >= self::MAXIMUM_TEXT_SIZE) { // Get closest breaking character, but not farther than MAXIMUM_TEXT_SIZE characters away. $i = 0; $find = ["\n", '.', ' ']; while (false === ($pos = strrpos($remainingQuery, $find[$i], -(strlen($remainingQuery) - self::MAXIMUM_TEXT_SIZE)))) { $i++; if ($i >= count($find)) { break; } } if (false === $pos || 0 === $pos) { break; } // Split. $queryArray[] = substr($remainingQuery, 0, $pos); $remainingQuery = substr($remainingQuery, $pos); } $queryArray[] = $remainingQuery; } // Translate piece by piece. $result = ''; foreach ($queryArray as $subQuery) { $options = [ 'key' => $this->apiKey, 'q' => $subQuery, 'source' => $source, 'target' => $target, 'format' => ($plainText ? 'text' : 'html'), ]; $result .= $this->process($options); } return $result; }
php
protected function handle($query, $target, $source = null, $plainText = false) { if (null === $source) { $source = $this->getDetector()->detect($query); } // Split up the query if it is too long. See MAXIMUM_TEXT_SIZE description for more info. { $queryArray = []; $remainingQuery = $query; while (strlen($remainingQuery) >= self::MAXIMUM_TEXT_SIZE) { // Get closest breaking character, but not farther than MAXIMUM_TEXT_SIZE characters away. $i = 0; $find = ["\n", '.', ' ']; while (false === ($pos = strrpos($remainingQuery, $find[$i], -(strlen($remainingQuery) - self::MAXIMUM_TEXT_SIZE)))) { $i++; if ($i >= count($find)) { break; } } if (false === $pos || 0 === $pos) { break; } // Split. $queryArray[] = substr($remainingQuery, 0, $pos); $remainingQuery = substr($remainingQuery, $pos); } $queryArray[] = $remainingQuery; } // Translate piece by piece. $result = ''; foreach ($queryArray as $subQuery) { $options = [ 'key' => $this->apiKey, 'q' => $subQuery, 'source' => $source, 'target' => $target, 'format' => ($plainText ? 'text' : 'html'), ]; $result .= $this->process($options); } return $result; }
[ "protected", "function", "handle", "(", "$", "query", ",", "$", "target", ",", "$", "source", "=", "null", ",", "$", "plainText", "=", "false", ")", "{", "if", "(", "null", "===", "$", "source", ")", "{", "$", "source", "=", "$", "this", "->", "g...
Handles a translation request. @param string $query A query string to translate @param string $target A target language @param string $source A source language @param bool $plainText The source (and response) are plain text @return string
[ "Handles", "a", "translation", "request", "." ]
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/Translate/Method/Translator.php#L119-L166
41,756
eko/GoogleTranslateBundle
Translate/Method/Languages.php
Languages.get
public function get($target = null) { $options = ['key' => $this->apiKey]; if (null !== $target) { $this->url = sprintf('%s&target={target}', $this->url); $options['target'] = $target; } return $this->process($options); }
php
public function get($target = null) { $options = ['key' => $this->apiKey]; if (null !== $target) { $this->url = sprintf('%s&target={target}', $this->url); $options['target'] = $target; } return $this->process($options); }
[ "public", "function", "get", "(", "$", "target", "=", "null", ")", "{", "$", "options", "=", "[", "'key'", "=>", "$", "this", "->", "apiKey", "]", ";", "if", "(", "null", "!==", "$", "target", ")", "{", "$", "this", "->", "url", "=", "sprintf", ...
Retrieves all languages availables with Google Translate API If a target language is specified, returns languages name translated in target language. @param string $target A target language to translate languages names @return string
[ "Retrieves", "all", "languages", "availables", "with", "Google", "Translate", "API", "If", "a", "target", "language", "is", "specified", "returns", "languages", "name", "translated", "in", "target", "language", "." ]
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/Translate/Method/Languages.php#L38-L49
41,757
eko/GoogleTranslateBundle
Translate/Method/Languages.php
Languages.process
protected function process(array $options) { $event = $this->startProfiling($this->getName(), 'get'); $response = $this->getClient()->get($this->url, ['query' => $options]); $json = json_decode($response->getBody()->getContents(), true); $result = isset($json['data']['languages']) ? $json['data']['languages'] : []; $this->stopProfiling($event, $this->getName(), $result); return $result; }
php
protected function process(array $options) { $event = $this->startProfiling($this->getName(), 'get'); $response = $this->getClient()->get($this->url, ['query' => $options]); $json = json_decode($response->getBody()->getContents(), true); $result = isset($json['data']['languages']) ? $json['data']['languages'] : []; $this->stopProfiling($event, $this->getName(), $result); return $result; }
[ "protected", "function", "process", "(", "array", "$", "options", ")", "{", "$", "event", "=", "$", "this", "->", "startProfiling", "(", "$", "this", "->", "getName", "(", ")", ",", "'get'", ")", ";", "$", "response", "=", "$", "this", "->", "getClie...
Process request and retrieve JSON result. @param array $options @return array
[ "Process", "request", "and", "retrieve", "JSON", "result", "." ]
8649b6e2d1aa6c4208ab779759e7e4105dfaf680
https://github.com/eko/GoogleTranslateBundle/blob/8649b6e2d1aa6c4208ab779759e7e4105dfaf680/Translate/Method/Languages.php#L58-L70
41,758
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.columns
public function columns(array $columns): self { foreach ($columns as $name => $alias) { if (!is_string($name)) { $this->column($alias, null); continue; } if (is_string($alias)) { $this->column($name, $alias); } else { $this->column($alias, $name); } } return $this; }
php
public function columns(array $columns): self { foreach ($columns as $name => $alias) { if (!is_string($name)) { $this->column($alias, null); continue; } if (is_string($alias)) { $this->column($name, $alias); } else { $this->column($alias, $name); } } return $this; }
[ "public", "function", "columns", "(", "array", "$", "columns", ")", ":", "self", "{", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "alias", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "$", "this", "->"...
Add multiple columns at once @param array $columns Columns @return $this
[ "Add", "multiple", "columns", "at", "once" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L57-L71
41,759
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.count
public function count($column = '*', string $alias = null, bool $distinct = false): self { return $this->column((new Expression())->count($column, $distinct), $alias); }
php
public function count($column = '*', string $alias = null, bool $distinct = false): self { return $this->column((new Expression())->count($column, $distinct), $alias); }
[ "public", "function", "count", "(", "$", "column", "=", "'*'", ",", "string", "$", "alias", "=", "null", ",", "bool", "$", "distinct", "=", "false", ")", ":", "self", "{", "return", "$", "this", "->", "column", "(", "(", "new", "Expression", "(", "...
Add a `COUNT` expression @param string|array|Expression $column Column @param string $alias (optional) Column's alias @param bool $distinct (optional) Distinct column @return $this
[ "Add", "a", "COUNT", "expression" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L82-L85
41,760
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.ucase
public function ucase($column, string $alias = null): self { return $this->column((new Expression())->ucase($column), $alias); }
php
public function ucase($column, string $alias = null): self { return $this->column((new Expression())->ucase($column), $alias); }
[ "public", "function", "ucase", "(", "$", "column", ",", "string", "$", "alias", "=", "null", ")", ":", "self", "{", "return", "$", "this", "->", "column", "(", "(", "new", "Expression", "(", ")", ")", "->", "ucase", "(", "$", "column", ")", ",", ...
Add a `UCASE` expression @param string|Expression $column Column @param string $alias (optional) Alias @return $this
[ "Add", "a", "UCASE", "expression" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L151-L154
41,761
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.lcase
public function lcase($column, string $alias = null): self { return $this->column((new Expression())->lcase($column), $alias); }
php
public function lcase($column, string $alias = null): self { return $this->column((new Expression())->lcase($column), $alias); }
[ "public", "function", "lcase", "(", "$", "column", ",", "string", "$", "alias", "=", "null", ")", ":", "self", "{", "return", "$", "this", "->", "column", "(", "(", "new", "Expression", "(", ")", ")", "->", "lcase", "(", "$", "column", ")", ",", ...
Add a `LCASE` expression @param string|Expression $column Column @param string $alias (optional) Alias @return $this
[ "Add", "a", "LCASE", "expression" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L164-L167
41,762
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.mid
public function mid($column, int $start = 1, string $alias = null, int $length = 0): self { return $this->column((new Expression())->mid($column, $start, $length), $alias); }
php
public function mid($column, int $start = 1, string $alias = null, int $length = 0): self { return $this->column((new Expression())->mid($column, $start, $length), $alias); }
[ "public", "function", "mid", "(", "$", "column", ",", "int", "$", "start", "=", "1", ",", "string", "$", "alias", "=", "null", ",", "int", "$", "length", "=", "0", ")", ":", "self", "{", "return", "$", "this", "->", "column", "(", "(", "new", "...
Add a `MID` expression @param string|Expression $column Column @param int $start (optional) Substring start @param string $alias (optional) Alias @param int $length (optional) Substring length @return $this
[ "Add", "a", "MID", "expression" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L179-L182
41,763
opis/database
src/SQL/ColumnExpression.php
ColumnExpression.len
public function len($column, string $alias = null): self { return $this->column((new Expression())->len($column), $alias); }
php
public function len($column, string $alias = null): self { return $this->column((new Expression())->len($column), $alias); }
[ "public", "function", "len", "(", "$", "column", ",", "string", "$", "alias", "=", "null", ")", ":", "self", "{", "return", "$", "this", "->", "column", "(", "(", "new", "Expression", "(", ")", ")", "->", "len", "(", "$", "column", ")", ",", "$",...
Add a `LEN` expression @param string|Expression $column Column @param string $alias (optional) Alias @return $this
[ "Add", "a", "LEN", "expression" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/ColumnExpression.php#L192-L195
41,764
opis/database
src/ResultSet.php
ResultSet.all
public function all($callable = null, $fetchStyle = 0) { if ($callable === null) { return $this->statement->fetchAll($fetchStyle); } return $this->statement->fetchAll($fetchStyle | PDO::FETCH_FUNC, $callable); }
php
public function all($callable = null, $fetchStyle = 0) { if ($callable === null) { return $this->statement->fetchAll($fetchStyle); } return $this->statement->fetchAll($fetchStyle | PDO::FETCH_FUNC, $callable); }
[ "public", "function", "all", "(", "$", "callable", "=", "null", ",", "$", "fetchStyle", "=", "0", ")", "{", "if", "(", "$", "callable", "===", "null", ")", "{", "return", "$", "this", "->", "statement", "->", "fetchAll", "(", "$", "fetchStyle", ")", ...
Fetch all results @param callable $callable (optional) Callback function @param int $fetchStyle (optional) PDO fetch style @return array
[ "Fetch", "all", "results" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/ResultSet.php#L65-L71
41,765
opis/database
src/ResultSet.php
ResultSet.first
public function first($callable = null) { if ($callable !== null) { $result = $this->statement->fetch(PDO::FETCH_ASSOC); $this->statement->closeCursor(); if (is_array($result)) { $result = call_user_func_array($callable, $result); } } else { $result = $this->statement->fetch(); $this->statement->closeCursor(); } return $result; }
php
public function first($callable = null) { if ($callable !== null) { $result = $this->statement->fetch(PDO::FETCH_ASSOC); $this->statement->closeCursor(); if (is_array($result)) { $result = call_user_func_array($callable, $result); } } else { $result = $this->statement->fetch(); $this->statement->closeCursor(); } return $result; }
[ "public", "function", "first", "(", "$", "callable", "=", "null", ")", "{", "if", "(", "$", "callable", "!==", "null", ")", "{", "$", "result", "=", "$", "this", "->", "statement", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "$", "thi...
Fetch first result @param callable $callable (optional) Callback function @return mixed
[ "Fetch", "first", "result" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/ResultSet.php#L95-L109
41,766
philipbrown/signature-php
src/Request.php
Request.sign
public function sign(Token $token, $prefix = self::PREFIX) { $auth = [ $prefix . 'version' => self::VERSION, $prefix . 'key' => $token->key(), $prefix . 'timestamp' => $this->timestamp, ]; $payload = $this->payload($auth, $this->params); $signature = $this->signature($payload, $this->method, $this->uri, $token->secret()); $auth[$prefix . 'signature'] = $signature; return $auth; }
php
public function sign(Token $token, $prefix = self::PREFIX) { $auth = [ $prefix . 'version' => self::VERSION, $prefix . 'key' => $token->key(), $prefix . 'timestamp' => $this->timestamp, ]; $payload = $this->payload($auth, $this->params); $signature = $this->signature($payload, $this->method, $this->uri, $token->secret()); $auth[$prefix . 'signature'] = $signature; return $auth; }
[ "public", "function", "sign", "(", "Token", "$", "token", ",", "$", "prefix", "=", "self", "::", "PREFIX", ")", "{", "$", "auth", "=", "[", "$", "prefix", ".", "'version'", "=>", "self", "::", "VERSION", ",", "$", "prefix", ".", "'key'", "=>", "$",...
Sign the Request with a Token @param Token $token @param string $prefix @return array
[ "Sign", "the", "Request", "with", "a", "Token" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Request.php#L52-L67
41,767
philipbrown/signature-php
src/Request.php
Request.payload
private function payload(array $auth, array $params) { $payload = array_merge($auth, $params); $payload = array_change_key_case($payload, CASE_LOWER); ksort($payload); return $payload; }
php
private function payload(array $auth, array $params) { $payload = array_merge($auth, $params); $payload = array_change_key_case($payload, CASE_LOWER); ksort($payload); return $payload; }
[ "private", "function", "payload", "(", "array", "$", "auth", ",", "array", "$", "params", ")", "{", "$", "payload", "=", "array_merge", "(", "$", "auth", ",", "$", "params", ")", ";", "$", "payload", "=", "array_change_key_case", "(", "$", "payload", "...
Create the payload @param array $auth @param array $params @return array
[ "Create", "the", "payload" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Request.php#L76-L84
41,768
philipbrown/signature-php
src/Request.php
Request.signature
private function signature(array $payload, $method, $uri, $secret) { $payload = urldecode(http_build_query($payload)); $payload = implode("\n", [$method, $uri, $payload]); return hash_hmac('sha256', $payload, $secret); }
php
private function signature(array $payload, $method, $uri, $secret) { $payload = urldecode(http_build_query($payload)); $payload = implode("\n", [$method, $uri, $payload]); return hash_hmac('sha256', $payload, $secret); }
[ "private", "function", "signature", "(", "array", "$", "payload", ",", "$", "method", ",", "$", "uri", ",", "$", "secret", ")", "{", "$", "payload", "=", "urldecode", "(", "http_build_query", "(", "$", "payload", ")", ")", ";", "$", "payload", "=", "...
Create the signature @param array $payload @param string $method @param string $uri @param string $secret @return string
[ "Create", "the", "signature" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Request.php#L95-L102
41,769
opis/database
src/Schema.php
Schema.getCurrentDatabase
public function getCurrentDatabase() { if ($this->currentDatabase === null) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->currentDatabase($this->connection->getDSN()); if (is_array($result)) { $this->currentDatabase = $this->connection->column($result['sql'], $result['params']); } else { $this->currentDatabase = $result; } } return $this->currentDatabase; }
php
public function getCurrentDatabase() { if ($this->currentDatabase === null) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->currentDatabase($this->connection->getDSN()); if (is_array($result)) { $this->currentDatabase = $this->connection->column($result['sql'], $result['params']); } else { $this->currentDatabase = $result; } } return $this->currentDatabase; }
[ "public", "function", "getCurrentDatabase", "(", ")", "{", "if", "(", "$", "this", "->", "currentDatabase", "===", "null", ")", "{", "$", "compiler", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", ";", "$", "result", "=", "$", ...
Get the name of the currently used database @return string @throws \Exception
[ "Get", "the", "name", "of", "the", "currently", "used", "database" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L53-L67
41,770
opis/database
src/Schema.php
Schema.hasTable
public function hasTable(string $table, bool $clear = false): bool { $list = $this->getTables($clear); return isset($list[strtolower($table)]); }
php
public function hasTable(string $table, bool $clear = false): bool { $list = $this->getTables($clear); return isset($list[strtolower($table)]); }
[ "public", "function", "hasTable", "(", "string", "$", "table", ",", "bool", "$", "clear", "=", "false", ")", ":", "bool", "{", "$", "list", "=", "$", "this", "->", "getTables", "(", "$", "clear", ")", ";", "return", "isset", "(", "$", "list", "[", ...
Check if the specified table exists @param string $table Table name @param boolean $clear (optional) Refresh table list @return boolean @throws \Exception
[ "Check", "if", "the", "specified", "table", "exists" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L78-L82
41,771
opis/database
src/Schema.php
Schema.getTables
public function getTables(bool $clear = false): array { if ($clear) { $this->tableList = null; } if ($this->tableList === null) { $compiler = $this->connection->schemaCompiler(); $database = $this->getCurrentDatabase(); $sql = $compiler->getTables($database); $results = $this->connection ->query($sql['sql'], $sql['params']) ->fetchNum() ->all(); $this->tableList = []; foreach ($results as $result) { $this->tableList[strtolower($result[0])] = $result[0]; } } return $this->tableList; }
php
public function getTables(bool $clear = false): array { if ($clear) { $this->tableList = null; } if ($this->tableList === null) { $compiler = $this->connection->schemaCompiler(); $database = $this->getCurrentDatabase(); $sql = $compiler->getTables($database); $results = $this->connection ->query($sql['sql'], $sql['params']) ->fetchNum() ->all(); $this->tableList = []; foreach ($results as $result) { $this->tableList[strtolower($result[0])] = $result[0]; } } return $this->tableList; }
[ "public", "function", "getTables", "(", "bool", "$", "clear", "=", "false", ")", ":", "array", "{", "if", "(", "$", "clear", ")", "{", "$", "this", "->", "tableList", "=", "null", ";", "}", "if", "(", "$", "this", "->", "tableList", "===", "null", ...
Get a list with all tables that belong to the currently used database @param boolean $clear (optional) Refresh table list @return string[] @throws \Exception
[ "Get", "a", "list", "with", "all", "tables", "that", "belong", "to", "the", "currently", "used", "database" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L92-L118
41,772
opis/database
src/Schema.php
Schema.getColumns
public function getColumns(string $table, bool $clear = false, bool $names = true) { if ($clear) { unset($this->columns[$table]); } if (!$this->hasTable($table, $clear)) { return false; } if (!isset($this->columns[$table])) { $compiler = $this->connection->schemaCompiler(); $database = $this->getCurrentDatabase(); $sql = $compiler->getColumns($database, $table); $results = $this->connection ->query($sql['sql'], $sql['params']) ->fetchAssoc() ->all(); $columns = []; foreach ($results as $ord => &$col) { $columns[$col['name']] = [ 'name' => $col['name'], 'type' => $col['type'], ]; } $this->columns[$table] = $columns; } return $names ? array_keys($this->columns[$table]) : $this->columns[$table]; }
php
public function getColumns(string $table, bool $clear = false, bool $names = true) { if ($clear) { unset($this->columns[$table]); } if (!$this->hasTable($table, $clear)) { return false; } if (!isset($this->columns[$table])) { $compiler = $this->connection->schemaCompiler(); $database = $this->getCurrentDatabase(); $sql = $compiler->getColumns($database, $table); $results = $this->connection ->query($sql['sql'], $sql['params']) ->fetchAssoc() ->all(); $columns = []; foreach ($results as $ord => &$col) { $columns[$col['name']] = [ 'name' => $col['name'], 'type' => $col['type'], ]; } $this->columns[$table] = $columns; } return $names ? array_keys($this->columns[$table]) : $this->columns[$table]; }
[ "public", "function", "getColumns", "(", "string", "$", "table", ",", "bool", "$", "clear", "=", "false", ",", "bool", "$", "names", "=", "true", ")", "{", "if", "(", "$", "clear", ")", "{", "unset", "(", "$", "this", "->", "columns", "[", "$", "...
Get a list with all columns that belong to the specified table @param string $table @param boolean $clear (optional) Refresh column list @param boolean $names (optional) Return only the column names @return false|string[] @throws \Exception
[ "Get", "a", "list", "with", "all", "columns", "that", "belong", "to", "the", "specified", "table" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L130-L165
41,773
opis/database
src/Schema.php
Schema.create
public function create(string $table, callable $callback) { $compiler = $this->connection->schemaCompiler(); $schema = new CreateTable($table); $callback($schema); foreach ($compiler->create($schema) as $result) { $this->connection->command($result['sql'], $result['params']); } //clear table list $this->tableList = null; }
php
public function create(string $table, callable $callback) { $compiler = $this->connection->schemaCompiler(); $schema = new CreateTable($table); $callback($schema); foreach ($compiler->create($schema) as $result) { $this->connection->command($result['sql'], $result['params']); } //clear table list $this->tableList = null; }
[ "public", "function", "create", "(", "string", "$", "table", ",", "callable", "$", "callback", ")", "{", "$", "compiler", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", ";", "$", "schema", "=", "new", "CreateTable", "(", "$", "...
Creates a new table @param string $table Table name @param callable $callback A callback that will define table's fields and indexes @throws \Exception
[ "Creates", "a", "new", "table" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L174-L188
41,774
opis/database
src/Schema.php
Schema.alter
public function alter(string $table, callable $callback) { $compiler = $this->connection->schemaCompiler(); $schema = new AlterTable($table); $callback($schema); unset($this->columns[strtolower($table)]); foreach ($compiler->alter($schema) as $result) { $this->connection->command($result['sql'], $result['params']); } }
php
public function alter(string $table, callable $callback) { $compiler = $this->connection->schemaCompiler(); $schema = new AlterTable($table); $callback($schema); unset($this->columns[strtolower($table)]); foreach ($compiler->alter($schema) as $result) { $this->connection->command($result['sql'], $result['params']); } }
[ "public", "function", "alter", "(", "string", "$", "table", ",", "callable", "$", "callback", ")", "{", "$", "compiler", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", ";", "$", "schema", "=", "new", "AlterTable", "(", "$", "ta...
Alters a table's definition @param string $table Table name @param callable $callback A callback that will add or remove fields or indexes @throws \Exception
[ "Alters", "a", "table", "s", "definition" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L197-L210
41,775
opis/database
src/Schema.php
Schema.renameTable
public function renameTable(string $table, string $name) { $result = $this->connection->schemaCompiler()->renameTable($table, $name); $this->connection->command($result['sql'], $result['params']); $this->tableList = null; unset($this->columns[strtolower($table)]); }
php
public function renameTable(string $table, string $name) { $result = $this->connection->schemaCompiler()->renameTable($table, $name); $this->connection->command($result['sql'], $result['params']); $this->tableList = null; unset($this->columns[strtolower($table)]); }
[ "public", "function", "renameTable", "(", "string", "$", "table", ",", "string", "$", "name", ")", "{", "$", "result", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", "->", "renameTable", "(", "$", "table", ",", "$", "name", ")"...
Change a table's name @param string $table The table @param string $name The new name of the table @throws \Exception
[ "Change", "a", "table", "s", "name" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L219-L225
41,776
opis/database
src/Schema.php
Schema.drop
public function drop(string $table) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->drop($table); $this->connection->command($result['sql'], $result['params']); //clear table list $this->tableList = null; unset($this->columns[strtolower($table)]); }
php
public function drop(string $table) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->drop($table); $this->connection->command($result['sql'], $result['params']); //clear table list $this->tableList = null; unset($this->columns[strtolower($table)]); }
[ "public", "function", "drop", "(", "string", "$", "table", ")", "{", "$", "compiler", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", ";", "$", "result", "=", "$", "compiler", "->", "drop", "(", "$", "table", ")", ";", "$", ...
Deletes a table @param string $table Table name @throws \Exception
[ "Deletes", "a", "table" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L233-L244
41,777
opis/database
src/Schema.php
Schema.truncate
public function truncate(string $table) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->truncate($table); $this->connection->command($result['sql'], $result['params']); }
php
public function truncate(string $table) { $compiler = $this->connection->schemaCompiler(); $result = $compiler->truncate($table); $this->connection->command($result['sql'], $result['params']); }
[ "public", "function", "truncate", "(", "string", "$", "table", ")", "{", "$", "compiler", "=", "$", "this", "->", "connection", "->", "schemaCompiler", "(", ")", ";", "$", "result", "=", "$", "compiler", "->", "truncate", "(", "$", "table", ")", ";", ...
Deletes all records from a table @param string $table Table name @throws \Exception
[ "Deletes", "all", "records", "from", "a", "table" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Schema.php#L252-L259
41,778
opis/database
src/Connection.php
Connection.initCommand
public function initCommand(string $query, array $params = []): self { $this->commands[] = [ 'sql' => $query, 'params' => $params, ]; return $this; }
php
public function initCommand(string $query, array $params = []): self { $this->commands[] = [ 'sql' => $query, 'params' => $params, ]; return $this; }
[ "public", "function", "initCommand", "(", "string", "$", "query", ",", "array", "$", "params", "=", "[", "]", ")", ":", "self", "{", "$", "this", "->", "commands", "[", "]", "=", "[", "'sql'", "=>", "$", "query", ",", "'params'", "=>", "$", "params...
Add an init command @param string $query SQL command @param array $params (optional) Params @return Connection
[ "Add", "an", "init", "command" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L140-L148
41,779
opis/database
src/Connection.php
Connection.options
public function options(array $options): self { foreach ($options as $name => $value) { $this->option($name, $value); } return $this; }
php
public function options(array $options): self { foreach ($options as $name => $value) { $this->option($name, $value); } return $this; }
[ "public", "function", "options", "(", "array", "$", "options", ")", ":", "self", "{", "foreach", "(", "$", "options", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "option", "(", "$", "name", ",", "$", "value", ")", ";", "}"...
Set PDO connection options @param array $options PDO options @return Connection
[ "Set", "PDO", "connection", "options" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L183-L190
41,780
opis/database
src/Connection.php
Connection.persistent
public function persistent(bool $value = true): self { return $this->option(PDO::ATTR_PERSISTENT, $value); }
php
public function persistent(bool $value = true): self { return $this->option(PDO::ATTR_PERSISTENT, $value); }
[ "public", "function", "persistent", "(", "bool", "$", "value", "=", "true", ")", ":", "self", "{", "return", "$", "this", "->", "option", "(", "PDO", "::", "ATTR_PERSISTENT", ",", "$", "value", ")", ";", "}" ]
Use persistent connections @param bool $value (optional) Value @return Connection
[ "Use", "persistent", "connections" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L213-L216
41,781
opis/database
src/Connection.php
Connection.setWrapperFormat
public function setWrapperFormat(string $wrapper): self { $this->compilerOptions['wrapper'] = $wrapper; $this->schemaCompilerOptions['wrapper'] = $wrapper; return $this; }
php
public function setWrapperFormat(string $wrapper): self { $this->compilerOptions['wrapper'] = $wrapper; $this->schemaCompilerOptions['wrapper'] = $wrapper; return $this; }
[ "public", "function", "setWrapperFormat", "(", "string", "$", "wrapper", ")", ":", "self", "{", "$", "this", "->", "compilerOptions", "[", "'wrapper'", "]", "=", "$", "wrapper", ";", "$", "this", "->", "schemaCompilerOptions", "[", "'wrapper'", "]", "=", "...
Set identifier wrapper @param string $wrapper Identifier wrapper @return Connection
[ "Set", "identifier", "wrapper" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L238-L243
41,782
opis/database
src/Connection.php
Connection.getDriver
public function getDriver() { if ($this->driver === null) { $this->driver = $this->getPDO()->getAttribute(PDO::ATTR_DRIVER_NAME); } return $this->driver; }
php
public function getDriver() { if ($this->driver === null) { $this->driver = $this->getPDO()->getAttribute(PDO::ATTR_DRIVER_NAME); } return $this->driver; }
[ "public", "function", "getDriver", "(", ")", "{", "if", "(", "$", "this", "->", "driver", "===", "null", ")", "{", "$", "this", "->", "driver", "=", "$", "this", "->", "getPDO", "(", ")", "->", "getAttribute", "(", "PDO", "::", "ATTR_DRIVER_NAME", ")...
Returns the driver's name @return string
[ "Returns", "the", "driver", "s", "name" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L260-L267
41,783
opis/database
src/Connection.php
Connection.getSchema
public function getSchema(): Schema { if ($this->schema === null) { $this->schema = new Schema($this); } return $this->schema; }
php
public function getSchema(): Schema { if ($this->schema === null) { $this->schema = new Schema($this); } return $this->schema; }
[ "public", "function", "getSchema", "(", ")", ":", "Schema", "{", "if", "(", "$", "this", "->", "schema", "===", "null", ")", "{", "$", "this", "->", "schema", "=", "new", "Schema", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "sc...
Returns the schema associated with this connection @return Schema
[ "Returns", "the", "schema", "associated", "with", "this", "connection" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L274-L281
41,784
opis/database
src/Connection.php
Connection.getPDO
public function getPDO(): PDO { if ($this->pdo == null) { $this->pdo = new PDO($this->getDSN(), $this->username, $this->password, $this->options); foreach ($this->commands as $command) { $this->command($command['sql'], $command['params']); } } return $this->pdo; }
php
public function getPDO(): PDO { if ($this->pdo == null) { $this->pdo = new PDO($this->getDSN(), $this->username, $this->password, $this->options); foreach ($this->commands as $command) { $this->command($command['sql'], $command['params']); } } return $this->pdo; }
[ "public", "function", "getPDO", "(", ")", ":", "PDO", "{", "if", "(", "$", "this", "->", "pdo", "==", "null", ")", "{", "$", "this", "->", "pdo", "=", "new", "PDO", "(", "$", "this", "->", "getDSN", "(", ")", ",", "$", "this", "->", "username",...
Returns the PDO object associated with this connection @return PDO
[ "Returns", "the", "PDO", "object", "associated", "with", "this", "connection" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L288-L299
41,785
opis/database
src/Connection.php
Connection.getCompiler
public function getCompiler(): SQL\Compiler { if ($this->compiler === null) { switch ($this->getDriver()) { case 'mysql': $this->compiler = new SQL\Compiler\MySQL(); break; case 'dblib': case 'mssql': case 'sqlsrv': case 'sybase': $this->compiler = new SQL\Compiler\SQLServer(); break; case 'oci': case 'oracle': $this->compiler = new SQL\Compiler\Oracle(); break; case 'firebird': $this->compiler = new SQL\Compiler\Firebird(); break; case 'db2': case 'ibm': case 'odbc': $this->compiler = new SQL\Compiler\DB2(); break; case 'nuodb': $this->compiler = new SQL\Compiler\NuoDB(); break; default: $this->compiler = new SQL\Compiler(); } $this->compiler->setOptions($this->compilerOptions); } return $this->compiler; }
php
public function getCompiler(): SQL\Compiler { if ($this->compiler === null) { switch ($this->getDriver()) { case 'mysql': $this->compiler = new SQL\Compiler\MySQL(); break; case 'dblib': case 'mssql': case 'sqlsrv': case 'sybase': $this->compiler = new SQL\Compiler\SQLServer(); break; case 'oci': case 'oracle': $this->compiler = new SQL\Compiler\Oracle(); break; case 'firebird': $this->compiler = new SQL\Compiler\Firebird(); break; case 'db2': case 'ibm': case 'odbc': $this->compiler = new SQL\Compiler\DB2(); break; case 'nuodb': $this->compiler = new SQL\Compiler\NuoDB(); break; default: $this->compiler = new SQL\Compiler(); } $this->compiler->setOptions($this->compilerOptions); } return $this->compiler; }
[ "public", "function", "getCompiler", "(", ")", ":", "SQL", "\\", "Compiler", "{", "if", "(", "$", "this", "->", "compiler", "===", "null", ")", "{", "switch", "(", "$", "this", "->", "getDriver", "(", ")", ")", "{", "case", "'mysql'", ":", "$", "th...
Returns an instance of the compiler associated with this connection @return SQL\Compiler
[ "Returns", "an", "instance", "of", "the", "compiler", "associated", "with", "this", "connection" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L306-L342
41,786
opis/database
src/Connection.php
Connection.schemaCompiler
public function schemaCompiler(): Schema\Compiler { if ($this->schemaCompiler === null) { switch ($this->getDriver()) { case 'mysql': $this->schemaCompiler = new Schema\Compiler\MySQL($this); break; case 'pgsql': $this->schemaCompiler = new Schema\Compiler\PostgreSQL($this); break; case 'dblib': case 'mssql': case 'sqlsrv': case 'sybase': $this->schemaCompiler = new Schema\Compiler\SQLServer($this); break; case 'sqlite': $this->schemaCompiler = new Schema\Compiler\SQLite($this); break; case 'oci': case 'oracle': $this->schemaCompiler = new Schema\Compiler\Oracle($this); break; default: throw new \Exception('Schema not supported yet'); } $this->schemaCompiler->setOptions($this->schemaCompilerOptions); } return $this->schemaCompiler; }
php
public function schemaCompiler(): Schema\Compiler { if ($this->schemaCompiler === null) { switch ($this->getDriver()) { case 'mysql': $this->schemaCompiler = new Schema\Compiler\MySQL($this); break; case 'pgsql': $this->schemaCompiler = new Schema\Compiler\PostgreSQL($this); break; case 'dblib': case 'mssql': case 'sqlsrv': case 'sybase': $this->schemaCompiler = new Schema\Compiler\SQLServer($this); break; case 'sqlite': $this->schemaCompiler = new Schema\Compiler\SQLite($this); break; case 'oci': case 'oracle': $this->schemaCompiler = new Schema\Compiler\Oracle($this); break; default: throw new \Exception('Schema not supported yet'); } $this->schemaCompiler->setOptions($this->schemaCompilerOptions); } return $this->schemaCompiler; }
[ "public", "function", "schemaCompiler", "(", ")", ":", "Schema", "\\", "Compiler", "{", "if", "(", "$", "this", "->", "schemaCompiler", "===", "null", ")", "{", "switch", "(", "$", "this", "->", "getDriver", "(", ")", ")", "{", "case", "'mysql'", ":", ...
Returns an instance of the schema compiler associated with this connection @throws \Exception @return Schema\Compiler
[ "Returns", "an", "instance", "of", "the", "schema", "compiler", "associated", "with", "this", "connection" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L351-L382
41,787
opis/database
src/Connection.php
Connection.command
public function command(string $sql, array $params = []) { return $this->execute($this->prepare($sql, $params)); }
php
public function command(string $sql, array $params = []) { return $this->execute($this->prepare($sql, $params)); }
[ "public", "function", "command", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "execute", "(", "$", "this", "->", "prepare", "(", "$", "sql", ",", "$", "params", ")", ")", ";", "}" ]
Execute a non-query SQL command @param string $sql SQL Command @param array $params (optional) Command params @return mixed Command result
[ "Execute", "a", "non", "-", "query", "SQL", "command" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L425-L428
41,788
opis/database
src/Connection.php
Connection.count
public function count(string $sql, array $params = []) { $prepared = $this->prepare($sql, $params); $this->execute($prepared); $result = $prepared['statement']->rowCount(); $prepared['statement']->closeCursor(); return $result; }
php
public function count(string $sql, array $params = []) { $prepared = $this->prepare($sql, $params); $this->execute($prepared); $result = $prepared['statement']->rowCount(); $prepared['statement']->closeCursor(); return $result; }
[ "public", "function", "count", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "prepared", "=", "$", "this", "->", "prepare", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "this", "->", "execute", "(", ...
Execute a query and return the number of affected rows @param string $sql SQL Query @param array $params (optional) Query params @return int
[ "Execute", "a", "query", "and", "return", "the", "number", "of", "affected", "rows" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L438-L445
41,789
opis/database
src/Connection.php
Connection.column
public function column(string $sql, array $params = []) { $prepared = $this->prepare($sql, $params); $this->execute($prepared); $result = $prepared['statement']->fetchColumn(); $prepared['statement']->closeCursor(); return $result; }
php
public function column(string $sql, array $params = []) { $prepared = $this->prepare($sql, $params); $this->execute($prepared); $result = $prepared['statement']->fetchColumn(); $prepared['statement']->closeCursor(); return $result; }
[ "public", "function", "column", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "prepared", "=", "$", "this", "->", "prepare", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "this", "->", "execute", "(",...
Execute a query and fetch the first column @param string $sql SQL Query @param array $params (optional) Query params @return mixed
[ "Execute", "a", "query", "and", "fetch", "the", "first", "column" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L455-L462
41,790
opis/database
src/Connection.php
Connection.replaceParams
protected function replaceParams(string $query, array $params): string { $compiler = $this->getCompiler(); return preg_replace_callback('/\?/', function () use (&$params, $compiler) { $param = array_shift($params); $param = is_object($param) ? get_class($param) : $param; if (is_int($param) || is_float($param)) { return $param; } elseif ($param === null) { return 'NULL'; } elseif (is_bool($param)) { return $param ? 'TRUE' : 'FALSE'; } else { return $compiler->quote($param); } }, $query); }
php
protected function replaceParams(string $query, array $params): string { $compiler = $this->getCompiler(); return preg_replace_callback('/\?/', function () use (&$params, $compiler) { $param = array_shift($params); $param = is_object($param) ? get_class($param) : $param; if (is_int($param) || is_float($param)) { return $param; } elseif ($param === null) { return 'NULL'; } elseif (is_bool($param)) { return $param ? 'TRUE' : 'FALSE'; } else { return $compiler->quote($param); } }, $query); }
[ "protected", "function", "replaceParams", "(", "string", "$", "query", ",", "array", "$", "params", ")", ":", "string", "{", "$", "compiler", "=", "$", "this", "->", "getCompiler", "(", ")", ";", "return", "preg_replace_callback", "(", "'/\\?/'", ",", "fun...
Replace placeholders with parameters. @param string $query SQL query @param array $params Query parameters @return string
[ "Replace", "placeholders", "with", "parameters", "." ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L510-L528
41,791
opis/database
src/Connection.php
Connection.execute
protected function execute(array $prepared) { if ($this->logQueries) { $start = microtime(true); $log = [ 'query' => $this->replaceParams($prepared['query'], $prepared['params']), ]; $this->log[] = &$log; } try { if ($prepared['params']) { $this->bindValues($prepared['statement'], $prepared['params']); } $result = $prepared['statement']->execute(); } catch (PDOException $e) { throw new PDOException($e->getMessage() . ' [ ' . $this->replaceParams($prepared['query'], $prepared['params']) . ' ] ', (int)$e->getCode(), $e->getPrevious()); } if ($this->logQueries) { /** @noinspection PhpUndefinedVariableInspection */ $log['time'] = microtime(true) - $start; } return $result; }
php
protected function execute(array $prepared) { if ($this->logQueries) { $start = microtime(true); $log = [ 'query' => $this->replaceParams($prepared['query'], $prepared['params']), ]; $this->log[] = &$log; } try { if ($prepared['params']) { $this->bindValues($prepared['statement'], $prepared['params']); } $result = $prepared['statement']->execute(); } catch (PDOException $e) { throw new PDOException($e->getMessage() . ' [ ' . $this->replaceParams($prepared['query'], $prepared['params']) . ' ] ', (int)$e->getCode(), $e->getPrevious()); } if ($this->logQueries) { /** @noinspection PhpUndefinedVariableInspection */ $log['time'] = microtime(true) - $start; } return $result; }
[ "protected", "function", "execute", "(", "array", "$", "prepared", ")", "{", "if", "(", "$", "this", "->", "logQueries", ")", "{", "$", "start", "=", "microtime", "(", "true", ")", ";", "$", "log", "=", "[", "'query'", "=>", "$", "this", "->", "rep...
Executes a prepared query and returns TRUE on success or FALSE on failure. @param array $prepared Prepared query @return boolean
[ "Executes", "a", "prepared", "query", "and", "returns", "TRUE", "on", "success", "or", "FALSE", "on", "failure", "." ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/Connection.php#L557-L583
41,792
opis/database
src/SQL/Compiler.php
Compiler.insert
public function insert(SQLStatement $insert): string { $columns = $this->handleColumns($insert->getColumns()); $sql = 'INSERT INTO '; $sql .= $this->handleTables($insert->getTables()); $sql .= ($columns === '*') ? '' : ' (' . $columns . ')'; $sql .= $this->handleInsertValues($insert->getValues()); return $sql; }
php
public function insert(SQLStatement $insert): string { $columns = $this->handleColumns($insert->getColumns()); $sql = 'INSERT INTO '; $sql .= $this->handleTables($insert->getTables()); $sql .= ($columns === '*') ? '' : ' (' . $columns . ')'; $sql .= $this->handleInsertValues($insert->getValues()); return $sql; }
[ "public", "function", "insert", "(", "SQLStatement", "$", "insert", ")", ":", "string", "{", "$", "columns", "=", "$", "this", "->", "handleColumns", "(", "$", "insert", "->", "getColumns", "(", ")", ")", ";", "$", "sql", "=", "'INSERT INTO '", ";", "$...
Returns the SQL for an insert statement @param SQLStatement $insert @return string
[ "Returns", "the", "SQL", "for", "an", "insert", "statement" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L64-L74
41,793
opis/database
src/SQL/Compiler.php
Compiler.update
public function update(SQLStatement $update): string { $sql = 'UPDATE '; $sql .= $this->handleTables($update->getTables()); $sql .= $this->handleJoins($update->getJoins()); $sql .= $this->handleSetColumns($update->getColumns()); $sql .= $this->handleWheres($update->getWheres()); return $sql; }
php
public function update(SQLStatement $update): string { $sql = 'UPDATE '; $sql .= $this->handleTables($update->getTables()); $sql .= $this->handleJoins($update->getJoins()); $sql .= $this->handleSetColumns($update->getColumns()); $sql .= $this->handleWheres($update->getWheres()); return $sql; }
[ "public", "function", "update", "(", "SQLStatement", "$", "update", ")", ":", "string", "{", "$", "sql", "=", "'UPDATE '", ";", "$", "sql", ".=", "$", "this", "->", "handleTables", "(", "$", "update", "->", "getTables", "(", ")", ")", ";", "$", "sql"...
Returns the SQL for an update statement @param SQLStatement $update @return string
[ "Returns", "the", "SQL", "for", "an", "update", "statement" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L83-L92
41,794
opis/database
src/SQL/Compiler.php
Compiler.delete
public function delete(SQLStatement $delete): string { $sql = 'DELETE ' . $this->handleTables($delete->getTables()); $sql .= $sql === 'DELETE ' ? 'FROM ' : ' FROM '; $sql .= $this->handleTables($delete->getFrom()); $sql .= $this->handleJoins($delete->getJoins()); $sql .= $this->handleWheres($delete->getWheres()); return $sql; }
php
public function delete(SQLStatement $delete): string { $sql = 'DELETE ' . $this->handleTables($delete->getTables()); $sql .= $sql === 'DELETE ' ? 'FROM ' : ' FROM '; $sql .= $this->handleTables($delete->getFrom()); $sql .= $this->handleJoins($delete->getJoins()); $sql .= $this->handleWheres($delete->getWheres()); return $sql; }
[ "public", "function", "delete", "(", "SQLStatement", "$", "delete", ")", ":", "string", "{", "$", "sql", "=", "'DELETE '", ".", "$", "this", "->", "handleTables", "(", "$", "delete", "->", "getTables", "(", ")", ")", ";", "$", "sql", ".=", "$", "sql"...
Returns the SQL for a delete statement @param SQLStatement $delete @return string
[ "Returns", "the", "SQL", "for", "a", "delete", "statement" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L100-L109
41,795
opis/database
src/SQL/Compiler.php
Compiler.wrap
protected function wrap($value) { if ($value instanceof Expression) { return $this->handleExpressions($value->getExpressions()); } $wrapped = []; foreach (explode('.', $value) as $segment) { if ($segment == '*') { $wrapped[] = $segment; } else { $wrapped[] = sprintf($this->wrapper, $segment); } } return implode('.', $wrapped); }
php
protected function wrap($value) { if ($value instanceof Expression) { return $this->handleExpressions($value->getExpressions()); } $wrapped = []; foreach (explode('.', $value) as $segment) { if ($segment == '*') { $wrapped[] = $segment; } else { $wrapped[] = sprintf($this->wrapper, $segment); } } return implode('.', $wrapped); }
[ "protected", "function", "wrap", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Expression", ")", "{", "return", "$", "this", "->", "handleExpressions", "(", "$", "value", "->", "getExpressions", "(", ")", ")", ";", "}", "$", "wra...
Wrap a value @param mixed $value @return string
[ "Wrap", "a", "value" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L181-L198
41,796
opis/database
src/SQL/Compiler.php
Compiler.param
protected function param($value) { if ($value instanceof Expression) { return $this->handleExpressions($value->getExpressions()); } elseif ($value instanceof DateTime) { $this->params[] = $value->format($this->dateFormat); } else { $this->params[] = $value; } return '?'; }
php
protected function param($value) { if ($value instanceof Expression) { return $this->handleExpressions($value->getExpressions()); } elseif ($value instanceof DateTime) { $this->params[] = $value->format($this->dateFormat); } else { $this->params[] = $value; } return '?'; }
[ "protected", "function", "param", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Expression", ")", "{", "return", "$", "this", "->", "handleExpressions", "(", "$", "value", "->", "getExpressions", "(", ")", ")", ";", "}", "elseif", ...
Stores a query param @param mixed $value @return string
[ "Stores", "a", "query", "param" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L207-L218
41,797
opis/database
src/SQL/Compiler.php
Compiler.handleExpressions
protected function handleExpressions(array $expressions) { $sql = []; foreach ($expressions as $expr) { switch ($expr['type']) { case 'column': $sql[] = $this->wrap($expr['value']); break; case 'op': $sql[] = $expr['value']; break; case 'value': $sql[] = $this->param($expr['value']); break; case 'group': /** @var Expression $expression */ $expression = $expr['value']; $sql[] = '(' . $this->handleExpressions($expression->getExpressions()) . ')'; break; case 'function': $sql[] = $this->handleSqlFunction($expr['value']); break; case 'subquery': /** @var Subquery $subquery */ $subquery = $expr['value']; $sql[] = '(' . $this->select($subquery->getSQLStatement()) . ')'; break; } } return implode(' ', $sql); }
php
protected function handleExpressions(array $expressions) { $sql = []; foreach ($expressions as $expr) { switch ($expr['type']) { case 'column': $sql[] = $this->wrap($expr['value']); break; case 'op': $sql[] = $expr['value']; break; case 'value': $sql[] = $this->param($expr['value']); break; case 'group': /** @var Expression $expression */ $expression = $expr['value']; $sql[] = '(' . $this->handleExpressions($expression->getExpressions()) . ')'; break; case 'function': $sql[] = $this->handleSqlFunction($expr['value']); break; case 'subquery': /** @var Subquery $subquery */ $subquery = $expr['value']; $sql[] = '(' . $this->select($subquery->getSQLStatement()) . ')'; break; } } return implode(' ', $sql); }
[ "protected", "function", "handleExpressions", "(", "array", "$", "expressions", ")", "{", "$", "sql", "=", "[", "]", ";", "foreach", "(", "$", "expressions", "as", "$", "expr", ")", "{", "switch", "(", "$", "expr", "[", "'type'", "]", ")", "{", "case...
Handle all expressions @param array $expressions @return string
[ "Handle", "all", "expressions" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L227-L259
41,798
opis/database
src/SQL/Compiler.php
Compiler.handleWheres
protected function handleWheres(array $wheres, $prefix = true) { if (empty($wheres)) { return ''; } $sql[] = $this->{$wheres[0]['type']}($wheres[0]); $count = count($wheres); for ($i = 1; $i < $count; $i++) { $sql[] = $wheres[$i]['separator'] . ' ' . $this->{$wheres[$i]['type']}($wheres[$i]); } return ($prefix ? ' WHERE ' : '') . implode(' ', $sql); }
php
protected function handleWheres(array $wheres, $prefix = true) { if (empty($wheres)) { return ''; } $sql[] = $this->{$wheres[0]['type']}($wheres[0]); $count = count($wheres); for ($i = 1; $i < $count; $i++) { $sql[] = $wheres[$i]['separator'] . ' ' . $this->{$wheres[$i]['type']}($wheres[$i]); } return ($prefix ? ' WHERE ' : '') . implode(' ', $sql); }
[ "protected", "function", "handleWheres", "(", "array", "$", "wheres", ",", "$", "prefix", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "wheres", ")", ")", "{", "return", "''", ";", "}", "$", "sql", "[", "]", "=", "$", "this", "->", "{", ...
Handle WHERE conditions @param array $wheres @param bool $prefix (optional) @return string
[ "Handle", "WHERE", "conditions" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L348-L363
41,799
opis/database
src/SQL/Compiler.php
Compiler.handleJoins
protected function handleJoins(array $joins) { if (empty($joins)) { return ''; } $sql = []; foreach ($joins as $join) { /** @var Join $joinObject */ $joinObject = $join['join']; $on = ''; if ($joinObject) { $on = $this->handleJoinConditions($joinObject->getJoinConditions()); } if ($on !== '') { $on = ' ON ' . $on; } $sql[] = $join['type'] . ' JOIN ' . $this->handleTables($join['table']) . $on; } return ' ' . implode(' ', $sql); }
php
protected function handleJoins(array $joins) { if (empty($joins)) { return ''; } $sql = []; foreach ($joins as $join) { /** @var Join $joinObject */ $joinObject = $join['join']; $on = ''; if ($joinObject) { $on = $this->handleJoinConditions($joinObject->getJoinConditions()); } if ($on !== '') { $on = ' ON ' . $on; } $sql[] = $join['type'] . ' JOIN ' . $this->handleTables($join['table']) . $on; } return ' ' . implode(' ', $sql); }
[ "protected", "function", "handleJoins", "(", "array", "$", "joins", ")", "{", "if", "(", "empty", "(", "$", "joins", ")", ")", "{", "return", "''", ";", "}", "$", "sql", "=", "[", "]", ";", "foreach", "(", "$", "joins", "as", "$", "join", ")", ...
Handle JOIN clauses @param array $joins @return string
[ "Handle", "JOIN", "clauses" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L384-L405