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
226,700
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.css
public static function css($pro = false) { if($pro) { $url = 'pro.fontawesome.com'; $integrity = 'sha384-Bx4pytHkyTDy3aJKjGkGoHPt3tvv6zlwwjc3iqN7ktaiEMLDPqLSZYts2OjKcBx1'; } else { $url = 'use.fontawesome.com'; $integrity = 'sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf'; } return '<link rel="stylesheet" href="https://' . $url . '/releases/v' . self::FA_VERSION . '/css/all.css" integrity="' . $integrity . '" crossorigin="anonymous">'; }
php
public static function css($pro = false) { if($pro) { $url = 'pro.fontawesome.com'; $integrity = 'sha384-Bx4pytHkyTDy3aJKjGkGoHPt3tvv6zlwwjc3iqN7ktaiEMLDPqLSZYts2OjKcBx1'; } else { $url = 'use.fontawesome.com'; $integrity = 'sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf'; } return '<link rel="stylesheet" href="https://' . $url . '/releases/v' . self::FA_VERSION . '/css/all.css" integrity="' . $integrity . '" crossorigin="anonymous">'; }
[ "public", "static", "function", "css", "(", "$", "pro", "=", "false", ")", "{", "if", "(", "$", "pro", ")", "{", "$", "url", "=", "'pro.fontawesome.com'", ";", "$", "integrity", "=", "'sha384-Bx4pytHkyTDy3aJKjGkGoHPt3tvv6zlwwjc3iqN7ktaiEMLDPqLSZYts2OjKcBx1'", ";", "}", "else", "{", "$", "url", "=", "'use.fontawesome.com'", ";", "$", "integrity", "=", "'sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf'", ";", "}", "return", "'<link rel=\"stylesheet\" href=\"https://'", ".", "$", "url", ".", "'/releases/v'", ".", "self", "::", "FA_VERSION", ".", "'/css/all.css\" integrity=\"'", ".", "$", "integrity", ".", "'\" crossorigin=\"anonymous\">'", ";", "}" ]
HTML link to the FontAwesome CSS file through the FontAwesome CDN @see https://fontawesome.com/get-started/web-fonts-with-css @return string HTML link element
[ "HTML", "link", "to", "the", "FontAwesome", "CSS", "file", "through", "the", "FontAwesome", "CDN" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L70-L85
226,701
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.js
public static function js($pro = false) { if($pro) { $url = 'pro.fontawesome.com'; $integrity = 'sha384-GBwm0s/0wYcqnK/JmrCoRqWYIWzFiGEucsfFqkB76Ouii5+d4R31vWHPQtfhv55b'; } else { $url = 'use.fontawesome.com'; $integrity = 'sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ'; } return '<script defer src="https://' . $url . '/releases/v' . self::FA_VERSION . '/js/all.js" integrity="' . $integrity . '" crossorigin="anonymous"></script>'; }
php
public static function js($pro = false) { if($pro) { $url = 'pro.fontawesome.com'; $integrity = 'sha384-GBwm0s/0wYcqnK/JmrCoRqWYIWzFiGEucsfFqkB76Ouii5+d4R31vWHPQtfhv55b'; } else { $url = 'use.fontawesome.com'; $integrity = 'sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ'; } return '<script defer src="https://' . $url . '/releases/v' . self::FA_VERSION . '/js/all.js" integrity="' . $integrity . '" crossorigin="anonymous"></script>'; }
[ "public", "static", "function", "js", "(", "$", "pro", "=", "false", ")", "{", "if", "(", "$", "pro", ")", "{", "$", "url", "=", "'pro.fontawesome.com'", ";", "$", "integrity", "=", "'sha384-GBwm0s/0wYcqnK/JmrCoRqWYIWzFiGEucsfFqkB76Ouii5+d4R31vWHPQtfhv55b'", ";", "}", "else", "{", "$", "url", "=", "'use.fontawesome.com'", ";", "$", "integrity", "=", "'sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ'", ";", "}", "return", "'<script defer src=\"https://'", ".", "$", "url", ".", "'/releases/v'", ".", "self", "::", "FA_VERSION", ".", "'/js/all.js\" integrity=\"'", ".", "$", "integrity", ".", "'\" crossorigin=\"anonymous\"></script>'", ";", "}" ]
HTML link to the FontAwesome JS file through the FontAwesome CDN @see https://fontawesome.com/get-started/svg-with-js @return string HTML script tag
[ "HTML", "link", "to", "the", "FontAwesome", "JS", "file", "through", "the", "FontAwesome", "CDN" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L93-L108
226,702
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.output
protected function output() { $attrs = ''; $classes = $this->style . ' fa-' . $this->icon; $transforms = ''; $mask = ''; if (!empty($this->classes) && count($this->classes) > 0) { $classes .= ' ' . implode(' ', $this->classes); } if (!empty($this->attributes) && count($this->attributes) > 0) { foreach ($this->attributes as $attr => $val) { $attrs .= ' ' . $attr . '="' . $val . '"'; } } if (!empty($this->transforms) && count($this->transforms) > 0) { $transformList = array(); foreach ($this->transforms as $transform) { $transformList[] = implode('-', $transform); } $transforms = ' data-fa-transform="' . implode(' ', $transformList) . '"'; } if($this->mask) { $mask = ' data-fa-mask="' . $this->mask . '"'; } $htmlOutput = sprintf(self::ICON_HTML, $classes, $attrs, $transforms, $mask); return $this->resetAndOutput($htmlOutput); }
php
protected function output() { $attrs = ''; $classes = $this->style . ' fa-' . $this->icon; $transforms = ''; $mask = ''; if (!empty($this->classes) && count($this->classes) > 0) { $classes .= ' ' . implode(' ', $this->classes); } if (!empty($this->attributes) && count($this->attributes) > 0) { foreach ($this->attributes as $attr => $val) { $attrs .= ' ' . $attr . '="' . $val . '"'; } } if (!empty($this->transforms) && count($this->transforms) > 0) { $transformList = array(); foreach ($this->transforms as $transform) { $transformList[] = implode('-', $transform); } $transforms = ' data-fa-transform="' . implode(' ', $transformList) . '"'; } if($this->mask) { $mask = ' data-fa-mask="' . $this->mask . '"'; } $htmlOutput = sprintf(self::ICON_HTML, $classes, $attrs, $transforms, $mask); return $this->resetAndOutput($htmlOutput); }
[ "protected", "function", "output", "(", ")", "{", "$", "attrs", "=", "''", ";", "$", "classes", "=", "$", "this", "->", "style", ".", "' fa-'", ".", "$", "this", "->", "icon", ";", "$", "transforms", "=", "''", ";", "$", "mask", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "classes", ")", "&&", "count", "(", "$", "this", "->", "classes", ")", ">", "0", ")", "{", "$", "classes", ".=", "' '", ".", "implode", "(", "' '", ",", "$", "this", "->", "classes", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "attributes", ")", "&&", "count", "(", "$", "this", "->", "attributes", ")", ">", "0", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "$", "attrs", ".=", "' '", ".", "$", "attr", ".", "'=\"'", ".", "$", "val", ".", "'\"'", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "transforms", ")", "&&", "count", "(", "$", "this", "->", "transforms", ")", ">", "0", ")", "{", "$", "transformList", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "transforms", "as", "$", "transform", ")", "{", "$", "transformList", "[", "]", "=", "implode", "(", "'-'", ",", "$", "transform", ")", ";", "}", "$", "transforms", "=", "' data-fa-transform=\"'", ".", "implode", "(", "' '", ",", "$", "transformList", ")", ".", "'\"'", ";", "}", "if", "(", "$", "this", "->", "mask", ")", "{", "$", "mask", "=", "' data-fa-mask=\"'", ".", "$", "this", "->", "mask", ".", "'\"'", ";", "}", "$", "htmlOutput", "=", "sprintf", "(", "self", "::", "ICON_HTML", ",", "$", "classes", ",", "$", "attrs", ",", "$", "transforms", ",", "$", "mask", ")", ";", "return", "$", "this", "->", "resetAndOutput", "(", "$", "htmlOutput", ")", ";", "}" ]
Builds the icon from the template @access protected @return string
[ "Builds", "the", "icon", "from", "the", "template" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L141-L173
226,703
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.ul
public function ul($iconsOrItems, $listItems = array()) { $has_string_keys = function (array $array) { return count(array_filter(array_keys($array), 'is_string')) > 0; }; if (is_string($iconsOrItems) === false && is_array($iconsOrItems) === false) { throw new IncompleteListException( 'The list must be started with a default icon or an array with explicitly defined icons.' ); } if (is_array($iconsOrItems) && $has_string_keys($iconsOrItems) === false) { throw new IncompleteListException( 'The list array must have with explicitly defined icons since no default was given.' ); } if (is_string($iconsOrItems)) { return new FontAwesomeList($iconsOrItems, $listItems); } else { return new FontAwesomeList('', $iconsOrItems); } }
php
public function ul($iconsOrItems, $listItems = array()) { $has_string_keys = function (array $array) { return count(array_filter(array_keys($array), 'is_string')) > 0; }; if (is_string($iconsOrItems) === false && is_array($iconsOrItems) === false) { throw new IncompleteListException( 'The list must be started with a default icon or an array with explicitly defined icons.' ); } if (is_array($iconsOrItems) && $has_string_keys($iconsOrItems) === false) { throw new IncompleteListException( 'The list array must have with explicitly defined icons since no default was given.' ); } if (is_string($iconsOrItems)) { return new FontAwesomeList($iconsOrItems, $listItems); } else { return new FontAwesomeList('', $iconsOrItems); } }
[ "public", "function", "ul", "(", "$", "iconsOrItems", ",", "$", "listItems", "=", "array", "(", ")", ")", "{", "$", "has_string_keys", "=", "function", "(", "array", "$", "array", ")", "{", "return", "count", "(", "array_filter", "(", "array_keys", "(", "$", "array", ")", ",", "'is_string'", ")", ")", ">", "0", ";", "}", ";", "if", "(", "is_string", "(", "$", "iconsOrItems", ")", "===", "false", "&&", "is_array", "(", "$", "iconsOrItems", ")", "===", "false", ")", "{", "throw", "new", "IncompleteListException", "(", "'The list must be started with a default icon or an array with explicitly defined icons.'", ")", ";", "}", "if", "(", "is_array", "(", "$", "iconsOrItems", ")", "&&", "$", "has_string_keys", "(", "$", "iconsOrItems", ")", "===", "false", ")", "{", "throw", "new", "IncompleteListException", "(", "'The list array must have with explicitly defined icons since no default was given.'", ")", ";", "}", "if", "(", "is_string", "(", "$", "iconsOrItems", ")", ")", "{", "return", "new", "FontAwesomeList", "(", "$", "iconsOrItems", ",", "$", "listItems", ")", ";", "}", "else", "{", "return", "new", "FontAwesomeList", "(", "''", ",", "$", "iconsOrItems", ")", ";", "}", "}" ]
Begins building an unordered list with icons When given a single, string input, the list is started with that parameter as the default icon for all items in the list. New items can be added with the li() method or as an array in the second parameter. If passed an array for the first parameter, then the list is created with the list items automatically applied. If the array has numeric, or was not explicitly defined an icon, then the default will be used. The default can be overriden by passing an icon name as the key to the value. @param $iconsOrItems string|array[string] Default icon to use if list has non defined @param $listItems array[string] Array of list items @return \Khill\FontAwesome\FontAwesomeList @throws \Khill\FontAwesome\Exceptions\IncompleteListException
[ "Begins", "building", "an", "unordered", "list", "with", "icons" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L228-L251
226,704
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.stack
public function stack($icon, array $classes = array()) { if (is_string($icon) === false) { throw new \InvalidArgumentException( 'Icon label must be a string.' ); } return new FontAwesomeStack($icon, $classes); }
php
public function stack($icon, array $classes = array()) { if (is_string($icon) === false) { throw new \InvalidArgumentException( 'Icon label must be a string.' ); } return new FontAwesomeStack($icon, $classes); }
[ "public", "function", "stack", "(", "$", "icon", ",", "array", "$", "classes", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "icon", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Icon label must be a string.'", ")", ";", "}", "return", "new", "FontAwesomeStack", "(", "$", "icon", ",", "$", "classes", ")", ";", "}" ]
Sets the top icon to be used in a stack @param string $icon Icon label, omitting the "fa-" prefix @param array $classes @return \Khill\FontAwesome\FontAwesomeStack
[ "Sets", "the", "top", "icon", "to", "be", "used", "in", "a", "stack" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L260-L269
226,705
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.store
public function store($label) { if ($this->icon === null) { throw new CollectionIconException( 'There was no icon defined to store.' ); } if (is_string($label) === false || empty($label) === true) { throw new \InvalidArgumentException( 'Collection icon label must be a non-empty string.' ); } $this->collection[$label] = $this->output(); return $this; }
php
public function store($label) { if ($this->icon === null) { throw new CollectionIconException( 'There was no icon defined to store.' ); } if (is_string($label) === false || empty($label) === true) { throw new \InvalidArgumentException( 'Collection icon label must be a non-empty string.' ); } $this->collection[$label] = $this->output(); return $this; }
[ "public", "function", "store", "(", "$", "label", ")", "{", "if", "(", "$", "this", "->", "icon", "===", "null", ")", "{", "throw", "new", "CollectionIconException", "(", "'There was no icon defined to store.'", ")", ";", "}", "if", "(", "is_string", "(", "$", "label", ")", "===", "false", "||", "empty", "(", "$", "label", ")", "===", "true", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Collection icon label must be a non-empty string.'", ")", ";", "}", "$", "this", "->", "collection", "[", "$", "label", "]", "=", "$", "this", "->", "output", "(", ")", ";", "return", "$", "this", ";", "}" ]
Stores icon to be rendered later and resets @param string $label Label of icon to save in collection @return self @throws \InvalidArgumentException If $label anything but a non-empty \string @throws \Khill\FontAwesome\Exceptions\CollectionIconException If store() method called without defining an icon
[ "Stores", "icon", "to", "be", "rendered", "later", "and", "resets" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L290-L307
226,706
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.collection
public function collection($label) { if (is_string($label) === false) { throw new \InvalidArgumentException( 'Collection icon label must be a string.' ); } if (isset($this->collection[$label]) === false) { throw new CollectionIconException( 'Collection icon "' . $label . '" does not exist.' ); } return $this->collection[$label]; }
php
public function collection($label) { if (is_string($label) === false) { throw new \InvalidArgumentException( 'Collection icon label must be a string.' ); } if (isset($this->collection[$label]) === false) { throw new CollectionIconException( 'Collection icon "' . $label . '" does not exist.' ); } return $this->collection[$label]; }
[ "public", "function", "collection", "(", "$", "label", ")", "{", "if", "(", "is_string", "(", "$", "label", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Collection icon label must be a string.'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "collection", "[", "$", "label", "]", ")", "===", "false", ")", "{", "throw", "new", "CollectionIconException", "(", "'Collection icon \"'", ".", "$", "label", ".", "'\" does not exist.'", ")", ";", "}", "return", "$", "this", "->", "collection", "[", "$", "label", "]", ";", "}" ]
Retrieve icon from collection @param string $label Icon label used in store method @return string HTML icon string @throws \InvalidArgumentException If $label anything but a non-empty \string @throws CollectionIconException If icon $label is not set
[ "Retrieve", "icon", "from", "collection" ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L341-L356
226,707
kevinkhill/FontAwesomePHP
src/FontAwesome.php
FontAwesome.resetAndOutput
private function resetAndOutput($htmlOutput) { $this->icon = null; $this->classes = null; $this->attributes = null; $this->mask = null; $this->style = self::DEFAULT_STYLE; return (string) $htmlOutput; }
php
private function resetAndOutput($htmlOutput) { $this->icon = null; $this->classes = null; $this->attributes = null; $this->mask = null; $this->style = self::DEFAULT_STYLE; return (string) $htmlOutput; }
[ "private", "function", "resetAndOutput", "(", "$", "htmlOutput", ")", "{", "$", "this", "->", "icon", "=", "null", ";", "$", "this", "->", "classes", "=", "null", ";", "$", "this", "->", "attributes", "=", "null", ";", "$", "this", "->", "mask", "=", "null", ";", "$", "this", "->", "style", "=", "self", "::", "DEFAULT_STYLE", ";", "return", "(", "string", ")", "$", "htmlOutput", ";", "}" ]
Outputs the current contents to the page. @param string $htmlOutput @return string
[ "Outputs", "the", "current", "contents", "to", "the", "page", "." ]
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesome.php#L388-L397
226,708
wapmorgan/Imagery
src/Imagery.php
Imagery.create
static public function create($width, $height) { $image = imagecreatetruecolor($width, $height); imagealphablending($image, false); imagesavealpha($image, true); return new self($image); }
php
static public function create($width, $height) { $image = imagecreatetruecolor($width, $height); imagealphablending($image, false); imagesavealpha($image, true); return new self($image); }
[ "static", "public", "function", "create", "(", "$", "width", ",", "$", "height", ")", "{", "$", "image", "=", "imagecreatetruecolor", "(", "$", "width", ",", "$", "height", ")", ";", "imagealphablending", "(", "$", "image", ",", "false", ")", ";", "imagesavealpha", "(", "$", "image", ",", "true", ")", ";", "return", "new", "self", "(", "$", "image", ")", ";", "}" ]
Creates an instance with specified size @param int $width Image width @param int $height Image height
[ "Creates", "an", "instance", "with", "specified", "size" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L78-L83
226,709
wapmorgan/Imagery
src/Imagery.php
Imagery.copyFrom
public function copyFrom(Imagery $source) { imagecopyresampled($this->_image, $source->resource, 0, 0, 0, 0, $this->width, $this->height, $source->width, $source->height); return $this; }
php
public function copyFrom(Imagery $source) { imagecopyresampled($this->_image, $source->resource, 0, 0, 0, 0, $this->width, $this->height, $source->width, $source->height); return $this; }
[ "public", "function", "copyFrom", "(", "Imagery", "$", "source", ")", "{", "imagecopyresampled", "(", "$", "this", "->", "_image", ",", "$", "source", "->", "resource", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "source", "->", "width", ",", "$", "source", "->", "height", ")", ";", "return", "$", "this", ";", "}" ]
Copies an image fron another instance with zoom @param Imagery $source An image that will be source for resampling @return Imagery this object
[ "Copies", "an", "image", "fron", "another", "instance", "with", "zoom" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L153-L156
226,710
wapmorgan/Imagery
src/Imagery.php
Imagery.flip
public function flip($horizontal = true) { if (function_exists('imageflip')) { imageflip($this->_image, $horizontal ? IMG_FLIP_HORIZONTAL : IMG_FLIP_VERTICAL); } else { $image = imagecreatetruecolor($this->width, $this->height); imagealphablending($image, false); imagesavealpha($image, true); if ($horizontal) { $dst_y = 0; $src_y = 0; $coordinate = ($this->width - 1); foreach (range($this->width, 0) as $range) { $src_x = $range; $dst_x = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, 1, $this->height); } } else { $dst_x = 0; $src_x = 0; $coordinate = ($this->height - 1); foreach (range($this->height, 0) as $range) { $src_y = $range; $dst_y = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, $this->width, 1); } } imagedestroy($this->_image); $this->_image = $image; } return $this; }
php
public function flip($horizontal = true) { if (function_exists('imageflip')) { imageflip($this->_image, $horizontal ? IMG_FLIP_HORIZONTAL : IMG_FLIP_VERTICAL); } else { $image = imagecreatetruecolor($this->width, $this->height); imagealphablending($image, false); imagesavealpha($image, true); if ($horizontal) { $dst_y = 0; $src_y = 0; $coordinate = ($this->width - 1); foreach (range($this->width, 0) as $range) { $src_x = $range; $dst_x = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, 1, $this->height); } } else { $dst_x = 0; $src_x = 0; $coordinate = ($this->height - 1); foreach (range($this->height, 0) as $range) { $src_y = $range; $dst_y = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, $this->width, 1); } } imagedestroy($this->_image); $this->_image = $image; } return $this; }
[ "public", "function", "flip", "(", "$", "horizontal", "=", "true", ")", "{", "if", "(", "function_exists", "(", "'imageflip'", ")", ")", "{", "imageflip", "(", "$", "this", "->", "_image", ",", "$", "horizontal", "?", "IMG_FLIP_HORIZONTAL", ":", "IMG_FLIP_VERTICAL", ")", ";", "}", "else", "{", "$", "image", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "imagealphablending", "(", "$", "image", ",", "false", ")", ";", "imagesavealpha", "(", "$", "image", ",", "true", ")", ";", "if", "(", "$", "horizontal", ")", "{", "$", "dst_y", "=", "0", ";", "$", "src_y", "=", "0", ";", "$", "coordinate", "=", "(", "$", "this", "->", "width", "-", "1", ")", ";", "foreach", "(", "range", "(", "$", "this", "->", "width", ",", "0", ")", "as", "$", "range", ")", "{", "$", "src_x", "=", "$", "range", ";", "$", "dst_x", "=", "$", "coordinate", "-", "$", "range", ";", "imagecopy", "(", "$", "image", ",", "$", "this", "->", "_image", ",", "$", "dst_x", ",", "$", "dst_y", ",", "$", "src_x", ",", "$", "src_y", ",", "1", ",", "$", "this", "->", "height", ")", ";", "}", "}", "else", "{", "$", "dst_x", "=", "0", ";", "$", "src_x", "=", "0", ";", "$", "coordinate", "=", "(", "$", "this", "->", "height", "-", "1", ")", ";", "foreach", "(", "range", "(", "$", "this", "->", "height", ",", "0", ")", "as", "$", "range", ")", "{", "$", "src_y", "=", "$", "range", ";", "$", "dst_y", "=", "$", "coordinate", "-", "$", "range", ";", "imagecopy", "(", "$", "image", ",", "$", "this", "->", "_image", ",", "$", "dst_x", ",", "$", "dst_y", ",", "$", "src_x", ",", "$", "src_y", ",", "$", "this", "->", "width", ",", "1", ")", ";", "}", "}", "imagedestroy", "(", "$", "this", "->", "_image", ")", ";", "$", "this", "->", "_image", "=", "$", "image", ";", "}", "return", "$", "this", ";", "}" ]
Flips an image. @return Imagery this object
[ "Flips", "an", "image", "." ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L425-L455
226,711
wapmorgan/Imagery
src/Imagery.php
Imagery.filter
public function filter($filter) { if (!in_array($filter, array(self::FILTER_NEGATE, self::FILTER_GRAYSCALE))) return false; imagefilter($this->resource, $filter); return $this; }
php
public function filter($filter) { if (!in_array($filter, array(self::FILTER_NEGATE, self::FILTER_GRAYSCALE))) return false; imagefilter($this->resource, $filter); return $this; }
[ "public", "function", "filter", "(", "$", "filter", ")", "{", "if", "(", "!", "in_array", "(", "$", "filter", ",", "array", "(", "self", "::", "FILTER_NEGATE", ",", "self", "::", "FILTER_GRAYSCALE", ")", ")", ")", "return", "false", ";", "imagefilter", "(", "$", "this", "->", "resource", ",", "$", "filter", ")", ";", "return", "$", "this", ";", "}" ]
Applies a filter to image @param int One of FILTER_* constants @return Imagery this object
[ "Applies", "a", "filter", "to", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L462-L467
226,712
wapmorgan/Imagery
src/Imagery.php
Imagery.changeBrightness
public function changeBrightness($newValue) { $newValue = max(-255, min(255, $newValue)); imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, $newValue); return $this; }
php
public function changeBrightness($newValue) { $newValue = max(-255, min(255, $newValue)); imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, $newValue); return $this; }
[ "public", "function", "changeBrightness", "(", "$", "newValue", ")", "{", "$", "newValue", "=", "max", "(", "-", "255", ",", "min", "(", "255", ",", "$", "newValue", ")", ")", ";", "imagefilter", "(", "$", "this", "->", "resource", ",", "IMG_FILTER_BRIGHTNESS", ",", "$", "newValue", ")", ";", "return", "$", "this", ";", "}" ]
Changes brightness of image @param int $newValue Range from 255 (max brightness) to -255 (min brightness). 0 means no change @return Imagery this object
[ "Changes", "brightness", "of", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L486-L490
226,713
wapmorgan/Imagery
src/Imagery.php
Imagery.colorize
public function colorize($red, $green, $blue, $alpha = 127) { $normalizer = function ($value) { return max(-255, min(255, $value)); }; $red = $normalizer($red); $green = $normalizer($green); $blue = $normalizer($blue); $alpha = min(127, max(0, $alpha)); imagefilter($this->resource, IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha); return $this; }
php
public function colorize($red, $green, $blue, $alpha = 127) { $normalizer = function ($value) { return max(-255, min(255, $value)); }; $red = $normalizer($red); $green = $normalizer($green); $blue = $normalizer($blue); $alpha = min(127, max(0, $alpha)); imagefilter($this->resource, IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha); return $this; }
[ "public", "function", "colorize", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ",", "$", "alpha", "=", "127", ")", "{", "$", "normalizer", "=", "function", "(", "$", "value", ")", "{", "return", "max", "(", "-", "255", ",", "min", "(", "255", ",", "$", "value", ")", ")", ";", "}", ";", "$", "red", "=", "$", "normalizer", "(", "$", "red", ")", ";", "$", "green", "=", "$", "normalizer", "(", "$", "green", ")", ";", "$", "blue", "=", "$", "normalizer", "(", "$", "blue", ")", ";", "$", "alpha", "=", "min", "(", "127", ",", "max", "(", "0", ",", "$", "alpha", ")", ")", ";", "imagefilter", "(", "$", "this", "->", "resource", ",", "IMG_FILTER_COLORIZE", ",", "$", "red", ",", "$", "green", ",", "$", "blue", ",", "$", "alpha", ")", ";", "return", "$", "this", ";", "}" ]
Changes colors of image @param int $red Range from 255 to -255 @param int $green Range from 255 to -255 @param int $blue Range from 255 to -255 @param int $alpha Range from 255 to -255 @return Imagery this object
[ "Changes", "colors", "of", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L500-L508
226,714
wapmorgan/Imagery
src/Imagery.php
Imagery.blur
public function blur($method = self::GAUSSIAN_BLUR) { if (!in_array($method, array(self::GAUSSIAN_BLUR, self::SELECTIVE_BLUR))) return false; imagefilter($this->resource, $method); return $this; }
php
public function blur($method = self::GAUSSIAN_BLUR) { if (!in_array($method, array(self::GAUSSIAN_BLUR, self::SELECTIVE_BLUR))) return false; imagefilter($this->resource, $method); return $this; }
[ "public", "function", "blur", "(", "$", "method", "=", "self", "::", "GAUSSIAN_BLUR", ")", "{", "if", "(", "!", "in_array", "(", "$", "method", ",", "array", "(", "self", "::", "GAUSSIAN_BLUR", ",", "self", "::", "SELECTIVE_BLUR", ")", ")", ")", "return", "false", ";", "imagefilter", "(", "$", "this", "->", "resource", ",", "$", "method", ")", ";", "return", "$", "this", ";", "}" ]
Blurs an image @param int $method One of blue methods: GAUSSIAN_BLUR or SELECTIVE_BLUR @return Imagery this object
[ "Blurs", "an", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L515-L520
226,715
wapmorgan/Imagery
src/Imagery.php
Imagery.smooth
public function smooth($level = 1) { $level = max(1, min(8, $level)); if ($level == 8) $level = 9; // inversion is needed. Do not delete. imagefilter($this->resource, IMG_FILTER_SMOOTH, -$level); return $this; }
php
public function smooth($level = 1) { $level = max(1, min(8, $level)); if ($level == 8) $level = 9; // inversion is needed. Do not delete. imagefilter($this->resource, IMG_FILTER_SMOOTH, -$level); return $this; }
[ "public", "function", "smooth", "(", "$", "level", "=", "1", ")", "{", "$", "level", "=", "max", "(", "1", ",", "min", "(", "8", ",", "$", "level", ")", ")", ";", "if", "(", "$", "level", "==", "8", ")", "$", "level", "=", "9", ";", "// inversion is needed. Do not delete.", "imagefilter", "(", "$", "this", "->", "resource", ",", "IMG_FILTER_SMOOTH", ",", "-", "$", "level", ")", ";", "return", "$", "this", ";", "}" ]
Smooths an image @param int $level Level of smoothness. Range from 0 to 8. 8 is un-smooth. @return Imagery this object
[ "Smooths", "an", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L527-L533
226,716
wapmorgan/Imagery
src/Imagery.php
Imagery.pixelate
public function pixelate($blockSize = 5, $useModernEffect = true) { imagefilter($this->resource, IMG_FILTER_PIXELATE, $blockSize, $useModernEffect); return $this; }
php
public function pixelate($blockSize = 5, $useModernEffect = true) { imagefilter($this->resource, IMG_FILTER_PIXELATE, $blockSize, $useModernEffect); return $this; }
[ "public", "function", "pixelate", "(", "$", "blockSize", "=", "5", ",", "$", "useModernEffect", "=", "true", ")", "{", "imagefilter", "(", "$", "this", "->", "resource", ",", "IMG_FILTER_PIXELATE", ",", "$", "blockSize", ",", "$", "useModernEffect", ")", ";", "return", "$", "this", ";", "}" ]
Pixelates an image @param int $blockSize Size of pixel block @param boolean $useModernEffect Use or not to use new pixelate effect @return Imagery this object
[ "Pixelates", "an", "image" ]
9e2a1294bd235bded9f893ea530b1d86bfc2d07c
https://github.com/wapmorgan/Imagery/blob/9e2a1294bd235bded9f893ea530b1d86bfc2d07c/src/Imagery.php#L541-L544
226,717
gigaai/framework
src/Broadcast/Broadcast.php
Broadcast.send
public static function send(BroadcastModel $broadcast) { // Send message if people hit send button $broadcastProperties = [ 'message_creative_id' => $broadcast->message_creative_id, 'notification_type' => $broadcast->notification_type, 'tag' => $broadcast->tags ]; $receivers = $broadcast->getReceivers(); $receivers = $receivers !== null && is_array($receivers) ? $receivers : ['all']; foreach ($receivers as $channel) { if ( ! is_null($channel) && $channel !== 'all') { $labelId = Group::find($channel)->meta['facebook_label_id']; $broadcastProperties['custom_label_id'] = $labelId; } $response = giga_facebook_post('me/broadcast_messages', $broadcastProperties); if (isset($response->broadcast_id)) { BroadcastModel::create([ 'instance_id' => $broadcast->instance_id, 'parent_id' => $broadcast->id, 'description' => $response->broadcast_id, 'content' => $response->broadcast_id ]); } } }
php
public static function send(BroadcastModel $broadcast) { // Send message if people hit send button $broadcastProperties = [ 'message_creative_id' => $broadcast->message_creative_id, 'notification_type' => $broadcast->notification_type, 'tag' => $broadcast->tags ]; $receivers = $broadcast->getReceivers(); $receivers = $receivers !== null && is_array($receivers) ? $receivers : ['all']; foreach ($receivers as $channel) { if ( ! is_null($channel) && $channel !== 'all') { $labelId = Group::find($channel)->meta['facebook_label_id']; $broadcastProperties['custom_label_id'] = $labelId; } $response = giga_facebook_post('me/broadcast_messages', $broadcastProperties); if (isset($response->broadcast_id)) { BroadcastModel::create([ 'instance_id' => $broadcast->instance_id, 'parent_id' => $broadcast->id, 'description' => $response->broadcast_id, 'content' => $response->broadcast_id ]); } } }
[ "public", "static", "function", "send", "(", "BroadcastModel", "$", "broadcast", ")", "{", "// Send message if people hit send button", "$", "broadcastProperties", "=", "[", "'message_creative_id'", "=>", "$", "broadcast", "->", "message_creative_id", ",", "'notification_type'", "=>", "$", "broadcast", "->", "notification_type", ",", "'tag'", "=>", "$", "broadcast", "->", "tags", "]", ";", "$", "receivers", "=", "$", "broadcast", "->", "getReceivers", "(", ")", ";", "$", "receivers", "=", "$", "receivers", "!==", "null", "&&", "is_array", "(", "$", "receivers", ")", "?", "$", "receivers", ":", "[", "'all'", "]", ";", "foreach", "(", "$", "receivers", "as", "$", "channel", ")", "{", "if", "(", "!", "is_null", "(", "$", "channel", ")", "&&", "$", "channel", "!==", "'all'", ")", "{", "$", "labelId", "=", "Group", "::", "find", "(", "$", "channel", ")", "->", "meta", "[", "'facebook_label_id'", "]", ";", "$", "broadcastProperties", "[", "'custom_label_id'", "]", "=", "$", "labelId", ";", "}", "$", "response", "=", "giga_facebook_post", "(", "'me/broadcast_messages'", ",", "$", "broadcastProperties", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "broadcast_id", ")", ")", "{", "BroadcastModel", "::", "create", "(", "[", "'instance_id'", "=>", "$", "broadcast", "->", "instance_id", ",", "'parent_id'", "=>", "$", "broadcast", "->", "id", ",", "'description'", "=>", "$", "response", "->", "broadcast_id", ",", "'content'", "=>", "$", "response", "->", "broadcast_id", "]", ")", ";", "}", "}", "}" ]
Send Broadcast to Facebook and let they do the rest @param Broadcast $broadcast
[ "Send", "Broadcast", "to", "Facebook", "and", "let", "they", "do", "the", "rest" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Broadcast/Broadcast.php#L24-L54
226,718
gigaai/framework
src/Broadcast/Broadcast.php
Broadcast.createMessageCreative
public static function createMessageCreative(BroadcastModel $broadcast) { if (is_numeric($broadcast->content)) { $template = Node::find($broadcast->content)->answers; } else { $model = new Model; $template = $model->parse(json_decode($broadcast->content, true)); } $messages = []; foreach ($template as $answer) { if (!in_array($answer['type'], ['text', 'receipt'])) { $messages[] = $answer['content']; } if ($answer['type'] === 'text') { // Convert to Dynamic Text if (str_contains($answer['content']['text'], '{{')) { $messages[] = [ 'dynamic_text' => [ 'text' => $answer['content']['text'], 'fallback_text' => $answer['content']['text'] ] ]; } else { $messages[] = $answer['content']; } } } // Create message creative $response = giga_facebook_post('me/message_creatives', compact('messages')); if (isset($response->message_creative_id)) { return $response->message_creative_id; } else { throw new \Exception("Cannot create message creative!", 1); } }
php
public static function createMessageCreative(BroadcastModel $broadcast) { if (is_numeric($broadcast->content)) { $template = Node::find($broadcast->content)->answers; } else { $model = new Model; $template = $model->parse(json_decode($broadcast->content, true)); } $messages = []; foreach ($template as $answer) { if (!in_array($answer['type'], ['text', 'receipt'])) { $messages[] = $answer['content']; } if ($answer['type'] === 'text') { // Convert to Dynamic Text if (str_contains($answer['content']['text'], '{{')) { $messages[] = [ 'dynamic_text' => [ 'text' => $answer['content']['text'], 'fallback_text' => $answer['content']['text'] ] ]; } else { $messages[] = $answer['content']; } } } // Create message creative $response = giga_facebook_post('me/message_creatives', compact('messages')); if (isset($response->message_creative_id)) { return $response->message_creative_id; } else { throw new \Exception("Cannot create message creative!", 1); } }
[ "public", "static", "function", "createMessageCreative", "(", "BroadcastModel", "$", "broadcast", ")", "{", "if", "(", "is_numeric", "(", "$", "broadcast", "->", "content", ")", ")", "{", "$", "template", "=", "Node", "::", "find", "(", "$", "broadcast", "->", "content", ")", "->", "answers", ";", "}", "else", "{", "$", "model", "=", "new", "Model", ";", "$", "template", "=", "$", "model", "->", "parse", "(", "json_decode", "(", "$", "broadcast", "->", "content", ",", "true", ")", ")", ";", "}", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "template", "as", "$", "answer", ")", "{", "if", "(", "!", "in_array", "(", "$", "answer", "[", "'type'", "]", ",", "[", "'text'", ",", "'receipt'", "]", ")", ")", "{", "$", "messages", "[", "]", "=", "$", "answer", "[", "'content'", "]", ";", "}", "if", "(", "$", "answer", "[", "'type'", "]", "===", "'text'", ")", "{", "// Convert to Dynamic Text", "if", "(", "str_contains", "(", "$", "answer", "[", "'content'", "]", "[", "'text'", "]", ",", "'{{'", ")", ")", "{", "$", "messages", "[", "]", "=", "[", "'dynamic_text'", "=>", "[", "'text'", "=>", "$", "answer", "[", "'content'", "]", "[", "'text'", "]", ",", "'fallback_text'", "=>", "$", "answer", "[", "'content'", "]", "[", "'text'", "]", "]", "]", ";", "}", "else", "{", "$", "messages", "[", "]", "=", "$", "answer", "[", "'content'", "]", ";", "}", "}", "}", "// Create message creative", "$", "response", "=", "giga_facebook_post", "(", "'me/message_creatives'", ",", "compact", "(", "'messages'", ")", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "message_creative_id", ")", ")", "{", "return", "$", "response", "->", "message_creative_id", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Cannot create message creative!\"", ",", "1", ")", ";", "}", "}" ]
Because each message creative can only attach to 1 broadcast so we'll create message creative each time we send @param Broadcast $broadcast @return Mixed
[ "Because", "each", "message", "creative", "can", "only", "attach", "to", "1", "broadcast", "so", "we", "ll", "create", "message", "creative", "each", "time", "we", "send" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Broadcast/Broadcast.php#L63-L104
226,719
loco/swizzle
src/Swizzle.php
Swizzle.verbose
public function verbose($resource) { $this->logger->pushHandler(new StreamHandler($resource, Logger::DEBUG)); return $this; }
php
public function verbose($resource) { $this->logger->pushHandler(new StreamHandler($resource, Logger::DEBUG)); return $this; }
[ "public", "function", "verbose", "(", "$", "resource", ")", "{", "$", "this", "->", "logger", "->", "pushHandler", "(", "new", "StreamHandler", "(", "$", "resource", ",", "Logger", "::", "DEBUG", ")", ")", ";", "return", "$", "this", ";", "}" ]
Enable debug logging to show build progress @param string|resource @return Swizzle @throws \Exception
[ "Enable", "debug", "logging", "to", "show", "build", "progress" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L111-L115
226,720
loco/swizzle
src/Swizzle.php
Swizzle.setInitValue
private function setInitValue($key, $value) { if ($this->serviceDescription !== null) { throw new \RuntimeException('Too late to set "'.$key.'"'); } $this->init[$key] = $value; return $this; }
php
private function setInitValue($key, $value) { if ($this->serviceDescription !== null) { throw new \RuntimeException('Too late to set "'.$key.'"'); } $this->init[$key] = $value; return $this; }
[ "private", "function", "setInitValue", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "serviceDescription", "!==", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Too late to set \"'", ".", "$", "key", ".", "'\"'", ")", ";", "}", "$", "this", "->", "init", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set an initial value to be passed to ServiceDescription constructor. @param string $key @param mixed $value @return Swizzle @throws \RuntimeException
[ "Set", "an", "initial", "value", "to", "be", "passed", "to", "ServiceDescription", "constructor", "." ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L153-L161
226,721
loco/swizzle
src/Swizzle.php
Swizzle.getServiceDescription
public function getServiceDescription() { if ($this->serviceDescription === null) { $this->serviceDescription = new Description($this->init); } return $this->serviceDescription; }
php
public function getServiceDescription() { if ($this->serviceDescription === null) { $this->serviceDescription = new Description($this->init); } return $this->serviceDescription; }
[ "public", "function", "getServiceDescription", "(", ")", "{", "if", "(", "$", "this", "->", "serviceDescription", "===", "null", ")", "{", "$", "this", "->", "serviceDescription", "=", "new", "Description", "(", "$", "this", "->", "init", ")", ";", "}", "return", "$", "this", "->", "serviceDescription", ";", "}" ]
Get compiled Guzzle service description @return Description @throws \InvalidArgumentException
[ "Get", "compiled", "Guzzle", "service", "description" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L198-L204
226,722
loco/swizzle
src/Swizzle.php
Swizzle.registerResponseClass
public function registerResponseClass($name, $class) { $this->responseClasses[$name] = $class; // set retrospectively if method already encountered if ($this->serviceDescription !== null && $this->hasOperation($name) === true ) { throw new \LogicException( "Too late to add new response class, {$name} operation has already been defined. " .'If you want to add a new response class, call reset() method first, add new response class ' .'and run build again.' ); } return $this; }
php
public function registerResponseClass($name, $class) { $this->responseClasses[$name] = $class; // set retrospectively if method already encountered if ($this->serviceDescription !== null && $this->hasOperation($name) === true ) { throw new \LogicException( "Too late to add new response class, {$name} operation has already been defined. " .'If you want to add a new response class, call reset() method first, add new response class ' .'and run build again.' ); } return $this; }
[ "public", "function", "registerResponseClass", "(", "$", "name", ",", "$", "class", ")", "{", "$", "this", "->", "responseClasses", "[", "$", "name", "]", "=", "$", "class", ";", "// set retrospectively if method already encountered", "if", "(", "$", "this", "->", "serviceDescription", "!==", "null", "&&", "$", "this", "->", "hasOperation", "(", "$", "name", ")", "===", "true", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Too late to add new response class, {$name} operation has already been defined. \"", ".", "'If you want to add a new response class, call reset() method first, add new response class '", ".", "'and run build again.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Apply a bespoke responseClass to a given method @param string name of command returning this response class @param string full class name for responseClass field @return Swizzle @throws \LogicException @throws \InvalidArgumentException
[ "Apply", "a", "bespoke", "responseClass", "to", "a", "given", "method" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L217-L231
226,723
loco/swizzle
src/Swizzle.php
Swizzle.build
public function build($baseUri) { $this->serviceDescription = null; $client = SwaggerClient::factory(['base_uri' => $baseUri]); $this->debug('Fetching resource listing from %s', $baseUri); $listing = $client->getResources(); // check this looks like a resource listing if (!$listing->isSwagger()) { throw new \RuntimeException("This doesn't look like a Swagger spec"); } if (!$listing->getApis()) { $this->logger->addAlert("Resource listing doesn't define any APIs"); } // check swagger version if (self::SWAGGER_VERSION !== $listing->getSwaggerVersion()) { throw new \RuntimeException('Unsupported Swagger version, Swizzle expects '.self::SWAGGER_VERSION); } // Declared version overrides anything we've set if ($version = $listing->getApiVersion()) { $this->debug('+ set apiVersion %s', $version); $this->setApiVersion($version); } // Set description if missing from constructor if (empty($this->init['description'])) { $info = $listing->getInfo(); $this->init['description'] = $info['description'] ?: $this->init['title']; } // set base path from docs location if not provided if (empty($this->init['baseUri'])) { $this->init['baseUri'] = self::mergeUrl('/', $baseUri); } // no more configs allowed now, Guzzle service gets constructed $service = $this->getServiceDescription(); // ready to pull each api declaration foreach ($listing->getApiPaths() as $path) { if ($this->delay) { usleep($this->delay); } // @todo do proper path resolution here, allowing a cross-domain spec. $path = rtrim(parse_url($baseUri)['path'], '/').'/'.ltrim($path, '/'); $this->debug('pulling %s ...', $path); $apiDeclaration = $client->getDeclaration(compact('path')); foreach ($apiDeclaration->getModels() as $model) { $this->addModel($model); } // Ensure a fully qualified base url for this api $baseUrl = self::mergeUrl($apiDeclaration->getBasePath(), $service->getBaseUri()); // add each api against required base url foreach ($apiDeclaration->getApis() as $api) { $this->addApi($api, $baseUrl); } } $this->debug('finished'); return $this; }
php
public function build($baseUri) { $this->serviceDescription = null; $client = SwaggerClient::factory(['base_uri' => $baseUri]); $this->debug('Fetching resource listing from %s', $baseUri); $listing = $client->getResources(); // check this looks like a resource listing if (!$listing->isSwagger()) { throw new \RuntimeException("This doesn't look like a Swagger spec"); } if (!$listing->getApis()) { $this->logger->addAlert("Resource listing doesn't define any APIs"); } // check swagger version if (self::SWAGGER_VERSION !== $listing->getSwaggerVersion()) { throw new \RuntimeException('Unsupported Swagger version, Swizzle expects '.self::SWAGGER_VERSION); } // Declared version overrides anything we've set if ($version = $listing->getApiVersion()) { $this->debug('+ set apiVersion %s', $version); $this->setApiVersion($version); } // Set description if missing from constructor if (empty($this->init['description'])) { $info = $listing->getInfo(); $this->init['description'] = $info['description'] ?: $this->init['title']; } // set base path from docs location if not provided if (empty($this->init['baseUri'])) { $this->init['baseUri'] = self::mergeUrl('/', $baseUri); } // no more configs allowed now, Guzzle service gets constructed $service = $this->getServiceDescription(); // ready to pull each api declaration foreach ($listing->getApiPaths() as $path) { if ($this->delay) { usleep($this->delay); } // @todo do proper path resolution here, allowing a cross-domain spec. $path = rtrim(parse_url($baseUri)['path'], '/').'/'.ltrim($path, '/'); $this->debug('pulling %s ...', $path); $apiDeclaration = $client->getDeclaration(compact('path')); foreach ($apiDeclaration->getModels() as $model) { $this->addModel($model); } // Ensure a fully qualified base url for this api $baseUrl = self::mergeUrl($apiDeclaration->getBasePath(), $service->getBaseUri()); // add each api against required base url foreach ($apiDeclaration->getApis() as $api) { $this->addApi($api, $baseUrl); } } $this->debug('finished'); return $this; }
[ "public", "function", "build", "(", "$", "baseUri", ")", "{", "$", "this", "->", "serviceDescription", "=", "null", ";", "$", "client", "=", "SwaggerClient", "::", "factory", "(", "[", "'base_uri'", "=>", "$", "baseUri", "]", ")", ";", "$", "this", "->", "debug", "(", "'Fetching resource listing from %s'", ",", "$", "baseUri", ")", ";", "$", "listing", "=", "$", "client", "->", "getResources", "(", ")", ";", "// check this looks like a resource listing", "if", "(", "!", "$", "listing", "->", "isSwagger", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"This doesn't look like a Swagger spec\"", ")", ";", "}", "if", "(", "!", "$", "listing", "->", "getApis", "(", ")", ")", "{", "$", "this", "->", "logger", "->", "addAlert", "(", "\"Resource listing doesn't define any APIs\"", ")", ";", "}", "// check swagger version", "if", "(", "self", "::", "SWAGGER_VERSION", "!==", "$", "listing", "->", "getSwaggerVersion", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Unsupported Swagger version, Swizzle expects '", ".", "self", "::", "SWAGGER_VERSION", ")", ";", "}", "// Declared version overrides anything we've set", "if", "(", "$", "version", "=", "$", "listing", "->", "getApiVersion", "(", ")", ")", "{", "$", "this", "->", "debug", "(", "'+ set apiVersion %s'", ",", "$", "version", ")", ";", "$", "this", "->", "setApiVersion", "(", "$", "version", ")", ";", "}", "// Set description if missing from constructor", "if", "(", "empty", "(", "$", "this", "->", "init", "[", "'description'", "]", ")", ")", "{", "$", "info", "=", "$", "listing", "->", "getInfo", "(", ")", ";", "$", "this", "->", "init", "[", "'description'", "]", "=", "$", "info", "[", "'description'", "]", "?", ":", "$", "this", "->", "init", "[", "'title'", "]", ";", "}", "// set base path from docs location if not provided", "if", "(", "empty", "(", "$", "this", "->", "init", "[", "'baseUri'", "]", ")", ")", "{", "$", "this", "->", "init", "[", "'baseUri'", "]", "=", "self", "::", "mergeUrl", "(", "'/'", ",", "$", "baseUri", ")", ";", "}", "// no more configs allowed now, Guzzle service gets constructed", "$", "service", "=", "$", "this", "->", "getServiceDescription", "(", ")", ";", "// ready to pull each api declaration", "foreach", "(", "$", "listing", "->", "getApiPaths", "(", ")", "as", "$", "path", ")", "{", "if", "(", "$", "this", "->", "delay", ")", "{", "usleep", "(", "$", "this", "->", "delay", ")", ";", "}", "// @todo do proper path resolution here, allowing a cross-domain spec.", "$", "path", "=", "rtrim", "(", "parse_url", "(", "$", "baseUri", ")", "[", "'path'", "]", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "$", "this", "->", "debug", "(", "'pulling %s ...'", ",", "$", "path", ")", ";", "$", "apiDeclaration", "=", "$", "client", "->", "getDeclaration", "(", "compact", "(", "'path'", ")", ")", ";", "foreach", "(", "$", "apiDeclaration", "->", "getModels", "(", ")", "as", "$", "model", ")", "{", "$", "this", "->", "addModel", "(", "$", "model", ")", ";", "}", "// Ensure a fully qualified base url for this api", "$", "baseUrl", "=", "self", "::", "mergeUrl", "(", "$", "apiDeclaration", "->", "getBasePath", "(", ")", ",", "$", "service", "->", "getBaseUri", "(", ")", ")", ";", "// add each api against required base url", "foreach", "(", "$", "apiDeclaration", "->", "getApis", "(", ")", "as", "$", "api", ")", "{", "$", "this", "->", "addApi", "(", "$", "api", ",", "$", "baseUrl", ")", ";", "}", "}", "$", "this", "->", "debug", "(", "'finished'", ")", ";", "return", "$", "this", ";", "}" ]
Build from a live endpoint @param string Swagger compliant JSON endpoint for resource listing @throws \Exception @return Swizzle
[ "Build", "from", "a", "live", "endpoint" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L254-L309
226,724
loco/swizzle
src/Swizzle.php
Swizzle.createModel
private function createModel(array $model, $location) { $name = null; if (isset($model['id']) === true) { // if model id is set, us it as a name $name = trim($model['id']); } elseif (isset($model['nickname'], $this->responseClasses[$model['nickname']])) { // if custom response class is defined with model nickname, use nickname $name = $model['nickname']; } elseif (isset($model['type']) === true && $model['type'] === 'array') { // if model is of array type if (isset($model['items']['$ref']) === true) { // E. g. if it's an array of 'Tag' models, call this model 'TagList'. $name = $model['items']['$ref'].'List'; } elseif (isset($model['nickname']) === true) { // Fallback generate name from operation nickname (e.g. getTags -> TagList) $found = preg_match('/[A-Z]/', $model['nickname'], $matches, PREG_OFFSET_CAPTURE); if ($found === 1) { $name = rtrim(substr($model['nickname'], $matches[0][1]), 's').'List'; } } } // if none of above worked to create a model name, hash model array if ($name === null) { $name = $model['id'] = 'anon_'.self::hashArray($model); } // a model is basically a parameter, but has name property added $defaults = [ 'name' => $name, 'type' => 'object', ]; /** @noinspection AdditionOperationOnArraysInspection */ $data = $this->transformSchema($model + $defaults); if ('object' === $data['type']) { $data['additionalProperties'] = false; // model must have top level properties specified as serialized response type, but no response type itself foreach ($data['properties'] as $key => $property) { $data['properties'][$key]['location'] = $location; } } elseif ('array' === $data['type']) { $data['location'] = $location; } // allow result class override if (isset($this->responseClasses[$name])) { $class = $this->responseClasses[$name]; $data['class'] = $class; if (is_subclass_of($class, ResultInterface::class)) { $data['type'] = 'object'; if (is_array($data['additionalProperties']) === false) { $data['additionalProperties'] = []; } $data['additionalProperties']['location'] = $location; } else { $data['type'] = 'class'; } } // required makes no sense at root of model unset($data['required']); return new Parameter($data, ['description' => $this->getServiceDescription()]); }
php
private function createModel(array $model, $location) { $name = null; if (isset($model['id']) === true) { // if model id is set, us it as a name $name = trim($model['id']); } elseif (isset($model['nickname'], $this->responseClasses[$model['nickname']])) { // if custom response class is defined with model nickname, use nickname $name = $model['nickname']; } elseif (isset($model['type']) === true && $model['type'] === 'array') { // if model is of array type if (isset($model['items']['$ref']) === true) { // E. g. if it's an array of 'Tag' models, call this model 'TagList'. $name = $model['items']['$ref'].'List'; } elseif (isset($model['nickname']) === true) { // Fallback generate name from operation nickname (e.g. getTags -> TagList) $found = preg_match('/[A-Z]/', $model['nickname'], $matches, PREG_OFFSET_CAPTURE); if ($found === 1) { $name = rtrim(substr($model['nickname'], $matches[0][1]), 's').'List'; } } } // if none of above worked to create a model name, hash model array if ($name === null) { $name = $model['id'] = 'anon_'.self::hashArray($model); } // a model is basically a parameter, but has name property added $defaults = [ 'name' => $name, 'type' => 'object', ]; /** @noinspection AdditionOperationOnArraysInspection */ $data = $this->transformSchema($model + $defaults); if ('object' === $data['type']) { $data['additionalProperties'] = false; // model must have top level properties specified as serialized response type, but no response type itself foreach ($data['properties'] as $key => $property) { $data['properties'][$key]['location'] = $location; } } elseif ('array' === $data['type']) { $data['location'] = $location; } // allow result class override if (isset($this->responseClasses[$name])) { $class = $this->responseClasses[$name]; $data['class'] = $class; if (is_subclass_of($class, ResultInterface::class)) { $data['type'] = 'object'; if (is_array($data['additionalProperties']) === false) { $data['additionalProperties'] = []; } $data['additionalProperties']['location'] = $location; } else { $data['type'] = 'class'; } } // required makes no sense at root of model unset($data['required']); return new Parameter($data, ['description' => $this->getServiceDescription()]); }
[ "private", "function", "createModel", "(", "array", "$", "model", ",", "$", "location", ")", "{", "$", "name", "=", "null", ";", "if", "(", "isset", "(", "$", "model", "[", "'id'", "]", ")", "===", "true", ")", "{", "// if model id is set, us it as a name", "$", "name", "=", "trim", "(", "$", "model", "[", "'id'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "model", "[", "'nickname'", "]", ",", "$", "this", "->", "responseClasses", "[", "$", "model", "[", "'nickname'", "]", "]", ")", ")", "{", "// if custom response class is defined with model nickname, use nickname", "$", "name", "=", "$", "model", "[", "'nickname'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "model", "[", "'type'", "]", ")", "===", "true", "&&", "$", "model", "[", "'type'", "]", "===", "'array'", ")", "{", "// if model is of array type", "if", "(", "isset", "(", "$", "model", "[", "'items'", "]", "[", "'$ref'", "]", ")", "===", "true", ")", "{", "// E. g. if it's an array of 'Tag' models, call this model 'TagList'.", "$", "name", "=", "$", "model", "[", "'items'", "]", "[", "'$ref'", "]", ".", "'List'", ";", "}", "elseif", "(", "isset", "(", "$", "model", "[", "'nickname'", "]", ")", "===", "true", ")", "{", "// Fallback generate name from operation nickname (e.g. getTags -> TagList)", "$", "found", "=", "preg_match", "(", "'/[A-Z]/'", ",", "$", "model", "[", "'nickname'", "]", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ";", "if", "(", "$", "found", "===", "1", ")", "{", "$", "name", "=", "rtrim", "(", "substr", "(", "$", "model", "[", "'nickname'", "]", ",", "$", "matches", "[", "0", "]", "[", "1", "]", ")", ",", "'s'", ")", ".", "'List'", ";", "}", "}", "}", "// if none of above worked to create a model name, hash model array", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "$", "model", "[", "'id'", "]", "=", "'anon_'", ".", "self", "::", "hashArray", "(", "$", "model", ")", ";", "}", "// a model is basically a parameter, but has name property added", "$", "defaults", "=", "[", "'name'", "=>", "$", "name", ",", "'type'", "=>", "'object'", ",", "]", ";", "/** @noinspection AdditionOperationOnArraysInspection */", "$", "data", "=", "$", "this", "->", "transformSchema", "(", "$", "model", "+", "$", "defaults", ")", ";", "if", "(", "'object'", "===", "$", "data", "[", "'type'", "]", ")", "{", "$", "data", "[", "'additionalProperties'", "]", "=", "false", ";", "// model must have top level properties specified as serialized response type, but no response type itself", "foreach", "(", "$", "data", "[", "'properties'", "]", "as", "$", "key", "=>", "$", "property", ")", "{", "$", "data", "[", "'properties'", "]", "[", "$", "key", "]", "[", "'location'", "]", "=", "$", "location", ";", "}", "}", "elseif", "(", "'array'", "===", "$", "data", "[", "'type'", "]", ")", "{", "$", "data", "[", "'location'", "]", "=", "$", "location", ";", "}", "// allow result class override", "if", "(", "isset", "(", "$", "this", "->", "responseClasses", "[", "$", "name", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "responseClasses", "[", "$", "name", "]", ";", "$", "data", "[", "'class'", "]", "=", "$", "class", ";", "if", "(", "is_subclass_of", "(", "$", "class", ",", "ResultInterface", "::", "class", ")", ")", "{", "$", "data", "[", "'type'", "]", "=", "'object'", ";", "if", "(", "is_array", "(", "$", "data", "[", "'additionalProperties'", "]", ")", "===", "false", ")", "{", "$", "data", "[", "'additionalProperties'", "]", "=", "[", "]", ";", "}", "$", "data", "[", "'additionalProperties'", "]", "[", "'location'", "]", "=", "$", "location", ";", "}", "else", "{", "$", "data", "[", "'type'", "]", "=", "'class'", ";", "}", "}", "// required makes no sense at root of model", "unset", "(", "$", "data", "[", "'required'", "]", ")", ";", "return", "new", "Parameter", "(", "$", "data", ",", "[", "'description'", "=>", "$", "this", "->", "getServiceDescription", "(", ")", "]", ")", ";", "}" ]
Create a Swagger model definition @param array $model @param string location where parameters will be found in request or response @return Parameter model resolved against service description but not added @throws \Exception
[ "Create", "a", "Swagger", "model", "definition" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L321-L385
226,725
loco/swizzle
src/Swizzle.php
Swizzle.addModel
public function addModel(array $modelData) { // swagger only has locations for requests, so we can safely default to our response serializer. $model = $this->createModel($modelData, $this->responseType); $modelData = $model->toArray(); if ($modelData['type'] === 'array' && isset($modelData['name'])) { unset($modelData['name']); } $this->debug('+ adding model %s', $model->getName()); $this->models[$model->getName()] = $modelData; return $model; }
php
public function addModel(array $modelData) { // swagger only has locations for requests, so we can safely default to our response serializer. $model = $this->createModel($modelData, $this->responseType); $modelData = $model->toArray(); if ($modelData['type'] === 'array' && isset($modelData['name'])) { unset($modelData['name']); } $this->debug('+ adding model %s', $model->getName()); $this->models[$model->getName()] = $modelData; return $model; }
[ "public", "function", "addModel", "(", "array", "$", "modelData", ")", "{", "// swagger only has locations for requests, so we can safely default to our response serializer.", "$", "model", "=", "$", "this", "->", "createModel", "(", "$", "modelData", ",", "$", "this", "->", "responseType", ")", ";", "$", "modelData", "=", "$", "model", "->", "toArray", "(", ")", ";", "if", "(", "$", "modelData", "[", "'type'", "]", "===", "'array'", "&&", "isset", "(", "$", "modelData", "[", "'name'", "]", ")", ")", "{", "unset", "(", "$", "modelData", "[", "'name'", "]", ")", ";", "}", "$", "this", "->", "debug", "(", "'+ adding model %s'", ",", "$", "model", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "models", "[", "$", "model", "->", "getName", "(", ")", "]", "=", "$", "modelData", ";", "return", "$", "model", ";", "}" ]
Add a response model @param array model structure from Swagger @return Parameter model added to service description @throws \Exception
[ "Add", "a", "response", "model" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L396-L408
226,726
loco/swizzle
src/Swizzle.php
Swizzle.transformParams
private function transformParams(array $params) { $locations = []; $namespace = []; foreach ($params as $name => $param) { if (isset($param['name'])) { $name = $param['name']; } else { $param['name'] = $name; } $param = $this->transformSchema($param); $location = isset($param['location']) ? $param['location'] : ''; // resolve models immediately. Guzzle will resolve anyway and we need the data for request body transforms if (isset($param['$ref'])) { $param = $this->models[$param['$ref']]; } // handle paramType -> location mapping. if ($location) { $location = $param['location'] = $this->transformLocation($location); // swagger doesn't allow optional path params if (!isset($param['required'])) { $param['required'] = 'uri' === $location; } } // handle serialization in request body. if ('body' === $location) { $location = $this->requestType; // objects properties must be moved into parent namespace or Guzzle will wrap them. /** @var array[] $param */ if (isset($param['properties'])) { foreach ($param['properties'] as $propertyName => $property) { $property['location'] = $location; $locations[$location][$propertyName] = $property; $namespace[$propertyName][$location] = 1; } continue; } } // else add single parameter by name $locations[$location][$name] = $param; $namespace[$name][$location] = 1; } // resolve all locations to single namespace // conflict can occur due to differences in swagger/guzzle modelling of complex params $target = []; /** * @var string $location * @var array[] $parameters */ foreach ($locations as $location => $parameters) { foreach ($parameters as $name => $param) { unset($namespace[$name][$location]); if ($conflicts = array_keys($namespace[$name])) { $alias = $name.'_'.$location; $this->debug('! %s parameter "%s" conflicts with %s, address as "%s"', $location, $name, implode(' and ', $conflicts), $alias); // namespace this property at our end ensuring it's sent to the API as expected. $param['sentAs'] = $name; $name = $param['name'] = $alias; } $target[$name] = $param; } } return $target; }
php
private function transformParams(array $params) { $locations = []; $namespace = []; foreach ($params as $name => $param) { if (isset($param['name'])) { $name = $param['name']; } else { $param['name'] = $name; } $param = $this->transformSchema($param); $location = isset($param['location']) ? $param['location'] : ''; // resolve models immediately. Guzzle will resolve anyway and we need the data for request body transforms if (isset($param['$ref'])) { $param = $this->models[$param['$ref']]; } // handle paramType -> location mapping. if ($location) { $location = $param['location'] = $this->transformLocation($location); // swagger doesn't allow optional path params if (!isset($param['required'])) { $param['required'] = 'uri' === $location; } } // handle serialization in request body. if ('body' === $location) { $location = $this->requestType; // objects properties must be moved into parent namespace or Guzzle will wrap them. /** @var array[] $param */ if (isset($param['properties'])) { foreach ($param['properties'] as $propertyName => $property) { $property['location'] = $location; $locations[$location][$propertyName] = $property; $namespace[$propertyName][$location] = 1; } continue; } } // else add single parameter by name $locations[$location][$name] = $param; $namespace[$name][$location] = 1; } // resolve all locations to single namespace // conflict can occur due to differences in swagger/guzzle modelling of complex params $target = []; /** * @var string $location * @var array[] $parameters */ foreach ($locations as $location => $parameters) { foreach ($parameters as $name => $param) { unset($namespace[$name][$location]); if ($conflicts = array_keys($namespace[$name])) { $alias = $name.'_'.$location; $this->debug('! %s parameter "%s" conflicts with %s, address as "%s"', $location, $name, implode(' and ', $conflicts), $alias); // namespace this property at our end ensuring it's sent to the API as expected. $param['sentAs'] = $name; $name = $param['name'] = $alias; } $target[$name] = $param; } } return $target; }
[ "private", "function", "transformParams", "(", "array", "$", "params", ")", "{", "$", "locations", "=", "[", "]", ";", "$", "namespace", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "name", "=>", "$", "param", ")", "{", "if", "(", "isset", "(", "$", "param", "[", "'name'", "]", ")", ")", "{", "$", "name", "=", "$", "param", "[", "'name'", "]", ";", "}", "else", "{", "$", "param", "[", "'name'", "]", "=", "$", "name", ";", "}", "$", "param", "=", "$", "this", "->", "transformSchema", "(", "$", "param", ")", ";", "$", "location", "=", "isset", "(", "$", "param", "[", "'location'", "]", ")", "?", "$", "param", "[", "'location'", "]", ":", "''", ";", "// resolve models immediately. Guzzle will resolve anyway and we need the data for request body transforms", "if", "(", "isset", "(", "$", "param", "[", "'$ref'", "]", ")", ")", "{", "$", "param", "=", "$", "this", "->", "models", "[", "$", "param", "[", "'$ref'", "]", "]", ";", "}", "// handle paramType -> location mapping.", "if", "(", "$", "location", ")", "{", "$", "location", "=", "$", "param", "[", "'location'", "]", "=", "$", "this", "->", "transformLocation", "(", "$", "location", ")", ";", "// swagger doesn't allow optional path params", "if", "(", "!", "isset", "(", "$", "param", "[", "'required'", "]", ")", ")", "{", "$", "param", "[", "'required'", "]", "=", "'uri'", "===", "$", "location", ";", "}", "}", "// handle serialization in request body.", "if", "(", "'body'", "===", "$", "location", ")", "{", "$", "location", "=", "$", "this", "->", "requestType", ";", "// objects properties must be moved into parent namespace or Guzzle will wrap them.", "/** @var array[] $param */", "if", "(", "isset", "(", "$", "param", "[", "'properties'", "]", ")", ")", "{", "foreach", "(", "$", "param", "[", "'properties'", "]", "as", "$", "propertyName", "=>", "$", "property", ")", "{", "$", "property", "[", "'location'", "]", "=", "$", "location", ";", "$", "locations", "[", "$", "location", "]", "[", "$", "propertyName", "]", "=", "$", "property", ";", "$", "namespace", "[", "$", "propertyName", "]", "[", "$", "location", "]", "=", "1", ";", "}", "continue", ";", "}", "}", "// else add single parameter by name", "$", "locations", "[", "$", "location", "]", "[", "$", "name", "]", "=", "$", "param", ";", "$", "namespace", "[", "$", "name", "]", "[", "$", "location", "]", "=", "1", ";", "}", "// resolve all locations to single namespace", "// conflict can occur due to differences in swagger/guzzle modelling of complex params", "$", "target", "=", "[", "]", ";", "/**\n * @var string $location\n * @var array[] $parameters\n */", "foreach", "(", "$", "locations", "as", "$", "location", "=>", "$", "parameters", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "name", "=>", "$", "param", ")", "{", "unset", "(", "$", "namespace", "[", "$", "name", "]", "[", "$", "location", "]", ")", ";", "if", "(", "$", "conflicts", "=", "array_keys", "(", "$", "namespace", "[", "$", "name", "]", ")", ")", "{", "$", "alias", "=", "$", "name", ".", "'_'", ".", "$", "location", ";", "$", "this", "->", "debug", "(", "'! %s parameter \"%s\" conflicts with %s, address as \"%s\"'", ",", "$", "location", ",", "$", "name", ",", "implode", "(", "' and '", ",", "$", "conflicts", ")", ",", "$", "alias", ")", ";", "// namespace this property at our end ensuring it's sent to the API as expected.", "$", "param", "[", "'sentAs'", "]", "=", "$", "name", ";", "$", "name", "=", "$", "param", "[", "'name'", "]", "=", "$", "alias", ";", "}", "$", "target", "[", "$", "name", "]", "=", "$", "param", ";", "}", "}", "return", "$", "target", ";", "}" ]
Transform a swagger parameter to a Guzzle one @param array $params @return array @throws \Exception
[ "Transform", "a", "swagger", "parameter", "to", "a", "Guzzle", "one" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L513-L576
226,727
loco/swizzle
src/Swizzle.php
Swizzle.transformLocation
private function transformLocation($paramType) { // Guzzle request locations: (statusCode|reasonPhrase|header|body|json|xml) // Guzzle response locations: (uri|query|header|body|formParam|multipart|json|xml|responseBody) static $valid = [ 'uri' => 1, 'xml' => 1, 'json' => 1, 'body' => 1, 'query' => 1, 'header' => 1, 'formParam' => 1, ]; // may be already transformed and just passing through if (isset($valid[$paramType])) { return $paramType; } static $aliases = [ 'path' => 'uri', 'body' => 'body', 'form' => 'formParam', 'query' => 'query', 'header' => 'header', ]; // return alias, defaulting to empty return isset($aliases[$paramType]) ? $aliases[$paramType] : ''; }
php
private function transformLocation($paramType) { // Guzzle request locations: (statusCode|reasonPhrase|header|body|json|xml) // Guzzle response locations: (uri|query|header|body|formParam|multipart|json|xml|responseBody) static $valid = [ 'uri' => 1, 'xml' => 1, 'json' => 1, 'body' => 1, 'query' => 1, 'header' => 1, 'formParam' => 1, ]; // may be already transformed and just passing through if (isset($valid[$paramType])) { return $paramType; } static $aliases = [ 'path' => 'uri', 'body' => 'body', 'form' => 'formParam', 'query' => 'query', 'header' => 'header', ]; // return alias, defaulting to empty return isset($aliases[$paramType]) ? $aliases[$paramType] : ''; }
[ "private", "function", "transformLocation", "(", "$", "paramType", ")", "{", "// Guzzle request locations: (statusCode|reasonPhrase|header|body|json|xml)", "// Guzzle response locations: (uri|query|header|body|formParam|multipart|json|xml|responseBody)", "static", "$", "valid", "=", "[", "'uri'", "=>", "1", ",", "'xml'", "=>", "1", ",", "'json'", "=>", "1", ",", "'body'", "=>", "1", ",", "'query'", "=>", "1", ",", "'header'", "=>", "1", ",", "'formParam'", "=>", "1", ",", "]", ";", "// may be already transformed and just passing through", "if", "(", "isset", "(", "$", "valid", "[", "$", "paramType", "]", ")", ")", "{", "return", "$", "paramType", ";", "}", "static", "$", "aliases", "=", "[", "'path'", "=>", "'uri'", ",", "'body'", "=>", "'body'", ",", "'form'", "=>", "'formParam'", ",", "'query'", "=>", "'query'", ",", "'header'", "=>", "'header'", ",", "]", ";", "// return alias, defaulting to empty", "return", "isset", "(", "$", "aliases", "[", "$", "paramType", "]", ")", "?", "$", "aliases", "[", "$", "paramType", "]", ":", "''", ";", "}" ]
Transform a Swagger request paramType to a Guzzle location. Note that Guzzle has response locations too. @param string Swagger paramType request field (path|query|body|header|form) @return string Guzzle location field (uri|query|body|header|postField|xml|json)
[ "Transform", "a", "Swagger", "request", "paramType", "to", "a", "Guzzle", "location", ".", "Note", "that", "Guzzle", "has", "response", "locations", "too", "." ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L586-L612
226,728
loco/swizzle
src/Swizzle.php
Swizzle.transformArray
private function transformArray(array $swagger, array $common, array $trans) { // initialize with common array keys $guzzle = array_intersect_key($swagger, $common); // translate other naming differences foreach ($trans as $source => $target) { if (isset($swagger[$source])) { $guzzle[$target] = $swagger[$source]; } } return $guzzle; }
php
private function transformArray(array $swagger, array $common, array $trans) { // initialize with common array keys $guzzle = array_intersect_key($swagger, $common); // translate other naming differences foreach ($trans as $source => $target) { if (isset($swagger[$source])) { $guzzle[$target] = $swagger[$source]; } } return $guzzle; }
[ "private", "function", "transformArray", "(", "array", "$", "swagger", ",", "array", "$", "common", ",", "array", "$", "trans", ")", "{", "// initialize with common array keys", "$", "guzzle", "=", "array_intersect_key", "(", "$", "swagger", ",", "$", "common", ")", ";", "// translate other naming differences", "foreach", "(", "$", "trans", "as", "$", "source", "=>", "$", "target", ")", "{", "if", "(", "isset", "(", "$", "swagger", "[", "$", "source", "]", ")", ")", "{", "$", "guzzle", "[", "$", "target", "]", "=", "$", "swagger", "[", "$", "source", "]", ";", "}", "}", "return", "$", "guzzle", ";", "}" ]
Utility transform an array based on similarities and differences between the two formats. @param array $swagger source format (swagger) @param array $common Keys common to both formats, { key: '', ... } @param array $trans key translation mappings, { keya: keyb, ... } @return array target format (guzzle)
[ "Utility", "transform", "an", "array", "based", "on", "similarities", "and", "differences", "between", "the", "two", "formats", "." ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L833-L845
226,729
loco/swizzle
src/Swizzle.php
Swizzle.mergeUrl
private static function mergeUrl($uri, $baseUrl) { $href = parse_url($uri); $base = parse_url($baseUrl); $full = $href + $base + parse_url('http://localhost/'); return $full['scheme'].'://'.$full['host'].$full['path']; }
php
private static function mergeUrl($uri, $baseUrl) { $href = parse_url($uri); $base = parse_url($baseUrl); $full = $href + $base + parse_url('http://localhost/'); return $full['scheme'].'://'.$full['host'].$full['path']; }
[ "private", "static", "function", "mergeUrl", "(", "$", "uri", ",", "$", "baseUrl", ")", "{", "$", "href", "=", "parse_url", "(", "$", "uri", ")", ";", "$", "base", "=", "parse_url", "(", "$", "baseUrl", ")", ";", "$", "full", "=", "$", "href", "+", "$", "base", "+", "parse_url", "(", "'http://localhost/'", ")", ";", "return", "$", "full", "[", "'scheme'", "]", ".", "'://'", ".", "$", "full", "[", "'host'", "]", ".", "$", "full", "[", "'path'", "]", ";", "}" ]
Utility for merging any URI into a fully qualified one @param string URI that may be a /path or http://address @param string full base URL that may or may not be on same domain @return string
[ "Utility", "for", "merging", "any", "URI", "into", "a", "fully", "qualified", "one" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L885-L891
226,730
loco/swizzle
src/Swizzle.php
Swizzle.toArray
public function toArray() { $result = [ 'name' => $this->init['name'], 'apiVersion' => $this->init['apiVersion'], 'baseUri' => isset($this->init['baseUri']) ? $this->init['baseUri'] : '', 'description' => $this->init['description'], ]; $result['operations'] = $this->operations; if (!empty($this->models)) { $result['models'] = $this->models; } return array_filter($result); }
php
public function toArray() { $result = [ 'name' => $this->init['name'], 'apiVersion' => $this->init['apiVersion'], 'baseUri' => isset($this->init['baseUri']) ? $this->init['baseUri'] : '', 'description' => $this->init['description'], ]; $result['operations'] = $this->operations; if (!empty($this->models)) { $result['models'] = $this->models; } return array_filter($result); }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "[", "'name'", "=>", "$", "this", "->", "init", "[", "'name'", "]", ",", "'apiVersion'", "=>", "$", "this", "->", "init", "[", "'apiVersion'", "]", ",", "'baseUri'", "=>", "isset", "(", "$", "this", "->", "init", "[", "'baseUri'", "]", ")", "?", "$", "this", "->", "init", "[", "'baseUri'", "]", ":", "''", ",", "'description'", "=>", "$", "this", "->", "init", "[", "'description'", "]", ",", "]", ";", "$", "result", "[", "'operations'", "]", "=", "$", "this", "->", "operations", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "models", ")", ")", "{", "$", "result", "[", "'models'", "]", "=", "$", "this", "->", "models", ";", "}", "return", "array_filter", "(", "$", "result", ")", ";", "}" ]
Export service description to JSON @return array
[ "Export", "service", "description", "to", "JSON" ]
539db44bc2341f3da403582052b770686c86a516
https://github.com/loco/swizzle/blob/539db44bc2341f3da403582052b770686c86a516/src/Swizzle.php#L908-L922
226,731
gigaai/framework
src/Storage/Eloquent/Broadcast.php
Broadcast.leadsCount
public function leadsCount() { if (isset($this->to_lead) && is_array($this->to_lead)) { return count($this->to_lead); } return count(Subscription::getSubscribers($this->to_channel)); }
php
public function leadsCount() { if (isset($this->to_lead) && is_array($this->to_lead)) { return count($this->to_lead); } return count(Subscription::getSubscribers($this->to_channel)); }
[ "public", "function", "leadsCount", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "to_lead", ")", "&&", "is_array", "(", "$", "this", "->", "to_lead", ")", ")", "{", "return", "count", "(", "$", "this", "->", "to_lead", ")", ";", "}", "return", "count", "(", "Subscription", "::", "getSubscribers", "(", "$", "this", "->", "to_channel", ")", ")", ";", "}" ]
Get total leads of a channel @return void
[ "Get", "total", "leads", "of", "a", "channel" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Storage/Eloquent/Broadcast.php#L109-L116
226,732
gigaai/framework
src/Storage/Eloquent/Broadcast.php
Broadcast.scopeStillActive
public function scopeStillActive($query) { $query->where(function ($query) { return $query->where('start_at', '<=', Carbon::now())->orWhereNull('start_at'); }) ->where(function ($query) { return $query->where('end_at', '>=', Carbon::now())->orWhereNull('end_at'); }) ->where(function ($query) { return $query->where('parent_id', 0)->orWhereNull('parent_id'); }); return $query; }
php
public function scopeStillActive($query) { $query->where(function ($query) { return $query->where('start_at', '<=', Carbon::now())->orWhereNull('start_at'); }) ->where(function ($query) { return $query->where('end_at', '>=', Carbon::now())->orWhereNull('end_at'); }) ->where(function ($query) { return $query->where('parent_id', 0)->orWhereNull('parent_id'); }); return $query; }
[ "public", "function", "scopeStillActive", "(", "$", "query", ")", "{", "$", "query", "->", "where", "(", "function", "(", "$", "query", ")", "{", "return", "$", "query", "->", "where", "(", "'start_at'", ",", "'<='", ",", "Carbon", "::", "now", "(", ")", ")", "->", "orWhereNull", "(", "'start_at'", ")", ";", "}", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "return", "$", "query", "->", "where", "(", "'end_at'", ",", "'>='", ",", "Carbon", "::", "now", "(", ")", ")", "->", "orWhereNull", "(", "'end_at'", ")", ";", "}", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "return", "$", "query", "->", "where", "(", "'parent_id'", ",", "0", ")", "->", "orWhereNull", "(", "'parent_id'", ")", ";", "}", ")", ";", "return", "$", "query", ";", "}" ]
Get active broadcast @return $query
[ "Get", "active", "broadcast" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Storage/Eloquent/Broadcast.php#L142-L155
226,733
gigaai/framework
src/Shared/CanLearn.php
CanLearn.answer
public function answer($ask, $answers = null, $attributes = []) { return $this->answers($ask, $answers, $attributes); }
php
public function answer($ask, $answers = null, $attributes = []) { return $this->answers($ask, $answers, $attributes); }
[ "public", "function", "answer", "(", "$", "ask", ",", "$", "answers", "=", "null", ",", "$", "attributes", "=", "[", "]", ")", "{", "return", "$", "this", "->", "answers", "(", "$", "ask", ",", "$", "answers", ",", "$", "attributes", ")", ";", "}" ]
Response user question with answers @param $ask @param null $answers @return $this
[ "Response", "user", "question", "with", "answers" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Shared/CanLearn.php#L19-L22
226,734
gigaai/framework
src/Shared/CanLearn.php
CanLearn.answers
public function answers($asks, $answers = null, $attributes = []) { $this->model->addNode($asks, $answers, $attributes); return $this; }
php
public function answers($asks, $answers = null, $attributes = []) { $this->model->addNode($asks, $answers, $attributes); return $this; }
[ "public", "function", "answers", "(", "$", "asks", ",", "$", "answers", "=", "null", ",", "$", "attributes", "=", "[", "]", ")", "{", "$", "this", "->", "model", "->", "addNode", "(", "$", "asks", ",", "$", "answers", ",", "$", "attributes", ")", ";", "return", "$", "this", ";", "}" ]
Format answer from short hand to proper form. @param $asks @param null $answers @return $this For chaining method
[ "Format", "answer", "from", "short", "hand", "to", "proper", "form", "." ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Shared/CanLearn.php#L32-L37
226,735
gigaai/framework
src/Shared/CanLearn.php
CanLearn.says
public function says($messages, $attributes = [], $lead_ids = null) { $messages = $this->model->parse($messages); if ( ! is_null($lead_ids)) { $lead_ids = (array) $lead_ids; $leads = Lead::withTrashed()->whereIn('user_id', $lead_ids)->get(); if (empty($leads) || $leads === null) { return; } $leads->each(function ($lead) use ($messages, $attributes) { $this->request->sendMessages($messages, $attributes, $lead); }); } else { $this->request->sendMessages($messages, $attributes, $lead_ids); } return $this; }
php
public function says($messages, $attributes = [], $lead_ids = null) { $messages = $this->model->parse($messages); if ( ! is_null($lead_ids)) { $lead_ids = (array) $lead_ids; $leads = Lead::withTrashed()->whereIn('user_id', $lead_ids)->get(); if (empty($leads) || $leads === null) { return; } $leads->each(function ($lead) use ($messages, $attributes) { $this->request->sendMessages($messages, $attributes, $lead); }); } else { $this->request->sendMessages($messages, $attributes, $lead_ids); } return $this; }
[ "public", "function", "says", "(", "$", "messages", ",", "$", "attributes", "=", "[", "]", ",", "$", "lead_ids", "=", "null", ")", "{", "$", "messages", "=", "$", "this", "->", "model", "->", "parse", "(", "$", "messages", ")", ";", "if", "(", "!", "is_null", "(", "$", "lead_ids", ")", ")", "{", "$", "lead_ids", "=", "(", "array", ")", "$", "lead_ids", ";", "$", "leads", "=", "Lead", "::", "withTrashed", "(", ")", "->", "whereIn", "(", "'user_id'", ",", "$", "lead_ids", ")", "->", "get", "(", ")", ";", "if", "(", "empty", "(", "$", "leads", ")", "||", "$", "leads", "===", "null", ")", "{", "return", ";", "}", "$", "leads", "->", "each", "(", "function", "(", "$", "lead", ")", "use", "(", "$", "messages", ",", "$", "attributes", ")", "{", "$", "this", "->", "request", "->", "sendMessages", "(", "$", "messages", ",", "$", "attributes", ",", "$", "lead", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "request", "->", "sendMessages", "(", "$", "messages", ",", "$", "attributes", ",", "$", "lead_ids", ")", ";", "}", "return", "$", "this", ";", "}" ]
Send message to user. @param mixed $messages Message to send @param array $attributes Message attributes @param $lead_ids Lead ID to send, by default current lead @return $this
[ "Send", "message", "to", "user", "." ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Shared/CanLearn.php#L62-L82
226,736
gigaai/framework
src/Shared/CanLearn.php
CanLearn.wait
public function wait($action) { $lead = $this->conversation->get('lead'); // For chaining after $bot->say() method if ($lead != null) { $lead->data('_wait', $action); } // For chaining after $bot->answer() method else { $this->model->addIntendedAction($action); } }
php
public function wait($action) { $lead = $this->conversation->get('lead'); // For chaining after $bot->say() method if ($lead != null) { $lead->data('_wait', $action); } // For chaining after $bot->answer() method else { $this->model->addIntendedAction($action); } }
[ "public", "function", "wait", "(", "$", "action", ")", "{", "$", "lead", "=", "$", "this", "->", "conversation", "->", "get", "(", "'lead'", ")", ";", "// For chaining after $bot->say() method", "if", "(", "$", "lead", "!=", "null", ")", "{", "$", "lead", "->", "data", "(", "'_wait'", ",", "$", "action", ")", ";", "}", "// For chaining after $bot->answer() method", "else", "{", "$", "this", "->", "model", "->", "addIntendedAction", "(", "$", "action", ")", ";", "}", "}" ]
Named Intended Action @param $action
[ "Named", "Intended", "Action" ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Shared/CanLearn.php#L89-L100
226,737
gigaai/framework
src/Shared/CanLearn.php
CanLearn.keep
public function keep($messages) { $previous_intended_action = $this->conversation->get('previous_intended_action'); if ($previous_intended_action == null) { return; } $this->says($messages)->wait($previous_intended_action); }
php
public function keep($messages) { $previous_intended_action = $this->conversation->get('previous_intended_action'); if ($previous_intended_action == null) { return; } $this->says($messages)->wait($previous_intended_action); }
[ "public", "function", "keep", "(", "$", "messages", ")", "{", "$", "previous_intended_action", "=", "$", "this", "->", "conversation", "->", "get", "(", "'previous_intended_action'", ")", ";", "if", "(", "$", "previous_intended_action", "==", "null", ")", "{", "return", ";", "}", "$", "this", "->", "says", "(", "$", "messages", ")", "->", "wait", "(", "$", "previous_intended_action", ")", ";", "}" ]
Keep staying in current intended action. @param $messages
[ "Keep", "staying", "in", "current", "intended", "action", "." ]
57380d93baf57bfdb8067e96c68ba72e4e993d96
https://github.com/gigaai/framework/blob/57380d93baf57bfdb8067e96c68ba72e4e993d96/src/Shared/CanLearn.php#L121-L130
226,738
wells/l4-ldap-ntlm
src/Wells/L4LdapNtlm/L4LdapNtlmUserProvider.php
L4LdapNtlmUserProvider.clean
public function clean(array $entry) { $entry['id'] = $entry['dn']; $entry['remember_token'] = $entry['dn']; $entry['username'] = $entry['samaccountname'][0]; // Default user type (ACL: 0 = admin, 1 = user) $entry['type'] = 1; $entry['group'] = ''; // Group based view access check if(count($this->config['groups']) > 0) { $entry['type'] = NULL; } foreach ($this->config['groups'] as $group) { $cn = 'CN='.$group.','.$this->config['groupdn']; if (isset($entry['dn']) && $this->checkGroup($entry['dn'], $cn)) { $entry['type'] = 1; $entry['group'] = $group; } } // Admin Group Check foreach ($this->config['admin_groups'] as $group) { $cn = 'CN='.$group.','.$this->config['groupdn']; if (isset($entry['dn']) && $this->checkGroup($entry['dn'], $cn)) { $entry['type'] = 0; $entry['group'] = $group; } } // Admin/Owner Check (individual user owner/admins) foreach ($this->config['owners'] as $owner) { if (isset($entry['samaccountname']) && $entry['samaccountname'][0] == $owner) { $entry['type'] = 0; $entry['group'] = ''; } } // If View Groups exist and User is not in group if($entry['type'] === NULL) return NULL; $this->model = new GenericUser( $entry ); return $this->model; }
php
public function clean(array $entry) { $entry['id'] = $entry['dn']; $entry['remember_token'] = $entry['dn']; $entry['username'] = $entry['samaccountname'][0]; // Default user type (ACL: 0 = admin, 1 = user) $entry['type'] = 1; $entry['group'] = ''; // Group based view access check if(count($this->config['groups']) > 0) { $entry['type'] = NULL; } foreach ($this->config['groups'] as $group) { $cn = 'CN='.$group.','.$this->config['groupdn']; if (isset($entry['dn']) && $this->checkGroup($entry['dn'], $cn)) { $entry['type'] = 1; $entry['group'] = $group; } } // Admin Group Check foreach ($this->config['admin_groups'] as $group) { $cn = 'CN='.$group.','.$this->config['groupdn']; if (isset($entry['dn']) && $this->checkGroup($entry['dn'], $cn)) { $entry['type'] = 0; $entry['group'] = $group; } } // Admin/Owner Check (individual user owner/admins) foreach ($this->config['owners'] as $owner) { if (isset($entry['samaccountname']) && $entry['samaccountname'][0] == $owner) { $entry['type'] = 0; $entry['group'] = ''; } } // If View Groups exist and User is not in group if($entry['type'] === NULL) return NULL; $this->model = new GenericUser( $entry ); return $this->model; }
[ "public", "function", "clean", "(", "array", "$", "entry", ")", "{", "$", "entry", "[", "'id'", "]", "=", "$", "entry", "[", "'dn'", "]", ";", "$", "entry", "[", "'remember_token'", "]", "=", "$", "entry", "[", "'dn'", "]", ";", "$", "entry", "[", "'username'", "]", "=", "$", "entry", "[", "'samaccountname'", "]", "[", "0", "]", ";", "// Default user type (ACL: 0 = admin, 1 = user)", "$", "entry", "[", "'type'", "]", "=", "1", ";", "$", "entry", "[", "'group'", "]", "=", "''", ";", "// Group based view access check", "if", "(", "count", "(", "$", "this", "->", "config", "[", "'groups'", "]", ")", ">", "0", ")", "{", "$", "entry", "[", "'type'", "]", "=", "NULL", ";", "}", "foreach", "(", "$", "this", "->", "config", "[", "'groups'", "]", "as", "$", "group", ")", "{", "$", "cn", "=", "'CN='", ".", "$", "group", ".", "','", ".", "$", "this", "->", "config", "[", "'groupdn'", "]", ";", "if", "(", "isset", "(", "$", "entry", "[", "'dn'", "]", ")", "&&", "$", "this", "->", "checkGroup", "(", "$", "entry", "[", "'dn'", "]", ",", "$", "cn", ")", ")", "{", "$", "entry", "[", "'type'", "]", "=", "1", ";", "$", "entry", "[", "'group'", "]", "=", "$", "group", ";", "}", "}", "// Admin Group Check", "foreach", "(", "$", "this", "->", "config", "[", "'admin_groups'", "]", "as", "$", "group", ")", "{", "$", "cn", "=", "'CN='", ".", "$", "group", ".", "','", ".", "$", "this", "->", "config", "[", "'groupdn'", "]", ";", "if", "(", "isset", "(", "$", "entry", "[", "'dn'", "]", ")", "&&", "$", "this", "->", "checkGroup", "(", "$", "entry", "[", "'dn'", "]", ",", "$", "cn", ")", ")", "{", "$", "entry", "[", "'type'", "]", "=", "0", ";", "$", "entry", "[", "'group'", "]", "=", "$", "group", ";", "}", "}", "// Admin/Owner Check (individual user owner/admins)", "foreach", "(", "$", "this", "->", "config", "[", "'owners'", "]", "as", "$", "owner", ")", "{", "if", "(", "isset", "(", "$", "entry", "[", "'samaccountname'", "]", ")", "&&", "$", "entry", "[", "'samaccountname'", "]", "[", "0", "]", "==", "$", "owner", ")", "{", "$", "entry", "[", "'type'", "]", "=", "0", ";", "$", "entry", "[", "'group'", "]", "=", "''", ";", "}", "}", "// If View Groups exist and User is not in group", "if", "(", "$", "entry", "[", "'type'", "]", "===", "NULL", ")", "return", "NULL", ";", "$", "this", "->", "model", "=", "new", "GenericUser", "(", "$", "entry", ")", ";", "return", "$", "this", "->", "model", ";", "}" ]
Cleans the data for the LDAP model including some additional fields. @param array $entry @return void
[ "Cleans", "the", "data", "for", "the", "LDAP", "model", "including", "some", "additional", "fields", "." ]
325876bb202c8ad68cec992c4847713360b854e7
https://github.com/wells/l4-ldap-ntlm/blob/325876bb202c8ad68cec992c4847713360b854e7/src/Wells/L4LdapNtlm/L4LdapNtlmUserProvider.php#L151-L208
226,739
phergie/phergie-irc-bot-react
src/EventQueue.php
EventQueue.getPriority
protected function getPriority($command, array $params) { $priority = new EventQueuePriority; $priority->value = $this->priorities[$command]; $priority->timestamp = (int) (microtime(true) * 10000); if ($priority->timestamp <= $this->lastTimestamp) { $priority->timestamp = $this->lastTimestamp + 1; } $this->lastTimestamp = $priority->timestamp; return $priority; }
php
protected function getPriority($command, array $params) { $priority = new EventQueuePriority; $priority->value = $this->priorities[$command]; $priority->timestamp = (int) (microtime(true) * 10000); if ($priority->timestamp <= $this->lastTimestamp) { $priority->timestamp = $this->lastTimestamp + 1; } $this->lastTimestamp = $priority->timestamp; return $priority; }
[ "protected", "function", "getPriority", "(", "$", "command", ",", "array", "$", "params", ")", "{", "$", "priority", "=", "new", "EventQueuePriority", ";", "$", "priority", "->", "value", "=", "$", "this", "->", "priorities", "[", "$", "command", "]", ";", "$", "priority", "->", "timestamp", "=", "(", "int", ")", "(", "microtime", "(", "true", ")", "*", "10000", ")", ";", "if", "(", "$", "priority", "->", "timestamp", "<=", "$", "this", "->", "lastTimestamp", ")", "{", "$", "priority", "->", "timestamp", "=", "$", "this", "->", "lastTimestamp", "+", "1", ";", "}", "$", "this", "->", "lastTimestamp", "=", "$", "priority", "->", "timestamp", ";", "return", "$", "priority", ";", "}" ]
Returns the priority of a specified command. @param string $command @param array $params Unused, intended for use by subclasses @return \Phergie\Irc\Bot\React\EventQueuePriority
[ "Returns", "the", "priority", "of", "a", "specified", "command", "." ]
17745ef6b846513258af3dbd86e5612d3deb19b7
https://github.com/phergie/phergie-irc-bot-react/blob/17745ef6b846513258af3dbd86e5612d3deb19b7/src/EventQueue.php#L114-L124
226,740
phergie/phergie-irc-bot-react
src/EventQueue.php
EventQueue.queueRequest
protected function queueRequest(UserEventInterface $event, $command, array $params) { $event->setPrefix($this->prefix); $event->setCommand($command); $event->setParams(array_filter($params, 'strlen')); $this->queue->insert($event, $this->getPriority($command, $params)); }
php
protected function queueRequest(UserEventInterface $event, $command, array $params) { $event->setPrefix($this->prefix); $event->setCommand($command); $event->setParams(array_filter($params, 'strlen')); $this->queue->insert($event, $this->getPriority($command, $params)); }
[ "protected", "function", "queueRequest", "(", "UserEventInterface", "$", "event", ",", "$", "command", ",", "array", "$", "params", ")", "{", "$", "event", "->", "setPrefix", "(", "$", "this", "->", "prefix", ")", ";", "$", "event", "->", "setCommand", "(", "$", "command", ")", ";", "$", "event", "->", "setParams", "(", "array_filter", "(", "$", "params", ",", "'strlen'", ")", ")", ";", "$", "this", "->", "queue", "->", "insert", "(", "$", "event", ",", "$", "this", "->", "getPriority", "(", "$", "command", ",", "$", "params", ")", ")", ";", "}" ]
Enqueues a new event. @param \Phergie\Irc\Event\UserEventInterface @param string $command @param array $params
[ "Enqueues", "a", "new", "event", "." ]
17745ef6b846513258af3dbd86e5612d3deb19b7
https://github.com/phergie/phergie-irc-bot-react/blob/17745ef6b846513258af3dbd86e5612d3deb19b7/src/EventQueue.php#L133-L139
226,741
phergie/phergie-irc-bot-react
src/EventQueue.php
EventQueue.queueCtcpEvent
protected function queueCtcpEvent($command, $ctcpCommand, array $params = []) { $event = new CtcpEvent; $event->setCtcpCommand($ctcpCommand); $this->queueRequest($event, $command, $params); }
php
protected function queueCtcpEvent($command, $ctcpCommand, array $params = []) { $event = new CtcpEvent; $event->setCtcpCommand($ctcpCommand); $this->queueRequest($event, $command, $params); }
[ "protected", "function", "queueCtcpEvent", "(", "$", "command", ",", "$", "ctcpCommand", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "event", "=", "new", "CtcpEvent", ";", "$", "event", "->", "setCtcpCommand", "(", "$", "ctcpCommand", ")", ";", "$", "this", "->", "queueRequest", "(", "$", "event", ",", "$", "command", ",", "$", "params", ")", ";", "}" ]
Enqueues a new CTCP event. @param string $command IRC command @param string $ctcpCommand CTCP command @param array $params Command parameters
[ "Enqueues", "a", "new", "CTCP", "event", "." ]
17745ef6b846513258af3dbd86e5612d3deb19b7
https://github.com/phergie/phergie-irc-bot-react/blob/17745ef6b846513258af3dbd86e5612d3deb19b7/src/EventQueue.php#L159-L164
226,742
kronostechnologies/encrypt
src/Kronos/Encrypt/Key/Provider/KMS.php
KMS.getKey
public function getKey() { if(!$this->decrypted_key) { $decoded_ciphertextblob = base64_decode($this->key_description->getCiphertextBlob(), true); if(!$decoded_ciphertextblob) { throw new FetchException('CiphertextBlob should be a valid base64 encoded string'); } $options = [ 'CiphertextBlob' => $decoded_ciphertextblob ]; $context = $this->key_description->getEncryptionContextAsArray(); if(!empty($context)) { $options['EncryptionContext'] = $context; } try { $response = $this->client->decrypt($options); } catch(KmsException $e) { throw new FetchException('Key decryption failed', 0, $e); } $this->decrypted_key = $response['Plaintext']; } return $this->decrypted_key; }
php
public function getKey() { if(!$this->decrypted_key) { $decoded_ciphertextblob = base64_decode($this->key_description->getCiphertextBlob(), true); if(!$decoded_ciphertextblob) { throw new FetchException('CiphertextBlob should be a valid base64 encoded string'); } $options = [ 'CiphertextBlob' => $decoded_ciphertextblob ]; $context = $this->key_description->getEncryptionContextAsArray(); if(!empty($context)) { $options['EncryptionContext'] = $context; } try { $response = $this->client->decrypt($options); } catch(KmsException $e) { throw new FetchException('Key decryption failed', 0, $e); } $this->decrypted_key = $response['Plaintext']; } return $this->decrypted_key; }
[ "public", "function", "getKey", "(", ")", "{", "if", "(", "!", "$", "this", "->", "decrypted_key", ")", "{", "$", "decoded_ciphertextblob", "=", "base64_decode", "(", "$", "this", "->", "key_description", "->", "getCiphertextBlob", "(", ")", ",", "true", ")", ";", "if", "(", "!", "$", "decoded_ciphertextblob", ")", "{", "throw", "new", "FetchException", "(", "'CiphertextBlob should be a valid base64 encoded string'", ")", ";", "}", "$", "options", "=", "[", "'CiphertextBlob'", "=>", "$", "decoded_ciphertextblob", "]", ";", "$", "context", "=", "$", "this", "->", "key_description", "->", "getEncryptionContextAsArray", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "context", ")", ")", "{", "$", "options", "[", "'EncryptionContext'", "]", "=", "$", "context", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "decrypt", "(", "$", "options", ")", ";", "}", "catch", "(", "KmsException", "$", "e", ")", "{", "throw", "new", "FetchException", "(", "'Key decryption failed'", ",", "0", ",", "$", "e", ")", ";", "}", "$", "this", "->", "decrypted_key", "=", "$", "response", "[", "'Plaintext'", "]", ";", "}", "return", "$", "this", "->", "decrypted_key", ";", "}" ]
Return KMS decrypted key @return string @throws FetchException
[ "Return", "KMS", "decrypted", "key" ]
1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414
https://github.com/kronostechnologies/encrypt/blob/1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414/src/Kronos/Encrypt/Key/Provider/KMS.php#L38-L66
226,743
kronostechnologies/encrypt
src/Kronos/Encrypt/Cipher/AES.php
AES.encrypt
public function encrypt($plaintext, $key) { $crypt_aes = $this->setupAES256($key); return $crypt_aes->encrypt($plaintext); }
php
public function encrypt($plaintext, $key) { $crypt_aes = $this->setupAES256($key); return $crypt_aes->encrypt($plaintext); }
[ "public", "function", "encrypt", "(", "$", "plaintext", ",", "$", "key", ")", "{", "$", "crypt_aes", "=", "$", "this", "->", "setupAES256", "(", "$", "key", ")", ";", "return", "$", "crypt_aes", "->", "encrypt", "(", "$", "plaintext", ")", ";", "}" ]
Use \phpseclib\Crypt\AES to encrypt plaintext using given key based on http://phpseclib.sourceforge.net/crypt/examples.html @param string $plaintext @param string $key @return string Ciphertext
[ "Use", "\\", "phpseclib", "\\", "Crypt", "\\", "AES", "to", "encrypt", "plaintext", "using", "given", "key" ]
1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414
https://github.com/kronostechnologies/encrypt/blob/1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414/src/Kronos/Encrypt/Cipher/AES.php#L25-L29
226,744
kronostechnologies/encrypt
src/Kronos/Encrypt/Encrypt.php
Encrypt.encrypt
public function encrypt($plaintext) { $key = $this->provider->getKey(); return $this->cipher->encrypt($plaintext, $key); }
php
public function encrypt($plaintext) { $key = $this->provider->getKey(); return $this->cipher->encrypt($plaintext, $key); }
[ "public", "function", "encrypt", "(", "$", "plaintext", ")", "{", "$", "key", "=", "$", "this", "->", "provider", "->", "getKey", "(", ")", ";", "return", "$", "this", "->", "cipher", "->", "encrypt", "(", "$", "plaintext", ",", "$", "key", ")", ";", "}" ]
Encrypt plaintext using given cypher and provided key @param $plaintext @return string
[ "Encrypt", "plaintext", "using", "given", "cypher", "and", "provided", "key" ]
1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414
https://github.com/kronostechnologies/encrypt/blob/1fbd4750cbcda2b1b76cf7caf54b0a5c53a67414/src/Kronos/Encrypt/Encrypt.php#L31-L35
226,745
CoopBelvedere/laravel-basecamp-api
src/Sections/Vaults.php
Vaults.show
public function show($id) { $vault = $this->client->get( sprintf('buckets/%d/vaults/%d.json', $this->bucket, $id) ); return new Vault($this->response($vault)); }
php
public function show($id) { $vault = $this->client->get( sprintf('buckets/%d/vaults/%d.json', $this->bucket, $id) ); return new Vault($this->response($vault)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "vault", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/vaults/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "Vault", "(", "$", "this", "->", "response", "(", "$", "vault", ")", ")", ";", "}" ]
Get a vault. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "vault", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Vaults.php#L15-L22
226,746
CoopBelvedere/laravel-basecamp-api
src/Sections/Inboxes.php
Inboxes.show
public function show($id) { $inbox = $this->client->get( sprintf('buckets/%d/inboxes/%d.json', $this->bucket, $id) ); return new Inbox($this->response($inbox)); }
php
public function show($id) { $inbox = $this->client->get( sprintf('buckets/%d/inboxes/%d.json', $this->bucket, $id) ); return new Inbox($this->response($inbox)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "inbox", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/inboxes/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "Inbox", "(", "$", "this", "->", "response", "(", "$", "inbox", ")", ")", ";", "}" ]
Get an inbox. @param int $id @return \Illuminate\Support\Collection
[ "Get", "an", "inbox", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Inboxes.php#L15-L22
226,747
CoopBelvedere/laravel-basecamp-api
src/Models/TodoListGroup.php
TodoListGroup.reposition
public function reposition($position) { return Basecamp::todoListGroups($this->bucket->id) ->reposition($this->id, $position); }
php
public function reposition($position) { return Basecamp::todoListGroups($this->bucket->id) ->reposition($this->id, $position); }
[ "public", "function", "reposition", "(", "$", "position", ")", "{", "return", "Basecamp", "::", "todoListGroups", "(", "$", "this", "->", "bucket", "->", "id", ")", "->", "reposition", "(", "$", "this", "->", "id", ",", "$", "position", ")", ";", "}" ]
Reposition the to-do list group. @param int $position @return string
[ "Reposition", "the", "to", "-", "do", "list", "group", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Models/TodoListGroup.php#L15-L19
226,748
platforg/adobe-connect
src/AdobeConnect/ExtraApiClient.php
ExtraApiClient.createOrUpdateUserByLoginEmail
public function createOrUpdateUserByLoginEmail($data) { if (! isset($data['login'])) { throw new \Exception(sprintf('Have to specify $data[login].')); } $data['principal-id'] = $this->getUserByLoginEmail($data['login'], true); return $this->createOrUpdateUser($data); }
php
public function createOrUpdateUserByLoginEmail($data) { if (! isset($data['login'])) { throw new \Exception(sprintf('Have to specify $data[login].')); } $data['principal-id'] = $this->getUserByLoginEmail($data['login'], true); return $this->createOrUpdateUser($data); }
[ "public", "function", "createOrUpdateUserByLoginEmail", "(", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'login'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Have to specify $data[login].'", ")", ")", ";", "}", "$", "data", "[", "'principal-id'", "]", "=", "$", "this", "->", "getUserByLoginEmail", "(", "$", "data", "[", "'login'", "]", ",", "true", ")", ";", "return", "$", "this", "->", "createOrUpdateUser", "(", "$", "data", ")", ";", "}" ]
Update an user by email, or create it if not exist. @param array $data @return int User's principal-id @throws \Exception If is not present the login data.
[ "Update", "an", "user", "by", "email", "or", "create", "it", "if", "not", "exist", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ExtraApiClient.php#L46-L55
226,749
platforg/adobe-connect
src/AdobeConnect/ExtraApiClient.php
ExtraApiClient.createOrUpdateUser
public function createOrUpdateUser($data) { if (! isset($data['login']) && isset($data['email'])) { $data['login'] = $data['email']; } elseif (! isset($data['email']) && isset($data['login'])) { $data['email'] = $data['login']; } if (isset($data['principal-id']) && $data['principal-id']) { return $this->updateUser($data); } else { return $this->createUser($data); } }
php
public function createOrUpdateUser($data) { if (! isset($data['login']) && isset($data['email'])) { $data['login'] = $data['email']; } elseif (! isset($data['email']) && isset($data['login'])) { $data['email'] = $data['login']; } if (isset($data['principal-id']) && $data['principal-id']) { return $this->updateUser($data); } else { return $this->createUser($data); } }
[ "public", "function", "createOrUpdateUser", "(", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'login'", "]", ")", "&&", "isset", "(", "$", "data", "[", "'email'", "]", ")", ")", "{", "$", "data", "[", "'login'", "]", "=", "$", "data", "[", "'email'", "]", ";", "}", "elseif", "(", "!", "isset", "(", "$", "data", "[", "'email'", "]", ")", "&&", "isset", "(", "$", "data", "[", "'login'", "]", ")", ")", "{", "$", "data", "[", "'email'", "]", "=", "$", "data", "[", "'login'", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'principal-id'", "]", ")", "&&", "$", "data", "[", "'principal-id'", "]", ")", "{", "return", "$", "this", "->", "updateUser", "(", "$", "data", ")", ";", "}", "else", "{", "return", "$", "this", "->", "createUser", "(", "$", "data", ")", ";", "}", "}" ]
Create or Update an user according if principal-id is present on the data @param array $data @return int User's principal-id
[ "Create", "or", "Update", "an", "user", "according", "if", "principal", "-", "id", "is", "present", "on", "the", "data" ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ExtraApiClient.php#L64-L77
226,750
cash/LRUCache
src/cash/LRUCache.php
LRUCache.put
public function put($key, $value) { if (isset($this->data[$key])) { $this->data[$key] = $value; $this->recordAccess($key); } else { $this->data[$key] = $value; if ($this->size() > $this->maximumSize) { // remove least recently used element (front of array) reset($this->data); unset($this->data[key($this->data)]); } } }
php
public function put($key, $value) { if (isset($this->data[$key])) { $this->data[$key] = $value; $this->recordAccess($key); } else { $this->data[$key] = $value; if ($this->size() > $this->maximumSize) { // remove least recently used element (front of array) reset($this->data); unset($this->data[key($this->data)]); } } }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "recordAccess", "(", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "if", "(", "$", "this", "->", "size", "(", ")", ">", "$", "this", "->", "maximumSize", ")", "{", "// remove least recently used element (front of array)", "reset", "(", "$", "this", "->", "data", ")", ";", "unset", "(", "$", "this", "->", "data", "[", "key", "(", "$", "this", "->", "data", ")", "]", ")", ";", "}", "}", "}" ]
Put something in the cache @param int|string $key The key. Strings that are ints are cast to ints. @param mixed $value The value to cache
[ "Put", "something", "in", "the", "cache" ]
4fa4c6834cec59690b43526c4da41d6153026289
https://github.com/cash/LRUCache/blob/4fa4c6834cec59690b43526c4da41d6153026289/src/cash/LRUCache.php#L58-L70
226,751
cash/LRUCache
src/cash/LRUCache.php
LRUCache.remove
public function remove($key) { if (isset($this->data[$key])) { $value = $this->data[$key]; unset($this->data[$key]); return $value; } else { return null; } }
php
public function remove($key) { if (isset($this->data[$key])) { $value = $this->data[$key]; unset($this->data[$key]); return $value; } else { return null; } }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "data", "[", "$", "key", "]", ";", "unset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "return", "$", "value", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Remove the element with this key. @param int|string $key The key @return mixed Value or null if not set
[ "Remove", "the", "element", "with", "this", "key", "." ]
4fa4c6834cec59690b43526c4da41d6153026289
https://github.com/cash/LRUCache/blob/4fa4c6834cec59690b43526c4da41d6153026289/src/cash/LRUCache.php#L97-L105
226,752
cash/LRUCache
src/cash/LRUCache.php
LRUCache.recordAccess
protected function recordAccess($key) { $value = $this->data[$key]; unset($this->data[$key]); $this->data[$key] = $value; }
php
protected function recordAccess($key) { $value = $this->data[$key]; unset($this->data[$key]); $this->data[$key] = $value; }
[ "protected", "function", "recordAccess", "(", "$", "key", ")", "{", "$", "value", "=", "$", "this", "->", "data", "[", "$", "key", "]", ";", "unset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Moves the element from current position to end of array @param int|string $key The key
[ "Moves", "the", "element", "from", "current", "position", "to", "end", "of", "array" ]
4fa4c6834cec59690b43526c4da41d6153026289
https://github.com/cash/LRUCache/blob/4fa4c6834cec59690b43526c4da41d6153026289/src/cash/LRUCache.php#L119-L123
226,753
CoopBelvedere/laravel-basecamp-api
src/Sections/Messages.php
Messages.index
public function index($page = null) { $url = sprintf('buckets/%d/message_boards/%d/messages.json', $this->bucket, $this->parent); $messages = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($messages, Message::class); }
php
public function index($page = null) { $url = sprintf('buckets/%d/message_boards/%d/messages.json', $this->bucket, $this->parent); $messages = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($messages, Message::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'buckets/%d/message_boards/%d/messages.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ";", "$", "messages", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "messages", ",", "Message", "::", "class", ")", ";", "}" ]
Index all messages. @param int $page @return \Illuminate\Support\Collection
[ "Index", "all", "messages", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Messages.php#L18-L29
226,754
CoopBelvedere/laravel-basecamp-api
src/Sections/Messages.php
Messages.store
public function store($data) { $message = $this->client->post( sprintf('buckets/%d/message_boards/%d/messages.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new Message($this->response($message)); }
php
public function store($data) { $message = $this->client->post( sprintf('buckets/%d/message_boards/%d/messages.json', $this->bucket, $this->parent), [ 'json' => $data, ] ); return new Message($this->response($message)); }
[ "public", "function", "store", "(", "$", "data", ")", "{", "$", "message", "=", "$", "this", "->", "client", "->", "post", "(", "sprintf", "(", "'buckets/%d/message_boards/%d/messages.json'", ",", "$", "this", "->", "bucket", ",", "$", "this", "->", "parent", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "Message", "(", "$", "this", "->", "response", "(", "$", "message", ")", ")", ";", "}" ]
Store a message. @param array $data @return \Illuminate\Support\Collection
[ "Store", "a", "message", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Messages.php#L52-L62
226,755
CoopBelvedere/laravel-basecamp-api
src/Sections/Messages.php
Messages.update
public function update($id, $data) { $message = $this->client->put( sprintf('buckets/%d/messages/%d.json', $this->bucket, $id), [ 'json' => $data, ] ); return new Message($this->response($message)); }
php
public function update($id, $data) { $message = $this->client->put( sprintf('buckets/%d/messages/%d.json', $this->bucket, $id), [ 'json' => $data, ] ); return new Message($this->response($message)); }
[ "public", "function", "update", "(", "$", "id", ",", "$", "data", ")", "{", "$", "message", "=", "$", "this", "->", "client", "->", "put", "(", "sprintf", "(", "'buckets/%d/messages/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "new", "Message", "(", "$", "this", "->", "response", "(", "$", "message", ")", ")", ";", "}" ]
Update a message. @param int $id @param array $data @return \Illuminate\Support\Collection
[ "Update", "a", "message", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Messages.php#L71-L81
226,756
THECALLR/sdk-php
src/CALLR/Realtime/Command/Params.php
Params.getParams
public function getParams() { $params = []; foreach ($this as $key => $value) { $pname = (string) ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $key)), '_'); $params[$pname] = $value; } return $params; }
php
public function getParams() { $params = []; foreach ($this as $key => $value) { $pname = (string) ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $key)), '_'); $params[$pname] = $value; } return $params; }
[ "public", "function", "getParams", "(", ")", "{", "$", "params", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "pname", "=", "(", "string", ")", "ltrim", "(", "strtolower", "(", "preg_replace", "(", "'/[A-Z]/'", ",", "'_$0'", ",", "$", "key", ")", ")", ",", "'_'", ")", ";", "$", "params", "[", "$", "pname", "]", "=", "$", "value", ";", "}", "return", "$", "params", ";", "}" ]
Convert properties to array with snake_case properties @return array { @var string Property name @var mixed Property value }
[ "Convert", "properties", "to", "array", "with", "snake_case", "properties" ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Realtime/Command/Params.php#L14-L22
226,757
CoopBelvedere/laravel-basecamp-api
src/Models/Todo.php
Todo.update
public function update(array $data) { $todo = Basecamp::todos($this->bucket->id)->update($this->id, $data); $this->setAttributes($todo); return $todo; }
php
public function update(array $data) { $todo = Basecamp::todos($this->bucket->id)->update($this->id, $data); $this->setAttributes($todo); return $todo; }
[ "public", "function", "update", "(", "array", "$", "data", ")", "{", "$", "todo", "=", "Basecamp", "::", "todos", "(", "$", "this", "->", "bucket", "->", "id", ")", "->", "update", "(", "$", "this", "->", "id", ",", "$", "data", ")", ";", "$", "this", "->", "setAttributes", "(", "$", "todo", ")", ";", "return", "$", "todo", ";", "}" ]
Update the to-do. @param array $data @return \Illuminate\Http\Collection
[ "Update", "the", "to", "-", "do", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Models/Todo.php#L18-L25
226,758
CoopBelvedere/laravel-basecamp-api
src/Models/Todo.php
Todo.reposition
public function reposition($position) { return Basecamp::todos($this->bucket->id) ->reposition($this->id, $position); }
php
public function reposition($position) { return Basecamp::todos($this->bucket->id) ->reposition($this->id, $position); }
[ "public", "function", "reposition", "(", "$", "position", ")", "{", "return", "Basecamp", "::", "todos", "(", "$", "this", "->", "bucket", "->", "id", ")", "->", "reposition", "(", "$", "this", "->", "id", ",", "$", "position", ")", ";", "}" ]
Reposition the to-do. @param int $position @return string
[ "Reposition", "the", "to", "-", "do", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Models/Todo.php#L53-L57
226,759
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.cacheCssAssetFiles
protected function cacheCssAssetFiles() { // Cache media asset files $this->cacheMediaAssetFiles(); if ($this->getOptions()->isProduction()) { // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); // Retrieve Css file filter if available $oCssFileFilter = $oAssetFileFiltersManager->has(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) ? $oAssetFileFiltersManager->get(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) : null; // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS); // Merge less asset files foreach ($this->cacheLessAssetFiles() as $oAssetFile) { $oTmpAssetFile->setAssetFileContents($this->rewriteAssetFileUrls( // File content $oCssFileFilter ? $oCssFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(), // Current asset file $oAssetFile ). PHP_EOL); // Remove temp less asset file \Zend\Stdlib\ErrorHandler::start(); unlink($oAssetFile->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); } // Merge css asset files foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) as $oAssetFile) { $oTmpAssetFile->setAssetFileContents($this->rewriteAssetFileUrls( // File content $oCssFileFilter ? $oCssFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(), // Current asset file $oAssetFile ) . PHP_EOL); } // Cache asset file if not empty if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)); } return array(); } // Cache less asset files $aAssetFiles = $this->cacheLessAssetFiles(); // Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) as $oAssetFile) { // Cache asset file if not empty if($oAssetFile->getAssetFileSize()){ $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
php
protected function cacheCssAssetFiles() { // Cache media asset files $this->cacheMediaAssetFiles(); if ($this->getOptions()->isProduction()) { // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); // Retrieve Css file filter if available $oCssFileFilter = $oAssetFileFiltersManager->has(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) ? $oAssetFileFiltersManager->get(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) : null; // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS); // Merge less asset files foreach ($this->cacheLessAssetFiles() as $oAssetFile) { $oTmpAssetFile->setAssetFileContents($this->rewriteAssetFileUrls( // File content $oCssFileFilter ? $oCssFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(), // Current asset file $oAssetFile ). PHP_EOL); // Remove temp less asset file \Zend\Stdlib\ErrorHandler::start(); unlink($oAssetFile->getAssetFilePath()); \Zend\Stdlib\ErrorHandler::stop(true); } // Merge css asset files foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) as $oAssetFile) { $oTmpAssetFile->setAssetFileContents($this->rewriteAssetFileUrls( // File content $oCssFileFilter ? $oCssFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(), // Current asset file $oAssetFile ) . PHP_EOL); } // Cache asset file if not empty if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)); } return array(); } // Cache less asset files $aAssetFiles = $this->cacheLessAssetFiles(); // Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS) as $oAssetFile) { // Cache asset file if not empty if($oAssetFile->getAssetFileSize()){ $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
[ "protected", "function", "cacheCssAssetFiles", "(", ")", "{", "// Cache media asset files", "$", "this", "->", "cacheMediaAssetFiles", "(", ")", ";", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "isProduction", "(", ")", ")", "{", "// Retrieve asset file filters manager", "$", "oAssetFileFiltersManager", "=", "$", "this", "->", "getAssetFileFiltersManager", "(", ")", ";", "// Retrieve Css file filter if available", "$", "oCssFileFilter", "=", "$", "oAssetFileFiltersManager", "->", "has", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", "?", "$", "oAssetFileFiltersManager", "->", "get", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", ":", "null", ";", "// Create tmp asset file", "$", "oTmpAssetFile", "=", "$", "this", "->", "createTmpAssetFile", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", ";", "// Merge less asset files", "foreach", "(", "$", "this", "->", "cacheLessAssetFiles", "(", ")", "as", "$", "oAssetFile", ")", "{", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "this", "->", "rewriteAssetFileUrls", "(", "// File content", "$", "oCssFileFilter", "?", "$", "oCssFileFilter", "->", "filterAssetFile", "(", "$", "oAssetFile", ")", ":", "$", "oAssetFile", "->", "getAssetFileContents", "(", ")", ",", "// Current asset file", "$", "oAssetFile", ")", ".", "PHP_EOL", ")", ";", "// Remove temp less asset file", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", ")", ";", "unlink", "(", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ")", ";", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", "true", ")", ";", "}", "// Merge css asset files", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", "as", "$", "oAssetFile", ")", "{", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "this", "->", "rewriteAssetFileUrls", "(", "// File content", "$", "oCssFileFilter", "?", "$", "oCssFileFilter", "->", "filterAssetFile", "(", "$", "oAssetFile", ")", ":", "$", "oAssetFile", "->", "getAssetFileContents", "(", ")", ",", "// Current asset file", "$", "oAssetFile", ")", ".", "PHP_EOL", ")", ";", "}", "// Cache asset file if not empty", "if", "(", "$", "oTmpAssetFile", "->", "getAssetFileSize", "(", ")", ")", "{", "return", "array", "(", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", "->", "cacheAssetFile", "(", "$", "oTmpAssetFile", ")", ")", ";", "}", "return", "array", "(", ")", ";", "}", "// Cache less asset files", "$", "aAssetFiles", "=", "$", "this", "->", "cacheLessAssetFiles", "(", ")", ";", "// Retrieve asset files cache manager", "$", "oAssetFilesCacheManager", "=", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", "as", "$", "oAssetFile", ")", "{", "// Cache asset file if not empty", "if", "(", "$", "oAssetFile", "->", "getAssetFileSize", "(", ")", ")", "{", "$", "aAssetFiles", "[", "]", "=", "$", "oAssetFilesCacheManager", "->", "cacheAssetFile", "(", "$", "oAssetFile", ")", ";", "}", "}", "return", "$", "aAssetFiles", ";", "}" ]
Cache Css asset files and retrieve cached asset files @return array
[ "Cache", "Css", "asset", "files", "and", "retrieve", "cached", "asset", "files" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L107-L167
226,760
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.cacheLessAssetFiles
protected function cacheLessAssetFiles() { // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS); // Retrieve Asset file cache manager; $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); // Production don't need to cache less asset file if ($this->getOptions()->isProduction()) { $oTmpAssetFile->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS); } // Retrieve asset file cached if exists if (file_exists($sAssetFileCachedPath = $oAssetFilesCacheManager->getAssetFileCachePath($oTmpAssetFile))) { \Zend\Stdlib\ErrorHandler::start(); $iAssetFileCachedFilemtime = filemtime($sAssetFileCachedPath); \Zend\Stdlib\ErrorHandler::stop(true); } else { $iAssetFileCachedFilemtime = null; } // Build import less file \Zend\Stdlib\ErrorHandler::start(); $bIsUpdated = !$this->getAssetFilesConfiguration()->assetsConfigurationHasChanged(array(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS)); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS) as $oAssetFile) { if ($iAssetFileCachedFilemtime && $bIsUpdated) { $bIsUpdated = $iAssetFileCachedFilemtime >= $oAssetFile->getAssetFileLastModified(); } // If less asset file is a php file, retrieve its content and add it as final less file content if ($oAssetFile->getAssetFileExtension() === 'php') { $sLessContent = $oAssetFile->getAssetFileContents(); } // Else import it in final less file else { $sLessContent = '@import "' . str_replace(array(getcwd(), DIRECTORY_SEPARATOR), array('', '/'), $oAssetFile->getAssetFilePath()) . '";'; } $oTmpAssetFile->setAssetFileContents($sLessContent . PHP_EOL); } \Zend\Stdlib\ErrorHandler::stop(true); // If less file is updated return cached asset file if ($iAssetFileCachedFilemtime && $bIsUpdated) { return array($oTmpAssetFile->setAssetFilePath($sAssetFileCachedPath)->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS)); } // Run less asset file filter $sAssetFileFilteredContent = $this->getAssetFileFiltersManager()->get(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS)->filterAssetFile($oTmpAssetFile); // Set new content to temp asset file contents $oTmpAssetFile->setAssetFileContents($sAssetFileFilteredContent, false); // Development need to cache less asset file if not empty if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS)); } return array(); }
php
protected function cacheLessAssetFiles() { // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS); // Retrieve Asset file cache manager; $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); // Production don't need to cache less asset file if ($this->getOptions()->isProduction()) { $oTmpAssetFile->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS); } // Retrieve asset file cached if exists if (file_exists($sAssetFileCachedPath = $oAssetFilesCacheManager->getAssetFileCachePath($oTmpAssetFile))) { \Zend\Stdlib\ErrorHandler::start(); $iAssetFileCachedFilemtime = filemtime($sAssetFileCachedPath); \Zend\Stdlib\ErrorHandler::stop(true); } else { $iAssetFileCachedFilemtime = null; } // Build import less file \Zend\Stdlib\ErrorHandler::start(); $bIsUpdated = !$this->getAssetFilesConfiguration()->assetsConfigurationHasChanged(array(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS)); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS) as $oAssetFile) { if ($iAssetFileCachedFilemtime && $bIsUpdated) { $bIsUpdated = $iAssetFileCachedFilemtime >= $oAssetFile->getAssetFileLastModified(); } // If less asset file is a php file, retrieve its content and add it as final less file content if ($oAssetFile->getAssetFileExtension() === 'php') { $sLessContent = $oAssetFile->getAssetFileContents(); } // Else import it in final less file else { $sLessContent = '@import "' . str_replace(array(getcwd(), DIRECTORY_SEPARATOR), array('', '/'), $oAssetFile->getAssetFilePath()) . '";'; } $oTmpAssetFile->setAssetFileContents($sLessContent . PHP_EOL); } \Zend\Stdlib\ErrorHandler::stop(true); // If less file is updated return cached asset file if ($iAssetFileCachedFilemtime && $bIsUpdated) { return array($oTmpAssetFile->setAssetFilePath($sAssetFileCachedPath)->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS)); } // Run less asset file filter $sAssetFileFilteredContent = $this->getAssetFileFiltersManager()->get(\AssetsBundle\AssetFile\AssetFile::ASSET_LESS)->filterAssetFile($oTmpAssetFile); // Set new content to temp asset file contents $oTmpAssetFile->setAssetFileContents($sAssetFileFilteredContent, false); // Development need to cache less asset file if not empty if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)->setAssetFileType(\AssetsBundle\AssetFile\AssetFile::ASSET_CSS)); } return array(); }
[ "protected", "function", "cacheLessAssetFiles", "(", ")", "{", "// Create tmp asset file", "$", "oTmpAssetFile", "=", "$", "this", "->", "createTmpAssetFile", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_LESS", ")", ";", "// Retrieve Asset file cache manager;", "$", "oAssetFilesCacheManager", "=", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", ";", "// Production don't need to cache less asset file", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "isProduction", "(", ")", ")", "{", "$", "oTmpAssetFile", "->", "setAssetFileType", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", ";", "}", "// Retrieve asset file cached if exists", "if", "(", "file_exists", "(", "$", "sAssetFileCachedPath", "=", "$", "oAssetFilesCacheManager", "->", "getAssetFileCachePath", "(", "$", "oTmpAssetFile", ")", ")", ")", "{", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", ")", ";", "$", "iAssetFileCachedFilemtime", "=", "filemtime", "(", "$", "sAssetFileCachedPath", ")", ";", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", "true", ")", ";", "}", "else", "{", "$", "iAssetFileCachedFilemtime", "=", "null", ";", "}", "// Build import less file", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", ")", ";", "$", "bIsUpdated", "=", "!", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "assetsConfigurationHasChanged", "(", "array", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_LESS", ")", ")", ";", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_LESS", ")", "as", "$", "oAssetFile", ")", "{", "if", "(", "$", "iAssetFileCachedFilemtime", "&&", "$", "bIsUpdated", ")", "{", "$", "bIsUpdated", "=", "$", "iAssetFileCachedFilemtime", ">=", "$", "oAssetFile", "->", "getAssetFileLastModified", "(", ")", ";", "}", "// If less asset file is a php file, retrieve its content and add it as final less file content", "if", "(", "$", "oAssetFile", "->", "getAssetFileExtension", "(", ")", "===", "'php'", ")", "{", "$", "sLessContent", "=", "$", "oAssetFile", "->", "getAssetFileContents", "(", ")", ";", "}", "// Else import it in final less file", "else", "{", "$", "sLessContent", "=", "'@import \"'", ".", "str_replace", "(", "array", "(", "getcwd", "(", ")", ",", "DIRECTORY_SEPARATOR", ")", ",", "array", "(", "''", ",", "'/'", ")", ",", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ")", ".", "'\";'", ";", "}", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "sLessContent", ".", "PHP_EOL", ")", ";", "}", "\\", "Zend", "\\", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", "true", ")", ";", "// If less file is updated return cached asset file", "if", "(", "$", "iAssetFileCachedFilemtime", "&&", "$", "bIsUpdated", ")", "{", "return", "array", "(", "$", "oTmpAssetFile", "->", "setAssetFilePath", "(", "$", "sAssetFileCachedPath", ")", "->", "setAssetFileType", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", ")", ";", "}", "// Run less asset file filter", "$", "sAssetFileFilteredContent", "=", "$", "this", "->", "getAssetFileFiltersManager", "(", ")", "->", "get", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_LESS", ")", "->", "filterAssetFile", "(", "$", "oTmpAssetFile", ")", ";", "// Set new content to temp asset file contents", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "sAssetFileFilteredContent", ",", "false", ")", ";", "// Development need to cache less asset file if not empty", "if", "(", "$", "oTmpAssetFile", "->", "getAssetFileSize", "(", ")", ")", "{", "return", "array", "(", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", "->", "cacheAssetFile", "(", "$", "oTmpAssetFile", ")", "->", "setAssetFileType", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_CSS", ")", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Cache Less asset files and retrieve cached asset files @return array
[ "Cache", "Less", "asset", "files", "and", "retrieve", "cached", "asset", "files" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L174-L235
226,761
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.cacheJsAssetFiles
protected function cacheJsAssetFiles() { if ($this->getOptions()->isProduction()) { // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); // Retrieve Js asset file filter if available $oJsFileFilter = $oAssetFileFiltersManager->has(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) ? $oAssetFileFiltersManager->get(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) : null; // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_JS); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) as $oAssetFile) { $sAssetFileContent = $oJsFileFilter ? $oJsFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(); $oTmpAssetFile->setAssetFileContents($sAssetFileContent . PHP_EOL); } if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)); } return array(); } // Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); $aAssetFiles = array(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) as $oAssetFile) { // Cache asset file if not empty if($oAssetFile->getAssetFileSize()){ $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
php
protected function cacheJsAssetFiles() { if ($this->getOptions()->isProduction()) { // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); // Retrieve Js asset file filter if available $oJsFileFilter = $oAssetFileFiltersManager->has(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) ? $oAssetFileFiltersManager->get(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) : null; // Create tmp asset file $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_JS); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) as $oAssetFile) { $sAssetFileContent = $oJsFileFilter ? $oJsFileFilter->filterAssetFile($oAssetFile) : $oAssetFile->getAssetFileContents(); $oTmpAssetFile->setAssetFileContents($sAssetFileContent . PHP_EOL); } if($oTmpAssetFile->getAssetFileSize()){ return array($this->getAssetFilesCacheManager()->cacheAssetFile($oTmpAssetFile)); } return array(); } // Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); $aAssetFiles = array(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_JS) as $oAssetFile) { // Cache asset file if not empty if($oAssetFile->getAssetFileSize()){ $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
[ "protected", "function", "cacheJsAssetFiles", "(", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "isProduction", "(", ")", ")", "{", "// Retrieve asset file filters manager", "$", "oAssetFileFiltersManager", "=", "$", "this", "->", "getAssetFileFiltersManager", "(", ")", ";", "// Retrieve Js asset file filter if available", "$", "oJsFileFilter", "=", "$", "oAssetFileFiltersManager", "->", "has", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", ")", "?", "$", "oAssetFileFiltersManager", "->", "get", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", ")", ":", "null", ";", "// Create tmp asset file", "$", "oTmpAssetFile", "=", "$", "this", "->", "createTmpAssetFile", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", ")", ";", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", ")", "as", "$", "oAssetFile", ")", "{", "$", "sAssetFileContent", "=", "$", "oJsFileFilter", "?", "$", "oJsFileFilter", "->", "filterAssetFile", "(", "$", "oAssetFile", ")", ":", "$", "oAssetFile", "->", "getAssetFileContents", "(", ")", ";", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "sAssetFileContent", ".", "PHP_EOL", ")", ";", "}", "if", "(", "$", "oTmpAssetFile", "->", "getAssetFileSize", "(", ")", ")", "{", "return", "array", "(", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", "->", "cacheAssetFile", "(", "$", "oTmpAssetFile", ")", ")", ";", "}", "return", "array", "(", ")", ";", "}", "// Retrieve asset files cache manager", "$", "oAssetFilesCacheManager", "=", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", ";", "$", "aAssetFiles", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_JS", ")", "as", "$", "oAssetFile", ")", "{", "// Cache asset file if not empty", "if", "(", "$", "oAssetFile", "->", "getAssetFileSize", "(", ")", ")", "{", "$", "aAssetFiles", "[", "]", "=", "$", "oAssetFilesCacheManager", "->", "cacheAssetFile", "(", "$", "oAssetFile", ")", ";", "}", "}", "return", "$", "aAssetFiles", ";", "}" ]
Cache Js asset files and retrieve cached asset files @return array
[ "Cache", "Js", "asset", "files", "and", "retrieve", "cached", "asset", "files" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L242-L274
226,762
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.cacheMediaAssetFiles
protected function cacheMediaAssetFiles() { $aAssetFileFilters = array(); $aAssetFiles = array(); //Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); $bIsProduction = $this->getOptions()->isProduction(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA) as $oAssetFile) { if ($oAssetFilesCacheManager->isAssetFileCached($oAssetFile)) { $aAssetFiles[] = $oAssetFilesCacheManager->getAssetFileCachePath($oAssetFile); continue; } if ($bIsProduction) { if (array_key_exists($sAssetFileExtension = $oAssetFile->getAssetFileExtension(), $aAssetFileFilters)) { $oMediaFileFilter = $aAssetFileFilters[$sAssetFileExtension]; } else { $oMediaFileFilter = $aAssetFileFilters[$sAssetFileExtension] = $oAssetFileFiltersManager->has($sAssetFileExtension) ? $oAssetFileFiltersManager->get($sAssetFileExtension) : null; } } else { $oMediaFileFilter = null; } if ($oMediaFileFilter) { $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA); $oTmpAssetFile->setAssetFileContents($oMediaFileFilter->filterAssetFile($oAssetFile), false); // Cache asset file $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oTmpAssetFile, $oAssetFile); } else { // Cache asset file $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
php
protected function cacheMediaAssetFiles() { $aAssetFileFilters = array(); $aAssetFiles = array(); //Retrieve asset files cache manager $oAssetFilesCacheManager = $this->getAssetFilesCacheManager(); // Retrieve asset file filters manager $oAssetFileFiltersManager = $this->getAssetFileFiltersManager(); $bIsProduction = $this->getOptions()->isProduction(); foreach ($this->getAssetFilesConfiguration()->getAssetFiles(\AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA) as $oAssetFile) { if ($oAssetFilesCacheManager->isAssetFileCached($oAssetFile)) { $aAssetFiles[] = $oAssetFilesCacheManager->getAssetFileCachePath($oAssetFile); continue; } if ($bIsProduction) { if (array_key_exists($sAssetFileExtension = $oAssetFile->getAssetFileExtension(), $aAssetFileFilters)) { $oMediaFileFilter = $aAssetFileFilters[$sAssetFileExtension]; } else { $oMediaFileFilter = $aAssetFileFilters[$sAssetFileExtension] = $oAssetFileFiltersManager->has($sAssetFileExtension) ? $oAssetFileFiltersManager->get($sAssetFileExtension) : null; } } else { $oMediaFileFilter = null; } if ($oMediaFileFilter) { $oTmpAssetFile = $this->createTmpAssetFile(\AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA); $oTmpAssetFile->setAssetFileContents($oMediaFileFilter->filterAssetFile($oAssetFile), false); // Cache asset file $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oTmpAssetFile, $oAssetFile); } else { // Cache asset file $aAssetFiles[] = $oAssetFilesCacheManager->cacheAssetFile($oAssetFile); } } return $aAssetFiles; }
[ "protected", "function", "cacheMediaAssetFiles", "(", ")", "{", "$", "aAssetFileFilters", "=", "array", "(", ")", ";", "$", "aAssetFiles", "=", "array", "(", ")", ";", "//Retrieve asset files cache manager", "$", "oAssetFilesCacheManager", "=", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", ";", "// Retrieve asset file filters manager", "$", "oAssetFileFiltersManager", "=", "$", "this", "->", "getAssetFileFiltersManager", "(", ")", ";", "$", "bIsProduction", "=", "$", "this", "->", "getOptions", "(", ")", "->", "isProduction", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAssetFilesConfiguration", "(", ")", "->", "getAssetFiles", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_MEDIA", ")", "as", "$", "oAssetFile", ")", "{", "if", "(", "$", "oAssetFilesCacheManager", "->", "isAssetFileCached", "(", "$", "oAssetFile", ")", ")", "{", "$", "aAssetFiles", "[", "]", "=", "$", "oAssetFilesCacheManager", "->", "getAssetFileCachePath", "(", "$", "oAssetFile", ")", ";", "continue", ";", "}", "if", "(", "$", "bIsProduction", ")", "{", "if", "(", "array_key_exists", "(", "$", "sAssetFileExtension", "=", "$", "oAssetFile", "->", "getAssetFileExtension", "(", ")", ",", "$", "aAssetFileFilters", ")", ")", "{", "$", "oMediaFileFilter", "=", "$", "aAssetFileFilters", "[", "$", "sAssetFileExtension", "]", ";", "}", "else", "{", "$", "oMediaFileFilter", "=", "$", "aAssetFileFilters", "[", "$", "sAssetFileExtension", "]", "=", "$", "oAssetFileFiltersManager", "->", "has", "(", "$", "sAssetFileExtension", ")", "?", "$", "oAssetFileFiltersManager", "->", "get", "(", "$", "sAssetFileExtension", ")", ":", "null", ";", "}", "}", "else", "{", "$", "oMediaFileFilter", "=", "null", ";", "}", "if", "(", "$", "oMediaFileFilter", ")", "{", "$", "oTmpAssetFile", "=", "$", "this", "->", "createTmpAssetFile", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_MEDIA", ")", ";", "$", "oTmpAssetFile", "->", "setAssetFileContents", "(", "$", "oMediaFileFilter", "->", "filterAssetFile", "(", "$", "oAssetFile", ")", ",", "false", ")", ";", "// Cache asset file", "$", "aAssetFiles", "[", "]", "=", "$", "oAssetFilesCacheManager", "->", "cacheAssetFile", "(", "$", "oTmpAssetFile", ",", "$", "oAssetFile", ")", ";", "}", "else", "{", "// Cache asset file", "$", "aAssetFiles", "[", "]", "=", "$", "oAssetFilesCacheManager", "->", "cacheAssetFile", "(", "$", "oAssetFile", ")", ";", "}", "}", "return", "$", "aAssetFiles", ";", "}" ]
Cache media asset files and retrieve cached asset files @return array
[ "Cache", "media", "asset", "files", "and", "retrieve", "cached", "asset", "files" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L281-L321
226,763
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.rewriteAssetFileUrls
public function rewriteAssetFileUrls($sAssetFileContent, \AssetsBundle\AssetFile\AssetFile $oAssetFile){ // Callback for url rewriting $oRewriteUrlCallback = array($this, 'rewriteUrl'); return preg_replace_callback('/url\(([^\)]+)\)/', function ($aMatches) use ($oAssetFile, $oRewriteUrlCallback) { return call_user_func($oRewriteUrlCallback, $aMatches, $oAssetFile); }, $sAssetFileContent); }
php
public function rewriteAssetFileUrls($sAssetFileContent, \AssetsBundle\AssetFile\AssetFile $oAssetFile){ // Callback for url rewriting $oRewriteUrlCallback = array($this, 'rewriteUrl'); return preg_replace_callback('/url\(([^\)]+)\)/', function ($aMatches) use ($oAssetFile, $oRewriteUrlCallback) { return call_user_func($oRewriteUrlCallback, $aMatches, $oAssetFile); }, $sAssetFileContent); }
[ "public", "function", "rewriteAssetFileUrls", "(", "$", "sAssetFileContent", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "$", "oAssetFile", ")", "{", "// Callback for url rewriting", "$", "oRewriteUrlCallback", "=", "array", "(", "$", "this", ",", "'rewriteUrl'", ")", ";", "return", "preg_replace_callback", "(", "'/url\\(([^\\)]+)\\)/'", ",", "function", "(", "$", "aMatches", ")", "use", "(", "$", "oAssetFile", ",", "$", "oRewriteUrlCallback", ")", "{", "return", "call_user_func", "(", "$", "oRewriteUrlCallback", ",", "$", "aMatches", ",", "$", "oAssetFile", ")", ";", "}", ",", "$", "sAssetFileContent", ")", ";", "}" ]
Rewrite url of an asset file content to match with cache path if needed @param string $sAssetFileContent @param \AssetsBundle\AssetFile\AssetFile $oAssetFile @return string
[ "Rewrite", "url", "of", "an", "asset", "file", "content", "to", "match", "with", "cache", "path", "if", "needed" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L329-L335
226,764
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.rewriteUrl
public function rewriteUrl(array $aMatches, \AssetsBundle\AssetFile\AssetFile $oAssetFile) { if (!isset($aMatches[1])) { throw new \InvalidArgumentException('Url match is not valid'); } // Remove quotes & double quotes from url $aFirstCharMatches = null; $sFirstChar = preg_match('/^("|\'){1}/', $sUrl = trim($aMatches[1]), $aFirstCharMatches) ? $aFirstCharMatches[1] : ''; $sUrl = str_ireplace(array('"', '\''), '', $sUrl); // Data url if (strpos($sUrl, 'data:') === 0) { return $aMatches[0]; } // Remote absolute url if (preg_match('/^http/', $sUrl)) { return $aMatches[0]; } // Split arguments if (strpos($sUrl, '?') !== false) { list($sUrl, $sArguments) = explode('?', $sUrl); } // Split anchor if (strpos($sUrl, '#') !== false) { list($sUrl, $sAnchor) = explode('#', $sUrl); } // Absolute url if (($sUrlRealpath = $this->getOptions()->getRealPath($sUrl, $oAssetFile))) { // Initialize asset file from url $oUrlAssetFile = new \AssetsBundle\AssetFile\AssetFile(array( 'asset_file_type' => \AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA, 'asset_file_path' => $sUrlRealpath )); $sAssetFileCachePath = $this->getAssetFilesCacheManager()->getAssetFileCachePath($oUrlAssetFile); if (!file_exists($sAssetFileCachePath)) { throw new \LogicException('Media file "' . $oUrlAssetFile->getAssetFilePath() . '" used by "' . $oAssetFile->getAssetFilePath() . '" does not have been cached. Please add it into ["assets_bundle"]["assets"]["media"] configuration array'); } // Define cached file path $oUrlAssetFile->setAssetFilePath($sAssetFileCachePath); // Retrieve asset file base url $sAssetFileBaseUrl = $this->getOptions()->getAssetFileBaseUrl($oUrlAssetFile); // Add argument and / or anchor to asset file base url $sAssetFileRealBaseUrl = $sFirstChar . $sAssetFileBaseUrl . (empty($sArguments) ? '' : '?' . $sArguments) . (empty($sAnchor) ? '' : '#' . $sAnchor) . $sFirstChar; // Return asset file base url return str_replace($aMatches[1], $sAssetFileRealBaseUrl, $aMatches[0]); } // Remote relative url elseif ($oAssetFile->isAssetFilePathUrl()) { return str_replace($aMatches[1], $sFirstChar . dirname($oAssetFile->getAssetFilePath()) . '/' . ltrim($sUrl, '/') . $sFirstChar, $aMatches[0]); } // Url is not an exising file else { throw new \LogicException('Url file "' . $sUrl . '" does not exist even relative with "' . $oAssetFile->getAssetFilePath() . '"'); } }
php
public function rewriteUrl(array $aMatches, \AssetsBundle\AssetFile\AssetFile $oAssetFile) { if (!isset($aMatches[1])) { throw new \InvalidArgumentException('Url match is not valid'); } // Remove quotes & double quotes from url $aFirstCharMatches = null; $sFirstChar = preg_match('/^("|\'){1}/', $sUrl = trim($aMatches[1]), $aFirstCharMatches) ? $aFirstCharMatches[1] : ''; $sUrl = str_ireplace(array('"', '\''), '', $sUrl); // Data url if (strpos($sUrl, 'data:') === 0) { return $aMatches[0]; } // Remote absolute url if (preg_match('/^http/', $sUrl)) { return $aMatches[0]; } // Split arguments if (strpos($sUrl, '?') !== false) { list($sUrl, $sArguments) = explode('?', $sUrl); } // Split anchor if (strpos($sUrl, '#') !== false) { list($sUrl, $sAnchor) = explode('#', $sUrl); } // Absolute url if (($sUrlRealpath = $this->getOptions()->getRealPath($sUrl, $oAssetFile))) { // Initialize asset file from url $oUrlAssetFile = new \AssetsBundle\AssetFile\AssetFile(array( 'asset_file_type' => \AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA, 'asset_file_path' => $sUrlRealpath )); $sAssetFileCachePath = $this->getAssetFilesCacheManager()->getAssetFileCachePath($oUrlAssetFile); if (!file_exists($sAssetFileCachePath)) { throw new \LogicException('Media file "' . $oUrlAssetFile->getAssetFilePath() . '" used by "' . $oAssetFile->getAssetFilePath() . '" does not have been cached. Please add it into ["assets_bundle"]["assets"]["media"] configuration array'); } // Define cached file path $oUrlAssetFile->setAssetFilePath($sAssetFileCachePath); // Retrieve asset file base url $sAssetFileBaseUrl = $this->getOptions()->getAssetFileBaseUrl($oUrlAssetFile); // Add argument and / or anchor to asset file base url $sAssetFileRealBaseUrl = $sFirstChar . $sAssetFileBaseUrl . (empty($sArguments) ? '' : '?' . $sArguments) . (empty($sAnchor) ? '' : '#' . $sAnchor) . $sFirstChar; // Return asset file base url return str_replace($aMatches[1], $sAssetFileRealBaseUrl, $aMatches[0]); } // Remote relative url elseif ($oAssetFile->isAssetFilePathUrl()) { return str_replace($aMatches[1], $sFirstChar . dirname($oAssetFile->getAssetFilePath()) . '/' . ltrim($sUrl, '/') . $sFirstChar, $aMatches[0]); } // Url is not an exising file else { throw new \LogicException('Url file "' . $sUrl . '" does not exist even relative with "' . $oAssetFile->getAssetFilePath() . '"'); } }
[ "public", "function", "rewriteUrl", "(", "array", "$", "aMatches", ",", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "$", "oAssetFile", ")", "{", "if", "(", "!", "isset", "(", "$", "aMatches", "[", "1", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Url match is not valid'", ")", ";", "}", "// Remove quotes & double quotes from url", "$", "aFirstCharMatches", "=", "null", ";", "$", "sFirstChar", "=", "preg_match", "(", "'/^(\"|\\'){1}/'", ",", "$", "sUrl", "=", "trim", "(", "$", "aMatches", "[", "1", "]", ")", ",", "$", "aFirstCharMatches", ")", "?", "$", "aFirstCharMatches", "[", "1", "]", ":", "''", ";", "$", "sUrl", "=", "str_ireplace", "(", "array", "(", "'\"'", ",", "'\\''", ")", ",", "''", ",", "$", "sUrl", ")", ";", "// Data url", "if", "(", "strpos", "(", "$", "sUrl", ",", "'data:'", ")", "===", "0", ")", "{", "return", "$", "aMatches", "[", "0", "]", ";", "}", "// Remote absolute url", "if", "(", "preg_match", "(", "'/^http/'", ",", "$", "sUrl", ")", ")", "{", "return", "$", "aMatches", "[", "0", "]", ";", "}", "// Split arguments", "if", "(", "strpos", "(", "$", "sUrl", ",", "'?'", ")", "!==", "false", ")", "{", "list", "(", "$", "sUrl", ",", "$", "sArguments", ")", "=", "explode", "(", "'?'", ",", "$", "sUrl", ")", ";", "}", "// Split anchor", "if", "(", "strpos", "(", "$", "sUrl", ",", "'#'", ")", "!==", "false", ")", "{", "list", "(", "$", "sUrl", ",", "$", "sAnchor", ")", "=", "explode", "(", "'#'", ",", "$", "sUrl", ")", ";", "}", "// Absolute url", "if", "(", "(", "$", "sUrlRealpath", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getRealPath", "(", "$", "sUrl", ",", "$", "oAssetFile", ")", ")", ")", "{", "// Initialize asset file from url", "$", "oUrlAssetFile", "=", "new", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "(", "array", "(", "'asset_file_type'", "=>", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFile", "::", "ASSET_MEDIA", ",", "'asset_file_path'", "=>", "$", "sUrlRealpath", ")", ")", ";", "$", "sAssetFileCachePath", "=", "$", "this", "->", "getAssetFilesCacheManager", "(", ")", "->", "getAssetFileCachePath", "(", "$", "oUrlAssetFile", ")", ";", "if", "(", "!", "file_exists", "(", "$", "sAssetFileCachePath", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Media file \"'", ".", "$", "oUrlAssetFile", "->", "getAssetFilePath", "(", ")", ".", "'\" used by \"'", ".", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ".", "'\" does not have been cached. Please add it into [\"assets_bundle\"][\"assets\"][\"media\"] configuration array'", ")", ";", "}", "// Define cached file path", "$", "oUrlAssetFile", "->", "setAssetFilePath", "(", "$", "sAssetFileCachePath", ")", ";", "// Retrieve asset file base url", "$", "sAssetFileBaseUrl", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getAssetFileBaseUrl", "(", "$", "oUrlAssetFile", ")", ";", "// Add argument and / or anchor to asset file base url", "$", "sAssetFileRealBaseUrl", "=", "$", "sFirstChar", ".", "$", "sAssetFileBaseUrl", ".", "(", "empty", "(", "$", "sArguments", ")", "?", "''", ":", "'?'", ".", "$", "sArguments", ")", ".", "(", "empty", "(", "$", "sAnchor", ")", "?", "''", ":", "'#'", ".", "$", "sAnchor", ")", ".", "$", "sFirstChar", ";", "// Return asset file base url", "return", "str_replace", "(", "$", "aMatches", "[", "1", "]", ",", "$", "sAssetFileRealBaseUrl", ",", "$", "aMatches", "[", "0", "]", ")", ";", "}", "// Remote relative url", "elseif", "(", "$", "oAssetFile", "->", "isAssetFilePathUrl", "(", ")", ")", "{", "return", "str_replace", "(", "$", "aMatches", "[", "1", "]", ",", "$", "sFirstChar", ".", "dirname", "(", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ")", ".", "'/'", ".", "ltrim", "(", "$", "sUrl", ",", "'/'", ")", ".", "$", "sFirstChar", ",", "$", "aMatches", "[", "0", "]", ")", ";", "}", "// Url is not an exising file", "else", "{", "throw", "new", "\\", "LogicException", "(", "'Url file \"'", ".", "$", "sUrl", ".", "'\" does not exist even relative with \"'", ".", "$", "oAssetFile", "->", "getAssetFilePath", "(", ")", ".", "'\"'", ")", ";", "}", "}" ]
Rewrite url to match with cache path if needed @param array $aMatches @param \AssetsBundle\AssetFile\AssetFile $oAssetFile @return array @throws \InvalidArgumentException @throws \LogicException
[ "Rewrite", "url", "to", "match", "with", "cache", "path", "if", "needed" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L346-L408
226,765
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.setAssetFilesConfiguration
public function setAssetFilesConfiguration(\AssetsBundle\AssetFile\AssetFilesConfiguration $oAssetFilesConfiguration) { $this->assetFilesConfiguration = $oAssetFilesConfiguration->setOptions($this->getOptions()); return $this; }
php
public function setAssetFilesConfiguration(\AssetsBundle\AssetFile\AssetFilesConfiguration $oAssetFilesConfiguration) { $this->assetFilesConfiguration = $oAssetFilesConfiguration->setOptions($this->getOptions()); return $this; }
[ "public", "function", "setAssetFilesConfiguration", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesConfiguration", "$", "oAssetFilesConfiguration", ")", "{", "$", "this", "->", "assetFilesConfiguration", "=", "$", "oAssetFilesConfiguration", "->", "setOptions", "(", "$", "this", "->", "getOptions", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the asset files configuration @param \AssetsBundle\AssetFile\AssetFilesConfiguration $oAssetFilesConfiguration @return \AssetsBundle\AssetFile\AssetFilesManager
[ "Set", "the", "asset", "files", "configuration" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L467-L471
226,766
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.getAssetFilesConfiguration
public function getAssetFilesConfiguration() { if (!$this->assetFilesConfiguration instanceof \AssetsBundle\AssetFile\AssetFilesConfiguration) { $this->setAssetFilesConfiguration(new \AssetsBundle\AssetFile\AssetFilesConfiguration()); } return $this->assetFilesConfiguration; }
php
public function getAssetFilesConfiguration() { if (!$this->assetFilesConfiguration instanceof \AssetsBundle\AssetFile\AssetFilesConfiguration) { $this->setAssetFilesConfiguration(new \AssetsBundle\AssetFile\AssetFilesConfiguration()); } return $this->assetFilesConfiguration; }
[ "public", "function", "getAssetFilesConfiguration", "(", ")", "{", "if", "(", "!", "$", "this", "->", "assetFilesConfiguration", "instanceof", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesConfiguration", ")", "{", "$", "this", "->", "setAssetFilesConfiguration", "(", "new", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesConfiguration", "(", ")", ")", ";", "}", "return", "$", "this", "->", "assetFilesConfiguration", ";", "}" ]
Retrieve the asset files configuration. Lazy loads an instance if none currently set. @return \AssetsBundle\AssetFile\AssetFilesConfiguration
[ "Retrieve", "the", "asset", "files", "configuration", ".", "Lazy", "loads", "an", "instance", "if", "none", "currently", "set", "." ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L478-L484
226,767
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.setAssetFileFiltersManager
public function setAssetFileFiltersManager(\AssetsBundle\AssetFile\AssetFileFiltersManager $oAssetFileFiltersManager) { $this->assetFileFiltersManager = $oAssetFileFiltersManager->setOptions($this->getOptions()); return $this; }
php
public function setAssetFileFiltersManager(\AssetsBundle\AssetFile\AssetFileFiltersManager $oAssetFileFiltersManager) { $this->assetFileFiltersManager = $oAssetFileFiltersManager->setOptions($this->getOptions()); return $this; }
[ "public", "function", "setAssetFileFiltersManager", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFileFiltersManager", "$", "oAssetFileFiltersManager", ")", "{", "$", "this", "->", "assetFileFiltersManager", "=", "$", "oAssetFileFiltersManager", "->", "setOptions", "(", "$", "this", "->", "getOptions", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the asset file filters manager @param \AssetsBundle\AssetFile\AssetFileFiltersManager $oAssetFileFiltersManager @return \AssetsBundle\AssetFile\AssetFilesManager
[ "Set", "the", "asset", "file", "filters", "manager" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L492-L496
226,768
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.getAssetFileFiltersManager
public function getAssetFileFiltersManager() { if (!$this->assetFileFiltersManager instanceof \AssetsBundle\AssetFile\AssetFileFiltersManager) { $this->setAssetFileFiltersManager(new \AssetsBundle\AssetFile\AssetFileFiltersManager()); } return $this->assetFileFiltersManager; }
php
public function getAssetFileFiltersManager() { if (!$this->assetFileFiltersManager instanceof \AssetsBundle\AssetFile\AssetFileFiltersManager) { $this->setAssetFileFiltersManager(new \AssetsBundle\AssetFile\AssetFileFiltersManager()); } return $this->assetFileFiltersManager; }
[ "public", "function", "getAssetFileFiltersManager", "(", ")", "{", "if", "(", "!", "$", "this", "->", "assetFileFiltersManager", "instanceof", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFileFiltersManager", ")", "{", "$", "this", "->", "setAssetFileFiltersManager", "(", "new", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFileFiltersManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "assetFileFiltersManager", ";", "}" ]
Retrieve the asset file filters manager. Lazy loads an instance if none currently set. @return \AssetsBundle\AssetFile\AssetFileFiltersManager
[ "Retrieve", "the", "asset", "file", "filters", "manager", ".", "Lazy", "loads", "an", "instance", "if", "none", "currently", "set", "." ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L503-L509
226,769
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.setAssetFilesCacheManager
public function setAssetFilesCacheManager(\AssetsBundle\AssetFile\AssetFilesCacheManager $oAssetFilesCacheManager) { $this->assetFilesCacheManager = $oAssetFilesCacheManager->setOptions($this->getOptions()); return $this; }
php
public function setAssetFilesCacheManager(\AssetsBundle\AssetFile\AssetFilesCacheManager $oAssetFilesCacheManager) { $this->assetFilesCacheManager = $oAssetFilesCacheManager->setOptions($this->getOptions()); return $this; }
[ "public", "function", "setAssetFilesCacheManager", "(", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesCacheManager", "$", "oAssetFilesCacheManager", ")", "{", "$", "this", "->", "assetFilesCacheManager", "=", "$", "oAssetFilesCacheManager", "->", "setOptions", "(", "$", "this", "->", "getOptions", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the asset files cache manager @param \AssetsBundle\AssetFile\AssetFilesCacheManager $oAssetFilesCacheManager @return \AssetsBundle\AssetFile\AssetFilesManager
[ "Set", "the", "asset", "files", "cache", "manager" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L517-L521
226,770
neilime/zf2-assets-bundle
src/AssetsBundle/AssetFile/AssetFilesManager.php
AssetFilesManager.getAssetFilesCacheManager
public function getAssetFilesCacheManager() { if (!$this->assetFilesCacheManager instanceof \AssetsBundle\AssetFile\AssetFilesCacheManager) { $this->setAssetFilesCacheManager(new \AssetsBundle\AssetFile\AssetFilesCacheManager()); } return $this->assetFilesCacheManager; }
php
public function getAssetFilesCacheManager() { if (!$this->assetFilesCacheManager instanceof \AssetsBundle\AssetFile\AssetFilesCacheManager) { $this->setAssetFilesCacheManager(new \AssetsBundle\AssetFile\AssetFilesCacheManager()); } return $this->assetFilesCacheManager; }
[ "public", "function", "getAssetFilesCacheManager", "(", ")", "{", "if", "(", "!", "$", "this", "->", "assetFilesCacheManager", "instanceof", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesCacheManager", ")", "{", "$", "this", "->", "setAssetFilesCacheManager", "(", "new", "\\", "AssetsBundle", "\\", "AssetFile", "\\", "AssetFilesCacheManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "assetFilesCacheManager", ";", "}" ]
Retrieve the asset files cache manager. Lazy loads an instance if none currently set. @return \AssetsBundle\AssetFile\AssetFilesCacheManager
[ "Retrieve", "the", "asset", "files", "cache", "manager", ".", "Lazy", "loads", "an", "instance", "if", "none", "currently", "set", "." ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/AssetFile/AssetFilesManager.php#L528-L534
226,771
CoopBelvedere/laravel-basecamp-api
src/Sections/People.php
People.index
public function index($page = null) { $url = 'people.json'; $people = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($people, Person::class); }
php
public function index($page = null) { $url = 'people.json'; $people = $this->client->get($url, [ 'query' => [ 'page' => $page, ] ]); return $this->indexResponse($people, Person::class); }
[ "public", "function", "index", "(", "$", "page", "=", "null", ")", "{", "$", "url", "=", "'people.json'", ";", "$", "people", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "people", ",", "Person", "::", "class", ")", ";", "}" ]
Get people. @param int $page @return \Illuminate\Support\Collection
[ "Get", "people", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/People.php#L15-L26
226,772
CoopBelvedere/laravel-basecamp-api
src/Sections/People.php
People.inProject
public function inProject($bucket, $page = null) { $url = sprintf('projects/%d/people.json', $bucket); $people = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($people, Person::class); }
php
public function inProject($bucket, $page = null) { $url = sprintf('projects/%d/people.json', $bucket); $people = $this->client->get($url, [ 'query' => [ 'page' => $page, ], ]); return $this->indexResponse($people, Person::class); }
[ "public", "function", "inProject", "(", "$", "bucket", ",", "$", "page", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'projects/%d/people.json'", ",", "$", "bucket", ")", ";", "$", "people", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ",", "[", "'query'", "=>", "[", "'page'", "=>", "$", "page", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "indexResponse", "(", "$", "people", ",", "Person", "::", "class", ")", ";", "}" ]
Get people on a project. @param int $bucket @param int $page @return \Illuminate\Support\Collection
[ "Get", "people", "on", "a", "project", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/People.php#L35-L46
226,773
CoopBelvedere/laravel-basecamp-api
src/Sections/People.php
People.updateAccessToProject
public function updateAccessToProject($bucket, $data) { $access = $this->client->put( sprintf('projects/%d/people/users.json', $bucket), [ 'json' => $data, ] ); return $this->response($access); }
php
public function updateAccessToProject($bucket, $data) { $access = $this->client->put( sprintf('projects/%d/people/users.json', $bucket), [ 'json' => $data, ] ); return $this->response($access); }
[ "public", "function", "updateAccessToProject", "(", "$", "bucket", ",", "$", "data", ")", "{", "$", "access", "=", "$", "this", "->", "client", "->", "put", "(", "sprintf", "(", "'projects/%d/people/users.json'", ",", "$", "bucket", ")", ",", "[", "'json'", "=>", "$", "data", ",", "]", ")", ";", "return", "$", "this", "->", "response", "(", "$", "access", ")", ";", "}" ]
Update an access to a project. @param int $bucket @param array $data @return \Illuminate\Support\Collection
[ "Update", "an", "access", "to", "a", "project", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/People.php#L55-L65
226,774
CoopBelvedere/laravel-basecamp-api
src/Sections/People.php
People.show
public function show($id) { $person = $this->client->get(sprintf('people/%d.json', $id)); return new Person($this->response($person)); }
php
public function show($id) { $person = $this->client->get(sprintf('people/%d.json', $id)); return new Person($this->response($person)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "person", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'people/%d.json'", ",", "$", "id", ")", ")", ";", "return", "new", "Person", "(", "$", "this", "->", "response", "(", "$", "person", ")", ")", ";", "}" ]
Get a person. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "person", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/People.php#L92-L97
226,775
stevenmaguire/laravel-middleware-csp
src/EnforceContentSecurity.php
EnforceContentSecurity.handle
public function handle($request, Closure $next) { $response = $next($request); if ($response instanceof Response) { $this->setProfiles($this->getProfileConfig()); $this->setProfilesWithParameters(func_get_args()); $psr7Response = $this->createPsr7Response($response); $psr7Response = $this->addPolicyHeader($psr7Response); $response = $this->createLaravelResponse($psr7Response); } return $response; }
php
public function handle($request, Closure $next) { $response = $next($request); if ($response instanceof Response) { $this->setProfiles($this->getProfileConfig()); $this->setProfilesWithParameters(func_get_args()); $psr7Response = $this->createPsr7Response($response); $psr7Response = $this->addPolicyHeader($psr7Response); $response = $this->createLaravelResponse($psr7Response); } return $response; }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "$", "response", "=", "$", "next", "(", "$", "request", ")", ";", "if", "(", "$", "response", "instanceof", "Response", ")", "{", "$", "this", "->", "setProfiles", "(", "$", "this", "->", "getProfileConfig", "(", ")", ")", ";", "$", "this", "->", "setProfilesWithParameters", "(", "func_get_args", "(", ")", ")", ";", "$", "psr7Response", "=", "$", "this", "->", "createPsr7Response", "(", "$", "response", ")", ";", "$", "psr7Response", "=", "$", "this", "->", "addPolicyHeader", "(", "$", "psr7Response", ")", ";", "$", "response", "=", "$", "this", "->", "createLaravelResponse", "(", "$", "psr7Response", ")", ";", "}", "return", "$", "response", ";", "}" ]
Handles an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
[ "Handles", "an", "incoming", "request", "." ]
3427292659bcab5010230122626c1fd68b921ba6
https://github.com/stevenmaguire/laravel-middleware-csp/blob/3427292659bcab5010230122626c1fd68b921ba6/src/EnforceContentSecurity.php#L41-L58
226,776
stevenmaguire/laravel-middleware-csp
src/EnforceContentSecurity.php
EnforceContentSecurity.createLaravelResponse
protected function createLaravelResponse(ResponseInterface $response) { return new Response( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() ); }
php
protected function createLaravelResponse(ResponseInterface $response) { return new Response( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() ); }
[ "protected", "function", "createLaravelResponse", "(", "ResponseInterface", "$", "response", ")", "{", "return", "new", "Response", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", "->", "getHeaders", "(", ")", ")", ";", "}" ]
Creates Laravel response object from PSR 7 response. @param ResponseInterface $response @return Response
[ "Creates", "Laravel", "response", "object", "from", "PSR", "7", "response", "." ]
3427292659bcab5010230122626c1fd68b921ba6
https://github.com/stevenmaguire/laravel-middleware-csp/blob/3427292659bcab5010230122626c1fd68b921ba6/src/EnforceContentSecurity.php#L67-L74
226,777
stevenmaguire/laravel-middleware-csp
src/EnforceContentSecurity.php
EnforceContentSecurity.createPsr7Response
protected function createPsr7Response(Response $response) { return new PsrResponse( $response->getStatusCode(), $response->headers->all(), $response->getContent(), $response->getProtocolVersion() ); }
php
protected function createPsr7Response(Response $response) { return new PsrResponse( $response->getStatusCode(), $response->headers->all(), $response->getContent(), $response->getProtocolVersion() ); }
[ "protected", "function", "createPsr7Response", "(", "Response", "$", "response", ")", "{", "return", "new", "PsrResponse", "(", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", "->", "headers", "->", "all", "(", ")", ",", "$", "response", "->", "getContent", "(", ")", ",", "$", "response", "->", "getProtocolVersion", "(", ")", ")", ";", "}" ]
Creates PSR 7 response object from Laravel response. @param Response $response @return ResponseInterface
[ "Creates", "PSR", "7", "response", "object", "from", "Laravel", "response", "." ]
3427292659bcab5010230122626c1fd68b921ba6
https://github.com/stevenmaguire/laravel-middleware-csp/blob/3427292659bcab5010230122626c1fd68b921ba6/src/EnforceContentSecurity.php#L83-L91
226,778
stevenmaguire/laravel-middleware-csp
src/EnforceContentSecurity.php
EnforceContentSecurity.getProfileConfig
protected function getProfileConfig() { $configCallable = $this->config; $config = $configCallable($this->getProfileConfigKey()); if (!is_array($config)) { $config = [$config]; } return array_filter($config); }
php
protected function getProfileConfig() { $configCallable = $this->config; $config = $configCallable($this->getProfileConfigKey()); if (!is_array($config)) { $config = [$config]; } return array_filter($config); }
[ "protected", "function", "getProfileConfig", "(", ")", "{", "$", "configCallable", "=", "$", "this", "->", "config", ";", "$", "config", "=", "$", "configCallable", "(", "$", "this", "->", "getProfileConfigKey", "(", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "$", "config", "=", "[", "$", "config", "]", ";", "}", "return", "array_filter", "(", "$", "config", ")", ";", "}" ]
Retrives profile configuration from Laravel config object. @return array
[ "Retrives", "profile", "configuration", "from", "Laravel", "config", "object", "." ]
3427292659bcab5010230122626c1fd68b921ba6
https://github.com/stevenmaguire/laravel-middleware-csp/blob/3427292659bcab5010230122626c1fd68b921ba6/src/EnforceContentSecurity.php#L98-L108
226,779
stevenmaguire/laravel-middleware-csp
src/EnforceContentSecurity.php
EnforceContentSecurity.getProfilesFromArguments
protected function getProfilesFromArguments(array $arguments) { $profiles = []; if (count($arguments) > 2) { unset($arguments[0]); unset($arguments[1]); $profiles = $arguments; } return $profiles; }
php
protected function getProfilesFromArguments(array $arguments) { $profiles = []; if (count($arguments) > 2) { unset($arguments[0]); unset($arguments[1]); $profiles = $arguments; } return $profiles; }
[ "protected", "function", "getProfilesFromArguments", "(", "array", "$", "arguments", ")", "{", "$", "profiles", "=", "[", "]", ";", "if", "(", "count", "(", "$", "arguments", ")", ">", "2", ")", "{", "unset", "(", "$", "arguments", "[", "0", "]", ")", ";", "unset", "(", "$", "arguments", "[", "1", "]", ")", ";", "$", "profiles", "=", "$", "arguments", ";", "}", "return", "$", "profiles", ";", "}" ]
Gets profiles from handle method arguments. @param array $arguments @return array
[ "Gets", "profiles", "from", "handle", "method", "arguments", "." ]
3427292659bcab5010230122626c1fd68b921ba6
https://github.com/stevenmaguire/laravel-middleware-csp/blob/3427292659bcab5010230122626c1fd68b921ba6/src/EnforceContentSecurity.php#L127-L136
226,780
kossmoss/yii2-postgresql-array-field
src/PostgresqlArrayFieldBehavior.php
PostgresqlArrayFieldBehavior._loadArray
public function _loadArray() { $rawData = $this->getRawData(); $value = $this->_postgresqlArrayDecode($rawData); $value = $value ?: []; $this->getModel()->setAttribute($this->getArrayFieldName(), $value); return $this; }
php
public function _loadArray() { $rawData = $this->getRawData(); $value = $this->_postgresqlArrayDecode($rawData); $value = $value ?: []; $this->getModel()->setAttribute($this->getArrayFieldName(), $value); return $this; }
[ "public", "function", "_loadArray", "(", ")", "{", "$", "rawData", "=", "$", "this", "->", "getRawData", "(", ")", ";", "$", "value", "=", "$", "this", "->", "_postgresqlArrayDecode", "(", "$", "rawData", ")", ";", "$", "value", "=", "$", "value", "?", ":", "[", "]", ";", "$", "this", "->", "getModel", "(", ")", "->", "setAttribute", "(", "$", "this", "->", "getArrayFieldName", "(", ")", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Loads array field @return $this
[ "Loads", "array", "field" ]
9f27fa5dbd1bd2700a44d52de7213bf837749569
https://github.com/kossmoss/yii2-postgresql-array-field/blob/9f27fa5dbd1bd2700a44d52de7213bf837749569/src/PostgresqlArrayFieldBehavior.php#L139-L147
226,781
kossmoss/yii2-postgresql-array-field
src/PostgresqlArrayFieldBehavior.php
PostgresqlArrayFieldBehavior._postgresqlArrayDecode
protected function _postgresqlArrayDecode($data, $start = 0) { if (empty($data) || $data[0] != '{') { return null; } $result = []; $string = false; $quote = ''; $len = strlen($data); $v = ''; for ($i = $start + 1; $i < $len; $i++) { $ch = $data[$i]; if (!$string && $ch == '}') { if ($v !== '' || !empty($result)) { $result[] = $v; } break; } else if (!$string && $ch == '{') { $v = $this->_postgresqlArrayDecode($data, $i); } else if (!$string && $ch == ',') { $result[] = $v; $v = ''; } else if (!$string && ($ch == '"' || $ch == "'")) { $string = true; $quote = $ch; } else if ($string && $ch == $quote && $data[$i - 1] == "\\") { $v = substr($v, 0, -1) . $ch; } else if ($string && $ch == $quote && $data[$i - 1] != "\\") { $string = false; } else { $v .= $ch; } } return $result; }
php
protected function _postgresqlArrayDecode($data, $start = 0) { if (empty($data) || $data[0] != '{') { return null; } $result = []; $string = false; $quote = ''; $len = strlen($data); $v = ''; for ($i = $start + 1; $i < $len; $i++) { $ch = $data[$i]; if (!$string && $ch == '}') { if ($v !== '' || !empty($result)) { $result[] = $v; } break; } else if (!$string && $ch == '{') { $v = $this->_postgresqlArrayDecode($data, $i); } else if (!$string && $ch == ',') { $result[] = $v; $v = ''; } else if (!$string && ($ch == '"' || $ch == "'")) { $string = true; $quote = $ch; } else if ($string && $ch == $quote && $data[$i - 1] == "\\") { $v = substr($v, 0, -1) . $ch; } else if ($string && $ch == $quote && $data[$i - 1] != "\\") { $string = false; } else { $v .= $ch; } } return $result; }
[ "protected", "function", "_postgresqlArrayDecode", "(", "$", "data", ",", "$", "start", "=", "0", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "||", "$", "data", "[", "0", "]", "!=", "'{'", ")", "{", "return", "null", ";", "}", "$", "result", "=", "[", "]", ";", "$", "string", "=", "false", ";", "$", "quote", "=", "''", ";", "$", "len", "=", "strlen", "(", "$", "data", ")", ";", "$", "v", "=", "''", ";", "for", "(", "$", "i", "=", "$", "start", "+", "1", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "ch", "=", "$", "data", "[", "$", "i", "]", ";", "if", "(", "!", "$", "string", "&&", "$", "ch", "==", "'}'", ")", "{", "if", "(", "$", "v", "!==", "''", "||", "!", "empty", "(", "$", "result", ")", ")", "{", "$", "result", "[", "]", "=", "$", "v", ";", "}", "break", ";", "}", "else", "if", "(", "!", "$", "string", "&&", "$", "ch", "==", "'{'", ")", "{", "$", "v", "=", "$", "this", "->", "_postgresqlArrayDecode", "(", "$", "data", ",", "$", "i", ")", ";", "}", "else", "if", "(", "!", "$", "string", "&&", "$", "ch", "==", "','", ")", "{", "$", "result", "[", "]", "=", "$", "v", ";", "$", "v", "=", "''", ";", "}", "else", "if", "(", "!", "$", "string", "&&", "(", "$", "ch", "==", "'\"'", "||", "$", "ch", "==", "\"'\"", ")", ")", "{", "$", "string", "=", "true", ";", "$", "quote", "=", "$", "ch", ";", "}", "else", "if", "(", "$", "string", "&&", "$", "ch", "==", "$", "quote", "&&", "$", "data", "[", "$", "i", "-", "1", "]", "==", "\"\\\\\"", ")", "{", "$", "v", "=", "substr", "(", "$", "v", ",", "0", ",", "-", "1", ")", ".", "$", "ch", ";", "}", "else", "if", "(", "$", "string", "&&", "$", "ch", "==", "$", "quote", "&&", "$", "data", "[", "$", "i", "-", "1", "]", "!=", "\"\\\\\"", ")", "{", "$", "string", "=", "false", ";", "}", "else", "{", "$", "v", ".=", "$", "ch", ";", "}", "}", "return", "$", "result", ";", "}" ]
Decodes PostgreSQL array data into PHP array @link http://stackoverflow.com/questions/3068683/convert-postgresql-array-to-php-array/27964420#27964420 @param string $data PostgreSQL-encoded array @param int $start start position for recursive inner arrays parsing @return array
[ "Decodes", "PostgreSQL", "array", "data", "into", "PHP", "array" ]
9f27fa5dbd1bd2700a44d52de7213bf837749569
https://github.com/kossmoss/yii2-postgresql-array-field/blob/9f27fa5dbd1bd2700a44d52de7213bf837749569/src/PostgresqlArrayFieldBehavior.php#L159-L198
226,782
kossmoss/yii2-postgresql-array-field
src/PostgresqlArrayFieldBehavior.php
PostgresqlArrayFieldBehavior._saveArray
public function _saveArray() { $value = $this->getModel()->getAttribute($this->getArrayFieldName());; $value = $this->_postgresqlArrayEncode($value); if($value === null && $this->onEmptySaveNull == false){ $value = '{}'; } $this->getModel()->setAttribute($this->getArrayFieldName(), $value); return $this; }
php
public function _saveArray() { $value = $this->getModel()->getAttribute($this->getArrayFieldName());; $value = $this->_postgresqlArrayEncode($value); if($value === null && $this->onEmptySaveNull == false){ $value = '{}'; } $this->getModel()->setAttribute($this->getArrayFieldName(), $value); return $this; }
[ "public", "function", "_saveArray", "(", ")", "{", "$", "value", "=", "$", "this", "->", "getModel", "(", ")", "->", "getAttribute", "(", "$", "this", "->", "getArrayFieldName", "(", ")", ")", ";", ";", "$", "value", "=", "$", "this", "->", "_postgresqlArrayEncode", "(", "$", "value", ")", ";", "if", "(", "$", "value", "===", "null", "&&", "$", "this", "->", "onEmptySaveNull", "==", "false", ")", "{", "$", "value", "=", "'{}'", ";", "}", "$", "this", "->", "getModel", "(", ")", "->", "setAttribute", "(", "$", "this", "->", "getArrayFieldName", "(", ")", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Sets array field data into format suitable for save @return $this
[ "Sets", "array", "field", "data", "into", "format", "suitable", "for", "save" ]
9f27fa5dbd1bd2700a44d52de7213bf837749569
https://github.com/kossmoss/yii2-postgresql-array-field/blob/9f27fa5dbd1bd2700a44d52de7213bf837749569/src/PostgresqlArrayFieldBehavior.php#L205-L215
226,783
kossmoss/yii2-postgresql-array-field
src/PostgresqlArrayFieldBehavior.php
PostgresqlArrayFieldBehavior._postgresqlArrayEncode
protected function _postgresqlArrayEncode($value) { if (empty($value) || !is_array($value)) { return null; } $result = '{'; $firstElem = true; foreach($value as $elem) { // add comma before element if it is not the first one if(!$firstElem){ $result .= ','; } if(is_array($elem)){ $result .= $this->_postgresqlArrayEncode($elem); }else if(is_string($elem)){ if(strpos($elem, ',') !== false) { $result .= '"'.$elem.'"'; }else{ $result .= $elem; } }else if(is_numeric($elem)){ $result .= $elem; }else{ // we can only save strings and numeric throw new \Exception('Array contains other than string or numeric values, can\'t save to PostgreSQL array field'); } $firstElem = false; } $result .= '}'; return $result; }
php
protected function _postgresqlArrayEncode($value) { if (empty($value) || !is_array($value)) { return null; } $result = '{'; $firstElem = true; foreach($value as $elem) { // add comma before element if it is not the first one if(!$firstElem){ $result .= ','; } if(is_array($elem)){ $result .= $this->_postgresqlArrayEncode($elem); }else if(is_string($elem)){ if(strpos($elem, ',') !== false) { $result .= '"'.$elem.'"'; }else{ $result .= $elem; } }else if(is_numeric($elem)){ $result .= $elem; }else{ // we can only save strings and numeric throw new \Exception('Array contains other than string or numeric values, can\'t save to PostgreSQL array field'); } $firstElem = false; } $result .= '}'; return $result; }
[ "protected", "function", "_postgresqlArrayEncode", "(", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", "||", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "$", "result", "=", "'{'", ";", "$", "firstElem", "=", "true", ";", "foreach", "(", "$", "value", "as", "$", "elem", ")", "{", "// add comma before element if it is not the first one", "if", "(", "!", "$", "firstElem", ")", "{", "$", "result", ".=", "','", ";", "}", "if", "(", "is_array", "(", "$", "elem", ")", ")", "{", "$", "result", ".=", "$", "this", "->", "_postgresqlArrayEncode", "(", "$", "elem", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "elem", ")", ")", "{", "if", "(", "strpos", "(", "$", "elem", ",", "','", ")", "!==", "false", ")", "{", "$", "result", ".=", "'\"'", ".", "$", "elem", ".", "'\"'", ";", "}", "else", "{", "$", "result", ".=", "$", "elem", ";", "}", "}", "else", "if", "(", "is_numeric", "(", "$", "elem", ")", ")", "{", "$", "result", ".=", "$", "elem", ";", "}", "else", "{", "// we can only save strings and numeric", "throw", "new", "\\", "Exception", "(", "'Array contains other than string or numeric values, can\\'t save to PostgreSQL array field'", ")", ";", "}", "$", "firstElem", "=", "false", ";", "}", "$", "result", ".=", "'}'", ";", "return", "$", "result", ";", "}" ]
Encodes PHP array into PostgreSQL array data format @param array $value @return string PostgreSQL-encoded array @throws \Exception
[ "Encodes", "PHP", "array", "into", "PostgreSQL", "array", "data", "format" ]
9f27fa5dbd1bd2700a44d52de7213bf837749569
https://github.com/kossmoss/yii2-postgresql-array-field/blob/9f27fa5dbd1bd2700a44d52de7213bf837749569/src/PostgresqlArrayFieldBehavior.php#L224-L256
226,784
THECALLR/sdk-php
src/CALLR/Realtime/Server.php
Server.start
public function start() { try { /* raw input handler */ $raw = file_get_contents(php_sapi_name() === 'cli' ? 'php://stdin' : 'php://input'); if ($this->rawInputHandler !== null) { call_user_func($this->rawInputHandler, $raw); } /* parse the incoming request */ $request = new Request($raw); /* find the CallFlow */ if (array_key_exists($request->app, $this->cf)) { $cf = $this->cf[$request->app]; } elseif (array_key_exists('*', $this->cf)) { $cf = $this->cf['*']; } else { throw new \Exception("CallFlow for '{$request->app}' Not Found", 404); } /* call the previous callback. if response is null, we just received a HANGUP */ if (($label = $cf->callback($request)) !== null) { /* call the next label */ $response = $cf->execute($label); /* output response */ echo $response->getJSON(); } } catch (\Exception $e) { /* if an exception is thrown, we reply with an HTTP error */ echo $this->httpError($e->getMessage(), $e->getCode()); } $output = ob_get_contents(); /* raw output handler */ if ($this->rawOutputHandler !== null) { call_user_func($this->rawOutputHandler, $output); } /* Content-Type */ header('Content-Type: '.self::CONTENT_TYPE); /* flush output buffer */ ob_end_flush(); }
php
public function start() { try { /* raw input handler */ $raw = file_get_contents(php_sapi_name() === 'cli' ? 'php://stdin' : 'php://input'); if ($this->rawInputHandler !== null) { call_user_func($this->rawInputHandler, $raw); } /* parse the incoming request */ $request = new Request($raw); /* find the CallFlow */ if (array_key_exists($request->app, $this->cf)) { $cf = $this->cf[$request->app]; } elseif (array_key_exists('*', $this->cf)) { $cf = $this->cf['*']; } else { throw new \Exception("CallFlow for '{$request->app}' Not Found", 404); } /* call the previous callback. if response is null, we just received a HANGUP */ if (($label = $cf->callback($request)) !== null) { /* call the next label */ $response = $cf->execute($label); /* output response */ echo $response->getJSON(); } } catch (\Exception $e) { /* if an exception is thrown, we reply with an HTTP error */ echo $this->httpError($e->getMessage(), $e->getCode()); } $output = ob_get_contents(); /* raw output handler */ if ($this->rawOutputHandler !== null) { call_user_func($this->rawOutputHandler, $output); } /* Content-Type */ header('Content-Type: '.self::CONTENT_TYPE); /* flush output buffer */ ob_end_flush(); }
[ "public", "function", "start", "(", ")", "{", "try", "{", "/* raw input handler */", "$", "raw", "=", "file_get_contents", "(", "php_sapi_name", "(", ")", "===", "'cli'", "?", "'php://stdin'", ":", "'php://input'", ")", ";", "if", "(", "$", "this", "->", "rawInputHandler", "!==", "null", ")", "{", "call_user_func", "(", "$", "this", "->", "rawInputHandler", ",", "$", "raw", ")", ";", "}", "/* parse the incoming request */", "$", "request", "=", "new", "Request", "(", "$", "raw", ")", ";", "/* find the CallFlow */", "if", "(", "array_key_exists", "(", "$", "request", "->", "app", ",", "$", "this", "->", "cf", ")", ")", "{", "$", "cf", "=", "$", "this", "->", "cf", "[", "$", "request", "->", "app", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "'*'", ",", "$", "this", "->", "cf", ")", ")", "{", "$", "cf", "=", "$", "this", "->", "cf", "[", "'*'", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"CallFlow for '{$request->app}' Not Found\"", ",", "404", ")", ";", "}", "/* call the previous callback. if response is null, we just received a HANGUP */", "if", "(", "(", "$", "label", "=", "$", "cf", "->", "callback", "(", "$", "request", ")", ")", "!==", "null", ")", "{", "/* call the next label */", "$", "response", "=", "$", "cf", "->", "execute", "(", "$", "label", ")", ";", "/* output response */", "echo", "$", "response", "->", "getJSON", "(", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "/* if an exception is thrown, we reply with an HTTP error */", "echo", "$", "this", "->", "httpError", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "$", "output", "=", "ob_get_contents", "(", ")", ";", "/* raw output handler */", "if", "(", "$", "this", "->", "rawOutputHandler", "!==", "null", ")", "{", "call_user_func", "(", "$", "this", "->", "rawOutputHandler", ",", "$", "output", ")", ";", "}", "/* Content-Type */", "header", "(", "'Content-Type: '", ".", "self", "::", "CONTENT_TYPE", ")", ";", "/* flush output buffer */", "ob_end_flush", "(", ")", ";", "}" ]
Starts the server.
[ "Starts", "the", "server", "." ]
3b6ade63a515dcf993cd2c8812950e39737fd3b9
https://github.com/THECALLR/sdk-php/blob/3b6ade63a515dcf993cd2c8812950e39737fd3b9/src/CALLR/Realtime/Server.php#L62-L100
226,785
nstapelbroek/culpa-laravel-5
src/Traits/Blameable.php
Blameable.getFields
protected function getFields() { // Abort if blameble has been disabled explicitly if (false === $this->blameable) { return false; } if (!isset($this->fields)) { $this->fields = BlameableObserver::findBlameableFields($this, $this->blameable); } return $this->fields; }
php
protected function getFields() { // Abort if blameble has been disabled explicitly if (false === $this->blameable) { return false; } if (!isset($this->fields)) { $this->fields = BlameableObserver::findBlameableFields($this, $this->blameable); } return $this->fields; }
[ "protected", "function", "getFields", "(", ")", "{", "// Abort if blameble has been disabled explicitly", "if", "(", "false", "===", "$", "this", "->", "blameable", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "this", "->", "fields", "=", "BlameableObserver", "::", "findBlameableFields", "(", "$", "this", ",", "$", "this", "->", "blameable", ")", ";", "}", "return", "$", "this", "->", "fields", ";", "}" ]
Get blameable fields. @return array
[ "Get", "blameable", "fields", "." ]
1a65af243fa52565c4a76c0446a80540bc5fded2
https://github.com/nstapelbroek/culpa-laravel-5/blob/1a65af243fa52565c4a76c0446a80540bc5fded2/src/Traits/Blameable.php#L39-L51
226,786
neilime/zf2-assets-bundle
src/AssetsBundle/View/Strategy/JsCustomStrategy.php
JsCustomStrategy.detach
public function detach(\Zend\EventManager\EventManagerInterface $oEvents) { foreach ($this->listeners as $iIndex => $oListener) { if ($oEvents->detach($oListener)) { unset($this->listeners[$iIndex]); } } }
php
public function detach(\Zend\EventManager\EventManagerInterface $oEvents) { foreach ($this->listeners as $iIndex => $oListener) { if ($oEvents->detach($oListener)) { unset($this->listeners[$iIndex]); } } }
[ "public", "function", "detach", "(", "\\", "Zend", "\\", "EventManager", "\\", "EventManagerInterface", "$", "oEvents", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "as", "$", "iIndex", "=>", "$", "oListener", ")", "{", "if", "(", "$", "oEvents", "->", "detach", "(", "$", "oListener", ")", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "iIndex", "]", ")", ";", "}", "}", "}" ]
Detach aggregate listeners from the specified event manager @param \Zend\EventManager\EventManagerInterface $oEvents @return void
[ "Detach", "aggregate", "listeners", "from", "the", "specified", "event", "manager" ]
6399912d05d37c91be330e7accf3291a2dbdfe49
https://github.com/neilime/zf2-assets-bundle/blob/6399912d05d37c91be330e7accf3291a2dbdfe49/src/AssetsBundle/View/Strategy/JsCustomStrategy.php#L74-L80
226,787
CoopBelvedere/laravel-basecamp-api
src/Sections/Questionnaires.php
Questionnaires.show
public function show($id) { $questionnaire = $this->client->get( sprintf('buckets/%d/questionnaires/%d.json', $this->bucket, $id) ); return new Questionnaire($this->response($questionnaire)); }
php
public function show($id) { $questionnaire = $this->client->get( sprintf('buckets/%d/questionnaires/%d.json', $this->bucket, $id) ); return new Questionnaire($this->response($questionnaire)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "questionnaire", "=", "$", "this", "->", "client", "->", "get", "(", "sprintf", "(", "'buckets/%d/questionnaires/%d.json'", ",", "$", "this", "->", "bucket", ",", "$", "id", ")", ")", ";", "return", "new", "Questionnaire", "(", "$", "this", "->", "response", "(", "$", "questionnaire", ")", ")", ";", "}" ]
Get a questionnaire. @param int $id @return \Illuminate\Support\Collection
[ "Get", "a", "questionnaire", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Sections/Questionnaires.php#L15-L22
226,788
CoopBelvedere/laravel-basecamp-api
src/Client.php
Client.getHttpClient
protected function getHttpClient() { if (is_null($this->httpClient)) { $handlerStack = $this->createHandlerStack(); return new Guzzle([ 'base_uri' => rtrim($this->api['href'],'/').'/', 'handler' => $handlerStack, ]); } return $this->httpClient; }
php
protected function getHttpClient() { if (is_null($this->httpClient)) { $handlerStack = $this->createHandlerStack(); return new Guzzle([ 'base_uri' => rtrim($this->api['href'],'/').'/', 'handler' => $handlerStack, ]); } return $this->httpClient; }
[ "protected", "function", "getHttpClient", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "httpClient", ")", ")", "{", "$", "handlerStack", "=", "$", "this", "->", "createHandlerStack", "(", ")", ";", "return", "new", "Guzzle", "(", "[", "'base_uri'", "=>", "rtrim", "(", "$", "this", "->", "api", "[", "'href'", "]", ",", "'/'", ")", ".", "'/'", ",", "'handler'", "=>", "$", "handlerStack", ",", "]", ")", ";", "}", "return", "$", "this", "->", "httpClient", ";", "}" ]
Get the Http Client. @return \GuzzleHttp\Client
[ "Get", "the", "Http", "Client", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Client.php#L92-L105
226,789
CoopBelvedere/laravel-basecamp-api
src/Client.php
Client.createHandlerStack
protected function createHandlerStack() { $stack = HandlerStack::create(new CurlHandler()); $stack->push(ClientMiddlewares::cache($this->cache)); $stack->push( ClientMiddlewares::setBaseHeaders( $this->api['token'], $this->config['basecamp.user-agent'] ) ); $stack->push( ClientMiddlewares::retry($this->api, $this->config) ); // Add custom middlewares. foreach ($this->middlewares as $middleware) { $stack->push($middleware); } return $stack; }
php
protected function createHandlerStack() { $stack = HandlerStack::create(new CurlHandler()); $stack->push(ClientMiddlewares::cache($this->cache)); $stack->push( ClientMiddlewares::setBaseHeaders( $this->api['token'], $this->config['basecamp.user-agent'] ) ); $stack->push( ClientMiddlewares::retry($this->api, $this->config) ); // Add custom middlewares. foreach ($this->middlewares as $middleware) { $stack->push($middleware); } return $stack; }
[ "protected", "function", "createHandlerStack", "(", ")", "{", "$", "stack", "=", "HandlerStack", "::", "create", "(", "new", "CurlHandler", "(", ")", ")", ";", "$", "stack", "->", "push", "(", "ClientMiddlewares", "::", "cache", "(", "$", "this", "->", "cache", ")", ")", ";", "$", "stack", "->", "push", "(", "ClientMiddlewares", "::", "setBaseHeaders", "(", "$", "this", "->", "api", "[", "'token'", "]", ",", "$", "this", "->", "config", "[", "'basecamp.user-agent'", "]", ")", ")", ";", "$", "stack", "->", "push", "(", "ClientMiddlewares", "::", "retry", "(", "$", "this", "->", "api", ",", "$", "this", "->", "config", ")", ")", ";", "// Add custom middlewares.", "foreach", "(", "$", "this", "->", "middlewares", "as", "$", "middleware", ")", "{", "$", "stack", "->", "push", "(", "$", "middleware", ")", ";", "}", "return", "$", "stack", ";", "}" ]
Create an Handler Stack to pass Middlewares to Guzzle. @return \GuzzleHttp\HandlerStack
[ "Create", "an", "Handler", "Stack", "to", "pass", "Middlewares", "to", "Guzzle", "." ]
cc0d6f25dfcbbe5c611642694bb6e4cb84664a82
https://github.com/CoopBelvedere/laravel-basecamp-api/blob/cc0d6f25dfcbbe5c611642694bb6e4cb84664a82/src/Client.php#L134-L154
226,790
beheh/flaps
src/Flaps/Throttling/LeakyBucketStrategy.php
LeakyBucketStrategy.setRequestsPerTimeSpan
public function setRequestsPerTimeSpan($requests) { if (!is_numeric($requests)) { throw new InvalidArgumentException('requests per timespan is not numeric'); } $requests = (int) $requests; if ($requests < 1) { throw new InvalidArgumentException('requests per timespan cannot be smaller than 1'); } $this->requestsPerTimeSpan = $requests; }
php
public function setRequestsPerTimeSpan($requests) { if (!is_numeric($requests)) { throw new InvalidArgumentException('requests per timespan is not numeric'); } $requests = (int) $requests; if ($requests < 1) { throw new InvalidArgumentException('requests per timespan cannot be smaller than 1'); } $this->requestsPerTimeSpan = $requests; }
[ "public", "function", "setRequestsPerTimeSpan", "(", "$", "requests", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "requests", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'requests per timespan is not numeric'", ")", ";", "}", "$", "requests", "=", "(", "int", ")", "$", "requests", ";", "if", "(", "$", "requests", "<", "1", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'requests per timespan cannot be smaller than 1'", ")", ";", "}", "$", "this", "->", "requestsPerTimeSpan", "=", "$", "requests", ";", "}" ]
Sets the maximum number of requests allowed per timespan for a single entity. @param int $requests @throws \InvalidArgumentException
[ "Sets", "the", "maximum", "number", "of", "requests", "allowed", "per", "timespan", "for", "a", "single", "entity", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Throttling/LeakyBucketStrategy.php#L30-L40
226,791
beheh/flaps
src/Flaps/Throttling/LeakyBucketStrategy.php
LeakyBucketStrategy.setTimeSpan
public function setTimeSpan($timeSpan) { if (is_string($timeSpan)) { $timeSpan = self::parseTime($timeSpan); } if (!is_numeric($timeSpan)) { throw new InvalidArgumentException('timespan is not numeric'); } $timeSpan = floatval($timeSpan); if ($timeSpan <= 0) { throw new InvalidArgumentException('timespan cannot be 0 or less'); } $this->timeSpan = $timeSpan; }
php
public function setTimeSpan($timeSpan) { if (is_string($timeSpan)) { $timeSpan = self::parseTime($timeSpan); } if (!is_numeric($timeSpan)) { throw new InvalidArgumentException('timespan is not numeric'); } $timeSpan = floatval($timeSpan); if ($timeSpan <= 0) { throw new InvalidArgumentException('timespan cannot be 0 or less'); } $this->timeSpan = $timeSpan; }
[ "public", "function", "setTimeSpan", "(", "$", "timeSpan", ")", "{", "if", "(", "is_string", "(", "$", "timeSpan", ")", ")", "{", "$", "timeSpan", "=", "self", "::", "parseTime", "(", "$", "timeSpan", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "timeSpan", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'timespan is not numeric'", ")", ";", "}", "$", "timeSpan", "=", "floatval", "(", "$", "timeSpan", ")", ";", "if", "(", "$", "timeSpan", "<=", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'timespan cannot be 0 or less'", ")", ";", "}", "$", "this", "->", "timeSpan", "=", "$", "timeSpan", ";", "}" ]
Sets the timespan in which the defined number of requests is allowed per single entity. @param float|string $timeSpan @throws InvalidArgumentException
[ "Sets", "the", "timespan", "in", "which", "the", "defined", "number", "of", "requests", "is", "allowed", "per", "single", "entity", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Throttling/LeakyBucketStrategy.php#L61-L74
226,792
beheh/flaps
src/Flaps/Throttling/LeakyBucketStrategy.php
LeakyBucketStrategy.parseTime
public static function parseTime($timeSpan) { $times = array('s' => 1, 'm' => 60, 'h' => 3600, 'd' => 86400, 'w' => 604800); $matches = array(); if (is_numeric($timeSpan)) { return $timeSpan; } if (preg_match('/^((\d+)?(\.\d+)?)('.implode('|', array_keys($times)).')$/', $timeSpan, $matches)) { return floatval($matches[1]) * $times[$matches[4]]; } return null; }
php
public static function parseTime($timeSpan) { $times = array('s' => 1, 'm' => 60, 'h' => 3600, 'd' => 86400, 'w' => 604800); $matches = array(); if (is_numeric($timeSpan)) { return $timeSpan; } if (preg_match('/^((\d+)?(\.\d+)?)('.implode('|', array_keys($times)).')$/', $timeSpan, $matches)) { return floatval($matches[1]) * $times[$matches[4]]; } return null; }
[ "public", "static", "function", "parseTime", "(", "$", "timeSpan", ")", "{", "$", "times", "=", "array", "(", "'s'", "=>", "1", ",", "'m'", "=>", "60", ",", "'h'", "=>", "3600", ",", "'d'", "=>", "86400", ",", "'w'", "=>", "604800", ")", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "is_numeric", "(", "$", "timeSpan", ")", ")", "{", "return", "$", "timeSpan", ";", "}", "if", "(", "preg_match", "(", "'/^((\\d+)?(\\.\\d+)?)('", ".", "implode", "(", "'|'", ",", "array_keys", "(", "$", "times", ")", ")", ".", "')$/'", ",", "$", "timeSpan", ",", "$", "matches", ")", ")", "{", "return", "floatval", "(", "$", "matches", "[", "1", "]", ")", "*", "$", "times", "[", "$", "matches", "[", "4", "]", "]", ";", "}", "return", "null", ";", "}" ]
Parses a timespan string such as "10s", "5m" or "1h" and returns the amount of seconds. @param string $timeSpan the time span to parse to seconds @return float|null the number of seconds or null, if $timeSpan couldn't be parsed
[ "Parses", "a", "timespan", "string", "such", "as", "10s", "5m", "or", "1h", "and", "returns", "the", "amount", "of", "seconds", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Throttling/LeakyBucketStrategy.php#L114-L126
226,793
beheh/flaps
src/Flaps/Throttling/LeakyBucketStrategy.php
LeakyBucketStrategy.isViolator
public function isViolator($identifier) { if ($this->storage === null) { throw new LogicException('no storage set'); } $time = microtime(true); $timestamp = $time; $rate = (float) $this->requestsPerTimeSpan / $this->timeSpan; $identifier = 'leaky:'.sha1($rate.$identifier); $requestCount = $this->storage->getValue($identifier); if ($requestCount > 0) { $secondsSince = $time - $this->storage->getTimestamp($identifier); $reduceBy = floor($secondsSince * $rate); $unfinishedSeconds = fmod($secondsSince, $rate); $requestCount = max($requestCount - $reduceBy, 0); if ($requestCount > 0) { $timestamp = $time - ($rate - $unfinishedSeconds); } } if ($requestCount + 1 > $this->requestsPerTimeSpan) { return true; } $requestCount++; $this->storage->setValue($identifier, $requestCount); $this->storage->setTimestamp($identifier, $timestamp); $this->storage->expireIn($identifier, $requestCount / $rate); return false; }
php
public function isViolator($identifier) { if ($this->storage === null) { throw new LogicException('no storage set'); } $time = microtime(true); $timestamp = $time; $rate = (float) $this->requestsPerTimeSpan / $this->timeSpan; $identifier = 'leaky:'.sha1($rate.$identifier); $requestCount = $this->storage->getValue($identifier); if ($requestCount > 0) { $secondsSince = $time - $this->storage->getTimestamp($identifier); $reduceBy = floor($secondsSince * $rate); $unfinishedSeconds = fmod($secondsSince, $rate); $requestCount = max($requestCount - $reduceBy, 0); if ($requestCount > 0) { $timestamp = $time - ($rate - $unfinishedSeconds); } } if ($requestCount + 1 > $this->requestsPerTimeSpan) { return true; } $requestCount++; $this->storage->setValue($identifier, $requestCount); $this->storage->setTimestamp($identifier, $timestamp); $this->storage->expireIn($identifier, $requestCount / $rate); return false; }
[ "public", "function", "isViolator", "(", "$", "identifier", ")", "{", "if", "(", "$", "this", "->", "storage", "===", "null", ")", "{", "throw", "new", "LogicException", "(", "'no storage set'", ")", ";", "}", "$", "time", "=", "microtime", "(", "true", ")", ";", "$", "timestamp", "=", "$", "time", ";", "$", "rate", "=", "(", "float", ")", "$", "this", "->", "requestsPerTimeSpan", "/", "$", "this", "->", "timeSpan", ";", "$", "identifier", "=", "'leaky:'", ".", "sha1", "(", "$", "rate", ".", "$", "identifier", ")", ";", "$", "requestCount", "=", "$", "this", "->", "storage", "->", "getValue", "(", "$", "identifier", ")", ";", "if", "(", "$", "requestCount", ">", "0", ")", "{", "$", "secondsSince", "=", "$", "time", "-", "$", "this", "->", "storage", "->", "getTimestamp", "(", "$", "identifier", ")", ";", "$", "reduceBy", "=", "floor", "(", "$", "secondsSince", "*", "$", "rate", ")", ";", "$", "unfinishedSeconds", "=", "fmod", "(", "$", "secondsSince", ",", "$", "rate", ")", ";", "$", "requestCount", "=", "max", "(", "$", "requestCount", "-", "$", "reduceBy", ",", "0", ")", ";", "if", "(", "$", "requestCount", ">", "0", ")", "{", "$", "timestamp", "=", "$", "time", "-", "(", "$", "rate", "-", "$", "unfinishedSeconds", ")", ";", "}", "}", "if", "(", "$", "requestCount", "+", "1", ">", "$", "this", "->", "requestsPerTimeSpan", ")", "{", "return", "true", ";", "}", "$", "requestCount", "++", ";", "$", "this", "->", "storage", "->", "setValue", "(", "$", "identifier", ",", "$", "requestCount", ")", ";", "$", "this", "->", "storage", "->", "setTimestamp", "(", "$", "identifier", ",", "$", "timestamp", ")", ";", "$", "this", "->", "storage", "->", "expireIn", "(", "$", "identifier", ",", "$", "requestCount", "/", "$", "rate", ")", ";", "return", "false", ";", "}" ]
Returns whether entity exceeds it's allowed request capacity with this request. @param string $identifier the identifer of the entity to check @return bool true if this requests exceeds the number of requests allowed @throws LogicException if no storage has been set
[ "Returns", "whether", "entity", "exceeds", "it", "s", "allowed", "request", "capacity", "with", "this", "request", "." ]
327110f6c97a3a3e90bd39c47ebb9e2f02db9d61
https://github.com/beheh/flaps/blob/327110f6c97a3a3e90bd39c47ebb9e2f02db9d61/src/Flaps/Throttling/LeakyBucketStrategy.php#L134-L169
226,794
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.principalInfo
public function principalInfo($principal_id) { $response = $this->call('principal-info', array( 'principal-id' => $principal_id, )); return array( 'contact' => current($response->xpath('/results/contact')), 'manager' => current($response->xpath('/results/manager')), 'preferences' => current($response->xpath('/results/preferences')), 'principal' => current($response->xpath('/results/principal')), ); }
php
public function principalInfo($principal_id) { $response = $this->call('principal-info', array( 'principal-id' => $principal_id, )); return array( 'contact' => current($response->xpath('/results/contact')), 'manager' => current($response->xpath('/results/manager')), 'preferences' => current($response->xpath('/results/preferences')), 'principal' => current($response->xpath('/results/principal')), ); }
[ "public", "function", "principalInfo", "(", "$", "principal_id", ")", "{", "$", "response", "=", "$", "this", "->", "call", "(", "'principal-info'", ",", "array", "(", "'principal-id'", "=>", "$", "principal_id", ",", ")", ")", ";", "return", "array", "(", "'contact'", "=>", "current", "(", "$", "response", "->", "xpath", "(", "'/results/contact'", ")", ")", ",", "'manager'", "=>", "current", "(", "$", "response", "->", "xpath", "(", "'/results/manager'", ")", ")", ",", "'preferences'", "=>", "current", "(", "$", "response", "->", "xpath", "(", "'/results/preferences'", ")", ")", ",", "'principal'", "=>", "current", "(", "$", "response", "->", "xpath", "(", "'/results/principal'", ")", ")", ",", ")", ";", "}" ]
Provides information about one principal, either a user or a group. @param int $principal_id The ID of a user or group you want information about. You can get the ID by calling principal-list. @return array An array with the principal information. Each element is a \SimpleXMLElement - contact: Information about the contact person for a principal. If the principal is a user, usually the same as information in principal. - manager: Information describing a user's manager, who is also a principal. - preferences: Information about the principal’s preferences. - principal: Information describing the principal.
[ "Provides", "information", "about", "one", "principal", "either", "a", "user", "or", "a", "group", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L164-L176
226,795
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.permissionsUpdate
public function permissionsUpdate($acl_id, $principal_id, $permission_id) { $this->call('permissions-update', array( 'acl-id' => $acl_id, 'principal-id' => $principal_id, 'permission-id' => $permission_id, )); return true; }
php
public function permissionsUpdate($acl_id, $principal_id, $permission_id) { $this->call('permissions-update', array( 'acl-id' => $acl_id, 'principal-id' => $principal_id, 'permission-id' => $permission_id, )); return true; }
[ "public", "function", "permissionsUpdate", "(", "$", "acl_id", ",", "$", "principal_id", ",", "$", "permission_id", ")", "{", "$", "this", "->", "call", "(", "'permissions-update'", ",", "array", "(", "'acl-id'", "=>", "$", "acl_id", ",", "'principal-id'", "=>", "$", "principal_id", ",", "'permission-id'", "=>", "$", "permission_id", ",", ")", ")", ";", "return", "true", ";", "}" ]
Updates the permissions a principal has to access a SCO, using a trio of principal-id, acl-id, and permission-id. @TODO: To update permissions for multiple principals or objects, specify multiple trios. You can update more than 200 permissions in a single call to permissions-update. Call permissions-update to give a user access to a Adobe Connect meeting, course, curriculum, or other SCO. For example, you can use permissions-update to: - Invite a user to a meeting as participant, presenter, or host (with a permission-id of view, mini-host, or host, respectively) - Remove a user's participant, presenter, or host access to a meeting (with a permission-id of remove) - Enroll users in courses (with a permission-id of view) If you use multiple trios and any of them have invalid information (for example, an incorrect acl-id or principal-id), permissions-update returns an ok status, the correct trios execute, and the invalid ones do not. @param int $acl_id The ID of a SCO (a sco-id) for which you want to update permissions. @param int $principal_id The ID of a principal, either a user or group. @param string $permission_id The permission to assign. (See \AdobeConnect\Permission) @return bool
[ "Updates", "the", "permissions", "a", "principal", "has", "to", "access", "a", "SCO", "using", "a", "trio", "of", "principal", "-", "id", "acl", "-", "id", "and", "permission", "-", "id", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L264-L273
226,796
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.meetingFeatureUpdate
public function meetingFeatureUpdate($account_id, $feature_id, $enable) { $response = $this->call('meeting-feature-update', array( 'account-id' => $account_id, 'feature-id' => $feature_id, 'enable' => $enable )); return true; }
php
public function meetingFeatureUpdate($account_id, $feature_id, $enable) { $response = $this->call('meeting-feature-update', array( 'account-id' => $account_id, 'feature-id' => $feature_id, 'enable' => $enable )); return true; }
[ "public", "function", "meetingFeatureUpdate", "(", "$", "account_id", ",", "$", "feature_id", ",", "$", "enable", ")", "{", "$", "response", "=", "$", "this", "->", "call", "(", "'meeting-feature-update'", ",", "array", "(", "'account-id'", "=>", "$", "account_id", ",", "'feature-id'", "=>", "$", "feature_id", ",", "'enable'", "=>", "$", "enable", ")", ")", ";", "return", "true", ";", "}" ]
Enables or disables features in a meeting. This action is used to manage features such as recording of meetings and control of pods. For more information on usage, see Configure compliance settings. @param string $account_id The ID of your Adobe Connect hosted account. For enterprise installations, the ID is 7. For licensed installations, use common-info to get the ID. @param string $feature_id The ID of the feature to enable or disable. @param bool $enable Whether to enable the specified feature (true) or not (false). @return bool
[ "Enables", "or", "disables", "features", "in", "a", "meeting", ".", "This", "action", "is", "used", "to", "manage", "features", "such", "as", "recording", "of", "meetings", "and", "control", "of", "pods", ".", "For", "more", "information", "on", "usage", "see", "Configure", "compliance", "settings", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L290-L299
226,797
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.reportMeetingAttendance
public function reportMeetingAttendance($sco_id, $filters = array()) { $response = $this->call('report-meeting-attendance', array_merge( array('sco-id' => $sco_id,), $filters )); return $response->xpath('/results/report-meeting-attendance/row'); }
php
public function reportMeetingAttendance($sco_id, $filters = array()) { $response = $this->call('report-meeting-attendance', array_merge( array('sco-id' => $sco_id,), $filters )); return $response->xpath('/results/report-meeting-attendance/row'); }
[ "public", "function", "reportMeetingAttendance", "(", "$", "sco_id", ",", "$", "filters", "=", "array", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "call", "(", "'report-meeting-attendance'", ",", "array_merge", "(", "array", "(", "'sco-id'", "=>", "$", "sco_id", ",", ")", ",", "$", "filters", ")", ")", ";", "return", "$", "response", "->", "xpath", "(", "'/results/report-meeting-attendance/row'", ")", ";", "}" ]
Returns a list of users who attended a Adobe Connect meeting. The data is returned in row elements, one for each person who attended. If the meeting hasn't started or had no attendees, the response contains no rows. The response does not include meeting hosts or users who were invited but did not attend. @param int $sco_id The sco-id of a meeting @param array $filters A filter to reduce the volume of the response. @return array An array with the list of users who attended a AdobeConnect meeting. Each element is a \SimpleXMLElement object.
[ "Returns", "a", "list", "of", "users", "who", "attended", "a", "Adobe", "Connect", "meeting", ".", "The", "data", "is", "returned", "in", "row", "elements", "one", "for", "each", "person", "who", "attended", ".", "If", "the", "meeting", "hasn", "t", "started", "or", "had", "no", "attendees", "the", "response", "contains", "no", "rows", ".", "The", "response", "does", "not", "include", "meeting", "hosts", "or", "users", "who", "were", "invited", "but", "did", "not", "attend", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L326-L334
226,798
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.reportMeetingSessions
public function reportMeetingSessions($sco_id, array $filters = array()) { $response = $this->call('report-meeting-sessions', array_merge( array('sco-id' => $sco_id,), $filters )); return $response->xpath('/results/report-meeting-sessions/row'); }
php
public function reportMeetingSessions($sco_id, array $filters = array()) { $response = $this->call('report-meeting-sessions', array_merge( array('sco-id' => $sco_id,), $filters )); return $response->xpath('/results/report-meeting-sessions/row'); }
[ "public", "function", "reportMeetingSessions", "(", "$", "sco_id", ",", "array", "$", "filters", "=", "array", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "call", "(", "'report-meeting-sessions'", ",", "array_merge", "(", "array", "(", "'sco-id'", "=>", "$", "sco_id", ",", ")", ",", "$", "filters", ")", ")", ";", "return", "$", "response", "->", "xpath", "(", "'/results/report-meeting-sessions/row'", ")", ";", "}" ]
Provides information about all the sessions of a Adobe Connect meeting. A session is created when a participant enters an empty meeting. As more participants join the meeting, they join the session. The session ends when all attendees leave the meeting. When a new participant enters the now-empty meeting, a new session starts. For example, a recurring weekly meeting has a session each week when the meeting is held. You can call report-meeting-sessions on past meetings, active meetings, or future meetings, but future meetings are not likely to have sessions. @param int $sco_id The ID of a meeting for which you want session information. @param array $filters A filter to reduce the volume of the response. @return array An array with the list of sessions of the meeting. Each element is a \SimpleXMLElement object.
[ "Provides", "information", "about", "all", "the", "sessions", "of", "a", "Adobe", "Connect", "meeting", ".", "A", "session", "is", "created", "when", "a", "participant", "enters", "an", "empty", "meeting", ".", "As", "more", "participants", "join", "the", "meeting", "they", "join", "the", "session", ".", "The", "session", "ends", "when", "all", "attendees", "leave", "the", "meeting", ".", "When", "a", "new", "participant", "enters", "the", "now", "-", "empty", "meeting", "a", "new", "session", "starts", ".", "For", "example", "a", "recurring", "weekly", "meeting", "has", "a", "session", "each", "week", "when", "the", "meeting", "is", "held", ".", "You", "can", "call", "report", "-", "meeting", "-", "sessions", "on", "past", "meetings", "active", "meetings", "or", "future", "meetings", "but", "future", "meetings", "are", "not", "likely", "to", "have", "sessions", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L370-L378
226,799
platforg/adobe-connect
src/AdobeConnect/ApiClient.php
ApiClient.scoContents
public function scoContents($sco_id, array $filters = array()) { $response = $this->call('sco-contents', array_merge(array( 'sco-id' => $sco_id, ), $filters)); return $response->xpath('/results/scos/sco'); }
php
public function scoContents($sco_id, array $filters = array()) { $response = $this->call('sco-contents', array_merge(array( 'sco-id' => $sco_id, ), $filters)); return $response->xpath('/results/scos/sco'); }
[ "public", "function", "scoContents", "(", "$", "sco_id", ",", "array", "$", "filters", "=", "array", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "call", "(", "'sco-contents'", ",", "array_merge", "(", "array", "(", "'sco-id'", "=>", "$", "sco_id", ",", ")", ",", "$", "filters", ")", ")", ";", "return", "$", "response", "->", "xpath", "(", "'/results/scos/sco'", ")", ";", "}" ]
Returns a list of SCOs within another SCO. The enclosing SCO can be a folder, meeting, or curriculum. @param int $sco_id The unique ID of a folder for which you want to list contents. You can get the sco-id by calling sco-shortcuts. @param array $filters A filter to reduce the volume of the response. @return array An array with a list of SCOs within another SCO. Each element is a \SimpleXMLElement object.
[ "Returns", "a", "list", "of", "SCOs", "within", "another", "SCO", ".", "The", "enclosing", "SCO", "can", "be", "a", "folder", "meeting", "or", "curriculum", "." ]
70f47a00e282ebc3b6491a2ec0e68a770dbfa549
https://github.com/platforg/adobe-connect/blob/70f47a00e282ebc3b6491a2ec0e68a770dbfa549/src/AdobeConnect/ApiClient.php#L479-L486