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
13,900
LightboxDigital/wp-dynamic-image-resizer
public/class-dynamic-image-resizer-public.php
Dynamic_Image_Resizer_Public.get_sizes
public function get_sizes( $size = '' ) { global $_wp_additional_image_sizes; $sizes = array(); $get_intermediate_image_sizes = get_intermediate_image_sizes(); // Create the full array with sizes and crop info. foreach ( $get_intermediate_image_sizes as $_size ) { if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) { $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' ); $sizes[ $_size ]['height'] = get_option( $_size . '_size_h' ); $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' ); } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { $sizes[ $_size ] = array( 'width' => $_wp_additional_image_sizes[ $_size ]['width'], 'height' => $_wp_additional_image_sizes[ $_size ]['height'], 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], ); } } // If $size argument is supplied, just return that size. if ( $size ) { if ( isset( $sizes[ $size ] ) ) { return $sizes[ $size ]; } else { return false; } } return $sizes; }
php
public function get_sizes( $size = '' ) { global $_wp_additional_image_sizes; $sizes = array(); $get_intermediate_image_sizes = get_intermediate_image_sizes(); // Create the full array with sizes and crop info. foreach ( $get_intermediate_image_sizes as $_size ) { if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) { $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' ); $sizes[ $_size ]['height'] = get_option( $_size . '_size_h' ); $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' ); } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { $sizes[ $_size ] = array( 'width' => $_wp_additional_image_sizes[ $_size ]['width'], 'height' => $_wp_additional_image_sizes[ $_size ]['height'], 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], ); } } // If $size argument is supplied, just return that size. if ( $size ) { if ( isset( $sizes[ $size ] ) ) { return $sizes[ $size ]; } else { return false; } } return $sizes; }
[ "public", "function", "get_sizes", "(", "$", "size", "=", "''", ")", "{", "global", "$", "_wp_additional_image_sizes", ";", "$", "sizes", "=", "array", "(", ")", ";", "$", "get_intermediate_image_sizes", "=", "get_intermediate_image_sizes", "(", ")", ";", "// Create the full array with sizes and crop info.", "foreach", "(", "$", "get_intermediate_image_sizes", "as", "$", "_size", ")", "{", "if", "(", "in_array", "(", "$", "_size", ",", "array", "(", "'thumbnail'", ",", "'medium'", ",", "'large'", ")", ")", ")", "{", "$", "sizes", "[", "$", "_size", "]", "[", "'width'", "]", "=", "get_option", "(", "$", "_size", ".", "'_size_w'", ")", ";", "$", "sizes", "[", "$", "_size", "]", "[", "'height'", "]", "=", "get_option", "(", "$", "_size", ".", "'_size_h'", ")", ";", "$", "sizes", "[", "$", "_size", "]", "[", "'crop'", "]", "=", "(", "bool", ")", "get_option", "(", "$", "_size", ".", "'_crop'", ")", ";", "}", "elseif", "(", "isset", "(", "$", "_wp_additional_image_sizes", "[", "$", "_size", "]", ")", ")", "{", "$", "sizes", "[", "$", "_size", "]", "=", "array", "(", "'width'", "=>", "$", "_wp_additional_image_sizes", "[", "$", "_size", "]", "[", "'width'", "]", ",", "'height'", "=>", "$", "_wp_additional_image_sizes", "[", "$", "_size", "]", "[", "'height'", "]", ",", "'crop'", "=>", "$", "_wp_additional_image_sizes", "[", "$", "_size", "]", "[", "'crop'", "]", ",", ")", ";", "}", "}", "// If $size argument is supplied, just return that size.", "if", "(", "$", "size", ")", "{", "if", "(", "isset", "(", "$", "sizes", "[", "$", "size", "]", ")", ")", "{", "return", "$", "sizes", "[", "$", "size", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "$", "sizes", ";", "}" ]
Get all the currently defined named image sizes @since 1.0.0 @param string $size If supplied, only return this size. @return array Image sizes
[ "Get", "all", "the", "currently", "defined", "named", "image", "sizes" ]
cc1d67192c8463eba4c0920130abec933ed2296b
https://github.com/LightboxDigital/wp-dynamic-image-resizer/blob/cc1d67192c8463eba4c0920130abec933ed2296b/public/class-dynamic-image-resizer-public.php#L164-L194
13,901
flagrow/flarum-ext-latex
src/Listeners/AddClientAssets.php
AddClientAssets.addForumAssets
public function addForumAssets(ConfigureClientView $event) { if ($event->isForum()) { $event->addAssets([ __DIR__.'/../../js/forum/dist/extension.js', ]); //Include css and java for KaTeX $event->view->addHeadString('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">'); $event->view->addHeadString('<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>'); $event->view->addHeadString('<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js"></script>'); $event->addBootstrapper('flagrow/latex/main'); } }
php
public function addForumAssets(ConfigureClientView $event) { if ($event->isForum()) { $event->addAssets([ __DIR__.'/../../js/forum/dist/extension.js', ]); //Include css and java for KaTeX $event->view->addHeadString('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">'); $event->view->addHeadString('<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>'); $event->view->addHeadString('<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js"></script>'); $event->addBootstrapper('flagrow/latex/main'); } }
[ "public", "function", "addForumAssets", "(", "ConfigureClientView", "$", "event", ")", "{", "if", "(", "$", "event", "->", "isForum", "(", ")", ")", "{", "$", "event", "->", "addAssets", "(", "[", "__DIR__", ".", "'/../../js/forum/dist/extension.js'", ",", "]", ")", ";", "//Include css and java for KaTeX", "$", "event", "->", "view", "->", "addHeadString", "(", "'<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css\">'", ")", ";", "$", "event", "->", "view", "->", "addHeadString", "(", "'<script src=\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js\"></script>'", ")", ";", "$", "event", "->", "view", "->", "addHeadString", "(", "'<script src=\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js\"></script>'", ")", ";", "$", "event", "->", "addBootstrapper", "(", "'flagrow/latex/main'", ")", ";", "}", "}" ]
Modifies the client view for the Forum. @param ConfigureClientView $event
[ "Modifies", "the", "client", "view", "for", "the", "Forum", "." ]
4db38817d26cb5e3a7e8a0b53f042c61d14af606
https://github.com/flagrow/flarum-ext-latex/blob/4db38817d26cb5e3a7e8a0b53f042c61d14af606/src/Listeners/AddClientAssets.php#L35-L48
13,902
mimmi20/Wurfl
src/Manager.php
Manager.getDeviceForRequest
private function getDeviceForRequest(Request\GenericRequest $request) { Handlers\Utils::reset(); $deviceId = $this->deviceIdForRequest($request); return $this->getWrappedDevice($deviceId, $request); }
php
private function getDeviceForRequest(Request\GenericRequest $request) { Handlers\Utils::reset(); $deviceId = $this->deviceIdForRequest($request); return $this->getWrappedDevice($deviceId, $request); }
[ "private", "function", "getDeviceForRequest", "(", "Request", "\\", "GenericRequest", "$", "request", ")", "{", "Handlers", "\\", "Utils", "::", "reset", "(", ")", ";", "$", "deviceId", "=", "$", "this", "->", "deviceIdForRequest", "(", "$", "request", ")", ";", "return", "$", "this", "->", "getWrappedDevice", "(", "$", "deviceId", ",", "$", "request", ")", ";", "}" ]
Returns the Device for the given \Wurfl\Request_GenericRequest @param Request\GenericRequest $request @return \Wurfl\CustomDevice
[ "Returns", "the", "Device", "for", "the", "given", "\\", "Wurfl", "\\", "Request_GenericRequest" ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Manager.php#L383-L390
13,903
mimmi20/Wurfl
src/Manager.php
Manager.getDevice
public function getDevice($deviceId, Request\GenericRequest $request = null) { if ($request !== null) { if (!($request instanceof GenericRequest)) { throw new \InvalidArgumentException( 'Error: Request parameter must be null or instance of WURFL_Request_GenericRequest' ); } // Normalization must be performed if request is passed so virtual capabilities can be // resolved correctly. This is normally handled in self::deviceIdForRequest() $generic_normalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($generic_normalizer->normalize($request->getUserAgent())); } return $this->getWrappedDevice($deviceId, $request); }
php
public function getDevice($deviceId, Request\GenericRequest $request = null) { if ($request !== null) { if (!($request instanceof GenericRequest)) { throw new \InvalidArgumentException( 'Error: Request parameter must be null or instance of WURFL_Request_GenericRequest' ); } // Normalization must be performed if request is passed so virtual capabilities can be // resolved correctly. This is normally handled in self::deviceIdForRequest() $generic_normalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($generic_normalizer->normalize($request->getUserAgent())); } return $this->getWrappedDevice($deviceId, $request); }
[ "public", "function", "getDevice", "(", "$", "deviceId", ",", "Request", "\\", "GenericRequest", "$", "request", "=", "null", ")", "{", "if", "(", "$", "request", "!==", "null", ")", "{", "if", "(", "!", "(", "$", "request", "instanceof", "GenericRequest", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Error: Request parameter must be null or instance of WURFL_Request_GenericRequest'", ")", ";", "}", "// Normalization must be performed if request is passed so virtual capabilities can be", "// resolved correctly. This is normally handled in self::deviceIdForRequest()", "$", "generic_normalizer", "=", "UserAgentHandlerChainFactory", "::", "createGenericNormalizers", "(", ")", ";", "$", "request", "->", "setUserAgentNormalized", "(", "$", "generic_normalizer", "->", "normalize", "(", "$", "request", "->", "getUserAgent", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "getWrappedDevice", "(", "$", "deviceId", ",", "$", "request", ")", ";", "}" ]
Return a device for the given device id @param string $deviceId @param Request\GenericRequest $request @throws \InvalidArgumentException @return \Wurfl\Device\ModelDeviceInterface
[ "Return", "a", "device", "for", "the", "given", "device", "id" ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Manager.php#L424-L440
13,904
mimmi20/Wurfl
src/Manager.php
Manager.getFallBackDevices
public function getFallBackDevices($deviceId) { $fallBackDevices = $this->getDeviceRepository()->getDeviceHierarchy($deviceId); array_shift($fallBackDevices); return array_map(array($this, 'deviceId'), $fallBackDevices); }
php
public function getFallBackDevices($deviceId) { $fallBackDevices = $this->getDeviceRepository()->getDeviceHierarchy($deviceId); array_shift($fallBackDevices); return array_map(array($this, 'deviceId'), $fallBackDevices); }
[ "public", "function", "getFallBackDevices", "(", "$", "deviceId", ")", "{", "$", "fallBackDevices", "=", "$", "this", "->", "getDeviceRepository", "(", ")", "->", "getDeviceHierarchy", "(", "$", "deviceId", ")", ";", "array_shift", "(", "$", "fallBackDevices", ")", ";", "return", "array_map", "(", "array", "(", "$", "this", ",", "'deviceId'", ")", ",", "$", "fallBackDevices", ")", ";", "}" ]
Returns an array of all the fall back devices starting from the given device @param string $deviceId @return array
[ "Returns", "an", "array", "of", "all", "the", "fall", "back", "devices", "starting", "from", "the", "given", "device" ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Manager.php#L472-L479
13,905
mimmi20/Wurfl
src/Manager.php
Manager.getWrappedDevice
private function getWrappedDevice($deviceId, Request\GenericRequest $request = null) { $modelDevices = $this->getCacheStorage()->load('DEVS_' . $deviceId); if (empty($modelDevices)) { $modelDevices = $this->getDeviceRepository()->getDeviceHierarchy($deviceId); } $this->getCacheStorage()->save('DEVS_' . $deviceId, $modelDevices); if ($request === null) { // If a request was not provided, we generate one from the WURFL entry itself // to help resolve the virtual capabilities $requestFactory = new GenericRequestFactory(); $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent); $genericNormalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($genericNormalizer->normalize($request->getUserAgent())); } // The CustomDevice is not cached since virtual capabilities must be recalculated // for every different request. return new CustomDevice($modelDevices, $request); }
php
private function getWrappedDevice($deviceId, Request\GenericRequest $request = null) { $modelDevices = $this->getCacheStorage()->load('DEVS_' . $deviceId); if (empty($modelDevices)) { $modelDevices = $this->getDeviceRepository()->getDeviceHierarchy($deviceId); } $this->getCacheStorage()->save('DEVS_' . $deviceId, $modelDevices); if ($request === null) { // If a request was not provided, we generate one from the WURFL entry itself // to help resolve the virtual capabilities $requestFactory = new GenericRequestFactory(); $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent); $genericNormalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($genericNormalizer->normalize($request->getUserAgent())); } // The CustomDevice is not cached since virtual capabilities must be recalculated // for every different request. return new CustomDevice($modelDevices, $request); }
[ "private", "function", "getWrappedDevice", "(", "$", "deviceId", ",", "Request", "\\", "GenericRequest", "$", "request", "=", "null", ")", "{", "$", "modelDevices", "=", "$", "this", "->", "getCacheStorage", "(", ")", "->", "load", "(", "'DEVS_'", ".", "$", "deviceId", ")", ";", "if", "(", "empty", "(", "$", "modelDevices", ")", ")", "{", "$", "modelDevices", "=", "$", "this", "->", "getDeviceRepository", "(", ")", "->", "getDeviceHierarchy", "(", "$", "deviceId", ")", ";", "}", "$", "this", "->", "getCacheStorage", "(", ")", "->", "save", "(", "'DEVS_'", ".", "$", "deviceId", ",", "$", "modelDevices", ")", ";", "if", "(", "$", "request", "===", "null", ")", "{", "// If a request was not provided, we generate one from the WURFL entry itself", "// to help resolve the virtual capabilities", "$", "requestFactory", "=", "new", "GenericRequestFactory", "(", ")", ";", "$", "request", "=", "$", "requestFactory", "->", "createRequestForUserAgent", "(", "$", "modelDevices", "[", "0", "]", "->", "userAgent", ")", ";", "$", "genericNormalizer", "=", "UserAgentHandlerChainFactory", "::", "createGenericNormalizers", "(", ")", ";", "$", "request", "->", "setUserAgentNormalized", "(", "$", "genericNormalizer", "->", "normalize", "(", "$", "request", "->", "getUserAgent", "(", ")", ")", ")", ";", "}", "// The CustomDevice is not cached since virtual capabilities must be recalculated", "// for every different request.", "return", "new", "CustomDevice", "(", "$", "modelDevices", ",", "$", "request", ")", ";", "}" ]
Wraps the model device with \Wurfl\Xml\ModelDeviceInterface. This function takes the Device ID and returns the \Wurfl\CustomDevice with all capabilities. @param string $deviceId @param Request\GenericRequest $request @return \Wurfl\CustomDevice
[ "Wraps", "the", "model", "device", "with", "\\", "Wurfl", "\\", "Xml", "\\", "ModelDeviceInterface", ".", "This", "function", "takes", "the", "Device", "ID", "and", "returns", "the", "\\", "Wurfl", "\\", "CustomDevice", "with", "all", "capabilities", "." ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Manager.php#L558-L581
13,906
codezero-be/flash
src/Flash.php
Flash.info
public function info($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'info', $dismissible); return $this; }
php
public function info($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'info', $dismissible); return $this; }
[ "public", "function", "info", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ",", "$", "dismissible", "=", "true", ")", "{", "$", "this", "->", "message", "(", "$", "message", ",", "null", ",", "$", "placeholders", ",", "'info'", ",", "$", "dismissible", ")", ";", "return", "$", "this", ";", "}" ]
Flash an info message. @param string $message @param array $placeholders @param bool $dismissible @return $this
[ "Flash", "an", "info", "message", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L64-L69
13,907
codezero-be/flash
src/Flash.php
Flash.success
public function success($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'success', $dismissible); return $this; }
php
public function success($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'success', $dismissible); return $this; }
[ "public", "function", "success", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ",", "$", "dismissible", "=", "true", ")", "{", "$", "this", "->", "message", "(", "$", "message", ",", "null", ",", "$", "placeholders", ",", "'success'", ",", "$", "dismissible", ")", ";", "return", "$", "this", ";", "}" ]
Flash a success message. @param string $message @param array $placeholders @param bool $dismissible @return $this
[ "Flash", "a", "success", "message", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L80-L85
13,908
codezero-be/flash
src/Flash.php
Flash.warning
public function warning($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'warning', $dismissible); return $this; }
php
public function warning($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'warning', $dismissible); return $this; }
[ "public", "function", "warning", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ",", "$", "dismissible", "=", "true", ")", "{", "$", "this", "->", "message", "(", "$", "message", ",", "null", ",", "$", "placeholders", ",", "'warning'", ",", "$", "dismissible", ")", ";", "return", "$", "this", ";", "}" ]
Flash a warning message. @param string $message @param array $placeholders @param bool $dismissible @return $this
[ "Flash", "a", "warning", "message", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L96-L101
13,909
codezero-be/flash
src/Flash.php
Flash.error
public function error($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'error', $dismissible); return $this; }
php
public function error($message, array $placeholders = [], $dismissible = true) { $this->message($message, null, $placeholders, 'error', $dismissible); return $this; }
[ "public", "function", "error", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ",", "$", "dismissible", "=", "true", ")", "{", "$", "this", "->", "message", "(", "$", "message", ",", "null", ",", "$", "placeholders", ",", "'error'", ",", "$", "dismissible", ")", ";", "return", "$", "this", ";", "}" ]
Flash an error message. @param string $message @param array $placeholders @param bool $dismissible @return $this
[ "Flash", "an", "error", "message", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L112-L117
13,910
codezero-be/flash
src/Flash.php
Flash.getExistingFlashMessages
private function getExistingFlashMessages() { return $this->session->has($this->sessionKey) ? $this->session->get($this->sessionKey) : []; }
php
private function getExistingFlashMessages() { return $this->session->has($this->sessionKey) ? $this->session->get($this->sessionKey) : []; }
[ "private", "function", "getExistingFlashMessages", "(", ")", "{", "return", "$", "this", "->", "session", "->", "has", "(", "$", "this", "->", "sessionKey", ")", "?", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "sessionKey", ")", ":", "[", "]", ";", "}" ]
Get messages that have already been flashed. @return array
[ "Get", "messages", "that", "have", "already", "been", "flashed", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L183-L188
13,911
codezero-be/flash
src/Flash.php
Flash.getTranslation
private function getTranslation($message, array $placeholders) { if ($this->translator->has($message)) { $message = $this->translator->get($message, $placeholders); } return $message; }
php
private function getTranslation($message, array $placeholders) { if ($this->translator->has($message)) { $message = $this->translator->get($message, $placeholders); } return $message; }
[ "private", "function", "getTranslation", "(", "$", "message", ",", "array", "$", "placeholders", ")", "{", "if", "(", "$", "this", "->", "translator", "->", "has", "(", "$", "message", ")", ")", "{", "$", "message", "=", "$", "this", "->", "translator", "->", "get", "(", "$", "message", ",", "$", "placeholders", ")", ";", "}", "return", "$", "message", ";", "}" ]
Get a translation for the message key or return the original message. @param string $message @param array $placeholders @return string
[ "Get", "a", "translation", "for", "the", "message", "key", "or", "return", "the", "original", "message", "." ]
ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0
https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/Flash.php#L199-L206
13,912
delatbabel/site-config
src/Models/Website.php
Website.currentServerName
public static function currentServerName() { if (! empty(env('SERVER_NAME'))) { $BASE_URL = env('SERVER_NAME'); } elseif (! empty($_SERVER['SERVER_NAME'])) { $BASE_URL = $_SERVER['SERVER_NAME']; } elseif (! empty($_SERVER['HTTP_HOST'])) { $BASE_URL = $_SERVER['HTTP_HOST']; } else { $BASE_URL = 'empty'; } return $BASE_URL; }
php
public static function currentServerName() { if (! empty(env('SERVER_NAME'))) { $BASE_URL = env('SERVER_NAME'); } elseif (! empty($_SERVER['SERVER_NAME'])) { $BASE_URL = $_SERVER['SERVER_NAME']; } elseif (! empty($_SERVER['HTTP_HOST'])) { $BASE_URL = $_SERVER['HTTP_HOST']; } else { $BASE_URL = 'empty'; } return $BASE_URL; }
[ "public", "static", "function", "currentServerName", "(", ")", "{", "if", "(", "!", "empty", "(", "env", "(", "'SERVER_NAME'", ")", ")", ")", "{", "$", "BASE_URL", "=", "env", "(", "'SERVER_NAME'", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ")", "{", "$", "BASE_URL", "=", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ")", "{", "$", "BASE_URL", "=", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ";", "}", "else", "{", "$", "BASE_URL", "=", "'empty'", ";", "}", "return", "$", "BASE_URL", ";", "}" ]
Determine the current website server name. This doesn't contain any URL identifiers such as 'http://', just the host name (e.g. www.myserver.com). @return string
[ "Determine", "the", "current", "website", "server", "name", "." ]
e547e63f5ea7140036bb3fe46ff47143b4f93d0f
https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Website.php#L49-L61
13,913
delatbabel/site-config
src/Models/Website.php
Website.currentWebsiteData
public static function currentWebsiteData() { static $current_data; $BASE_URL = static::currentServerName(); $cache_key = 'website-data.' . $BASE_URL; // Get the current ID from the cache if it is present. if (empty($current_data)) { if (Cache::has($cache_key)) { return Cache::get($cache_key); } } // If the cache doesn't have it then get it from the database. if (empty($current_data)) { // Have to do this using a raw query because Laravel doesn't INSTR. try { /** @var Website $result */ $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0") ->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc') ->first(); if (empty($result)) { $current_data = null; } else { $current_data = $result->toArray(); } Cache::put($cache_key, $current_data, 60); } catch (\Exception $e) { $current_data = null; } } return $current_data; }
php
public static function currentWebsiteData() { static $current_data; $BASE_URL = static::currentServerName(); $cache_key = 'website-data.' . $BASE_URL; // Get the current ID from the cache if it is present. if (empty($current_data)) { if (Cache::has($cache_key)) { return Cache::get($cache_key); } } // If the cache doesn't have it then get it from the database. if (empty($current_data)) { // Have to do this using a raw query because Laravel doesn't INSTR. try { /** @var Website $result */ $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0") ->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc') ->first(); if (empty($result)) { $current_data = null; } else { $current_data = $result->toArray(); } Cache::put($cache_key, $current_data, 60); } catch (\Exception $e) { $current_data = null; } } return $current_data; }
[ "public", "static", "function", "currentWebsiteData", "(", ")", "{", "static", "$", "current_data", ";", "$", "BASE_URL", "=", "static", "::", "currentServerName", "(", ")", ";", "$", "cache_key", "=", "'website-data.'", ".", "$", "BASE_URL", ";", "// Get the current ID from the cache if it is present.", "if", "(", "empty", "(", "$", "current_data", ")", ")", "{", "if", "(", "Cache", "::", "has", "(", "$", "cache_key", ")", ")", "{", "return", "Cache", "::", "get", "(", "$", "cache_key", ")", ";", "}", "}", "// If the cache doesn't have it then get it from the database.", "if", "(", "empty", "(", "$", "current_data", ")", ")", "{", "// Have to do this using a raw query because Laravel doesn't INSTR.", "try", "{", "/** @var Website $result */", "$", "result", "=", "static", "::", "whereRaw", "(", "\"INSTR('\"", ".", "$", "BASE_URL", ".", "\"', `http_host`) > 0\"", ")", "->", "orderBy", "(", "DB", "::", "raw", "(", "'LENGTH(`http_host`)'", ")", ",", "'desc'", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "current_data", "=", "null", ";", "}", "else", "{", "$", "current_data", "=", "$", "result", "->", "toArray", "(", ")", ";", "}", "Cache", "::", "put", "(", "$", "cache_key", ",", "$", "current_data", ",", "60", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "current_data", "=", "null", ";", "}", "}", "return", "$", "current_data", ";", "}" ]
Determine the current website data. Returns null if the web site is not found in the websites table. @return array
[ "Determine", "the", "current", "website", "data", "." ]
e547e63f5ea7140036bb3fe46ff47143b4f93d0f
https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Models/Website.php#L70-L105
13,914
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.__before
protected function __before(ServerRequestInterface $request, array $arguments) { $type_id_variable = $this->getTypeIdVariable(); if (array_key_exists($type_id_variable, $arguments)) { $this->active_object = empty($arguments[$type_id_variable]) ? null : $this->pool->getById($this->getTypeClassName(), $arguments[$type_id_variable]); if (empty($this->active_object)) { return new NotFoundStatusResponse(); } } return null; }
php
protected function __before(ServerRequestInterface $request, array $arguments) { $type_id_variable = $this->getTypeIdVariable(); if (array_key_exists($type_id_variable, $arguments)) { $this->active_object = empty($arguments[$type_id_variable]) ? null : $this->pool->getById($this->getTypeClassName(), $arguments[$type_id_variable]); if (empty($this->active_object)) { return new NotFoundStatusResponse(); } } return null; }
[ "protected", "function", "__before", "(", "ServerRequestInterface", "$", "request", ",", "array", "$", "arguments", ")", "{", "$", "type_id_variable", "=", "$", "this", "->", "getTypeIdVariable", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "type_id_variable", ",", "$", "arguments", ")", ")", "{", "$", "this", "->", "active_object", "=", "empty", "(", "$", "arguments", "[", "$", "type_id_variable", "]", ")", "?", "null", ":", "$", "this", "->", "pool", "->", "getById", "(", "$", "this", "->", "getTypeClassName", "(", ")", ",", "$", "arguments", "[", "$", "type_id_variable", "]", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "active_object", ")", ")", "{", "return", "new", "NotFoundStatusResponse", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Run before every action. @param ServerRequestInterface $request @param array $arguments @return void|StatusResponse
[ "Run", "before", "every", "action", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L50-L63
13,915
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.index
public function index(ServerRequestInterface $request) { if ($this->shouldCheckPermissions()) { $authenticated_user = $this->getAuthenticatedUser($request); if (!$this->canList($authenticated_user)) { return new ForbiddenStatusResponse(); } } $collection_class = $this->getCollectionClassName(); /** @var CollectionInterface $collection */ $collection = $this->$collection_class; if ($collection instanceof CollectionInterface) { if ($collection->isPaginated()) { return $collection->currentPage($this->getPageFromQueryParams($request->getQueryParams())); } else { return $collection; } } else { throw new CollectionNotFoundException(get_class($this), __FUNCTION__, $collection_class); } }
php
public function index(ServerRequestInterface $request) { if ($this->shouldCheckPermissions()) { $authenticated_user = $this->getAuthenticatedUser($request); if (!$this->canList($authenticated_user)) { return new ForbiddenStatusResponse(); } } $collection_class = $this->getCollectionClassName(); /** @var CollectionInterface $collection */ $collection = $this->$collection_class; if ($collection instanceof CollectionInterface) { if ($collection->isPaginated()) { return $collection->currentPage($this->getPageFromQueryParams($request->getQueryParams())); } else { return $collection; } } else { throw new CollectionNotFoundException(get_class($this), __FUNCTION__, $collection_class); } }
[ "public", "function", "index", "(", "ServerRequestInterface", "$", "request", ")", "{", "if", "(", "$", "this", "->", "shouldCheckPermissions", "(", ")", ")", "{", "$", "authenticated_user", "=", "$", "this", "->", "getAuthenticatedUser", "(", "$", "request", ")", ";", "if", "(", "!", "$", "this", "->", "canList", "(", "$", "authenticated_user", ")", ")", "{", "return", "new", "ForbiddenStatusResponse", "(", ")", ";", "}", "}", "$", "collection_class", "=", "$", "this", "->", "getCollectionClassName", "(", ")", ";", "/** @var CollectionInterface $collection */", "$", "collection", "=", "$", "this", "->", "$", "collection_class", ";", "if", "(", "$", "collection", "instanceof", "CollectionInterface", ")", "{", "if", "(", "$", "collection", "->", "isPaginated", "(", ")", ")", "{", "return", "$", "collection", "->", "currentPage", "(", "$", "this", "->", "getPageFromQueryParams", "(", "$", "request", "->", "getQueryParams", "(", ")", ")", ")", ";", "}", "else", "{", "return", "$", "collection", ";", "}", "}", "else", "{", "throw", "new", "CollectionNotFoundException", "(", "get_class", "(", "$", "this", ")", ",", "__FUNCTION__", ",", "$", "collection_class", ")", ";", "}", "}" ]
Return a collection of type instances. @param ServerRequestInterface $request @return CollectionInterface
[ "Return", "a", "collection", "of", "type", "instances", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L71-L95
13,916
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.edit
public function edit(ServerRequestInterface $request) { if ($this->isReadOnly()) { return new NotFoundStatusResponse(); } if ($this->active_object && $this->active_object->isLoaded()) { $authenticated_user = $this->getAuthenticatedUser($request); if ($this->shouldCheckPermissions() && !$this->canEdit($this->active_object, $authenticated_user)) { return new ForbiddenStatusResponse(); } $request_body = $request->getParsedBody(); if (empty($request_body)) { $request_body = []; } if ($this->requestBodyContainsProtectedFields($this->active_object, $request_body)) { return new BadRequestStatusResponse(); } $this->cleanUpRequestBodyForEdit($request_body, $authenticated_user); try { return $this->pool->modify($this->active_object, $request_body); } catch (ValidationException $e) { return $e; } } else { return new NotFoundStatusResponse(); } }
php
public function edit(ServerRequestInterface $request) { if ($this->isReadOnly()) { return new NotFoundStatusResponse(); } if ($this->active_object && $this->active_object->isLoaded()) { $authenticated_user = $this->getAuthenticatedUser($request); if ($this->shouldCheckPermissions() && !$this->canEdit($this->active_object, $authenticated_user)) { return new ForbiddenStatusResponse(); } $request_body = $request->getParsedBody(); if (empty($request_body)) { $request_body = []; } if ($this->requestBodyContainsProtectedFields($this->active_object, $request_body)) { return new BadRequestStatusResponse(); } $this->cleanUpRequestBodyForEdit($request_body, $authenticated_user); try { return $this->pool->modify($this->active_object, $request_body); } catch (ValidationException $e) { return $e; } } else { return new NotFoundStatusResponse(); } }
[ "public", "function", "edit", "(", "ServerRequestInterface", "$", "request", ")", "{", "if", "(", "$", "this", "->", "isReadOnly", "(", ")", ")", "{", "return", "new", "NotFoundStatusResponse", "(", ")", ";", "}", "if", "(", "$", "this", "->", "active_object", "&&", "$", "this", "->", "active_object", "->", "isLoaded", "(", ")", ")", "{", "$", "authenticated_user", "=", "$", "this", "->", "getAuthenticatedUser", "(", "$", "request", ")", ";", "if", "(", "$", "this", "->", "shouldCheckPermissions", "(", ")", "&&", "!", "$", "this", "->", "canEdit", "(", "$", "this", "->", "active_object", ",", "$", "authenticated_user", ")", ")", "{", "return", "new", "ForbiddenStatusResponse", "(", ")", ";", "}", "$", "request_body", "=", "$", "request", "->", "getParsedBody", "(", ")", ";", "if", "(", "empty", "(", "$", "request_body", ")", ")", "{", "$", "request_body", "=", "[", "]", ";", "}", "if", "(", "$", "this", "->", "requestBodyContainsProtectedFields", "(", "$", "this", "->", "active_object", ",", "$", "request_body", ")", ")", "{", "return", "new", "BadRequestStatusResponse", "(", ")", ";", "}", "$", "this", "->", "cleanUpRequestBodyForEdit", "(", "$", "request_body", ",", "$", "authenticated_user", ")", ";", "try", "{", "return", "$", "this", "->", "pool", "->", "modify", "(", "$", "this", "->", "active_object", ",", "$", "request_body", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "$", "e", ";", "}", "}", "else", "{", "return", "new", "NotFoundStatusResponse", "(", ")", ";", "}", "}" ]
Update an existing type instance. @param ServerRequestInterface $request @return EntityInterface
[ "Update", "an", "existing", "type", "instance", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L170-L203
13,917
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.delete
public function delete(ServerRequestInterface $request) { if ($this->isReadOnly()) { return new NotFoundStatusResponse(); } if ($this->active_object && $this->active_object->isLoaded()) { $authenticated_user = $this->getAuthenticatedUser($request); if ($this->shouldCheckPermissions() && !$this->canDelete($this->active_object, $authenticated_user)) { return new ForbiddenStatusResponse(); } $this->active_object = $this->pool->scrap($this->active_object); if ($this->active_object->isNew()) { return [ 'single' => ['id' => $this->active_object->getId()], ]; } else { return $this->active_object; } } else { return new NotFoundStatusResponse(); } }
php
public function delete(ServerRequestInterface $request) { if ($this->isReadOnly()) { return new NotFoundStatusResponse(); } if ($this->active_object && $this->active_object->isLoaded()) { $authenticated_user = $this->getAuthenticatedUser($request); if ($this->shouldCheckPermissions() && !$this->canDelete($this->active_object, $authenticated_user)) { return new ForbiddenStatusResponse(); } $this->active_object = $this->pool->scrap($this->active_object); if ($this->active_object->isNew()) { return [ 'single' => ['id' => $this->active_object->getId()], ]; } else { return $this->active_object; } } else { return new NotFoundStatusResponse(); } }
[ "public", "function", "delete", "(", "ServerRequestInterface", "$", "request", ")", "{", "if", "(", "$", "this", "->", "isReadOnly", "(", ")", ")", "{", "return", "new", "NotFoundStatusResponse", "(", ")", ";", "}", "if", "(", "$", "this", "->", "active_object", "&&", "$", "this", "->", "active_object", "->", "isLoaded", "(", ")", ")", "{", "$", "authenticated_user", "=", "$", "this", "->", "getAuthenticatedUser", "(", "$", "request", ")", ";", "if", "(", "$", "this", "->", "shouldCheckPermissions", "(", ")", "&&", "!", "$", "this", "->", "canDelete", "(", "$", "this", "->", "active_object", ",", "$", "authenticated_user", ")", ")", "{", "return", "new", "ForbiddenStatusResponse", "(", ")", ";", "}", "$", "this", "->", "active_object", "=", "$", "this", "->", "pool", "->", "scrap", "(", "$", "this", "->", "active_object", ")", ";", "if", "(", "$", "this", "->", "active_object", "->", "isNew", "(", ")", ")", "{", "return", "[", "'single'", "=>", "[", "'id'", "=>", "$", "this", "->", "active_object", "->", "getId", "(", ")", "]", ",", "]", ";", "}", "else", "{", "return", "$", "this", "->", "active_object", ";", "}", "}", "else", "{", "return", "new", "NotFoundStatusResponse", "(", ")", ";", "}", "}" ]
Drop an existing type instance. @param ServerRequestInterface $request @return EntityInterface|StatusResponse
[ "Drop", "an", "existing", "type", "instance", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L211-L236
13,918
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.getPageFromQueryParams
protected function getPageFromQueryParams(array $query_params) { $page = 1; if (isset($query_params['page'])) { $page = (integer) $query_params['page']; } return $page < 1 ? 1 : $page; }
php
protected function getPageFromQueryParams(array $query_params) { $page = 1; if (isset($query_params['page'])) { $page = (integer) $query_params['page']; } return $page < 1 ? 1 : $page; }
[ "protected", "function", "getPageFromQueryParams", "(", "array", "$", "query_params", ")", "{", "$", "page", "=", "1", ";", "if", "(", "isset", "(", "$", "query_params", "[", "'page'", "]", ")", ")", "{", "$", "page", "=", "(", "integer", ")", "$", "query_params", "[", "'page'", "]", ";", "}", "return", "$", "page", "<", "1", "?", "1", ":", "$", "page", ";", "}" ]
Return page from request query params. @param array $query_params @return int
[ "Return", "page", "from", "request", "query", "params", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L248-L257
13,919
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.getTypeFromRequestBody
protected function getTypeFromRequestBody(array &$request_body) { $type_class = $this->getTypeClassName(); if (isset($request_body['type'])) { $type_class = $request_body['type']; unset($request_body['type']); } if (class_exists($type_class)) { $type_class_reflection = new ReflectionClass($type_class); if ($type_class_reflection->isSubclassOf($this->getTypeClassName()) && !$type_class_reflection->isAbstract()) { return $type_class; } } throw new InvalidArgumentException('Please specify a valid type'); }
php
protected function getTypeFromRequestBody(array &$request_body) { $type_class = $this->getTypeClassName(); if (isset($request_body['type'])) { $type_class = $request_body['type']; unset($request_body['type']); } if (class_exists($type_class)) { $type_class_reflection = new ReflectionClass($type_class); if ($type_class_reflection->isSubclassOf($this->getTypeClassName()) && !$type_class_reflection->isAbstract()) { return $type_class; } } throw new InvalidArgumentException('Please specify a valid type'); }
[ "protected", "function", "getTypeFromRequestBody", "(", "array", "&", "$", "request_body", ")", "{", "$", "type_class", "=", "$", "this", "->", "getTypeClassName", "(", ")", ";", "if", "(", "isset", "(", "$", "request_body", "[", "'type'", "]", ")", ")", "{", "$", "type_class", "=", "$", "request_body", "[", "'type'", "]", ";", "unset", "(", "$", "request_body", "[", "'type'", "]", ")", ";", "}", "if", "(", "class_exists", "(", "$", "type_class", ")", ")", "{", "$", "type_class_reflection", "=", "new", "ReflectionClass", "(", "$", "type_class", ")", ";", "if", "(", "$", "type_class_reflection", "->", "isSubclassOf", "(", "$", "this", "->", "getTypeClassName", "(", ")", ")", "&&", "!", "$", "type_class_reflection", "->", "isAbstract", "(", ")", ")", "{", "return", "$", "type_class", ";", "}", "}", "throw", "new", "InvalidArgumentException", "(", "'Please specify a valid type'", ")", ";", "}" ]
Get a valid type class from request body. @param array $request_body @return string
[ "Get", "a", "valid", "type", "class", "from", "request", "body", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L265-L283
13,920
activecollab/bootstrap
src/Controller/TypeController.php
TypeController.cleanUpRequestBodyForEdit
protected function cleanUpRequestBodyForEdit(array &$request_body, UserInterface $user = null) { $this->cleanUpRequestBody($request_body, $user); if ($this->pool->isTypePolymorph($this->getTypeClassName()) && array_key_exists('type', $request_body)) { unset($request_body['type']); } }
php
protected function cleanUpRequestBodyForEdit(array &$request_body, UserInterface $user = null) { $this->cleanUpRequestBody($request_body, $user); if ($this->pool->isTypePolymorph($this->getTypeClassName()) && array_key_exists('type', $request_body)) { unset($request_body['type']); } }
[ "protected", "function", "cleanUpRequestBodyForEdit", "(", "array", "&", "$", "request_body", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "$", "this", "->", "cleanUpRequestBody", "(", "$", "request_body", ",", "$", "user", ")", ";", "if", "(", "$", "this", "->", "pool", "->", "isTypePolymorph", "(", "$", "this", "->", "getTypeClassName", "(", ")", ")", "&&", "array_key_exists", "(", "'type'", ",", "$", "request_body", ")", ")", "{", "unset", "(", "$", "request_body", "[", "'type'", "]", ")", ";", "}", "}" ]
Perform request data clean-up before reqeust data is being used for edit action. @param array $request_body @param UserInterface|null $user
[ "Perform", "request", "data", "clean", "-", "up", "before", "reqeust", "data", "is", "being", "used", "for", "edit", "action", "." ]
92eea19b2b2b329035f20e855a78f36e74084ccf
https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/Controller/TypeController.php#L330-L337
13,921
ignasbernotas/console
src/Question/Question.php
Question.ask
public function ask() { $this->drawer->open(); $phkey = new Detector(); $listener = $phkey->getListenerInstance(); $event = $listener->getEventDispatcher(); $event->addListener( 'key:up', function () { $this->cursor->moveUp(count($this->choices)); $this->draw(); } ); $event->addListener( 'key:down', function () { $this->cursor->moveDown(count($this->choices)); $this->draw(); } ); $event->addListener( 'key:space', function () { $this->selectChoice(); $this->draw(); } ); $event->addListener( 'key:enter', function () use ($event) { $event->dispatch('key:stop:listening'); $this->drawer->closeWindow(); } ); $this->draw(); $listener->start(); return $this->getAnswers(); }
php
public function ask() { $this->drawer->open(); $phkey = new Detector(); $listener = $phkey->getListenerInstance(); $event = $listener->getEventDispatcher(); $event->addListener( 'key:up', function () { $this->cursor->moveUp(count($this->choices)); $this->draw(); } ); $event->addListener( 'key:down', function () { $this->cursor->moveDown(count($this->choices)); $this->draw(); } ); $event->addListener( 'key:space', function () { $this->selectChoice(); $this->draw(); } ); $event->addListener( 'key:enter', function () use ($event) { $event->dispatch('key:stop:listening'); $this->drawer->closeWindow(); } ); $this->draw(); $listener->start(); return $this->getAnswers(); }
[ "public", "function", "ask", "(", ")", "{", "$", "this", "->", "drawer", "->", "open", "(", ")", ";", "$", "phkey", "=", "new", "Detector", "(", ")", ";", "$", "listener", "=", "$", "phkey", "->", "getListenerInstance", "(", ")", ";", "$", "event", "=", "$", "listener", "->", "getEventDispatcher", "(", ")", ";", "$", "event", "->", "addListener", "(", "'key:up'", ",", "function", "(", ")", "{", "$", "this", "->", "cursor", "->", "moveUp", "(", "count", "(", "$", "this", "->", "choices", ")", ")", ";", "$", "this", "->", "draw", "(", ")", ";", "}", ")", ";", "$", "event", "->", "addListener", "(", "'key:down'", ",", "function", "(", ")", "{", "$", "this", "->", "cursor", "->", "moveDown", "(", "count", "(", "$", "this", "->", "choices", ")", ")", ";", "$", "this", "->", "draw", "(", ")", ";", "}", ")", ";", "$", "event", "->", "addListener", "(", "'key:space'", ",", "function", "(", ")", "{", "$", "this", "->", "selectChoice", "(", ")", ";", "$", "this", "->", "draw", "(", ")", ";", "}", ")", ";", "$", "event", "->", "addListener", "(", "'key:enter'", ",", "function", "(", ")", "use", "(", "$", "event", ")", "{", "$", "event", "->", "dispatch", "(", "'key:stop:listening'", ")", ";", "$", "this", "->", "drawer", "->", "closeWindow", "(", ")", ";", "}", ")", ";", "$", "this", "->", "draw", "(", ")", ";", "$", "listener", "->", "start", "(", ")", ";", "return", "$", "this", "->", "getAnswers", "(", ")", ";", "}" ]
Asks the question @return array
[ "Asks", "the", "question" ]
909e613b140413062424d6a465da08aac355be55
https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Question/Question.php#L113-L157
13,922
ignasbernotas/console
src/Question/Question.php
Question.draw
protected function draw() { $this->drawer->drawWindow( $this->title, $this->choices, $this->cursor->getPosition(), $this->answers ); }
php
protected function draw() { $this->drawer->drawWindow( $this->title, $this->choices, $this->cursor->getPosition(), $this->answers ); }
[ "protected", "function", "draw", "(", ")", "{", "$", "this", "->", "drawer", "->", "drawWindow", "(", "$", "this", "->", "title", ",", "$", "this", "->", "choices", ",", "$", "this", "->", "cursor", "->", "getPosition", "(", ")", ",", "$", "this", "->", "answers", ")", ";", "}" ]
Draws the window
[ "Draws", "the", "window" ]
909e613b140413062424d6a465da08aac355be55
https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Question/Question.php#L162-L170
13,923
nyeholt/silverstripe-simplewiki
thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/URIScheme.php
HTMLPurifier_URIScheme.validate
public function validate(&$uri, $config, $context) { if ($this->default_port == $uri->port) $uri->port = null; return true; }
php
public function validate(&$uri, $config, $context) { if ($this->default_port == $uri->port) $uri->port = null; return true; }
[ "public", "function", "validate", "(", "&", "$", "uri", ",", "$", "config", ",", "$", "context", ")", "{", "if", "(", "$", "this", "->", "default_port", "==", "$", "uri", "->", "port", ")", "$", "uri", "->", "port", "=", "null", ";", "return", "true", ";", "}" ]
Validates the components of a URI @note This implementation should be called by children if they define a default port, as it does port processing. @param $uri Instance of HTMLPurifier_URI @param $config HTMLPurifier_Config object @param $context HTMLPurifier_Context object @return Bool success or failure
[ "Validates", "the", "components", "of", "a", "URI" ]
ecffed0d75be1454901e1cb24633472b8f67c967
https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/URIScheme.php#L35-L38
13,924
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.exportImage
public function exportImage( $keep_resorce = false ) { // prepare Capatcha $this->getCaptchaImage(); # Sending Header Info header( 'content-type: image/png' ); # Exporting the final image imagepng( $this->_final_image ); # Clearing final image from the memory imagedestroy( $this->_final_image ); # Method End }
php
public function exportImage( $keep_resorce = false ) { // prepare Capatcha $this->getCaptchaImage(); # Sending Header Info header( 'content-type: image/png' ); # Exporting the final image imagepng( $this->_final_image ); # Clearing final image from the memory imagedestroy( $this->_final_image ); # Method End }
[ "public", "function", "exportImage", "(", "$", "keep_resorce", "=", "false", ")", "{", "// prepare Capatcha", "$", "this", "->", "getCaptchaImage", "(", ")", ";", "# Sending Header Info", "header", "(", "'content-type: image/png'", ")", ";", "# Exporting the final image", "imagepng", "(", "$", "this", "->", "_final_image", ")", ";", "# Clearing final image from the memory", "imagedestroy", "(", "$", "this", "->", "_final_image", ")", ";", "# Method End", "}" ]
send image to browser
[ "send", "image", "to", "browser" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L78-L93
13,925
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.init
public static function init( $blocks = 2, $block_min_length = 4, $block_max_length = 7 ) { if( !is_numeric( $blocks ) || !is_numeric( $block_min_length ) || !is_numeric( $block_max_length ) ) throw new CaptchaException( __METHOD__ . ' arguments must be numeric values' ); if( $blocks < 1 || $blocks > 5 ) throw new CaptchaException( '__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.' ); if( $block_min_length < 1 || $block_min_length > 20 ) throw new CaptchaException( '__construct( , $block_min_length, ) $block_min_length must be +ve integer' ); if( $block_max_length < $block_min_length || $block_max_length > 100 ) throw new CaptchaException( '__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100' ); # Generate Captcha Code $code = ''; $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; for( $i = 1; $i <= $blocks ; $i++) { # generate block #i $block_length = rand( $block_min_length, $block_max_length ); # get block, from 0 to length-1 to get exact block_length $code .= substr(str_shuffle(str_repeat($pool, 5)), 0, $block_length-1 ); # Add Space if it wasn't the last block $code .= ( $i >= $blocks ) ?: ' '; } # Save Captcha Code To Session Session::put( 'captcha', $code ); }
php
public static function init( $blocks = 2, $block_min_length = 4, $block_max_length = 7 ) { if( !is_numeric( $blocks ) || !is_numeric( $block_min_length ) || !is_numeric( $block_max_length ) ) throw new CaptchaException( __METHOD__ . ' arguments must be numeric values' ); if( $blocks < 1 || $blocks > 5 ) throw new CaptchaException( '__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.' ); if( $block_min_length < 1 || $block_min_length > 20 ) throw new CaptchaException( '__construct( , $block_min_length, ) $block_min_length must be +ve integer' ); if( $block_max_length < $block_min_length || $block_max_length > 100 ) throw new CaptchaException( '__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100' ); # Generate Captcha Code $code = ''; $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; for( $i = 1; $i <= $blocks ; $i++) { # generate block #i $block_length = rand( $block_min_length, $block_max_length ); # get block, from 0 to length-1 to get exact block_length $code .= substr(str_shuffle(str_repeat($pool, 5)), 0, $block_length-1 ); # Add Space if it wasn't the last block $code .= ( $i >= $blocks ) ?: ' '; } # Save Captcha Code To Session Session::put( 'captcha', $code ); }
[ "public", "static", "function", "init", "(", "$", "blocks", "=", "2", ",", "$", "block_min_length", "=", "4", ",", "$", "block_max_length", "=", "7", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "blocks", ")", "||", "!", "is_numeric", "(", "$", "block_min_length", ")", "||", "!", "is_numeric", "(", "$", "block_max_length", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "' arguments must be numeric values'", ")", ";", "if", "(", "$", "blocks", "<", "1", "||", "$", "blocks", ">", "5", ")", "throw", "new", "CaptchaException", "(", "'__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.'", ")", ";", "if", "(", "$", "block_min_length", "<", "1", "||", "$", "block_min_length", ">", "20", ")", "throw", "new", "CaptchaException", "(", "'__construct( , $block_min_length, ) $block_min_length must be +ve integer'", ")", ";", "if", "(", "$", "block_max_length", "<", "$", "block_min_length", "||", "$", "block_max_length", ">", "100", ")", "throw", "new", "CaptchaException", "(", "'__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100'", ")", ";", "#\tGenerate Captcha Code", "$", "code", "=", "''", ";", "$", "pool", "=", "'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "blocks", ";", "$", "i", "++", ")", "{", "# generate block #i", "$", "block_length", "=", "rand", "(", "$", "block_min_length", ",", "$", "block_max_length", ")", ";", "# get block, from 0 to length-1 to get exact block_length", "$", "code", ".=", "substr", "(", "str_shuffle", "(", "str_repeat", "(", "$", "pool", ",", "5", ")", ")", ",", "0", ",", "$", "block_length", "-", "1", ")", ";", "# Add Space if it wasn't the last block", "$", "code", ".=", "(", "$", "i", ">=", "$", "blocks", ")", "?", ":", "' '", ";", "}", "# Save Captcha Code To Session\t", "Session", "::", "put", "(", "'captcha'", ",", "$", "code", ")", ";", "}" ]
This Method Will Generate a Capatcha Code and Store it in Session
[ "This", "Method", "Will", "Generate", "a", "Capatcha", "Code", "and", "Store", "it", "in", "Session" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L109-L146
13,926
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.calculateDimensions
private function calculateDimensions() { # calculate capatcha text box dimensions # which are the minimum image resource dimensions $this->_calculated_text_box['dimensions'] = $this->getTextBoxDimensions( $this->_background_text['size'], 0, $this->_background_text['font'], $this->_code ); # calculate how much each character takes from width $this->_calculated_text_box['char_width'] = $this->_calculated_text_box['dimensions']['width'] / $this->_code_length; # calculate additional width to add to the minimum text box width later $this->_calculated_text_box['additional_width'] = $this->_calculated_text_box['char_width'] * $this->_code_length + $this->_blocks_seperation; $this->_calculated_text_box['additional_height'] = rand( 5, 15 ); # set Initial Image Information width, height $this->_image_info['width'] = $this->_calculated_text_box['dimensions']['width'] + $this->_calculated_text_box['additional_width']; $this->_image_info['height'] = $this->_calculated_text_box['dimensions']['height'] + $this->_calculated_text_box['additional_height']; # Method End }
php
private function calculateDimensions() { # calculate capatcha text box dimensions # which are the minimum image resource dimensions $this->_calculated_text_box['dimensions'] = $this->getTextBoxDimensions( $this->_background_text['size'], 0, $this->_background_text['font'], $this->_code ); # calculate how much each character takes from width $this->_calculated_text_box['char_width'] = $this->_calculated_text_box['dimensions']['width'] / $this->_code_length; # calculate additional width to add to the minimum text box width later $this->_calculated_text_box['additional_width'] = $this->_calculated_text_box['char_width'] * $this->_code_length + $this->_blocks_seperation; $this->_calculated_text_box['additional_height'] = rand( 5, 15 ); # set Initial Image Information width, height $this->_image_info['width'] = $this->_calculated_text_box['dimensions']['width'] + $this->_calculated_text_box['additional_width']; $this->_image_info['height'] = $this->_calculated_text_box['dimensions']['height'] + $this->_calculated_text_box['additional_height']; # Method End }
[ "private", "function", "calculateDimensions", "(", ")", "{", "# calculate capatcha text box dimensions", "# which are the minimum image resource dimensions", "$", "this", "->", "_calculated_text_box", "[", "'dimensions'", "]", "=", "$", "this", "->", "getTextBoxDimensions", "(", "$", "this", "->", "_background_text", "[", "'size'", "]", ",", "0", ",", "$", "this", "->", "_background_text", "[", "'font'", "]", ",", "$", "this", "->", "_code", ")", ";", "# calculate how much each character takes from width", "$", "this", "->", "_calculated_text_box", "[", "'char_width'", "]", "=", "$", "this", "->", "_calculated_text_box", "[", "'dimensions'", "]", "[", "'width'", "]", "/", "$", "this", "->", "_code_length", ";", "# calculate additional width to add to the minimum text box width later", "$", "this", "->", "_calculated_text_box", "[", "'additional_width'", "]", "=", "$", "this", "->", "_calculated_text_box", "[", "'char_width'", "]", "*", "$", "this", "->", "_code_length", "+", "$", "this", "->", "_blocks_seperation", ";", "$", "this", "->", "_calculated_text_box", "[", "'additional_height'", "]", "=", "rand", "(", "5", ",", "15", ")", ";", "# set Initial Image Information width, height", "$", "this", "->", "_image_info", "[", "'width'", "]", "=", "$", "this", "->", "_calculated_text_box", "[", "'dimensions'", "]", "[", "'width'", "]", "+", "$", "this", "->", "_calculated_text_box", "[", "'additional_width'", "]", ";", "$", "this", "->", "_image_info", "[", "'height'", "]", "=", "$", "this", "->", "_calculated_text_box", "[", "'dimensions'", "]", "[", "'height'", "]", "+", "$", "this", "->", "_calculated_text_box", "[", "'additional_height'", "]", ";", "# Method End", "}" ]
calculate required size of capatcha image
[ "calculate", "required", "size", "of", "capatcha", "image" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L191-L219
13,927
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.createCaptchaImage
private function createCaptchaImage() { $this->_image_resource = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->_image_resource, true ); # Get Colors Values $rgb = $this->getRGBFromRange( $this->_image_info['color'][0], $this->_image_info['color'][1], $this->_image_info['color'][2], $this->_image_info['color']['range'] ); # Get Color; $background_color = imagecolorallocate( $this->_image_resource, # Image Resource $rgb[0], # R $rgb[1], # G $rgb[2] # B ); # Apply Color imagefill( $this->_image_resource, # Image Resource 0, # Positon X 0, # Positon Y $background_color # Color ); # Method End }
php
private function createCaptchaImage() { $this->_image_resource = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->_image_resource, true ); # Get Colors Values $rgb = $this->getRGBFromRange( $this->_image_info['color'][0], $this->_image_info['color'][1], $this->_image_info['color'][2], $this->_image_info['color']['range'] ); # Get Color; $background_color = imagecolorallocate( $this->_image_resource, # Image Resource $rgb[0], # R $rgb[1], # G $rgb[2] # B ); # Apply Color imagefill( $this->_image_resource, # Image Resource 0, # Positon X 0, # Positon Y $background_color # Color ); # Method End }
[ "private", "function", "createCaptchaImage", "(", ")", "{", "$", "this", "->", "_image_resource", "=", "imagecreatetruecolor", "(", "$", "this", "->", "_image_info", "[", "'width'", "]", ",", "$", "this", "->", "_image_info", "[", "'height'", "]", ")", ";", "if", "(", "function_exists", "(", "'imageantialias'", ")", ")", "imageantialias", "(", "$", "this", "->", "_image_resource", ",", "true", ")", ";", "# Get Colors Values\t", "$", "rgb", "=", "$", "this", "->", "getRGBFromRange", "(", "$", "this", "->", "_image_info", "[", "'color'", "]", "[", "0", "]", ",", "$", "this", "->", "_image_info", "[", "'color'", "]", "[", "1", "]", ",", "$", "this", "->", "_image_info", "[", "'color'", "]", "[", "2", "]", ",", "$", "this", "->", "_image_info", "[", "'color'", "]", "[", "'range'", "]", ")", ";", "# Get Color;", "$", "background_color", "=", "imagecolorallocate", "(", "$", "this", "->", "_image_resource", ",", "# Image Resource", "$", "rgb", "[", "0", "]", ",", "# R", "$", "rgb", "[", "1", "]", ",", "# G", "$", "rgb", "[", "2", "]", "# B", ")", ";", "# Apply Color", "imagefill", "(", "$", "this", "->", "_image_resource", ",", "# Image Resource", "0", ",", "# Positon X", "0", ",", "# Positon Y", "$", "background_color", "# Color", ")", ";", "# Method End", "}" ]
create capatcha image resource
[ "create", "capatcha", "image", "resource" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L225-L259
13,928
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.fixCaptchaImage
private function fixCaptchaImage(){ # Final equired image width must be # Last _front_text x position + initial_x $final_width = $this->_front_text['x'] + $this->_front_text['initial_x']; # check if to set final width if( $this->_image_info['width'] > $final_width ) $this->_image_info['width'] = $final_width; $this->_final_image = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->_final_image, true ); imagecopy( $this->_final_image, # destination image resource to copy into $this->_image_resource, # source image resource to copy from 0, # start x position to copy into in destination image 0, # start y position to copy into in destination image 0, # start x position to copy from in source image 0, # start y position to copy from in source image $this->_image_info['width'], # width to copy from source image $this->_image_info['height'] # height to copy from source image ); # Removing the first image from memory imagedestroy( $this->_image_resource ); # Method End }
php
private function fixCaptchaImage(){ # Final equired image width must be # Last _front_text x position + initial_x $final_width = $this->_front_text['x'] + $this->_front_text['initial_x']; # check if to set final width if( $this->_image_info['width'] > $final_width ) $this->_image_info['width'] = $final_width; $this->_final_image = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->_final_image, true ); imagecopy( $this->_final_image, # destination image resource to copy into $this->_image_resource, # source image resource to copy from 0, # start x position to copy into in destination image 0, # start y position to copy into in destination image 0, # start x position to copy from in source image 0, # start y position to copy from in source image $this->_image_info['width'], # width to copy from source image $this->_image_info['height'] # height to copy from source image ); # Removing the first image from memory imagedestroy( $this->_image_resource ); # Method End }
[ "private", "function", "fixCaptchaImage", "(", ")", "{", "# Final equired image width must be", "# Last _front_text x position + initial_x", "$", "final_width", "=", "$", "this", "->", "_front_text", "[", "'x'", "]", "+", "$", "this", "->", "_front_text", "[", "'initial_x'", "]", ";", "# check if to set final width", "if", "(", "$", "this", "->", "_image_info", "[", "'width'", "]", ">", "$", "final_width", ")", "$", "this", "->", "_image_info", "[", "'width'", "]", "=", "$", "final_width", ";", "$", "this", "->", "_final_image", "=", "imagecreatetruecolor", "(", "$", "this", "->", "_image_info", "[", "'width'", "]", ",", "$", "this", "->", "_image_info", "[", "'height'", "]", ")", ";", "if", "(", "function_exists", "(", "'imageantialias'", ")", ")", "imageantialias", "(", "$", "this", "->", "_final_image", ",", "true", ")", ";", "imagecopy", "(", "$", "this", "->", "_final_image", ",", "# destination image resource to copy into", "$", "this", "->", "_image_resource", ",", "# source image resource to copy from", "0", ",", "# start x position to copy into in destination image", "0", ",", "# start y position to copy into in destination image", "0", ",", "# start x position to copy from in source image", "0", ",", "# start y position to copy from in source image", "$", "this", "->", "_image_info", "[", "'width'", "]", ",", "# width to copy from source image ", "$", "this", "->", "_image_info", "[", "'height'", "]", "# height to copy from source image", ")", ";", "# Removing the first image from memory", "imagedestroy", "(", "$", "this", "->", "_image_resource", ")", ";", "# Method End", "}" ]
Fix Final Capatcha image Size if needed
[ "Fix", "Final", "Capatcha", "image", "Size", "if", "needed" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L423-L456
13,929
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.setTextSize
public function setTextSize( $front, $background = null ) { # comment if( !is_numeric( $front ) ) throw new CaptchaException( __METHOD__ . '($arg) must be numeric' ); if( !$background ) { $this->_front_text['size'] = $front; $this->_background_text['size'] = $front + 10; } else { if( !is_numeric( $background ) ) throw new CaptchaException( __METHOD__ . '($arg) must be numeric' ); if( $front > $background ) throw new CaptchaException( __METHOD__ . '($front, $background) $background must be greater than or equal front' ); $this->_front_text['size'] = $front; $this->_background_text['size'] = $background; } return $this; # Method End }
php
public function setTextSize( $front, $background = null ) { # comment if( !is_numeric( $front ) ) throw new CaptchaException( __METHOD__ . '($arg) must be numeric' ); if( !$background ) { $this->_front_text['size'] = $front; $this->_background_text['size'] = $front + 10; } else { if( !is_numeric( $background ) ) throw new CaptchaException( __METHOD__ . '($arg) must be numeric' ); if( $front > $background ) throw new CaptchaException( __METHOD__ . '($front, $background) $background must be greater than or equal front' ); $this->_front_text['size'] = $front; $this->_background_text['size'] = $background; } return $this; # Method End }
[ "public", "function", "setTextSize", "(", "$", "front", ",", "$", "background", "=", "null", ")", "{", "#\tcomment", "if", "(", "!", "is_numeric", "(", "$", "front", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'($arg) must be numeric'", ")", ";", "if", "(", "!", "$", "background", ")", "{", "$", "this", "->", "_front_text", "[", "'size'", "]", "=", "$", "front", ";", "$", "this", "->", "_background_text", "[", "'size'", "]", "=", "$", "front", "+", "10", ";", "}", "else", "{", "if", "(", "!", "is_numeric", "(", "$", "background", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'($arg) must be numeric'", ")", ";", "if", "(", "$", "front", ">", "$", "background", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'($front, $background) $background must be greater than or equal front'", ")", ";", "$", "this", "->", "_front_text", "[", "'size'", "]", "=", "$", "front", ";", "$", "this", "->", "_background_text", "[", "'size'", "]", "=", "$", "background", ";", "}", "return", "$", "this", ";", "# Method End", "}" ]
Set Text Size @param integer $front front text size @param integer $background text size
[ "Set", "Text", "Size" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L470-L498
13,930
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.setColor
public function setColor( $key, $r, $g, $b, $alpha = 0, $range = 0 ) { # Set color if( !in_array( $key, array( 'background', 'background_text', 'front_text' ) ) ) throw new CaptchaException( __METHOD__ . '($key, ) must be one of( background, background_text, front_text ).' ); if( !is_numeric( $r ) || !is_numeric( $g ) || !is_numeric( $b ) || !is_numeric( $alpha ) || !is_numeric( $range ) ) throw new CaptchaException( __METHOD__ . '( , $args ) second argument and the followers must be numeric values.' ); # set values $property = ( $key == 'background' ) ? '_image_info' : '_' . $key; $this->{$property}['color'] = array( $r, $g, $b, $alpha ); $this->{$property}['color']['range'] = $range; return $this; # Method End }
php
public function setColor( $key, $r, $g, $b, $alpha = 0, $range = 0 ) { # Set color if( !in_array( $key, array( 'background', 'background_text', 'front_text' ) ) ) throw new CaptchaException( __METHOD__ . '($key, ) must be one of( background, background_text, front_text ).' ); if( !is_numeric( $r ) || !is_numeric( $g ) || !is_numeric( $b ) || !is_numeric( $alpha ) || !is_numeric( $range ) ) throw new CaptchaException( __METHOD__ . '( , $args ) second argument and the followers must be numeric values.' ); # set values $property = ( $key == 'background' ) ? '_image_info' : '_' . $key; $this->{$property}['color'] = array( $r, $g, $b, $alpha ); $this->{$property}['color']['range'] = $range; return $this; # Method End }
[ "public", "function", "setColor", "(", "$", "key", ",", "$", "r", ",", "$", "g", ",", "$", "b", ",", "$", "alpha", "=", "0", ",", "$", "range", "=", "0", ")", "{", "#\tSet color", "if", "(", "!", "in_array", "(", "$", "key", ",", "array", "(", "'background'", ",", "'background_text'", ",", "'front_text'", ")", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'($key, ) must be one of( background, background_text, front_text ).'", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "r", ")", "||", "!", "is_numeric", "(", "$", "g", ")", "||", "!", "is_numeric", "(", "$", "b", ")", "||", "!", "is_numeric", "(", "$", "alpha", ")", "||", "!", "is_numeric", "(", "$", "range", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'( , $args ) second argument and the followers must be numeric values.'", ")", ";", "# set values", "$", "property", "=", "(", "$", "key", "==", "'background'", ")", "?", "'_image_info'", ":", "'_'", ".", "$", "key", ";", "$", "this", "->", "{", "$", "property", "}", "[", "'color'", "]", "=", "array", "(", "$", "r", ",", "$", "g", ",", "$", "b", ",", "$", "alpha", ")", ";", "$", "this", "->", "{", "$", "property", "}", "[", "'color'", "]", "[", "'range'", "]", "=", "$", "range", ";", "return", "$", "this", ";", "# Method End", "}" ]
Set Text Color @param string $key define which property to set it's color @param integer $r red value @param integer $g green value @param integer $b blue value @param integer $alpha alpha value @param integer $range range
[ "Set", "Text", "Color" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L510-L529
13,931
ahmad-sa3d/saad-image
src/Captcha/Captcha.php
Captcha.setFont
public function setFont( $key, $font ) { # Set Fonts if( $key != 'background_text' && $key != 'front_text' ) throw new CaptchaException( __METHOD__ . '($key, ) $key must be background_text or front_text.' ); # check font file existence $font_file = Config::get( 'images.captcha.font_dir' ) . DIRECTORY_SEPARATOR . $font; if( !file_exists( $font_file ) ) throw new CaptchaException( __METHOD__ . "( , $font) provided font file '$font_file' doesn't exists." ); $property = '_' . $key; $this->{$property}['font'] = $font_file; return $this; # Method End }
php
public function setFont( $key, $font ) { # Set Fonts if( $key != 'background_text' && $key != 'front_text' ) throw new CaptchaException( __METHOD__ . '($key, ) $key must be background_text or front_text.' ); # check font file existence $font_file = Config::get( 'images.captcha.font_dir' ) . DIRECTORY_SEPARATOR . $font; if( !file_exists( $font_file ) ) throw new CaptchaException( __METHOD__ . "( , $font) provided font file '$font_file' doesn't exists." ); $property = '_' . $key; $this->{$property}['font'] = $font_file; return $this; # Method End }
[ "public", "function", "setFont", "(", "$", "key", ",", "$", "font", ")", "{", "#\tSet Fonts", "if", "(", "$", "key", "!=", "'background_text'", "&&", "$", "key", "!=", "'front_text'", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "'($key, ) $key must be background_text or front_text.'", ")", ";", "# check font file existence", "$", "font_file", "=", "Config", "::", "get", "(", "'images.captcha.font_dir'", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "font", ";", "if", "(", "!", "file_exists", "(", "$", "font_file", ")", ")", "throw", "new", "CaptchaException", "(", "__METHOD__", ".", "\"( , $font) provided font file '$font_file' doesn't exists.\"", ")", ";", "$", "property", "=", "'_'", ".", "$", "key", ";", "$", "this", "->", "{", "$", "property", "}", "[", "'font'", "]", "=", "$", "font_file", ";", "return", "$", "this", ";", "# Method End", "}" ]
Set Captcha Font @param string $key define which text we want to set it's font @param string $font font file name
[ "Set", "Captcha", "Font" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Captcha/Captcha.php#L537-L556
13,932
chippyash/Strong-Type
src/Chippyash/Type/Number/Rational/AbstractRationalType.php
AbstractRationalType.asComplex
public function asComplex() { return new ComplexType( new RationalType(clone $this->numerator(), clone $this->denominator()), new RationalType(new IntType(0), new IntType(1)) ); }
php
public function asComplex() { return new ComplexType( new RationalType(clone $this->numerator(), clone $this->denominator()), new RationalType(new IntType(0), new IntType(1)) ); }
[ "public", "function", "asComplex", "(", ")", "{", "return", "new", "ComplexType", "(", "new", "RationalType", "(", "clone", "$", "this", "->", "numerator", "(", ")", ",", "clone", "$", "this", "->", "denominator", "(", ")", ")", ",", "new", "RationalType", "(", "new", "IntType", "(", "0", ")", ",", "new", "IntType", "(", "1", ")", ")", ")", ";", "}" ]
Return the number as a Complex number i.e. n+0i @return \Chippyash\Type\Number\Complex\ComplexType
[ "Return", "the", "number", "as", "a", "Complex", "number", "i", ".", "e", ".", "n", "+", "0i" ]
9d364c10c68c10f768254fb25b0b1db3dbef6fa9
https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Rational/AbstractRationalType.php#L48-L54
13,933
chippyash/Strong-Type
src/Chippyash/Type/Number/Rational/AbstractRationalType.php
AbstractRationalType.getAsNativeType
public function getAsNativeType() { if ($this->isInteger()) { return intval($this->value['num']->get()); } return floatval($this->value['num']->get() / $this->value['den']->get()); }
php
public function getAsNativeType() { if ($this->isInteger()) { return intval($this->value['num']->get()); } return floatval($this->value['num']->get() / $this->value['den']->get()); }
[ "public", "function", "getAsNativeType", "(", ")", "{", "if", "(", "$", "this", "->", "isInteger", "(", ")", ")", "{", "return", "intval", "(", "$", "this", "->", "value", "[", "'num'", "]", "->", "get", "(", ")", ")", ";", "}", "return", "floatval", "(", "$", "this", "->", "value", "[", "'num'", "]", "->", "get", "(", ")", "/", "$", "this", "->", "value", "[", "'den'", "]", "->", "get", "(", ")", ")", ";", "}" ]
Get the basic PHP value of the object type properly In this case, the type is an int or float @return int|float
[ "Get", "the", "basic", "PHP", "value", "of", "the", "object", "type", "properly", "In", "this", "case", "the", "type", "is", "an", "int", "or", "float" ]
9d364c10c68c10f768254fb25b0b1db3dbef6fa9
https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Rational/AbstractRationalType.php#L155-L162
13,934
mimmi20/Wurfl
src/Handlers/Normalizer/Generic/IISLogging.php
IISLogging.normalize
public function normalize($userAgent) { //If there are no spaces in a UA and more than 2 plus symbols, the UA is likely affected by IIS style logging issues if (substr_count($userAgent, ' ') === 0 and substr_count($userAgent, '+') > 2) { $userAgent = str_replace('+', ' ', $userAgent); } return $userAgent; }
php
public function normalize($userAgent) { //If there are no spaces in a UA and more than 2 plus symbols, the UA is likely affected by IIS style logging issues if (substr_count($userAgent, ' ') === 0 and substr_count($userAgent, '+') > 2) { $userAgent = str_replace('+', ' ', $userAgent); } return $userAgent; }
[ "public", "function", "normalize", "(", "$", "userAgent", ")", "{", "//If there are no spaces in a UA and more than 2 plus symbols, the UA is likely affected by IIS style logging issues", "if", "(", "substr_count", "(", "$", "userAgent", ",", "' '", ")", "===", "0", "and", "substr_count", "(", "$", "userAgent", ",", "'+'", ")", ">", "2", ")", "{", "$", "userAgent", "=", "str_replace", "(", "'+'", ",", "' '", ",", "$", "userAgent", ")", ";", "}", "return", "$", "userAgent", ";", "}" ]
This method clean the IIS logging from user agent string. @param string $userAgent @return string Normalized user agent
[ "This", "method", "clean", "the", "IIS", "logging", "from", "user", "agent", "string", "." ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/Normalizer/Generic/IISLogging.php#L34-L42
13,935
geniv/nette-thumbnail
src/MacroThumb.php
MacroThumb.macroThumb
public function macroThumb(MacroNode $node, PhpWriter $writer) { if ($node->modifiers) { // accept dataStream modifier for base64 if (Helpers::removeFilter($node->modifiers, 'dataStream')) { return $writer->write('$_fi=Thumbnail\\Thumbnail::getSrcPath(%node.word, %node.args); echo Latte\\Runtime\\Filters::dataStream(file_get_contents(__DIR__."/../../../".$_fi));'); } throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); } return $writer->write('echo Thumbnail\\Thumbnail::getSrcPath(%node.word, %node.args)'); }
php
public function macroThumb(MacroNode $node, PhpWriter $writer) { if ($node->modifiers) { // accept dataStream modifier for base64 if (Helpers::removeFilter($node->modifiers, 'dataStream')) { return $writer->write('$_fi=Thumbnail\\Thumbnail::getSrcPath(%node.word, %node.args); echo Latte\\Runtime\\Filters::dataStream(file_get_contents(__DIR__."/../../../".$_fi));'); } throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); } return $writer->write('echo Thumbnail\\Thumbnail::getSrcPath(%node.word, %node.args)'); }
[ "public", "function", "macroThumb", "(", "MacroNode", "$", "node", ",", "PhpWriter", "$", "writer", ")", "{", "if", "(", "$", "node", "->", "modifiers", ")", "{", "// accept dataStream modifier for base64", "if", "(", "Helpers", "::", "removeFilter", "(", "$", "node", "->", "modifiers", ",", "'dataStream'", ")", ")", "{", "return", "$", "writer", "->", "write", "(", "'$_fi=Thumbnail\\\\Thumbnail::getSrcPath(%node.word, %node.args); echo Latte\\\\Runtime\\\\Filters::dataStream(file_get_contents(__DIR__.\"/../../../\".$_fi));'", ")", ";", "}", "throw", "new", "CompileException", "(", "'Modifiers are not allowed in '", ".", "$", "node", "->", "getNotation", "(", ")", ")", ";", "}", "return", "$", "writer", "->", "write", "(", "'echo Thumbnail\\\\Thumbnail::getSrcPath(%node.word, %node.args)'", ")", ";", "}" ]
Macro thumb. @param MacroNode $node @param PhpWriter $writer @return string @throws CompileException
[ "Macro", "thumb", "." ]
408fc61e0df99113a873ca1ec463e4fc85016eed
https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/MacroThumb.php#L42-L52
13,936
itrnka/ha-framework
src/ha/Access/HTTP/Router/Route/HTTPRouteExample.php
HTTPRouteExample.prepareResponse
public function prepareResponse(): void { // change default HTTP status code $this->response->setStatusCode(200); // clear default response headers $this->response->resetHeaders(); // add your response headers $this->response->setCharset('UTF-8'); $this->response->setContentType('text/html'); $this->response->addHeader( 'X-Some-Header-Example-Name: headerValueExample' ); // add some other headers by this example // call here your controller to get real response body $body = 'This is an example generated in Route <i>' . get_class($this) . '</i> with a fictive Controller.'; // set body to response as response body $this->response->setBody($body); }
php
public function prepareResponse(): void { // change default HTTP status code $this->response->setStatusCode(200); // clear default response headers $this->response->resetHeaders(); // add your response headers $this->response->setCharset('UTF-8'); $this->response->setContentType('text/html'); $this->response->addHeader( 'X-Some-Header-Example-Name: headerValueExample' ); // add some other headers by this example // call here your controller to get real response body $body = 'This is an example generated in Route <i>' . get_class($this) . '</i> with a fictive Controller.'; // set body to response as response body $this->response->setBody($body); }
[ "public", "function", "prepareResponse", "(", ")", ":", "void", "{", "// change default HTTP status code", "$", "this", "->", "response", "->", "setStatusCode", "(", "200", ")", ";", "// clear default response headers", "$", "this", "->", "response", "->", "resetHeaders", "(", ")", ";", "// add your response headers", "$", "this", "->", "response", "->", "setCharset", "(", "'UTF-8'", ")", ";", "$", "this", "->", "response", "->", "setContentType", "(", "'text/html'", ")", ";", "$", "this", "->", "response", "->", "addHeader", "(", "'X-Some-Header-Example-Name: headerValueExample'", ")", ";", "// add some other headers by this example", "// call here your controller to get real response body", "$", "body", "=", "'This is an example generated in Route <i>'", ".", "get_class", "(", "$", "this", ")", ".", "'</i> with a fictive Controller.'", ";", "// set body to response as response body", "$", "this", "->", "response", "->", "setBody", "(", "$", "body", ")", ";", "}" ]
Setup response headers and body by your controller or other logic.
[ "Setup", "response", "headers", "and", "body", "by", "your", "controller", "or", "other", "logic", "." ]
a72b09c28f8e966c37f98a0004e4fbbce80df42c
https://github.com/itrnka/ha-framework/blob/a72b09c28f8e966c37f98a0004e4fbbce80df42c/src/ha/Access/HTTP/Router/Route/HTTPRouteExample.php#L28-L48
13,937
todstoychev/icr
src/Manipulator/AbstractManipulator.php
AbstractManipulator.calculateResize
protected function calculateResize(AbstractImage $abstractImage, $width, $height) { if (!is_numeric($width) || !is_numeric($height)) { throw new \LogicException('Non numeric value provide for calculating resize!'); } $imageWidth = $abstractImage->getSize()->getWidth(); $imageHeight = $abstractImage->getSize()->getHeight(); $widthRatio = $imageWidth / (int) $width; $heightRatio = $imageHeight / (int) $height; $ratio = min($widthRatio, $heightRatio); if ($ratio < 1) { throw new ImageTooSmallException('Provided image is too small to be resize! Provide larger image.'); } $calcWidth = $imageWidth / $ratio; $calcHeight = $imageHeight / $ratio; $box = clone $this->box; $box->setWidth(round($calcWidth)) ->setHeight(round($calcHeight)); return $box; }
php
protected function calculateResize(AbstractImage $abstractImage, $width, $height) { if (!is_numeric($width) || !is_numeric($height)) { throw new \LogicException('Non numeric value provide for calculating resize!'); } $imageWidth = $abstractImage->getSize()->getWidth(); $imageHeight = $abstractImage->getSize()->getHeight(); $widthRatio = $imageWidth / (int) $width; $heightRatio = $imageHeight / (int) $height; $ratio = min($widthRatio, $heightRatio); if ($ratio < 1) { throw new ImageTooSmallException('Provided image is too small to be resize! Provide larger image.'); } $calcWidth = $imageWidth / $ratio; $calcHeight = $imageHeight / $ratio; $box = clone $this->box; $box->setWidth(round($calcWidth)) ->setHeight(round($calcHeight)); return $box; }
[ "protected", "function", "calculateResize", "(", "AbstractImage", "$", "abstractImage", ",", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "width", ")", "||", "!", "is_numeric", "(", "$", "height", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Non numeric value provide for calculating resize!'", ")", ";", "}", "$", "imageWidth", "=", "$", "abstractImage", "->", "getSize", "(", ")", "->", "getWidth", "(", ")", ";", "$", "imageHeight", "=", "$", "abstractImage", "->", "getSize", "(", ")", "->", "getHeight", "(", ")", ";", "$", "widthRatio", "=", "$", "imageWidth", "/", "(", "int", ")", "$", "width", ";", "$", "heightRatio", "=", "$", "imageHeight", "/", "(", "int", ")", "$", "height", ";", "$", "ratio", "=", "min", "(", "$", "widthRatio", ",", "$", "heightRatio", ")", ";", "if", "(", "$", "ratio", "<", "1", ")", "{", "throw", "new", "ImageTooSmallException", "(", "'Provided image is too small to be resize! Provide larger image.'", ")", ";", "}", "$", "calcWidth", "=", "$", "imageWidth", "/", "$", "ratio", ";", "$", "calcHeight", "=", "$", "imageHeight", "/", "$", "ratio", ";", "$", "box", "=", "clone", "$", "this", "->", "box", ";", "$", "box", "->", "setWidth", "(", "round", "(", "$", "calcWidth", ")", ")", "->", "setHeight", "(", "round", "(", "$", "calcHeight", ")", ")", ";", "return", "$", "box", ";", "}" ]
Calculates image resize @param AbstractImage $abstractImage @param int $width @param int $height @return Box
[ "Calculates", "image", "resize" ]
0214c7bc76e44488e98758d55deb707b72e24000
https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/AbstractManipulator.php#L56-L82
13,938
todstoychev/icr
src/Manipulator/AbstractManipulator.php
AbstractManipulator.createCropPoint
protected function createCropPoint(AbstractImage $abstractImage, $width, $height) { if (!is_numeric($width) || !is_numeric($height)) { throw new \LogicException('Provided values for width and height are not numeric!'); } $width = (int) $width; $height = (int) $height; $imageWidth = $abstractImage->getSize() ->getWidth(); $imageHeight = $abstractImage->getSize() ->getHeight(); if ($imageWidth < $width || $imageHeight < $height) { throw new ImageTooSmallException('Provided image is too small to be resize! Provide larger image.'); } $cropWidth = ($imageWidth / 2) - ($width / 2); $cropHeight = ($imageHeight / 2) - ($height / 2); $box = clone $this->box; $box->setWidth(round($cropWidth)) ->setHeight(round($cropHeight)); $this->point->setBox($box); return $this->point; }
php
protected function createCropPoint(AbstractImage $abstractImage, $width, $height) { if (!is_numeric($width) || !is_numeric($height)) { throw new \LogicException('Provided values for width and height are not numeric!'); } $width = (int) $width; $height = (int) $height; $imageWidth = $abstractImage->getSize() ->getWidth(); $imageHeight = $abstractImage->getSize() ->getHeight(); if ($imageWidth < $width || $imageHeight < $height) { throw new ImageTooSmallException('Provided image is too small to be resize! Provide larger image.'); } $cropWidth = ($imageWidth / 2) - ($width / 2); $cropHeight = ($imageHeight / 2) - ($height / 2); $box = clone $this->box; $box->setWidth(round($cropWidth)) ->setHeight(round($cropHeight)); $this->point->setBox($box); return $this->point; }
[ "protected", "function", "createCropPoint", "(", "AbstractImage", "$", "abstractImage", ",", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "width", ")", "||", "!", "is_numeric", "(", "$", "height", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Provided values for width and height are not numeric!'", ")", ";", "}", "$", "width", "=", "(", "int", ")", "$", "width", ";", "$", "height", "=", "(", "int", ")", "$", "height", ";", "$", "imageWidth", "=", "$", "abstractImage", "->", "getSize", "(", ")", "->", "getWidth", "(", ")", ";", "$", "imageHeight", "=", "$", "abstractImage", "->", "getSize", "(", ")", "->", "getHeight", "(", ")", ";", "if", "(", "$", "imageWidth", "<", "$", "width", "||", "$", "imageHeight", "<", "$", "height", ")", "{", "throw", "new", "ImageTooSmallException", "(", "'Provided image is too small to be resize! Provide larger image.'", ")", ";", "}", "$", "cropWidth", "=", "(", "$", "imageWidth", "/", "2", ")", "-", "(", "$", "width", "/", "2", ")", ";", "$", "cropHeight", "=", "(", "$", "imageHeight", "/", "2", ")", "-", "(", "$", "height", "/", "2", ")", ";", "$", "box", "=", "clone", "$", "this", "->", "box", ";", "$", "box", "->", "setWidth", "(", "round", "(", "$", "cropWidth", ")", ")", "->", "setHeight", "(", "round", "(", "$", "cropHeight", ")", ")", ";", "$", "this", "->", "point", "->", "setBox", "(", "$", "box", ")", ";", "return", "$", "this", "->", "point", ";", "}" ]
Creates crop point @param AbstractImage $abstractImage @param int $width @param int $height @return Point
[ "Creates", "crop", "point" ]
0214c7bc76e44488e98758d55deb707b72e24000
https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/AbstractManipulator.php#L93-L120
13,939
dphn/ScContent
src/ScContent/Entity/Widget.php
Widget.isApplicable
public function isApplicable($role) { if (isset($this->options['roles'][$role])) { return (bool) (int) $this->options['roles'][$role]; } return true; }
php
public function isApplicable($role) { if (isset($this->options['roles'][$role])) { return (bool) (int) $this->options['roles'][$role]; } return true; }
[ "public", "function", "isApplicable", "(", "$", "role", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'roles'", "]", "[", "$", "role", "]", ")", ")", "{", "return", "(", "bool", ")", "(", "int", ")", "$", "this", "->", "options", "[", "'roles'", "]", "[", "$", "role", "]", ";", "}", "return", "true", ";", "}" ]
Checks whether the widget is applicable to the role. This behavior differs from the ACL. Returns FALSE if and only if the widget is explicitly disabled for a given role. This is true because the widgets do not have to perform any function other than displaying information. To change the information are frontend and backend controllers, protected access to them engaged ACL. @param string $role @return boolean
[ "Checks", "whether", "the", "widget", "is", "applicable", "to", "the", "role", ".", "This", "behavior", "differs", "from", "the", "ACL", ".", "Returns", "FALSE", "if", "and", "only", "if", "the", "widget", "is", "explicitly", "disabled", "for", "a", "given", "role", "." ]
9dd5732490c45fd788b96cedf7b3c7adfacb30d2
https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Entity/Widget.php#L237-L243
13,940
chippyash/Strong-Type
src/Chippyash/Type/Number/GMPIntType.php
GMPIntType.gmpTypeCheck
protected function gmpTypeCheck($value) { if (version_compare(PHP_VERSION, '5.6.0') < 0) { return is_resource($value) && get_resource_type($value) == 'GMP integer'; } return ($value instanceof \GMP); }
php
protected function gmpTypeCheck($value) { if (version_compare(PHP_VERSION, '5.6.0') < 0) { return is_resource($value) && get_resource_type($value) == 'GMP integer'; } return ($value instanceof \GMP); }
[ "protected", "function", "gmpTypeCheck", "(", "$", "value", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.6.0'", ")", "<", "0", ")", "{", "return", "is_resource", "(", "$", "value", ")", "&&", "get_resource_type", "(", "$", "value", ")", "==", "'GMP integer'", ";", "}", "return", "(", "$", "value", "instanceof", "\\", "GMP", ")", ";", "}" ]
Check gmp type depending on PHP version @param mixed $value value to check type of @return boolean true if gmp number else false
[ "Check", "gmp", "type", "depending", "on", "PHP", "version" ]
9d364c10c68c10f768254fb25b0b1db3dbef6fa9
https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/GMPIntType.php#L292-L299
13,941
demisang/yii2-recaptcha
ReCaptcha.php
ReCaptcha.registerClientScript
public function registerClientScript($gCaptchaParams = []) { $id = $this->id; $view = $this->view; ReCaptchaAsset::register($view); $options = Json::encode($gCaptchaParams); // Directly creating captcha widgets. // This code placed only one time irrespective of count of captcha-widgets $view->registerJs(<<<JS if (typeof (renderReCaptchaCallback) === "undefined") { var reCaptchaWidgets = {}; var renderReCaptchaCallback = function() { for (var widgetId in reCaptchaWidgets) { if (reCaptchaWidgets.hasOwnProperty(widgetId)) { grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]); } } }; } JS , View::POS_HEAD, 'renderReCaptchaCallbackFunction'); // Append new captcha widget info $view->registerJs(<<<JS reCaptchaWidgets.$id = $options; JS , View::POS_HEAD); }
php
public function registerClientScript($gCaptchaParams = []) { $id = $this->id; $view = $this->view; ReCaptchaAsset::register($view); $options = Json::encode($gCaptchaParams); // Directly creating captcha widgets. // This code placed only one time irrespective of count of captcha-widgets $view->registerJs(<<<JS if (typeof (renderReCaptchaCallback) === "undefined") { var reCaptchaWidgets = {}; var renderReCaptchaCallback = function() { for (var widgetId in reCaptchaWidgets) { if (reCaptchaWidgets.hasOwnProperty(widgetId)) { grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]); } } }; } JS , View::POS_HEAD, 'renderReCaptchaCallbackFunction'); // Append new captcha widget info $view->registerJs(<<<JS reCaptchaWidgets.$id = $options; JS , View::POS_HEAD); }
[ "public", "function", "registerClientScript", "(", "$", "gCaptchaParams", "=", "[", "]", ")", "{", "$", "id", "=", "$", "this", "->", "id", ";", "$", "view", "=", "$", "this", "->", "view", ";", "ReCaptchaAsset", "::", "register", "(", "$", "view", ")", ";", "$", "options", "=", "Json", "::", "encode", "(", "$", "gCaptchaParams", ")", ";", "// Directly creating captcha widgets.", "// This code placed only one time irrespective of count of captcha-widgets", "$", "view", "->", "registerJs", "(", "<<<JS\nif (typeof (renderReCaptchaCallback) === \"undefined\") {\n var reCaptchaWidgets = {};\n var renderReCaptchaCallback = function() {\n for (var widgetId in reCaptchaWidgets) {\n if (reCaptchaWidgets.hasOwnProperty(widgetId)) {\n grecaptcha.render(document.getElementById(widgetId), reCaptchaWidgets[widgetId]);\n }\n }\n };\n}\nJS", ",", "View", "::", "POS_HEAD", ",", "'renderReCaptchaCallbackFunction'", ")", ";", "// Append new captcha widget info", "$", "view", "->", "registerJs", "(", "<<<JS\nreCaptchaWidgets.$id = $options;\nJS", ",", "View", "::", "POS_HEAD", ")", ";", "}" ]
Register google reCAPTCHA js api and custom render scripts @param array $gCaptchaParams
[ "Register", "google", "reCAPTCHA", "js", "api", "and", "custom", "render", "scripts" ]
ecedd26b7e252c6d307365fbd9ab012a9ee33294
https://github.com/demisang/yii2-recaptcha/blob/ecedd26b7e252c6d307365fbd9ab012a9ee33294/ReCaptcha.php#L94-L123
13,942
venta/framework
src/Container/src/AbstractContainer.php
AbstractContainer.instantiateService
protected function instantiateService(string $id, array $arguments) { if (isset($this->instances[$id])) { return $this->instances[$id]; } if (isset($this->factories[$id])) { return ($this->factories[$id])($arguments); } if (isset($this->callableDefinitions[$id])) { $this->factories[$id] = $this->createServiceFactoryFromCallable($this->callableDefinitions[$id]); return $this->invokeFactory($id, $arguments); } $class = $this->classDefinitions[$id] ?? $id; if ($class !== $id) { // Recursive call allows to bind contract to contract. return $this->saveShared($id, $this->instantiateService($class, $arguments)); } if (!class_exists($class)) { throw new NotFoundException($id, $this->resolving); } $this->factories[$id] = $this->createServiceFactoryFromClass($class); return $this->invokeFactory($id, $arguments); }
php
protected function instantiateService(string $id, array $arguments) { if (isset($this->instances[$id])) { return $this->instances[$id]; } if (isset($this->factories[$id])) { return ($this->factories[$id])($arguments); } if (isset($this->callableDefinitions[$id])) { $this->factories[$id] = $this->createServiceFactoryFromCallable($this->callableDefinitions[$id]); return $this->invokeFactory($id, $arguments); } $class = $this->classDefinitions[$id] ?? $id; if ($class !== $id) { // Recursive call allows to bind contract to contract. return $this->saveShared($id, $this->instantiateService($class, $arguments)); } if (!class_exists($class)) { throw new NotFoundException($id, $this->resolving); } $this->factories[$id] = $this->createServiceFactoryFromClass($class); return $this->invokeFactory($id, $arguments); }
[ "protected", "function", "instantiateService", "(", "string", "$", "id", ",", "array", "$", "arguments", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "instances", "[", "$", "id", "]", ")", ")", "{", "return", "$", "this", "->", "instances", "[", "$", "id", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "factories", "[", "$", "id", "]", ")", ")", "{", "return", "(", "$", "this", "->", "factories", "[", "$", "id", "]", ")", "(", "$", "arguments", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "callableDefinitions", "[", "$", "id", "]", ")", ")", "{", "$", "this", "->", "factories", "[", "$", "id", "]", "=", "$", "this", "->", "createServiceFactoryFromCallable", "(", "$", "this", "->", "callableDefinitions", "[", "$", "id", "]", ")", ";", "return", "$", "this", "->", "invokeFactory", "(", "$", "id", ",", "$", "arguments", ")", ";", "}", "$", "class", "=", "$", "this", "->", "classDefinitions", "[", "$", "id", "]", "??", "$", "id", ";", "if", "(", "$", "class", "!==", "$", "id", ")", "{", "// Recursive call allows to bind contract to contract.", "return", "$", "this", "->", "saveShared", "(", "$", "id", ",", "$", "this", "->", "instantiateService", "(", "$", "class", ",", "$", "arguments", ")", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "NotFoundException", "(", "$", "id", ",", "$", "this", "->", "resolving", ")", ";", "}", "$", "this", "->", "factories", "[", "$", "id", "]", "=", "$", "this", "->", "createServiceFactoryFromClass", "(", "$", "class", ")", ";", "return", "$", "this", "->", "invokeFactory", "(", "$", "id", ",", "$", "arguments", ")", ";", "}" ]
Create callable factory for the subject service. @param string $id @param array $arguments @return mixed @throws NotFoundException
[ "Create", "callable", "factory", "for", "the", "subject", "service", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/AbstractContainer.php#L123-L150
13,943
venta/framework
src/Container/src/AbstractContainer.php
AbstractContainer.isResolvableService
protected function isResolvableService(string $id): bool { return isset($this->keys[$id]) || class_exists($id); }
php
protected function isResolvableService(string $id): bool { return isset($this->keys[$id]) || class_exists($id); }
[ "protected", "function", "isResolvableService", "(", "string", "$", "id", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "keys", "[", "$", "id", "]", ")", "||", "class_exists", "(", "$", "id", ")", ";", "}" ]
Check if container can resolve the service with subject identifier. @param string $id @return bool
[ "Check", "if", "container", "can", "resolve", "the", "service", "with", "subject", "identifier", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/AbstractContainer.php#L166-L169
13,944
venta/framework
src/Container/src/AbstractContainer.php
AbstractContainer.resolving
protected function resolving(string $id) { if (isset($this->resolving[$id])) { throw new CircularReferenceException($id, $this->resolving); } // We mark service as being resolved to detect circular references through out the resolution chain. $this->resolving[$id] = $id; }
php
protected function resolving(string $id) { if (isset($this->resolving[$id])) { throw new CircularReferenceException($id, $this->resolving); } // We mark service as being resolved to detect circular references through out the resolution chain. $this->resolving[$id] = $id; }
[ "protected", "function", "resolving", "(", "string", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "resolving", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "CircularReferenceException", "(", "$", "id", ",", "$", "this", "->", "resolving", ")", ";", "}", "// We mark service as being resolved to detect circular references through out the resolution chain.", "$", "this", "->", "resolving", "[", "$", "id", "]", "=", "$", "id", ";", "}" ]
Detects circular references. @param string $id @return void @throws CircularReferenceException
[ "Detects", "circular", "references", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/AbstractContainer.php#L207-L215
13,945
venta/framework
src/Container/src/AbstractContainer.php
AbstractContainer.createServiceFactoryFromCallable
private function createServiceFactoryFromCallable(Invokable $invokable): Closure { return function (array $arguments = []) use ($invokable) { return $this->invoker->invoke($invokable, $arguments); }; }
php
private function createServiceFactoryFromCallable(Invokable $invokable): Closure { return function (array $arguments = []) use ($invokable) { return $this->invoker->invoke($invokable, $arguments); }; }
[ "private", "function", "createServiceFactoryFromCallable", "(", "Invokable", "$", "invokable", ")", ":", "Closure", "{", "return", "function", "(", "array", "$", "arguments", "=", "[", "]", ")", "use", "(", "$", "invokable", ")", "{", "return", "$", "this", "->", "invoker", "->", "invoke", "(", "$", "invokable", ",", "$", "arguments", ")", ";", "}", ";", "}" ]
Create callable factory with resolved arguments from callable. @param Invokable $invokable @return Closure
[ "Create", "callable", "factory", "with", "resolved", "arguments", "from", "callable", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/AbstractContainer.php#L241-L246
13,946
venta/framework
src/Container/src/AbstractContainer.php
AbstractContainer.createServiceFactoryFromClass
private function createServiceFactoryFromClass(string $class): Closure { $reflection = new ReflectionClass($class); if (!$reflection->isInstantiable()) { throw new UninstantiableServiceException($class, $this->resolving); } $constructor = $reflection->getConstructor(); if ($constructor && $constructor->getNumberOfParameters() > 0) { if ($constructor->getDeclaringClass() !== $class) { $invokable = new Invokable([$class, '__construct']); } else { $invokable = new Invokable($constructor); } return function (array $arguments = []) use ($invokable) { return $this->invoker->invoke($invokable, $arguments); }; } return function () use ($class) { return new $class(); }; }
php
private function createServiceFactoryFromClass(string $class): Closure { $reflection = new ReflectionClass($class); if (!$reflection->isInstantiable()) { throw new UninstantiableServiceException($class, $this->resolving); } $constructor = $reflection->getConstructor(); if ($constructor && $constructor->getNumberOfParameters() > 0) { if ($constructor->getDeclaringClass() !== $class) { $invokable = new Invokable([$class, '__construct']); } else { $invokable = new Invokable($constructor); } return function (array $arguments = []) use ($invokable) { return $this->invoker->invoke($invokable, $arguments); }; } return function () use ($class) { return new $class(); }; }
[ "private", "function", "createServiceFactoryFromClass", "(", "string", "$", "class", ")", ":", "Closure", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "!", "$", "reflection", "->", "isInstantiable", "(", ")", ")", "{", "throw", "new", "UninstantiableServiceException", "(", "$", "class", ",", "$", "this", "->", "resolving", ")", ";", "}", "$", "constructor", "=", "$", "reflection", "->", "getConstructor", "(", ")", ";", "if", "(", "$", "constructor", "&&", "$", "constructor", "->", "getNumberOfParameters", "(", ")", ">", "0", ")", "{", "if", "(", "$", "constructor", "->", "getDeclaringClass", "(", ")", "!==", "$", "class", ")", "{", "$", "invokable", "=", "new", "Invokable", "(", "[", "$", "class", ",", "'__construct'", "]", ")", ";", "}", "else", "{", "$", "invokable", "=", "new", "Invokable", "(", "$", "constructor", ")", ";", "}", "return", "function", "(", "array", "$", "arguments", "=", "[", "]", ")", "use", "(", "$", "invokable", ")", "{", "return", "$", "this", "->", "invoker", "->", "invoke", "(", "$", "invokable", ",", "$", "arguments", ")", ";", "}", ";", "}", "return", "function", "(", ")", "use", "(", "$", "class", ")", "{", "return", "new", "$", "class", "(", ")", ";", "}", ";", "}" ]
Create callable factory with resolved arguments from class name. @param string $class @return Closure @throws UninstantiableServiceException
[ "Create", "callable", "factory", "with", "resolved", "arguments", "from", "class", "name", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Container/src/AbstractContainer.php#L255-L278
13,947
thienhungho/yii2-customer-management
src/modules/CustomerManage/controllers/CustomerController.php
CustomerController.actionIndex
public function actionIndex() { $searchModel = new CustomerSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex() { $searchModel = new CustomerSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "CustomerSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Lists all Customer models. @return mixed
[ "Lists", "all", "Customer", "models", "." ]
9283027541b34a86be85df592248909014968688
https://github.com/thienhungho/yii2-customer-management/blob/9283027541b34a86be85df592248909014968688/src/modules/CustomerManage/controllers/CustomerController.php#L34-L43
13,948
cauditor/php-analyzer
src/Config.php
Config.normalizePath
protected function normalizePath($value) { // array of paths = recursive if (is_array($value)) { foreach ($value as $i => $val) { $value[$i] = $this->normalizePath($val); } return $value; } $converter = new PathConverter(dirname($this->config['config_path']), $this->config['path']); return $converter->convert($value); }
php
protected function normalizePath($value) { // array of paths = recursive if (is_array($value)) { foreach ($value as $i => $val) { $value[$i] = $this->normalizePath($val); } return $value; } $converter = new PathConverter(dirname($this->config['config_path']), $this->config['path']); return $converter->convert($value); }
[ "protected", "function", "normalizePath", "(", "$", "value", ")", "{", "// array of paths = recursive", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "i", "=>", "$", "val", ")", "{", "$", "value", "[", "$", "i", "]", "=", "$", "this", "->", "normalizePath", "(", "$", "val", ")", ";", "}", "return", "$", "value", ";", "}", "$", "converter", "=", "new", "PathConverter", "(", "dirname", "(", "$", "this", "->", "config", "[", "'config_path'", "]", ")", ",", "$", "this", "->", "config", "[", "'path'", "]", ")", ";", "return", "$", "converter", "->", "convert", "(", "$", "value", ")", ";", "}" ]
Normalize all relative paths by prefixing them with the project path. @param string|string[] $value @return string|string[]
[ "Normalize", "all", "relative", "paths", "by", "prefixing", "them", "with", "the", "project", "path", "." ]
0d86686d64d01e6aaed433898841894fa3ce1101
https://github.com/cauditor/php-analyzer/blob/0d86686d64d01e6aaed433898841894fa3ce1101/src/Config.php#L127-L141
13,949
Im0rtality/Underscore
src/Mutator.php
Mutator.copyCollectionWith
protected function copyCollectionWith(Collection $collection, array $values) { $collection = clone $collection; $collection->exchangeArray($values); return $collection; }
php
protected function copyCollectionWith(Collection $collection, array $values) { $collection = clone $collection; $collection->exchangeArray($values); return $collection; }
[ "protected", "function", "copyCollectionWith", "(", "Collection", "$", "collection", ",", "array", "$", "values", ")", "{", "$", "collection", "=", "clone", "$", "collection", ";", "$", "collection", "->", "exchangeArray", "(", "$", "values", ")", ";", "return", "$", "collection", ";", "}" ]
Get a copy of a collection with new values. @param Collection $collection @param array $values @return Collection
[ "Get", "a", "copy", "of", "a", "collection", "with", "new", "values", "." ]
2deb95cfd340761d00ecd0f033e67ce600f2b535
https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Mutator.php#L14-L21
13,950
bantenprov/tanara
app/Http/Controllers/Settings/ProfileController.php
ProfileController.update
public function update(Request $request) { $user = $request->user(); $this->validate($request, [ 'name' => 'required', 'email' => 'required|email|unique:users,email,'.$user->id, ]); return tap($user)->update($request->only('name', 'email')); }
php
public function update(Request $request) { $user = $request->user(); $this->validate($request, [ 'name' => 'required', 'email' => 'required|email|unique:users,email,'.$user->id, ]); return tap($user)->update($request->only('name', 'email')); }
[ "public", "function", "update", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "$", "request", "->", "user", "(", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'name'", "=>", "'required'", ",", "'email'", "=>", "'required|email|unique:users,email,'", ".", "$", "user", "->", "id", ",", "]", ")", ";", "return", "tap", "(", "$", "user", ")", "->", "update", "(", "$", "request", "->", "only", "(", "'name'", ",", "'email'", ")", ")", ";", "}" ]
Update the user's profile information. @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Update", "the", "user", "s", "profile", "information", "." ]
e70b027cbbc59bb57a31fa3c7347e7eae87671c3
https://github.com/bantenprov/tanara/blob/e70b027cbbc59bb57a31fa3c7347e7eae87671c3/app/Http/Controllers/Settings/ProfileController.php#L16-L26
13,951
DevGroup-ru/yii2-data-structure-tools
src/helpers/PropertyStorageHelper.php
PropertyStorageHelper.storageById
public static function storageById($id) { $handlers = self::storageHandlers(); if (isset($handlers[$id])) { return $handlers[$id]; } else { throw new ServerErrorHttpException("Storage handler with id $id not found."); } }
php
public static function storageById($id) { $handlers = self::storageHandlers(); if (isset($handlers[$id])) { return $handlers[$id]; } else { throw new ServerErrorHttpException("Storage handler with id $id not found."); } }
[ "public", "static", "function", "storageById", "(", "$", "id", ")", "{", "$", "handlers", "=", "self", "::", "storageHandlers", "(", ")", ";", "if", "(", "isset", "(", "$", "handlers", "[", "$", "id", "]", ")", ")", "{", "return", "$", "handlers", "[", "$", "id", "]", ";", "}", "else", "{", "throw", "new", "ServerErrorHttpException", "(", "\"Storage handler with id $id not found.\"", ")", ";", "}", "}" ]
Returns AbstractPropertyStorage instance by PropertyStorage.id @param integer $id @return \DevGroup\DataStructure\propertyStorage\AbstractPropertyStorage @throws ServerErrorHttpException
[ "Returns", "AbstractPropertyStorage", "instance", "by", "PropertyStorage", ".", "id" ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/helpers/PropertyStorageHelper.php#L110-L118
13,952
DevGroup-ru/yii2-data-structure-tools
src/helpers/PropertyStorageHelper.php
PropertyStorageHelper.storageIdByClass
public static function storageIdByClass($className) { foreach (self::storageHandlers() as $id => $handler) { if ($handler instanceof $className) { return $id; } } return null; }
php
public static function storageIdByClass($className) { foreach (self::storageHandlers() as $id => $handler) { if ($handler instanceof $className) { return $id; } } return null; }
[ "public", "static", "function", "storageIdByClass", "(", "$", "className", ")", "{", "foreach", "(", "self", "::", "storageHandlers", "(", ")", "as", "$", "id", "=>", "$", "handler", ")", "{", "if", "(", "$", "handler", "instanceof", "$", "className", ")", "{", "return", "$", "id", ";", "}", "}", "return", "null", ";", "}" ]
Return a property storage id by storage class name. @param string $className @return int|null|string
[ "Return", "a", "property", "storage", "id", "by", "storage", "class", "name", "." ]
a5b24d7c0b24d4b0d58cacd91ec7fd876e979097
https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/helpers/PropertyStorageHelper.php#L125-L133
13,953
dphn/ScContent
src/ScContent/Controller/Back/GarbageController.php
GarbageController.collectAction
public function collectAction() { // @todo json $service = $this->getGarbageCollector(); if ($service->collect()) { return $this->redirect()->toRoute('sc-admin/content-manager'); } return $this->redirect() ->toRoute( 'sc-admin/file/delete', ['random' => Stdlib::randomKey(6)] ) ->setStatusCode(303); }
php
public function collectAction() { // @todo json $service = $this->getGarbageCollector(); if ($service->collect()) { return $this->redirect()->toRoute('sc-admin/content-manager'); } return $this->redirect() ->toRoute( 'sc-admin/file/delete', ['random' => Stdlib::randomKey(6)] ) ->setStatusCode(303); }
[ "public", "function", "collectAction", "(", ")", "{", "// @todo json", "$", "service", "=", "$", "this", "->", "getGarbageCollector", "(", ")", ";", "if", "(", "$", "service", "->", "collect", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'sc-admin/content-manager'", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'sc-admin/file/delete'", ",", "[", "'random'", "=>", "Stdlib", "::", "randomKey", "(", "6", ")", "]", ")", "->", "setStatusCode", "(", "303", ")", ";", "}" ]
Collects garbage - removes files from the file system. @return \Zend\Stdlib\ResponseInterface
[ "Collects", "garbage", "-", "removes", "files", "from", "the", "file", "system", "." ]
9dd5732490c45fd788b96cedf7b3c7adfacb30d2
https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/GarbageController.php#L32-L45
13,954
ipunkt/social-auth
src/controllers/SocialRegisterController.php
SocialRegisterController.auth
public function auth($provider_name, &$profile = null) { $identifier = null; try { $provider = $this->hybrid_auth->authenticate($provider_name); $userProfile = $provider->getUserProfile(); $identifier = $userProfile->identifier; $profile = $userProfile; } catch (\Exception $e) { dd($e->getMessage()); } return $identifier; }
php
public function auth($provider_name, &$profile = null) { $identifier = null; try { $provider = $this->hybrid_auth->authenticate($provider_name); $userProfile = $provider->getUserProfile(); $identifier = $userProfile->identifier; $profile = $userProfile; } catch (\Exception $e) { dd($e->getMessage()); } return $identifier; }
[ "public", "function", "auth", "(", "$", "provider_name", ",", "&", "$", "profile", "=", "null", ")", "{", "$", "identifier", "=", "null", ";", "try", "{", "$", "provider", "=", "$", "this", "->", "hybrid_auth", "->", "authenticate", "(", "$", "provider_name", ")", ";", "$", "userProfile", "=", "$", "provider", "->", "getUserProfile", "(", ")", ";", "$", "identifier", "=", "$", "userProfile", "->", "identifier", ";", "$", "profile", "=", "$", "userProfile", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "dd", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "identifier", ";", "}" ]
Prompt the User to authenticate with a social-auth provider @param $provider_name @param null $profile @return null
[ "Prompt", "the", "User", "to", "authenticate", "with", "a", "social", "-", "auth", "provider" ]
28723a8e449612789a2cd7d21137996c48b62229
https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/controllers/SocialRegisterController.php#L56-L68
13,955
ipunkt/social-auth
src/controllers/SocialRegisterController.php
SocialRegisterController.attach
public function attach($provider_name) { $response = null; $profile = null; $identifier = $this->auth($provider_name, $profile); if(!$this->checkRegistered($provider_name, $identifier)) { $id = Auth::user()->getAuthIdentifier(); $login = $this->login_repository->create(); $login->setProvider($provider_name); $login->setIdentifier($identifier); $login->setUser($id); if($this->login_repository->save($login)) { $providers = SocialAuth::getConnectedProviders(); $socialProfile = $providers[$provider_name]->getProfile(); Event::fire('social-auth.attach', ['user' => Auth::user(), 'provider' => $provider_name, 'profile' => $socialProfile]); $response = Redirect::back()->with(['message' => trans('social-auth::user.account attach success', ['provider' => $provider_name, 'accountname' => $socialProfile->getDisplayName()])]); } else { $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account attach fail', ['accoutnname' => $profile->displayName])]); } } else { $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]) ]); } return $response; }
php
public function attach($provider_name) { $response = null; $profile = null; $identifier = $this->auth($provider_name, $profile); if(!$this->checkRegistered($provider_name, $identifier)) { $id = Auth::user()->getAuthIdentifier(); $login = $this->login_repository->create(); $login->setProvider($provider_name); $login->setIdentifier($identifier); $login->setUser($id); if($this->login_repository->save($login)) { $providers = SocialAuth::getConnectedProviders(); $socialProfile = $providers[$provider_name]->getProfile(); Event::fire('social-auth.attach', ['user' => Auth::user(), 'provider' => $provider_name, 'profile' => $socialProfile]); $response = Redirect::back()->with(['message' => trans('social-auth::user.account attach success', ['provider' => $provider_name, 'accountname' => $socialProfile->getDisplayName()])]); } else { $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account attach fail', ['accoutnname' => $profile->displayName])]); } } else { $response = Redirect::back()->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]) ]); } return $response; }
[ "public", "function", "attach", "(", "$", "provider_name", ")", "{", "$", "response", "=", "null", ";", "$", "profile", "=", "null", ";", "$", "identifier", "=", "$", "this", "->", "auth", "(", "$", "provider_name", ",", "$", "profile", ")", ";", "if", "(", "!", "$", "this", "->", "checkRegistered", "(", "$", "provider_name", ",", "$", "identifier", ")", ")", "{", "$", "id", "=", "Auth", "::", "user", "(", ")", "->", "getAuthIdentifier", "(", ")", ";", "$", "login", "=", "$", "this", "->", "login_repository", "->", "create", "(", ")", ";", "$", "login", "->", "setProvider", "(", "$", "provider_name", ")", ";", "$", "login", "->", "setIdentifier", "(", "$", "identifier", ")", ";", "$", "login", "->", "setUser", "(", "$", "id", ")", ";", "if", "(", "$", "this", "->", "login_repository", "->", "save", "(", "$", "login", ")", ")", "{", "$", "providers", "=", "SocialAuth", "::", "getConnectedProviders", "(", ")", ";", "$", "socialProfile", "=", "$", "providers", "[", "$", "provider_name", "]", "->", "getProfile", "(", ")", ";", "Event", "::", "fire", "(", "'social-auth.attach'", ",", "[", "'user'", "=>", "Auth", "::", "user", "(", ")", ",", "'provider'", "=>", "$", "provider_name", ",", "'profile'", "=>", "$", "socialProfile", "]", ")", ";", "$", "response", "=", "Redirect", "::", "back", "(", ")", "->", "with", "(", "[", "'message'", "=>", "trans", "(", "'social-auth::user.account attach success'", ",", "[", "'provider'", "=>", "$", "provider_name", ",", "'accountname'", "=>", "$", "socialProfile", "->", "getDisplayName", "(", ")", "]", ")", "]", ")", ";", "}", "else", "{", "$", "response", "=", "Redirect", "::", "back", "(", ")", "->", "withErrors", "(", "[", "'message'", "=>", "trans", "(", "'social-auth::user.account attach fail'", ",", "[", "'accoutnname'", "=>", "$", "profile", "->", "displayName", "]", ")", "]", ")", ";", "}", "}", "else", "{", "$", "response", "=", "Redirect", "::", "back", "(", ")", "->", "withErrors", "(", "[", "'message'", "=>", "trans", "(", "'social-auth::user.account already registered'", ",", "[", "'accountname'", "=>", "$", "profile", "->", "displayName", "]", ")", "]", ")", ";", "}", "return", "$", "response", ";", "}" ]
Attempt to login to a social-auth provider If successful, attach the social-auth user to the currently logged in user on this system @param $provider_name @return \Illuminate\Http\RedirectResponse|null
[ "Attempt", "to", "login", "to", "a", "social", "-", "auth", "provider", "If", "successful", "attach", "the", "social", "-", "auth", "user", "to", "the", "currently", "logged", "in", "user", "on", "this", "system" ]
28723a8e449612789a2cd7d21137996c48b62229
https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/controllers/SocialRegisterController.php#L90-L120
13,956
ipunkt/social-auth
src/controllers/SocialRegisterController.php
SocialRegisterController.register
public function register($provider_name) { $response = null; $profile = null; $route = Config::get('social-auth::register_route'); $identifier = $this->auth($provider_name, $profile); if(!$this->checkRegistered($provider_name, $identifier)) { $register_info = App::make('Ipunkt\SocialAuth\RegisterInfo'); /** * @var RegisterInfo $register_info */ $register_info->setProvider($provider_name); SocialAuth::setRegistration($register_info); $response = Redirect::route($route); } else { $response = Redirect::route($route)->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]), ['accountname' => $profile->displayName]]); } return $response; }
php
public function register($provider_name) { $response = null; $profile = null; $route = Config::get('social-auth::register_route'); $identifier = $this->auth($provider_name, $profile); if(!$this->checkRegistered($provider_name, $identifier)) { $register_info = App::make('Ipunkt\SocialAuth\RegisterInfo'); /** * @var RegisterInfo $register_info */ $register_info->setProvider($provider_name); SocialAuth::setRegistration($register_info); $response = Redirect::route($route); } else { $response = Redirect::route($route)->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]), ['accountname' => $profile->displayName]]); } return $response; }
[ "public", "function", "register", "(", "$", "provider_name", ")", "{", "$", "response", "=", "null", ";", "$", "profile", "=", "null", ";", "$", "route", "=", "Config", "::", "get", "(", "'social-auth::register_route'", ")", ";", "$", "identifier", "=", "$", "this", "->", "auth", "(", "$", "provider_name", ",", "$", "profile", ")", ";", "if", "(", "!", "$", "this", "->", "checkRegistered", "(", "$", "provider_name", ",", "$", "identifier", ")", ")", "{", "$", "register_info", "=", "App", "::", "make", "(", "'Ipunkt\\SocialAuth\\RegisterInfo'", ")", ";", "/**\n * @var RegisterInfo $register_info\n */", "$", "register_info", "->", "setProvider", "(", "$", "provider_name", ")", ";", "SocialAuth", "::", "setRegistration", "(", "$", "register_info", ")", ";", "$", "response", "=", "Redirect", "::", "route", "(", "$", "route", ")", ";", "}", "else", "{", "$", "response", "=", "Redirect", "::", "route", "(", "$", "route", ")", "->", "withErrors", "(", "[", "'message'", "=>", "trans", "(", "'social-auth::user.account already registered'", ",", "[", "'accountname'", "=>", "$", "profile", "->", "displayName", "]", ")", ",", "[", "'accountname'", "=>", "$", "profile", "->", "displayName", "]", "]", ")", ";", "}", "return", "$", "response", ";", "}" ]
Login into a social-auth account intending to register a new user with it It is considered successful if the user logs into the social-auth account and the account is not yet attached to a different Account on this system. If Successful it will redirect back to the register page as set in the config and flash a new registerInfo => ProfileRegisterInfo object to the register page. On successful registration it is necessary to call registerInfo->success(newUser) to actualy attach the social-auth user to the newly registered user @see ProfileRegisterInfo @param $provider_name @return \Illuminate\Http\RedirectResponse|null
[ "Login", "into", "a", "social", "-", "auth", "account", "intending", "to", "register", "a", "new", "user", "with", "it", "It", "is", "considered", "successful", "if", "the", "user", "logs", "into", "the", "social", "-", "auth", "account", "and", "the", "account", "is", "not", "yet", "attached", "to", "a", "different", "Account", "on", "this", "system", "." ]
28723a8e449612789a2cd7d21137996c48b62229
https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/controllers/SocialRegisterController.php#L136-L158
13,957
guillaumemonet/Rad
src/Rad/Http/Uri.php
Uri.isURL
public static function isURL(string $url): bool { return (boolean) !(filter_var($url, FILTER_SANITIZE_URL | FILTER_VALIDATE_URL) === false); }
php
public static function isURL(string $url): bool { return (boolean) !(filter_var($url, FILTER_SANITIZE_URL | FILTER_VALIDATE_URL) === false); }
[ "public", "static", "function", "isURL", "(", "string", "$", "url", ")", ":", "bool", "{", "return", "(", "boolean", ")", "!", "(", "filter_var", "(", "$", "url", ",", "FILTER_SANITIZE_URL", "|", "FILTER_VALIDATE_URL", ")", "===", "false", ")", ";", "}" ]
Valid if current provided string is an URL @param string $url @return bool
[ "Valid", "if", "current", "provided", "string", "is", "an", "URL" ]
cb9932f570cf3c2a7197f81e1d959c2729989e59
https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Http/Uri.php#L51-L53
13,958
andylolz/everypolitician-popolo-php
src/Collections/PopoloCollection.php
PopoloCollection.filter
public function filter($filters) { $filtered = []; foreach ($this->objectArr as $obj) { $success = true; foreach ($filters as $prop => $value) { if ($obj->$prop !== $value) { $success = false; break; } } if ($success) { $filtered[] = $obj; } } return $filtered; }
php
public function filter($filters) { $filtered = []; foreach ($this->objectArr as $obj) { $success = true; foreach ($filters as $prop => $value) { if ($obj->$prop !== $value) { $success = false; break; } } if ($success) { $filtered[] = $obj; } } return $filtered; }
[ "public", "function", "filter", "(", "$", "filters", ")", "{", "$", "filtered", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "objectArr", "as", "$", "obj", ")", "{", "$", "success", "=", "true", ";", "foreach", "(", "$", "filters", "as", "$", "prop", "=>", "$", "value", ")", "{", "if", "(", "$", "obj", "->", "$", "prop", "!==", "$", "value", ")", "{", "$", "success", "=", "false", ";", "break", ";", "}", "}", "if", "(", "$", "success", ")", "{", "$", "filtered", "[", "]", "=", "$", "obj", ";", "}", "}", "return", "$", "filtered", ";", "}" ]
Gets an array of matching items, according to the array of filters provided. Filters are key-value pairs that are ANDed together, i.e. returned items match all the criteria @param string[] $filters key-value set of criteria @return object[]
[ "Gets", "an", "array", "of", "matching", "items", "according", "to", "the", "array", "of", "filters", "provided", ".", "Filters", "are", "key", "-", "value", "pairs", "that", "are", "ANDed", "together", "i", ".", "e", ".", "returned", "items", "match", "all", "the", "criteria" ]
701fca91b782871d463cfb56f3c1c7afb121eb9f
https://github.com/andylolz/everypolitician-popolo-php/blob/701fca91b782871d463cfb56f3c1c7afb121eb9f/src/Collections/PopoloCollection.php#L83-L99
13,959
andylolz/everypolitician-popolo-php
src/Collections/PopoloCollection.php
PopoloCollection.get
public function get($filters) { $matches = $this->filter($filters); $n = count($matches); if ($n == 0) { $msg = "No ".$this->objectClass." found matching ".json_encode($filters); throw new Exceptions\ObjectDoesNotExistException($msg); } elseif ($n > 1) { $msg = "Multiple ".$this->objectClass." objects ($n) found matching ".json_encode($filters); throw new Exceptions\MultipleObjectsReturnedException($msg); } return $matches[0]; }
php
public function get($filters) { $matches = $this->filter($filters); $n = count($matches); if ($n == 0) { $msg = "No ".$this->objectClass." found matching ".json_encode($filters); throw new Exceptions\ObjectDoesNotExistException($msg); } elseif ($n > 1) { $msg = "Multiple ".$this->objectClass." objects ($n) found matching ".json_encode($filters); throw new Exceptions\MultipleObjectsReturnedException($msg); } return $matches[0]; }
[ "public", "function", "get", "(", "$", "filters", ")", "{", "$", "matches", "=", "$", "this", "->", "filter", "(", "$", "filters", ")", ";", "$", "n", "=", "count", "(", "$", "matches", ")", ";", "if", "(", "$", "n", "==", "0", ")", "{", "$", "msg", "=", "\"No \"", ".", "$", "this", "->", "objectClass", ".", "\" found matching \"", ".", "json_encode", "(", "$", "filters", ")", ";", "throw", "new", "Exceptions", "\\", "ObjectDoesNotExistException", "(", "$", "msg", ")", ";", "}", "elseif", "(", "$", "n", ">", "1", ")", "{", "$", "msg", "=", "\"Multiple \"", ".", "$", "this", "->", "objectClass", ".", "\" objects ($n) found matching \"", ".", "json_encode", "(", "$", "filters", ")", ";", "throw", "new", "Exceptions", "\\", "MultipleObjectsReturnedException", "(", "$", "msg", ")", ";", "}", "return", "$", "matches", "[", "0", "]", ";", "}" ]
Gets a single matching item, according to the array of filters provided. Filters are key-value pairs that are ANDed together, i.e. returned items match all the criteria. If more or less than one item matches, an exception is thrown @param string[] $filters key-value set of criteria @return object
[ "Gets", "a", "single", "matching", "item", "according", "to", "the", "array", "of", "filters", "provided", ".", "Filters", "are", "key", "-", "value", "pairs", "that", "are", "ANDed", "together", "i", ".", "e", ".", "returned", "items", "match", "all", "the", "criteria", ".", "If", "more", "or", "less", "than", "one", "item", "matches", "an", "exception", "is", "thrown" ]
701fca91b782871d463cfb56f3c1c7afb121eb9f
https://github.com/andylolz/everypolitician-popolo-php/blob/701fca91b782871d463cfb56f3c1c7afb121eb9f/src/Collections/PopoloCollection.php#L112-L124
13,960
attm2x/m2x-php
src/StreamCollection.php
StreamCollection.setResource
protected function setResource($i, $data) { $this->resources[$i] = new static::$resourceClass($this->client, $this->parent, $data); }
php
protected function setResource($i, $data) { $this->resources[$i] = new static::$resourceClass($this->client, $this->parent, $data); }
[ "protected", "function", "setResource", "(", "$", "i", ",", "$", "data", ")", "{", "$", "this", "->", "resources", "[", "$", "i", "]", "=", "new", "static", "::", "$", "resourceClass", "(", "$", "this", "->", "client", ",", "$", "this", "->", "parent", ",", "$", "data", ")", ";", "}" ]
Initialize and add a resource to the collection @param integer $i @param array $data
[ "Initialize", "and", "add", "a", "resource", "to", "the", "collection" ]
4c2ff6d70af50538818855e648af24bf5cf16ead
https://github.com/attm2x/m2x-php/blob/4c2ff6d70af50538818855e648af24bf5cf16ead/src/StreamCollection.php#L68-L70
13,961
cpliakas/search-framework
src/Search/Framework/SearchEngineAbstract.php
SearchEngineAbstract.getNormalizer
public function getNormalizer($data_type) { if (!isset($this->_normalizers[$data_type])) { $message = 'Normalizer not attached for data type: ' . $data_type; throw new \InvalidArgumentException($message); } return $this->_normalizers[$data_type]; }
php
public function getNormalizer($data_type) { if (!isset($this->_normalizers[$data_type])) { $message = 'Normalizer not attached for data type: ' . $data_type; throw new \InvalidArgumentException($message); } return $this->_normalizers[$data_type]; }
[ "public", "function", "getNormalizer", "(", "$", "data_type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_normalizers", "[", "$", "data_type", "]", ")", ")", "{", "$", "message", "=", "'Normalizer not attached for data type: '", ".", "$", "data_type", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "message", ")", ";", "}", "return", "$", "this", "->", "_normalizers", "[", "$", "data_type", "]", ";", "}" ]
Returns a mormalizer that is applied to fields of the given data type. @param string $data_type The data type the normalizer is applied to. @return NormalizerInterface
[ "Returns", "a", "mormalizer", "that", "is", "applied", "to", "fields", "of", "the", "given", "data", "type", "." ]
7c5832d38ed998e04837c26e0daef59115563b98
https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/SearchEngineAbstract.php#L149-L156
13,962
gorkalaucirica/HipchatAPIv2Client
Client.php
Client.get
public function get($resource, $query = array()) { $url = $this->baseUrl . $resource; if (count($query) > 0) { $url .= "?"; } foreach ($query as $key => $value) { $url .= "$key=$value&"; } $headers = array("Authorization" => $this->auth->getCredential()); try { $response = $this->browser->get($url, $headers); } catch (\Buzz\Exception\ClientException $e) { throw new RequestException($e->getMessage()); } if ($this->browser->getLastResponse()->getStatusCode() > 299) { throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true)); } return json_decode($response->getContent(), true); }
php
public function get($resource, $query = array()) { $url = $this->baseUrl . $resource; if (count($query) > 0) { $url .= "?"; } foreach ($query as $key => $value) { $url .= "$key=$value&"; } $headers = array("Authorization" => $this->auth->getCredential()); try { $response = $this->browser->get($url, $headers); } catch (\Buzz\Exception\ClientException $e) { throw new RequestException($e->getMessage()); } if ($this->browser->getLastResponse()->getStatusCode() > 299) { throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true)); } return json_decode($response->getContent(), true); }
[ "public", "function", "get", "(", "$", "resource", ",", "$", "query", "=", "array", "(", ")", ")", "{", "$", "url", "=", "$", "this", "->", "baseUrl", ".", "$", "resource", ";", "if", "(", "count", "(", "$", "query", ")", ">", "0", ")", "{", "$", "url", ".=", "\"?\"", ";", "}", "foreach", "(", "$", "query", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "url", ".=", "\"$key=$value&\"", ";", "}", "$", "headers", "=", "array", "(", "\"Authorization\"", "=>", "$", "this", "->", "auth", "->", "getCredential", "(", ")", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "browser", "->", "get", "(", "$", "url", ",", "$", "headers", ")", ";", "}", "catch", "(", "\\", "Buzz", "\\", "Exception", "\\", "ClientException", "$", "e", ")", "{", "throw", "new", "RequestException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "browser", "->", "getLastResponse", "(", ")", "->", "getStatusCode", "(", ")", ">", "299", ")", "{", "throw", "new", "RequestException", "(", "json_decode", "(", "$", "this", "->", "browser", "->", "getLastResponse", "(", ")", "->", "getContent", "(", ")", ",", "true", ")", ")", ";", "}", "return", "json_decode", "(", "$", "response", "->", "getContent", "(", ")", ",", "true", ")", ";", "}" ]
Common get request for all API calls @param string $resource The path to the resource wanted. For example v2/room @param array $query Parameters to filter the response for example array('max-results' => 50) @return array Decoded array containing response @throws Exception\RequestException
[ "Common", "get", "request", "for", "all", "API", "calls" ]
eef9c91d5efe5ae9cad27c503601ffff089c9547
https://github.com/gorkalaucirica/HipchatAPIv2Client/blob/eef9c91d5efe5ae9cad27c503601ffff089c9547/Client.php#L64-L88
13,963
gorkalaucirica/HipchatAPIv2Client
Client.php
Client.post
public function post($resource, $content) { $url = $this->baseUrl . $resource; $headers = array( 'Content-Type' => 'application/json', 'Authorization' => $this->auth->getCredential() ); try { $response = $this->browser->post($url, $headers, json_encode($content)); } catch (\Buzz\Exception\ClientException $e) { throw new RequestException($e->getMessage()); } if ($this->browser->getLastResponse()->getStatusCode() > 299) { throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true)); } return json_decode($response->getContent(), true); }
php
public function post($resource, $content) { $url = $this->baseUrl . $resource; $headers = array( 'Content-Type' => 'application/json', 'Authorization' => $this->auth->getCredential() ); try { $response = $this->browser->post($url, $headers, json_encode($content)); } catch (\Buzz\Exception\ClientException $e) { throw new RequestException($e->getMessage()); } if ($this->browser->getLastResponse()->getStatusCode() > 299) { throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true)); } return json_decode($response->getContent(), true); }
[ "public", "function", "post", "(", "$", "resource", ",", "$", "content", ")", "{", "$", "url", "=", "$", "this", "->", "baseUrl", ".", "$", "resource", ";", "$", "headers", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ",", "'Authorization'", "=>", "$", "this", "->", "auth", "->", "getCredential", "(", ")", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "browser", "->", "post", "(", "$", "url", ",", "$", "headers", ",", "json_encode", "(", "$", "content", ")", ")", ";", "}", "catch", "(", "\\", "Buzz", "\\", "Exception", "\\", "ClientException", "$", "e", ")", "{", "throw", "new", "RequestException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "browser", "->", "getLastResponse", "(", ")", "->", "getStatusCode", "(", ")", ">", "299", ")", "{", "throw", "new", "RequestException", "(", "json_decode", "(", "$", "this", "->", "browser", "->", "getLastResponse", "(", ")", "->", "getContent", "(", ")", ",", "true", ")", ")", ";", "}", "return", "json_decode", "(", "$", "response", "->", "getContent", "(", ")", ",", "true", ")", ";", "}" ]
Common post request for all API calls @param string $resource The path to the resource wanted. For example v2/room @param array $content Parameters be posted for example: array( 'name' => 'Example name', 'privacy' => 'private', 'is_archived' => 'false', 'is_guest_accessible' => 'false', 'topic' => 'New topic', ) @return array Decoded array containing response @throws Exception\RequestException
[ "Common", "post", "request", "for", "all", "API", "calls" ]
eef9c91d5efe5ae9cad27c503601ffff089c9547
https://github.com/gorkalaucirica/HipchatAPIv2Client/blob/eef9c91d5efe5ae9cad27c503601ffff089c9547/Client.php#L106-L126
13,964
chippyash/Strong-Type
src/Chippyash/Type/String/DigitType.php
DigitType.filter
protected function filter($value) { if (!is_scalar($value)) { return $value; } $value = (string) $value; if (!$this->hasPcreUnicodeSupport()) { // POSIX named classes are not supported, use alternative 0-9 match return preg_replace('/[^0-9]/', '', $value); } if (extension_loaded('mbstring')) { // Filter for the value with mbstring return preg_replace('/[^[:digit:]]/', '', $value); } // Filter for the value without mbstring return preg_replace('/[\p{^N}]/', '', $value); }
php
protected function filter($value) { if (!is_scalar($value)) { return $value; } $value = (string) $value; if (!$this->hasPcreUnicodeSupport()) { // POSIX named classes are not supported, use alternative 0-9 match return preg_replace('/[^0-9]/', '', $value); } if (extension_loaded('mbstring')) { // Filter for the value with mbstring return preg_replace('/[^[:digit:]]/', '', $value); } // Filter for the value without mbstring return preg_replace('/[\p{^N}]/', '', $value); }
[ "protected", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "(", "string", ")", "$", "value", ";", "if", "(", "!", "$", "this", "->", "hasPcreUnicodeSupport", "(", ")", ")", "{", "// POSIX named classes are not supported, use alternative 0-9 match", "return", "preg_replace", "(", "'/[^0-9]/'", ",", "''", ",", "$", "value", ")", ";", "}", "if", "(", "extension_loaded", "(", "'mbstring'", ")", ")", "{", "// Filter for the value with mbstring", "return", "preg_replace", "(", "'/[^[:digit:]]/'", ",", "''", ",", "$", "value", ")", ";", "}", "// Filter for the value without mbstring", "return", "preg_replace", "(", "'/[\\p{^N}]/'", ",", "''", ",", "$", "value", ")", ";", "}" ]
Lifted entirely from the Zend framework so that we don't have to include the Zend\Filter package and all its dependencies. @param string $value @return string|mixed zendframework/zend-filter/Zend/Filter/Digits.php Zend Framework (http://framework.zend.com/) @link http://github.com/zendframework/zf2 for the canonical source repository @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) @license http://framework.zend.com/license/new-bsd New BSD License Defined by Zend\Filter\FilterInterface Returns the string $value, removing all but digit characters If the value provided is non-scalar, the value will remain unfiltered
[ "Lifted", "entirely", "from", "the", "Zend", "framework", "so", "that", "we", "don", "t", "have", "to", "include", "the", "Zend", "\\", "Filter", "package", "and", "all", "its", "dependencies", "." ]
9d364c10c68c10f768254fb25b0b1db3dbef6fa9
https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/String/DigitType.php#L62-L81
13,965
f3ath/appnexusclient
src/AppNexusClient.php
AppNexusClient.getNewToken
public function getNewToken() { $post = array( 'auth' => array( 'username' => $this->username, 'password' => $this->password, ), ); return $this->http->call(HttpMethod::POST, $this->host.'/auth', $post)->token; }
php
public function getNewToken() { $post = array( 'auth' => array( 'username' => $this->username, 'password' => $this->password, ), ); return $this->http->call(HttpMethod::POST, $this->host.'/auth', $post)->token; }
[ "public", "function", "getNewToken", "(", ")", "{", "$", "post", "=", "array", "(", "'auth'", "=>", "array", "(", "'username'", "=>", "$", "this", "->", "username", ",", "'password'", "=>", "$", "this", "->", "password", ",", ")", ",", ")", ";", "return", "$", "this", "->", "http", "->", "call", "(", "HttpMethod", "::", "POST", ",", "$", "this", "->", "host", ".", "'/auth'", ",", "$", "post", ")", "->", "token", ";", "}" ]
Get a new auth token from server @return string
[ "Get", "a", "new", "auth", "token", "from", "server" ]
cfe3f3a98a9c2883484154c8997c7459b1504742
https://github.com/f3ath/appnexusclient/blob/cfe3f3a98a9c2883484154c8997c7459b1504742/src/AppNexusClient.php#L35-L44
13,966
ahmad-sa3d/saad-image
src/Image.php
Image.setSaveOptions
public function setSaveOptions($file_name = null, $directory = null, $suffix = null) { # Set Directory, or use Old if setted before from instance, or use img src directory if ($directory) { $this->_save_dir = rtrim($directory, DIRECTORY_SEPARATOR); } else if (!$this->_save_dir) { $this->_save_dir = $this->_image_info['dirname']; } // Check Directory if (!is_dir($directory)) { mkdir($directory, 0755, true); } else if (!is_writable($directory)) { chmod($directory, 0755); } # Set Filename if ($file_name) { $this->_save_name = basename($file_name, '.' . pathinfo($file_name, PATHINFO_EXTENSION)) . $suffix . '.' . $this->_output_format; } else if (!$this->_save_name) { $this->_save_name = $this->_image_info['filename'] . $suffix . '.' . $this->_output_format; } $this->_save_path = $this->_save_dir . DIRECTORY_SEPARATOR . $this->_save_name; return $this; # Method End }
php
public function setSaveOptions($file_name = null, $directory = null, $suffix = null) { # Set Directory, or use Old if setted before from instance, or use img src directory if ($directory) { $this->_save_dir = rtrim($directory, DIRECTORY_SEPARATOR); } else if (!$this->_save_dir) { $this->_save_dir = $this->_image_info['dirname']; } // Check Directory if (!is_dir($directory)) { mkdir($directory, 0755, true); } else if (!is_writable($directory)) { chmod($directory, 0755); } # Set Filename if ($file_name) { $this->_save_name = basename($file_name, '.' . pathinfo($file_name, PATHINFO_EXTENSION)) . $suffix . '.' . $this->_output_format; } else if (!$this->_save_name) { $this->_save_name = $this->_image_info['filename'] . $suffix . '.' . $this->_output_format; } $this->_save_path = $this->_save_dir . DIRECTORY_SEPARATOR . $this->_save_name; return $this; # Method End }
[ "public", "function", "setSaveOptions", "(", "$", "file_name", "=", "null", ",", "$", "directory", "=", "null", ",", "$", "suffix", "=", "null", ")", "{", "# Set Directory, or use Old if setted before from instance, or use img src directory", "if", "(", "$", "directory", ")", "{", "$", "this", "->", "_save_dir", "=", "rtrim", "(", "$", "directory", ",", "DIRECTORY_SEPARATOR", ")", ";", "}", "else", "if", "(", "!", "$", "this", "->", "_save_dir", ")", "{", "$", "this", "->", "_save_dir", "=", "$", "this", "->", "_image_info", "[", "'dirname'", "]", ";", "}", "// Check Directory", "if", "(", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "mkdir", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "else", "if", "(", "!", "is_writable", "(", "$", "directory", ")", ")", "{", "chmod", "(", "$", "directory", ",", "0755", ")", ";", "}", "# Set Filename", "if", "(", "$", "file_name", ")", "{", "$", "this", "->", "_save_name", "=", "basename", "(", "$", "file_name", ",", "'.'", ".", "pathinfo", "(", "$", "file_name", ",", "PATHINFO_EXTENSION", ")", ")", ".", "$", "suffix", ".", "'.'", ".", "$", "this", "->", "_output_format", ";", "}", "else", "if", "(", "!", "$", "this", "->", "_save_name", ")", "{", "$", "this", "->", "_save_name", "=", "$", "this", "->", "_image_info", "[", "'filename'", "]", ".", "$", "suffix", ".", "'.'", ".", "$", "this", "->", "_output_format", ";", "}", "$", "this", "->", "_save_path", "=", "$", "this", "->", "_save_dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "_save_name", ";", "return", "$", "this", ";", "# Method End", "}" ]
Set Saving Options @param String $file_name saving file name @param String $directory directory to save into
[ "Set", "Saving", "Options" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L288-L315
13,967
ahmad-sa3d/saad-image
src/Image.php
Image.setOutputFormat
public function setOutputFormat($format = null, $quality = null, $filters = null) { if ($format) { $format = strtolower($format); if (in_array($format, static::$_allowed_formates)) { $this->_output_format = $format; # fix file extension if this method was called after calling setSaveOptions Method if ($this->_save_path) { $this->_save_name = preg_replace( '/(?<=\.)(?:png|jpeg|jpg|gif)$/i', $this->_output_format, $this->_save_name ); $this->_save_path = $this->_save_dir . DIRECTORY_SEPARATOR . $this->_save_name; } } } // Quality $this->_output_options = []; if (is_numeric($quality)) { // if($format == 'jpg' || $format == 'jpeg') // { // if($quality < 0 || $quality > 100) // throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-100'); // } // else if($format == 'png') // { // if($quality < 0 || $quality > 9) // throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-9'); // } if ($this->_output_format == 'jpg' || $this->_output_format == 'jpeg') { $quality = round($quality * 100 / 100); } else if ($this->_output_format == 'png') { $quality = round($quality * 9 / 100); } $this->_output_options[] = $quality; } // Filters if ($filters !== null) { // Filters must come after quality if (empty($this->_output_options)) { $this->_output_options[] = null; } $this->_output_options[] = $filters; } return $this; }
php
public function setOutputFormat($format = null, $quality = null, $filters = null) { if ($format) { $format = strtolower($format); if (in_array($format, static::$_allowed_formates)) { $this->_output_format = $format; # fix file extension if this method was called after calling setSaveOptions Method if ($this->_save_path) { $this->_save_name = preg_replace( '/(?<=\.)(?:png|jpeg|jpg|gif)$/i', $this->_output_format, $this->_save_name ); $this->_save_path = $this->_save_dir . DIRECTORY_SEPARATOR . $this->_save_name; } } } // Quality $this->_output_options = []; if (is_numeric($quality)) { // if($format == 'jpg' || $format == 'jpeg') // { // if($quality < 0 || $quality > 100) // throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-100'); // } // else if($format == 'png') // { // if($quality < 0 || $quality > 9) // throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-9'); // } if ($this->_output_format == 'jpg' || $this->_output_format == 'jpeg') { $quality = round($quality * 100 / 100); } else if ($this->_output_format == 'png') { $quality = round($quality * 9 / 100); } $this->_output_options[] = $quality; } // Filters if ($filters !== null) { // Filters must come after quality if (empty($this->_output_options)) { $this->_output_options[] = null; } $this->_output_options[] = $filters; } return $this; }
[ "public", "function", "setOutputFormat", "(", "$", "format", "=", "null", ",", "$", "quality", "=", "null", ",", "$", "filters", "=", "null", ")", "{", "if", "(", "$", "format", ")", "{", "$", "format", "=", "strtolower", "(", "$", "format", ")", ";", "if", "(", "in_array", "(", "$", "format", ",", "static", "::", "$", "_allowed_formates", ")", ")", "{", "$", "this", "->", "_output_format", "=", "$", "format", ";", "# fix file extension if this method was called after calling setSaveOptions Method", "if", "(", "$", "this", "->", "_save_path", ")", "{", "$", "this", "->", "_save_name", "=", "preg_replace", "(", "'/(?<=\\.)(?:png|jpeg|jpg|gif)$/i'", ",", "$", "this", "->", "_output_format", ",", "$", "this", "->", "_save_name", ")", ";", "$", "this", "->", "_save_path", "=", "$", "this", "->", "_save_dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "_save_name", ";", "}", "}", "}", "// Quality", "$", "this", "->", "_output_options", "=", "[", "]", ";", "if", "(", "is_numeric", "(", "$", "quality", ")", ")", "{", "// if($format == 'jpg' || $format == 'jpeg')", "// {", "// \tif($quality < 0 || $quality > 100)", "// \t\tthrow new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-100');", "// }", "// else if($format == 'png')", "// {", "// \tif($quality < 0 || $quality > 9)", "// \t\tthrow new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-9');", "// }", "if", "(", "$", "this", "->", "_output_format", "==", "'jpg'", "||", "$", "this", "->", "_output_format", "==", "'jpeg'", ")", "{", "$", "quality", "=", "round", "(", "$", "quality", "*", "100", "/", "100", ")", ";", "}", "else", "if", "(", "$", "this", "->", "_output_format", "==", "'png'", ")", "{", "$", "quality", "=", "round", "(", "$", "quality", "*", "9", "/", "100", ")", ";", "}", "$", "this", "->", "_output_options", "[", "]", "=", "$", "quality", ";", "}", "// Filters", "if", "(", "$", "filters", "!==", "null", ")", "{", "// Filters must come after quality", "if", "(", "empty", "(", "$", "this", "->", "_output_options", ")", ")", "{", "$", "this", "->", "_output_options", "[", "]", "=", "null", ";", "}", "$", "this", "->", "_output_options", "[", "]", "=", "$", "filters", ";", "}", "return", "$", "this", ";", "}" ]
Setting Output Format @param String $format png, jpeg, jpg OR gif
[ "Setting", "Output", "Format" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L322-L377
13,968
ahmad-sa3d/saad-image
src/Image.php
Image.exportImage
public function exportImage($keep_resource = false) { # export current resource image array_unshift($this->_output_options, $this->_image_resource, $this->_save_path); switch($this->_output_format) { case 'jpeg' : case 'jpg' : if (!$this->_save_path) { header('content-type: image/jpeg'); } $result = call_user_func_array('imagejpeg', $this->_output_options); break; case 'png' : if (!$this->_save_path) { header('content-type: image/png'); } $result = call_user_func_array('imagepng', $this->_output_options); break; case 'gif' : if (!$this->_save_path) { header('content-type: image/gif'); } $result = call_user_func_array('imagegif', $this->_output_options); break; } // Reset output_options unset($this->_output_options[0], $this->_output_options[1]); $this->_output_options = array_values($this->_output_options); // Destroy Image if ($keep_resource === false) { $this->destroy(); } // Exit incase of exporting to browser if (!$this->_save_path) { exit; } return ($result) ? ($this->_save_name ? $this->_save_name : true) : false; # Method End }
php
public function exportImage($keep_resource = false) { # export current resource image array_unshift($this->_output_options, $this->_image_resource, $this->_save_path); switch($this->_output_format) { case 'jpeg' : case 'jpg' : if (!$this->_save_path) { header('content-type: image/jpeg'); } $result = call_user_func_array('imagejpeg', $this->_output_options); break; case 'png' : if (!$this->_save_path) { header('content-type: image/png'); } $result = call_user_func_array('imagepng', $this->_output_options); break; case 'gif' : if (!$this->_save_path) { header('content-type: image/gif'); } $result = call_user_func_array('imagegif', $this->_output_options); break; } // Reset output_options unset($this->_output_options[0], $this->_output_options[1]); $this->_output_options = array_values($this->_output_options); // Destroy Image if ($keep_resource === false) { $this->destroy(); } // Exit incase of exporting to browser if (!$this->_save_path) { exit; } return ($result) ? ($this->_save_name ? $this->_save_name : true) : false; # Method End }
[ "public", "function", "exportImage", "(", "$", "keep_resource", "=", "false", ")", "{", "# export current resource image", "array_unshift", "(", "$", "this", "->", "_output_options", ",", "$", "this", "->", "_image_resource", ",", "$", "this", "->", "_save_path", ")", ";", "switch", "(", "$", "this", "->", "_output_format", ")", "{", "case", "'jpeg'", ":", "case", "'jpg'", ":", "if", "(", "!", "$", "this", "->", "_save_path", ")", "{", "header", "(", "'content-type: image/jpeg'", ")", ";", "}", "$", "result", "=", "call_user_func_array", "(", "'imagejpeg'", ",", "$", "this", "->", "_output_options", ")", ";", "break", ";", "case", "'png'", ":", "if", "(", "!", "$", "this", "->", "_save_path", ")", "{", "header", "(", "'content-type: image/png'", ")", ";", "}", "$", "result", "=", "call_user_func_array", "(", "'imagepng'", ",", "$", "this", "->", "_output_options", ")", ";", "break", ";", "case", "'gif'", ":", "if", "(", "!", "$", "this", "->", "_save_path", ")", "{", "header", "(", "'content-type: image/gif'", ")", ";", "}", "$", "result", "=", "call_user_func_array", "(", "'imagegif'", ",", "$", "this", "->", "_output_options", ")", ";", "break", ";", "}", "// Reset output_options", "unset", "(", "$", "this", "->", "_output_options", "[", "0", "]", ",", "$", "this", "->", "_output_options", "[", "1", "]", ")", ";", "$", "this", "->", "_output_options", "=", "array_values", "(", "$", "this", "->", "_output_options", ")", ";", "// Destroy Image", "if", "(", "$", "keep_resource", "===", "false", ")", "{", "$", "this", "->", "destroy", "(", ")", ";", "}", "// Exit incase of exporting to browser", "if", "(", "!", "$", "this", "->", "_save_path", ")", "{", "exit", ";", "}", "return", "(", "$", "result", ")", "?", "(", "$", "this", "->", "_save_name", "?", "$", "this", "->", "_save_name", ":", "true", ")", ":", "false", ";", "# Method End", "}" ]
Save Or Output Current Image Resource @return Boolean indicates to success or fail @param $keep_resource Boolean If To Not Destroy Resource After Exporting, Useful If Weneed to continue on image resource
[ "Save", "Or", "Output", "Current", "Image", "Resource" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L392-L440
13,969
ahmad-sa3d/saad-image
src/Image.php
Image.embed
public function embed($keep_resource = false) { ob_start(); switch ($this->_output_format) { case 'jpeg' : case 'jpg' : imagejpeg($this->_image_resource); break; case 'png': imagepng($this->_image_resource); break; case 'gif': imagegif($this->_image_resource); break; } $str = ob_get_contents(); ob_end_clean(); if (!$keep_resource) { imagedestroy($this->_image_resource); } return 'data:image/' . $this->_output_format . ';base64,' . base64_encode($str); }
php
public function embed($keep_resource = false) { ob_start(); switch ($this->_output_format) { case 'jpeg' : case 'jpg' : imagejpeg($this->_image_resource); break; case 'png': imagepng($this->_image_resource); break; case 'gif': imagegif($this->_image_resource); break; } $str = ob_get_contents(); ob_end_clean(); if (!$keep_resource) { imagedestroy($this->_image_resource); } return 'data:image/' . $this->_output_format . ';base64,' . base64_encode($str); }
[ "public", "function", "embed", "(", "$", "keep_resource", "=", "false", ")", "{", "ob_start", "(", ")", ";", "switch", "(", "$", "this", "->", "_output_format", ")", "{", "case", "'jpeg'", ":", "case", "'jpg'", ":", "imagejpeg", "(", "$", "this", "->", "_image_resource", ")", ";", "break", ";", "case", "'png'", ":", "imagepng", "(", "$", "this", "->", "_image_resource", ")", ";", "break", ";", "case", "'gif'", ":", "imagegif", "(", "$", "this", "->", "_image_resource", ")", ";", "break", ";", "}", "$", "str", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "if", "(", "!", "$", "keep_resource", ")", "{", "imagedestroy", "(", "$", "this", "->", "_image_resource", ")", ";", "}", "return", "'data:image/'", ".", "$", "this", "->", "_output_format", ".", "';base64,'", ".", "base64_encode", "(", "$", "str", ")", ";", "}" ]
Get Image as embeded code @param bool $keep_resource @return string
[ "Get", "Image", "as", "embeded", "code" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L448-L473
13,970
ahmad-sa3d/saad-image
src/Image.php
Image.reset
public function reset() { if (!$this->_image_resource_backup) { throw new ImageException('Cannot restore, no backup has been taken for image resource'); } $cloned = $this->cloneResource($this->_image_resource_backup); $this->_image_resource = $cloned['resource']; $this->updateImageInfo($cloned['width'], $cloned['height']); return $this; }
php
public function reset() { if (!$this->_image_resource_backup) { throw new ImageException('Cannot restore, no backup has been taken for image resource'); } $cloned = $this->cloneResource($this->_image_resource_backup); $this->_image_resource = $cloned['resource']; $this->updateImageInfo($cloned['width'], $cloned['height']); return $this; }
[ "public", "function", "reset", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_image_resource_backup", ")", "{", "throw", "new", "ImageException", "(", "'Cannot restore, no backup has been taken for image resource'", ")", ";", "}", "$", "cloned", "=", "$", "this", "->", "cloneResource", "(", "$", "this", "->", "_image_resource_backup", ")", ";", "$", "this", "->", "_image_resource", "=", "$", "cloned", "[", "'resource'", "]", ";", "$", "this", "->", "updateImageInfo", "(", "$", "cloned", "[", "'width'", "]", ",", "$", "cloned", "[", "'height'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Restore Image resource from backup
[ "Restore", "Image", "resource", "from", "backup" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L524-L534
13,971
ahmad-sa3d/saad-image
src/Image.php
Image.updateImageInfo
private function updateImageInfo($width, $height) { $this->_image_info[0] = $width; $this->_image_info[1] = $height; $this->_image_info[3] = 'width="' . $width . '" height="' . $height . '"'; $this->_image_info['aspect'] = $width / $height; }
php
private function updateImageInfo($width, $height) { $this->_image_info[0] = $width; $this->_image_info[1] = $height; $this->_image_info[3] = 'width="' . $width . '" height="' . $height . '"'; $this->_image_info['aspect'] = $width / $height; }
[ "private", "function", "updateImageInfo", "(", "$", "width", ",", "$", "height", ")", "{", "$", "this", "->", "_image_info", "[", "0", "]", "=", "$", "width", ";", "$", "this", "->", "_image_info", "[", "1", "]", "=", "$", "height", ";", "$", "this", "->", "_image_info", "[", "3", "]", "=", "'width=\"'", ".", "$", "width", ".", "'\" height=\"'", ".", "$", "height", ".", "'\"'", ";", "$", "this", "->", "_image_info", "[", "'aspect'", "]", "=", "$", "width", "/", "$", "height", ";", "}" ]
Update Image Resource Info @param $width @param $height
[ "Update", "Image", "Resource", "Info" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L558-L563
13,972
ahmad-sa3d/saad-image
src/Image.php
Image.getRGBFromRange
protected function getRGBFromRange($r, $g, $b, $range) { # get randomized rgb values on a specific range from a agiven value if (!$range) { return array($r, $g, $b); } $range = round($range / 2); $color = array(); # red $min = $r - $range; $max = $r + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['r'] = $color[0] = rand($min, $max); # Green $min = $g - $range; $max = $g + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['g'] = $color[1] = rand($min, $max); # blue $min = $b - $range; $max = $b + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['b'] = $color[2] = rand($min, $max); return $color; }
php
protected function getRGBFromRange($r, $g, $b, $range) { # get randomized rgb values on a specific range from a agiven value if (!$range) { return array($r, $g, $b); } $range = round($range / 2); $color = array(); # red $min = $r - $range; $max = $r + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['r'] = $color[0] = rand($min, $max); # Green $min = $g - $range; $max = $g + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['g'] = $color[1] = rand($min, $max); # blue $min = $b - $range; $max = $b + $range; if ($min < 0) { $min = 0; } if ($max > 255) { $max = 255; } $color['b'] = $color[2] = rand($min, $max); return $color; }
[ "protected", "function", "getRGBFromRange", "(", "$", "r", ",", "$", "g", ",", "$", "b", ",", "$", "range", ")", "{", "#\tget randomized rgb values on a specific range from a agiven value", "if", "(", "!", "$", "range", ")", "{", "return", "array", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", ";", "}", "$", "range", "=", "round", "(", "$", "range", "/", "2", ")", ";", "$", "color", "=", "array", "(", ")", ";", "# red", "$", "min", "=", "$", "r", "-", "$", "range", ";", "$", "max", "=", "$", "r", "+", "$", "range", ";", "if", "(", "$", "min", "<", "0", ")", "{", "$", "min", "=", "0", ";", "}", "if", "(", "$", "max", ">", "255", ")", "{", "$", "max", "=", "255", ";", "}", "$", "color", "[", "'r'", "]", "=", "$", "color", "[", "0", "]", "=", "rand", "(", "$", "min", ",", "$", "max", ")", ";", "# Green", "$", "min", "=", "$", "g", "-", "$", "range", ";", "$", "max", "=", "$", "g", "+", "$", "range", ";", "if", "(", "$", "min", "<", "0", ")", "{", "$", "min", "=", "0", ";", "}", "if", "(", "$", "max", ">", "255", ")", "{", "$", "max", "=", "255", ";", "}", "$", "color", "[", "'g'", "]", "=", "$", "color", "[", "1", "]", "=", "rand", "(", "$", "min", ",", "$", "max", ")", ";", "# blue", "$", "min", "=", "$", "b", "-", "$", "range", ";", "$", "max", "=", "$", "b", "+", "$", "range", ";", "if", "(", "$", "min", "<", "0", ")", "{", "$", "min", "=", "0", ";", "}", "if", "(", "$", "max", ">", "255", ")", "{", "$", "max", "=", "255", ";", "}", "$", "color", "[", "'b'", "]", "=", "$", "color", "[", "2", "]", "=", "rand", "(", "$", "min", ",", "$", "max", ")", ";", "return", "$", "color", ";", "}" ]
Get Random RGB Values on a specific range @param integer $r Red @param integer $g Green @param integer $b Blue @param integer $range Range to randomize given values @return array array of randomized rgb
[ "Get", "Random", "RGB", "Values", "on", "a", "specific", "range" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L574-L627
13,973
ahmad-sa3d/saad-image
src/Image.php
Image.cloneResource
private function cloneResource($resource) { // Get width from image. $w = imagesx($resource); // Get height from image. $h = imagesy($resource); // Get the transparent color from a 256 palette image. $trans = imagecolortransparent($resource); if (imageistruecolor($resource)) { // this is a true color image... $clone = imagecreatetruecolor($w, $h); imagealphablending($clone, false); imagesavealpha($clone, true); } else { // this is a 256 color palette image... $clone = imagecreate($w, $h); // If the image has transparency... if ($trans >= 0) { $rgb = imagecolorsforindex($resource, $trans); imagesavealpha($clone, true); $trans_index = imagecolorallocatealpha($clone, $rgb['red'], $rgb['green'], $rgb['blue'], $rgb['alpha']); imagefill($clone, 0, 0, $trans_index); } } // Create the Clone!! imagecopy($clone, $resource, 0, 0, 0, 0, $w, $h); return [ 'resource' => $clone, 'width' => $w, 'height' => $h, ]; }
php
private function cloneResource($resource) { // Get width from image. $w = imagesx($resource); // Get height from image. $h = imagesy($resource); // Get the transparent color from a 256 palette image. $trans = imagecolortransparent($resource); if (imageistruecolor($resource)) { // this is a true color image... $clone = imagecreatetruecolor($w, $h); imagealphablending($clone, false); imagesavealpha($clone, true); } else { // this is a 256 color palette image... $clone = imagecreate($w, $h); // If the image has transparency... if ($trans >= 0) { $rgb = imagecolorsforindex($resource, $trans); imagesavealpha($clone, true); $trans_index = imagecolorallocatealpha($clone, $rgb['red'], $rgb['green'], $rgb['blue'], $rgb['alpha']); imagefill($clone, 0, 0, $trans_index); } } // Create the Clone!! imagecopy($clone, $resource, 0, 0, 0, 0, $w, $h); return [ 'resource' => $clone, 'width' => $w, 'height' => $h, ]; }
[ "private", "function", "cloneResource", "(", "$", "resource", ")", "{", "// Get width from image.", "$", "w", "=", "imagesx", "(", "$", "resource", ")", ";", "// Get height from image.", "$", "h", "=", "imagesy", "(", "$", "resource", ")", ";", "// Get the transparent color from a 256 palette image.", "$", "trans", "=", "imagecolortransparent", "(", "$", "resource", ")", ";", "if", "(", "imageistruecolor", "(", "$", "resource", ")", ")", "{", "// this is a true color image...", "$", "clone", "=", "imagecreatetruecolor", "(", "$", "w", ",", "$", "h", ")", ";", "imagealphablending", "(", "$", "clone", ",", "false", ")", ";", "imagesavealpha", "(", "$", "clone", ",", "true", ")", ";", "}", "else", "{", "// this is a 256 color palette image...", "$", "clone", "=", "imagecreate", "(", "$", "w", ",", "$", "h", ")", ";", "// If the image has transparency...", "if", "(", "$", "trans", ">=", "0", ")", "{", "$", "rgb", "=", "imagecolorsforindex", "(", "$", "resource", ",", "$", "trans", ")", ";", "imagesavealpha", "(", "$", "clone", ",", "true", ")", ";", "$", "trans_index", "=", "imagecolorallocatealpha", "(", "$", "clone", ",", "$", "rgb", "[", "'red'", "]", ",", "$", "rgb", "[", "'green'", "]", ",", "$", "rgb", "[", "'blue'", "]", ",", "$", "rgb", "[", "'alpha'", "]", ")", ";", "imagefill", "(", "$", "clone", ",", "0", ",", "0", ",", "$", "trans_index", ")", ";", "}", "}", "// Create the Clone!!", "imagecopy", "(", "$", "clone", ",", "$", "resource", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "w", ",", "$", "h", ")", ";", "return", "[", "'resource'", "=>", "$", "clone", ",", "'width'", "=>", "$", "w", ",", "'height'", "=>", "$", "h", ",", "]", ";", "}" ]
Clone Image Resource @param $resource @return array
[ "Clone", "Image", "Resource" ]
2485e585e0c2ae2b8f0afeb3d513f2df3e369939
https://github.com/ahmad-sa3d/saad-image/blob/2485e585e0c2ae2b8f0afeb3d513f2df3e369939/src/Image.php#L781-L815
13,974
wpup/digster
src/class-factory.php
Factory.composer
public function composer( $views, $callback ) { foreach ( (array) $views as $view ) { if ( $callback instanceof Closure === false ) { $callback = function () use ( $callback ) { return $callback; }; } if ( $view === '*' ) { $this->composers['*'][] = $callback; continue; } $view = $this->view( $view ); if ( ! isset( $this->composers[$view] ) ) { $this->composers[$view] = []; } $this->composers[$view][] = $callback; } return $this; }
php
public function composer( $views, $callback ) { foreach ( (array) $views as $view ) { if ( $callback instanceof Closure === false ) { $callback = function () use ( $callback ) { return $callback; }; } if ( $view === '*' ) { $this->composers['*'][] = $callback; continue; } $view = $this->view( $view ); if ( ! isset( $this->composers[$view] ) ) { $this->composers[$view] = []; } $this->composers[$view][] = $callback; } return $this; }
[ "public", "function", "composer", "(", "$", "views", ",", "$", "callback", ")", "{", "foreach", "(", "(", "array", ")", "$", "views", "as", "$", "view", ")", "{", "if", "(", "$", "callback", "instanceof", "Closure", "===", "false", ")", "{", "$", "callback", "=", "function", "(", ")", "use", "(", "$", "callback", ")", "{", "return", "$", "callback", ";", "}", ";", "}", "if", "(", "$", "view", "===", "'*'", ")", "{", "$", "this", "->", "composers", "[", "'*'", "]", "[", "]", "=", "$", "callback", ";", "continue", ";", "}", "$", "view", "=", "$", "this", "->", "view", "(", "$", "view", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "composers", "[", "$", "view", "]", ")", ")", "{", "$", "this", "->", "composers", "[", "$", "view", "]", "=", "[", "]", ";", "}", "$", "this", "->", "composers", "[", "$", "view", "]", "[", "]", "=", "$", "callback", ";", "}", "return", "$", "this", ";", "}" ]
Register preprocess with views. @param array|string $views @param \Closure $callback @return $this
[ "Register", "preprocess", "with", "views", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L81-L104
13,975
wpup/digster
src/class-factory.php
Factory.extension
protected function extension( $view ) { $extensions = $this->extensions(); // Return if a valid extension exists in the template string. $ext_reg = '/(' . implode( '|', $extensions ) . ')+$/'; if ( preg_match( $ext_reg, $view ) ) { return $template; } // Add extension to template string if it don't exists. return substr( $view, -strlen( $extensions[0] ) ) === $extensions[0] ? $view : $view . $extensions[0]; }
php
protected function extension( $view ) { $extensions = $this->extensions(); // Return if a valid extension exists in the template string. $ext_reg = '/(' . implode( '|', $extensions ) . ')+$/'; if ( preg_match( $ext_reg, $view ) ) { return $template; } // Add extension to template string if it don't exists. return substr( $view, -strlen( $extensions[0] ) ) === $extensions[0] ? $view : $view . $extensions[0]; }
[ "protected", "function", "extension", "(", "$", "view", ")", "{", "$", "extensions", "=", "$", "this", "->", "extensions", "(", ")", ";", "// Return if a valid extension exists in the template string.", "$", "ext_reg", "=", "'/('", ".", "implode", "(", "'|'", ",", "$", "extensions", ")", ".", "')+$/'", ";", "if", "(", "preg_match", "(", "$", "ext_reg", ",", "$", "view", ")", ")", "{", "return", "$", "template", ";", "}", "// Add extension to template string if it don't exists.", "return", "substr", "(", "$", "view", ",", "-", "strlen", "(", "$", "extensions", "[", "0", "]", ")", ")", "===", "$", "extensions", "[", "0", "]", "?", "$", "view", ":", "$", "view", ".", "$", "extensions", "[", "0", "]", ";", "}" ]
Add extension to the view string if it don't exists. @param string $view @return string
[ "Add", "extension", "to", "the", "view", "string", "if", "it", "don", "t", "exists", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L133-L145
13,976
wpup/digster
src/class-factory.php
Factory.create_data
public function create_data( $data = [] ) { if ( is_object( $data ) && method_exists( $data, 'to_array' ) ) { return $data->to_array(); } return is_array( $data ) ? $data : []; }
php
public function create_data( $data = [] ) { if ( is_object( $data ) && method_exists( $data, 'to_array' ) ) { return $data->to_array(); } return is_array( $data ) ? $data : []; }
[ "public", "function", "create_data", "(", "$", "data", "=", "[", "]", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", "&&", "method_exists", "(", "$", "data", ",", "'to_array'", ")", ")", "{", "return", "$", "data", "->", "to_array", "(", ")", ";", "}", "return", "is_array", "(", "$", "data", ")", "?", "$", "data", ":", "[", "]", ";", "}" ]
Create view data. @param mixed $data @return array
[ "Create", "view", "data", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L163-L169
13,977
wpup/digster
src/class-factory.php
Factory.get_composer
public function get_composer( View $view ) { $view_name = $view->get_name(); if ( isset( $this->composers[$view_name] ) ) { return $this->composers[$view_name]; } return []; }
php
public function get_composer( View $view ) { $view_name = $view->get_name(); if ( isset( $this->composers[$view_name] ) ) { return $this->composers[$view_name]; } return []; }
[ "public", "function", "get_composer", "(", "View", "$", "view", ")", "{", "$", "view_name", "=", "$", "view", "->", "get_name", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "composers", "[", "$", "view_name", "]", ")", ")", "{", "return", "$", "this", "->", "composers", "[", "$", "view_name", "]", ";", "}", "return", "[", "]", ";", "}" ]
Call composer. @param \Frozzare\Digster\View $view @return string
[ "Call", "composer", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L209-L217
13,978
wpup/digster
src/class-factory.php
Factory.view
protected function view( $view ) { if ( preg_match( '/\.\w+$/', $view, $matches ) && in_array( $matches[0], $this->extensions() ) ) { return str_replace( '.', '/', preg_replace( '/' . $matches[0] . '$/', '', $view ) ) . $matches[0]; } return $this->extension( str_replace( '.', '/', $view ) ); }
php
protected function view( $view ) { if ( preg_match( '/\.\w+$/', $view, $matches ) && in_array( $matches[0], $this->extensions() ) ) { return str_replace( '.', '/', preg_replace( '/' . $matches[0] . '$/', '', $view ) ) . $matches[0]; } return $this->extension( str_replace( '.', '/', $view ) ); }
[ "protected", "function", "view", "(", "$", "view", ")", "{", "if", "(", "preg_match", "(", "'/\\.\\w+$/'", ",", "$", "view", ",", "$", "matches", ")", "&&", "in_array", "(", "$", "matches", "[", "0", "]", ",", "$", "this", "->", "extensions", "(", ")", ")", ")", "{", "return", "str_replace", "(", "'.'", ",", "'/'", ",", "preg_replace", "(", "'/'", ".", "$", "matches", "[", "0", "]", ".", "'$/'", ",", "''", ",", "$", "view", ")", ")", ".", "$", "matches", "[", "0", "]", ";", "}", "return", "$", "this", "->", "extension", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "view", ")", ")", ";", "}" ]
Get the right view string from dot view or view that missing extension. @param string $view @return string
[ "Get", "the", "right", "view", "string", "from", "dot", "view", "or", "view", "that", "missing", "extension", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L256-L262
13,979
wpup/digster
src/class-factory.php
Factory.reset_composer
protected function reset_composer( View $view ) { $view_name = $view->get_name(); if ( isset( $this->composers[$view_name] ) ) { unset( $this->composers[$view_name] ); } }
php
protected function reset_composer( View $view ) { $view_name = $view->get_name(); if ( isset( $this->composers[$view_name] ) ) { unset( $this->composers[$view_name] ); } }
[ "protected", "function", "reset_composer", "(", "View", "$", "view", ")", "{", "$", "view_name", "=", "$", "view", "->", "get_name", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "composers", "[", "$", "view_name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "composers", "[", "$", "view_name", "]", ")", ";", "}", "}" ]
Reset view composer. @param \Frozzare\Digster\View $view
[ "Reset", "view", "composer", "." ]
9ef9626ce82673af698bc0976d6c38a532e4a6d9
https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-factory.php#L269-L275
13,980
mimmi20/Wurfl
src/VirtualCapability/VirtualCapabilityProvider.php
VirtualCapabilityProvider.getControlCapabilities
public static function getControlCapabilities() { $caps = array(); foreach (array_keys(self::$virtualCapabilities) as $capabilityName) { $caps[] = self::PREFIX_CONTROL . $capabilityName; } return $caps; }
php
public static function getControlCapabilities() { $caps = array(); foreach (array_keys(self::$virtualCapabilities) as $capabilityName) { $caps[] = self::PREFIX_CONTROL . $capabilityName; } return $caps; }
[ "public", "static", "function", "getControlCapabilities", "(", ")", "{", "$", "caps", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "virtualCapabilities", ")", "as", "$", "capabilityName", ")", "{", "$", "caps", "[", "]", "=", "self", "::", "PREFIX_CONTROL", ".", "$", "capabilityName", ";", "}", "return", "$", "caps", ";", "}" ]
Returns an array of all the control capabilities @return array
[ "Returns", "an", "array", "of", "all", "the", "control", "capabilities" ]
443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec
https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/VirtualCapability/VirtualCapabilityProvider.php#L157-L165
13,981
liupdhc/yii2-liuxy-themes
admin/plugins/datatables/examples/server_side/scripts/ssp.class.php
SSP.sql_exec
static function sql_exec ( $db, $bindings, $sql=null ) { // Argument shifting if ( $sql === null ) { $sql = $bindings; } $stmt = $db->prepare( $sql ); //echo $sql; // Bind parameters if ( is_array( $bindings ) ) { for ( $i=0, $ien=count($bindings) ; $i<$ien ; $i++ ) { $binding = $bindings[$i]; $stmt->bindValue( $binding['key'], $binding['val'], $binding['type'] ); } } // Execute try { $stmt->execute(); } catch (PDOException $e) { self::fatal( "An SQL error occurred: ".$e->getMessage() ); } // Return all return $stmt->fetchAll(); }
php
static function sql_exec ( $db, $bindings, $sql=null ) { // Argument shifting if ( $sql === null ) { $sql = $bindings; } $stmt = $db->prepare( $sql ); //echo $sql; // Bind parameters if ( is_array( $bindings ) ) { for ( $i=0, $ien=count($bindings) ; $i<$ien ; $i++ ) { $binding = $bindings[$i]; $stmt->bindValue( $binding['key'], $binding['val'], $binding['type'] ); } } // Execute try { $stmt->execute(); } catch (PDOException $e) { self::fatal( "An SQL error occurred: ".$e->getMessage() ); } // Return all return $stmt->fetchAll(); }
[ "static", "function", "sql_exec", "(", "$", "db", ",", "$", "bindings", ",", "$", "sql", "=", "null", ")", "{", "// Argument shifting", "if", "(", "$", "sql", "===", "null", ")", "{", "$", "sql", "=", "$", "bindings", ";", "}", "$", "stmt", "=", "$", "db", "->", "prepare", "(", "$", "sql", ")", ";", "//echo $sql;", "// Bind parameters", "if", "(", "is_array", "(", "$", "bindings", ")", ")", "{", "for", "(", "$", "i", "=", "0", ",", "$", "ien", "=", "count", "(", "$", "bindings", ")", ";", "$", "i", "<", "$", "ien", ";", "$", "i", "++", ")", "{", "$", "binding", "=", "$", "bindings", "[", "$", "i", "]", ";", "$", "stmt", "->", "bindValue", "(", "$", "binding", "[", "'key'", "]", ",", "$", "binding", "[", "'val'", "]", ",", "$", "binding", "[", "'type'", "]", ")", ";", "}", "}", "// Execute", "try", "{", "$", "stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "self", "::", "fatal", "(", "\"An SQL error occurred: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "// Return all", "return", "$", "stmt", "->", "fetchAll", "(", ")", ";", "}" ]
Execute an SQL query on the database @param resource $db Database handler @param array $bindings Array of PDO binding values from bind() to be used for safely escaping strings. Note that this can be given as the SQL query string if no bindings are required. @param string $sql SQL query to execute. @return array Result from the query (all rows)
[ "Execute", "an", "SQL", "query", "on", "the", "database" ]
0f804715092718776ecab9748d1dc0562b6ebcac
https://github.com/liupdhc/yii2-liuxy-themes/blob/0f804715092718776ecab9748d1dc0562b6ebcac/admin/plugins/datatables/examples/server_side/scripts/ssp.class.php#L295-L323
13,982
liupdhc/yii2-liuxy-themes
admin/plugins/datatables/examples/server_side/scripts/ssp.class.php
SSP.pluck
static function pluck ( $a, $prop ) { $out = array(); for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) { $out[] = $a[$i][$prop]; } return $out; }
php
static function pluck ( $a, $prop ) { $out = array(); for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) { $out[] = $a[$i][$prop]; } return $out; }
[ "static", "function", "pluck", "(", "$", "a", ",", "$", "prop", ")", "{", "$", "out", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "len", "=", "count", "(", "$", "a", ")", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "out", "[", "]", "=", "$", "a", "[", "$", "i", "]", "[", "$", "prop", "]", ";", "}", "return", "$", "out", ";", "}" ]
Pull a particular property from each assoc. array in a numeric array, returning and array of the property values from each item. @param array $a Array to get data from @param string $prop Property to read @return array Array of property values
[ "Pull", "a", "particular", "property", "from", "each", "assoc", ".", "array", "in", "a", "numeric", "array", "returning", "and", "array", "of", "the", "property", "values", "from", "each", "item", "." ]
0f804715092718776ecab9748d1dc0562b6ebcac
https://github.com/liupdhc/yii2-liuxy-themes/blob/0f804715092718776ecab9748d1dc0562b6ebcac/admin/plugins/datatables/examples/server_side/scripts/ssp.class.php#L379-L388
13,983
PandaPlatform/framework
src/Panda/Support/Configuration/Parsers/PhpParser.php
PhpParser.parse
public function parse($configFile = '') { // Load default configuration $defaultConfigFile = $this->getConfigFile($configFile, 'default'); $defaultConfigArray = parent::parse($defaultConfigFile) ?: []; // Load environment configuration $envConfigFile = $this->getConfigFile($configFile, $this->app->getEnvironment()); $envConfigArray = parent::parse($envConfigFile) ?: []; // Merge environment config to default and set to application return ArrayHelper::merge($defaultConfigArray, $envConfigArray, $deep = true); }
php
public function parse($configFile = '') { // Load default configuration $defaultConfigFile = $this->getConfigFile($configFile, 'default'); $defaultConfigArray = parent::parse($defaultConfigFile) ?: []; // Load environment configuration $envConfigFile = $this->getConfigFile($configFile, $this->app->getEnvironment()); $envConfigArray = parent::parse($envConfigFile) ?: []; // Merge environment config to default and set to application return ArrayHelper::merge($defaultConfigArray, $envConfigArray, $deep = true); }
[ "public", "function", "parse", "(", "$", "configFile", "=", "''", ")", "{", "// Load default configuration", "$", "defaultConfigFile", "=", "$", "this", "->", "getConfigFile", "(", "$", "configFile", ",", "'default'", ")", ";", "$", "defaultConfigArray", "=", "parent", "::", "parse", "(", "$", "defaultConfigFile", ")", "?", ":", "[", "]", ";", "// Load environment configuration", "$", "envConfigFile", "=", "$", "this", "->", "getConfigFile", "(", "$", "configFile", ",", "$", "this", "->", "app", "->", "getEnvironment", "(", ")", ")", ";", "$", "envConfigArray", "=", "parent", "::", "parse", "(", "$", "envConfigFile", ")", "?", ":", "[", "]", ";", "// Merge environment config to default and set to application", "return", "ArrayHelper", "::", "merge", "(", "$", "defaultConfigArray", ",", "$", "envConfigArray", ",", "$", "deep", "=", "true", ")", ";", "}" ]
Parse the configuration file and get the configuration array. @param string $configFile @return array
[ "Parse", "the", "configuration", "file", "and", "get", "the", "configuration", "array", "." ]
a78cf051b379896b5a4d5df620988e37a0e632f5
https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Configuration/Parsers/PhpParser.php#L46-L58
13,984
PandaPlatform/framework
src/Panda/Support/Configuration/Parsers/PhpParser.php
PhpParser.getConfigFile
private function getConfigFile($configFile, $environment = 'default') { // Normalize config file $configFile = $configFile ?: 'config'; // Check if there is an environment-specific config file $envConfigFile = $this->app->getConfigPath() . DIRECTORY_SEPARATOR . $configFile . '-' . $environment . '.php'; if (!is_file($envConfigFile)) { $envConfigFile = $this->app->getConfigPath() . DIRECTORY_SEPARATOR . $configFile . '.php'; } return $envConfigFile; }
php
private function getConfigFile($configFile, $environment = 'default') { // Normalize config file $configFile = $configFile ?: 'config'; // Check if there is an environment-specific config file $envConfigFile = $this->app->getConfigPath() . DIRECTORY_SEPARATOR . $configFile . '-' . $environment . '.php'; if (!is_file($envConfigFile)) { $envConfigFile = $this->app->getConfigPath() . DIRECTORY_SEPARATOR . $configFile . '.php'; } return $envConfigFile; }
[ "private", "function", "getConfigFile", "(", "$", "configFile", ",", "$", "environment", "=", "'default'", ")", "{", "// Normalize config file", "$", "configFile", "=", "$", "configFile", "?", ":", "'config'", ";", "// Check if there is an environment-specific config file", "$", "envConfigFile", "=", "$", "this", "->", "app", "->", "getConfigPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "configFile", ".", "'-'", ".", "$", "environment", ".", "'.php'", ";", "if", "(", "!", "is_file", "(", "$", "envConfigFile", ")", ")", "{", "$", "envConfigFile", "=", "$", "this", "->", "app", "->", "getConfigPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "configFile", ".", "'.php'", ";", "}", "return", "$", "envConfigFile", ";", "}" ]
Get the configuration file according to the given environment, if any. @param string $configFile @param string $environment @return string
[ "Get", "the", "configuration", "file", "according", "to", "the", "given", "environment", "if", "any", "." ]
a78cf051b379896b5a4d5df620988e37a0e632f5
https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Configuration/Parsers/PhpParser.php#L68-L80
13,985
vi-kon/laravel-parser
src/ViKon/Parser/rule/AbstractRuleSet.php
AbstractRuleSet.init
public function init(Parser $parser, Lexer $lexer) { $parser->setStartRule($this->startRule); foreach ($this->rules as $rule) { $parser->addRule($rule); } $parser->setLexer($lexer); $lexer->setParser($parser); return $this; }
php
public function init(Parser $parser, Lexer $lexer) { $parser->setStartRule($this->startRule); foreach ($this->rules as $rule) { $parser->addRule($rule); } $parser->setLexer($lexer); $lexer->setParser($parser); return $this; }
[ "public", "function", "init", "(", "Parser", "$", "parser", ",", "Lexer", "$", "lexer", ")", "{", "$", "parser", "->", "setStartRule", "(", "$", "this", "->", "startRule", ")", ";", "foreach", "(", "$", "this", "->", "rules", "as", "$", "rule", ")", "{", "$", "parser", "->", "addRule", "(", "$", "rule", ")", ";", "}", "$", "parser", "->", "setLexer", "(", "$", "lexer", ")", ";", "$", "lexer", "->", "setParser", "(", "$", "parser", ")", ";", "return", "$", "this", ";", "}" ]
Set start rule and add set's rules to parser @param \ViKon\Parser\Parser $parser @param \ViKon\Parser\Lexer\Lexer $lexer @return $this @throws \ViKon\Parser\ParserException
[ "Set", "start", "rule", "and", "add", "set", "s", "rules", "to", "parser" ]
070f0bb9120cb9ca6ff836d4f418e78ee33ee182
https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/rule/AbstractRuleSet.php#L125-L136
13,986
vi-kon/laravel-parser
src/ViKon/Parser/rule/AbstractRuleSet.php
AbstractRuleSet.addRule
protected function addRule(AbstractRule $rule, $category = self::CATEGORY_NONE) { $rule->setRuleSet($this); $this->rules[] = $rule; $this->categories[$category][] = $rule; return $this; }
php
protected function addRule(AbstractRule $rule, $category = self::CATEGORY_NONE) { $rule->setRuleSet($this); $this->rules[] = $rule; $this->categories[$category][] = $rule; return $this; }
[ "protected", "function", "addRule", "(", "AbstractRule", "$", "rule", ",", "$", "category", "=", "self", "::", "CATEGORY_NONE", ")", "{", "$", "rule", "->", "setRuleSet", "(", "$", "this", ")", ";", "$", "this", "->", "rules", "[", "]", "=", "$", "rule", ";", "$", "this", "->", "categories", "[", "$", "category", "]", "[", "]", "=", "$", "rule", ";", "return", "$", "this", ";", "}" ]
Add new rule to set @param \ViKon\Parser\Rule\AbstractRule $rule @param string $category @return $this
[ "Add", "new", "rule", "to", "set" ]
070f0bb9120cb9ca6ff836d4f418e78ee33ee182
https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/rule/AbstractRuleSet.php#L146-L153
13,987
venta/framework
src/Event/src/EventDispatcher.php
EventDispatcher.getListeners
protected function getListeners(string $eventName): array { if (!isset($this->listeners[$eventName])) { return []; } if (!isset($this->sortedListeners[$eventName])) { $this->sortedListeners[$eventName] = $this->sortEventListeners($eventName); } return $this->sortedListeners[$eventName]; }
php
protected function getListeners(string $eventName): array { if (!isset($this->listeners[$eventName])) { return []; } if (!isset($this->sortedListeners[$eventName])) { $this->sortedListeners[$eventName] = $this->sortEventListeners($eventName); } return $this->sortedListeners[$eventName]; }
[ "protected", "function", "getListeners", "(", "string", "$", "eventName", ")", ":", "array", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "sortedListeners", "[", "$", "eventName", "]", ")", ")", "{", "$", "this", "->", "sortedListeners", "[", "$", "eventName", "]", "=", "$", "this", "->", "sortEventListeners", "(", "$", "eventName", ")", ";", "}", "return", "$", "this", "->", "sortedListeners", "[", "$", "eventName", "]", ";", "}" ]
Returns array of event listeners. @param string $eventName @return array
[ "Returns", "array", "of", "event", "listeners", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Event/src/EventDispatcher.php#L102-L113
13,988
venta/framework
src/Event/src/EventDispatcher.php
EventDispatcher.sortEventListeners
protected function sortEventListeners(string $eventName): array { $listeners = $this->listeners[$eventName]; $normalised = []; ksort($listeners); foreach ($listeners as $priorityListeners) { foreach ($priorityListeners as $listener) { $normalised[] = $listener; } } return $normalised; }
php
protected function sortEventListeners(string $eventName): array { $listeners = $this->listeners[$eventName]; $normalised = []; ksort($listeners); foreach ($listeners as $priorityListeners) { foreach ($priorityListeners as $listener) { $normalised[] = $listener; } } return $normalised; }
[ "protected", "function", "sortEventListeners", "(", "string", "$", "eventName", ")", ":", "array", "{", "$", "listeners", "=", "$", "this", "->", "listeners", "[", "$", "eventName", "]", ";", "$", "normalised", "=", "[", "]", ";", "ksort", "(", "$", "listeners", ")", ";", "foreach", "(", "$", "listeners", "as", "$", "priorityListeners", ")", "{", "foreach", "(", "$", "priorityListeners", "as", "$", "listener", ")", "{", "$", "normalised", "[", "]", "=", "$", "listener", ";", "}", "}", "return", "$", "normalised", ";", "}" ]
Merges all event listeners for particular event. @param string $eventName @return array
[ "Merges", "all", "event", "listeners", "for", "particular", "event", "." ]
514a7854cc69f84f47e62a58cc55efd68b7c9f83
https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Event/src/EventDispatcher.php#L121-L135
13,989
taskforcedev/laravel-support
src/Helpers/UI.php
UI.cssClass
public function cssClass($type) { $framework = $this->getFramework(); $classes = $this->getClasses($framework); if (property_exists($classes, $type)) { return $classes->$type; } return ''; }
php
public function cssClass($type) { $framework = $this->getFramework(); $classes = $this->getClasses($framework); if (property_exists($classes, $type)) { return $classes->$type; } return ''; }
[ "public", "function", "cssClass", "(", "$", "type", ")", "{", "$", "framework", "=", "$", "this", "->", "getFramework", "(", ")", ";", "$", "classes", "=", "$", "this", "->", "getClasses", "(", "$", "framework", ")", ";", "if", "(", "property_exists", "(", "$", "classes", ",", "$", "type", ")", ")", "{", "return", "$", "classes", "->", "$", "type", ";", "}", "return", "''", ";", "}" ]
Get the css class for a given object type. @param string $type Object type. @return string
[ "Get", "the", "css", "class", "for", "a", "given", "object", "type", "." ]
fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221
https://github.com/taskforcedev/laravel-support/blob/fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221/src/Helpers/UI.php#L25-L35
13,990
taskforcedev/laravel-support
src/Helpers/UI.php
UI.columns
public function columns($xs, $sm, $md, $lg) { $framework = $this->getFramework(); switch ($framework) { case 'bs3': case 'bs4': $xsC = $this->cssClass('column_extra_small') . $xs; $smC = $this->cssClass('column_small') . $sm; $mdC = $this->cssClass('column_medium') . $md; $lgC = $this->cssClass('column_large') . $lg; return $this->buildClassString([$xsC, $smC, $mdC, $lgC]); case 'f6': // Build the foundation classes $smC = $this->cssClass('column_small') . $sm; $mdC = $this->cssClass('column_medium') . $md; $lgC = $this->cssClass('column_large') . $lg; $columns = $this->cssClass('column'); // Build the string return $this->buildClassString([$columns, $smC, $mdC, $lgC]); default: return ''; break; } }
php
public function columns($xs, $sm, $md, $lg) { $framework = $this->getFramework(); switch ($framework) { case 'bs3': case 'bs4': $xsC = $this->cssClass('column_extra_small') . $xs; $smC = $this->cssClass('column_small') . $sm; $mdC = $this->cssClass('column_medium') . $md; $lgC = $this->cssClass('column_large') . $lg; return $this->buildClassString([$xsC, $smC, $mdC, $lgC]); case 'f6': // Build the foundation classes $smC = $this->cssClass('column_small') . $sm; $mdC = $this->cssClass('column_medium') . $md; $lgC = $this->cssClass('column_large') . $lg; $columns = $this->cssClass('column'); // Build the string return $this->buildClassString([$columns, $smC, $mdC, $lgC]); default: return ''; break; } }
[ "public", "function", "columns", "(", "$", "xs", ",", "$", "sm", ",", "$", "md", ",", "$", "lg", ")", "{", "$", "framework", "=", "$", "this", "->", "getFramework", "(", ")", ";", "switch", "(", "$", "framework", ")", "{", "case", "'bs3'", ":", "case", "'bs4'", ":", "$", "xsC", "=", "$", "this", "->", "cssClass", "(", "'column_extra_small'", ")", ".", "$", "xs", ";", "$", "smC", "=", "$", "this", "->", "cssClass", "(", "'column_small'", ")", ".", "$", "sm", ";", "$", "mdC", "=", "$", "this", "->", "cssClass", "(", "'column_medium'", ")", ".", "$", "md", ";", "$", "lgC", "=", "$", "this", "->", "cssClass", "(", "'column_large'", ")", ".", "$", "lg", ";", "return", "$", "this", "->", "buildClassString", "(", "[", "$", "xsC", ",", "$", "smC", ",", "$", "mdC", ",", "$", "lgC", "]", ")", ";", "case", "'f6'", ":", "// Build the foundation classes", "$", "smC", "=", "$", "this", "->", "cssClass", "(", "'column_small'", ")", ".", "$", "sm", ";", "$", "mdC", "=", "$", "this", "->", "cssClass", "(", "'column_medium'", ")", ".", "$", "md", ";", "$", "lgC", "=", "$", "this", "->", "cssClass", "(", "'column_large'", ")", ".", "$", "lg", ";", "$", "columns", "=", "$", "this", "->", "cssClass", "(", "'column'", ")", ";", "// Build the string", "return", "$", "this", "->", "buildClassString", "(", "[", "$", "columns", ",", "$", "smC", ",", "$", "mdC", ",", "$", "lgC", "]", ")", ";", "default", ":", "return", "''", ";", "break", ";", "}", "}" ]
Create framework column class. @param integer $xs Extra Small (Ignored on Foundation @param integer $sm Small. @param integer $md Medium. @param integer $lg Large. @return string
[ "Create", "framework", "column", "class", "." ]
fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221
https://github.com/taskforcedev/laravel-support/blob/fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221/src/Helpers/UI.php#L47-L71
13,991
taskforcedev/laravel-support
src/Helpers/UI.php
UI.getClasses
public function getClasses($framework) { switch ($framework) { case 'bs3': $classes = $this->json->bs3; break; case 'bs4': $classes = $this->json->bs4; break; case 'f6': $classes = $this->json->f6; break; case '': default: return ''; } return $classes; }
php
public function getClasses($framework) { switch ($framework) { case 'bs3': $classes = $this->json->bs3; break; case 'bs4': $classes = $this->json->bs4; break; case 'f6': $classes = $this->json->f6; break; case '': default: return ''; } return $classes; }
[ "public", "function", "getClasses", "(", "$", "framework", ")", "{", "switch", "(", "$", "framework", ")", "{", "case", "'bs3'", ":", "$", "classes", "=", "$", "this", "->", "json", "->", "bs3", ";", "break", ";", "case", "'bs4'", ":", "$", "classes", "=", "$", "this", "->", "json", "->", "bs4", ";", "break", ";", "case", "'f6'", ":", "$", "classes", "=", "$", "this", "->", "json", "->", "f6", ";", "break", ";", "case", "''", ":", "default", ":", "return", "''", ";", "}", "return", "$", "classes", ";", "}" ]
Get the css class matrix for the given framework. @param string $framework Framework. @return string
[ "Get", "the", "css", "class", "matrix", "for", "the", "given", "framework", "." ]
fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221
https://github.com/taskforcedev/laravel-support/blob/fdfa90ca10ffd57bc6f7aca20d2f3db7dc259221/src/Helpers/UI.php#L96-L114
13,992
sifophp/sifo-common-instance
classes/MailExt.php
MailExt.send
public function send( $to, $subject, $body ) { // Debug advice: if ( \Sifo\Domains::getInstance()->getDebugMode() ) { $this->_dispatchMailController( $to, $subject, $body ); } return parent::send( $to, $subject, $body ); }
php
public function send( $to, $subject, $body ) { // Debug advice: if ( \Sifo\Domains::getInstance()->getDebugMode() ) { $this->_dispatchMailController( $to, $subject, $body ); } return parent::send( $to, $subject, $body ); }
[ "public", "function", "send", "(", "$", "to", ",", "$", "subject", ",", "$", "body", ")", "{", "// Debug advice:", "if", "(", "\\", "Sifo", "\\", "Domains", "::", "getInstance", "(", ")", "->", "getDebugMode", "(", ")", ")", "{", "$", "this", "->", "_dispatchMailController", "(", "$", "to", ",", "$", "subject", ",", "$", "body", ")", ";", "}", "return", "parent", "::", "send", "(", "$", "to", ",", "$", "subject", ",", "$", "body", ")", ";", "}" ]
Send an email whith debug interruption. @param string $to @param string $subject @param string $body @return boolean
[ "Send", "an", "email", "whith", "debug", "interruption", "." ]
52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5
https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/MailExt.php#L15-L23
13,993
ignasbernotas/console
src/Question/MultipleChoiceQuestion.php
MultipleChoiceQuestion.selectChoice
protected function selectChoice() { $index = array_search( $this->choices[$this->cursor->getPosition()], $this->answers ); if (false !== $index) { unset($this->answers[$index]); } else { $this->answers[] = $this->choices[$this->cursor->getPosition()]; } $this->answers = array_values($this->answers); return $this; }
php
protected function selectChoice() { $index = array_search( $this->choices[$this->cursor->getPosition()], $this->answers ); if (false !== $index) { unset($this->answers[$index]); } else { $this->answers[] = $this->choices[$this->cursor->getPosition()]; } $this->answers = array_values($this->answers); return $this; }
[ "protected", "function", "selectChoice", "(", ")", "{", "$", "index", "=", "array_search", "(", "$", "this", "->", "choices", "[", "$", "this", "->", "cursor", "->", "getPosition", "(", ")", "]", ",", "$", "this", "->", "answers", ")", ";", "if", "(", "false", "!==", "$", "index", ")", "{", "unset", "(", "$", "this", "->", "answers", "[", "$", "index", "]", ")", ";", "}", "else", "{", "$", "this", "->", "answers", "[", "]", "=", "$", "this", "->", "choices", "[", "$", "this", "->", "cursor", "->", "getPosition", "(", ")", "]", ";", "}", "$", "this", "->", "answers", "=", "array_values", "(", "$", "this", "->", "answers", ")", ";", "return", "$", "this", ";", "}" ]
Allows selecting multiple choices @return $this
[ "Allows", "selecting", "multiple", "choices" ]
909e613b140413062424d6a465da08aac355be55
https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Question/MultipleChoiceQuestion.php#L27-L43
13,994
MissAllSunday/Ohara
src/Suki/Data.php
Data.sanitize
public function sanitize($var) { global $smcFunc; if (is_array($var)) { foreach ($var as $k => $v) $var[$k] = $this->sanitize($v); return $var; } else { $var = (string) $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($var), ENT_QUOTES); if (ctype_digit($var)) $var = (int) $var; if (empty($var)) $var = false; } return $var; }
php
public function sanitize($var) { global $smcFunc; if (is_array($var)) { foreach ($var as $k => $v) $var[$k] = $this->sanitize($v); return $var; } else { $var = (string) $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($var), ENT_QUOTES); if (ctype_digit($var)) $var = (int) $var; if (empty($var)) $var = false; } return $var; }
[ "public", "function", "sanitize", "(", "$", "var", ")", "{", "global", "$", "smcFunc", ";", "if", "(", "is_array", "(", "$", "var", ")", ")", "{", "foreach", "(", "$", "var", "as", "$", "k", "=>", "$", "v", ")", "$", "var", "[", "$", "k", "]", "=", "$", "this", "->", "sanitize", "(", "$", "v", ")", ";", "return", "$", "var", ";", "}", "else", "{", "$", "var", "=", "(", "string", ")", "$", "smcFunc", "[", "'htmltrim'", "]", "(", "$", "smcFunc", "[", "'htmlspecialchars'", "]", "(", "$", "var", ")", ",", "ENT_QUOTES", ")", ";", "if", "(", "ctype_digit", "(", "$", "var", ")", ")", "$", "var", "=", "(", "int", ")", "$", "var", ";", "if", "(", "empty", "(", "$", "var", ")", ")", "$", "var", "=", "false", ";", "}", "return", "$", "var", ";", "}" ]
Sanitizes a var. Recursive. Treats any var as a string and cast it as an integer if necessary. @param mixed $var The var you want to sanitize @access public @return mixed
[ "Sanitizes", "a", "var", ".", "Recursive", ".", "Treats", "any", "var", "as", "a", "string", "and", "cast", "it", "as", "an", "integer", "if", "necessary", "." ]
7753500cde1d51a0d7b37593aeaf2fc05fefd903
https://github.com/MissAllSunday/Ohara/blob/7753500cde1d51a0d7b37593aeaf2fc05fefd903/src/Suki/Data.php#L130-L154
13,995
kriskbx/mikado
spec/DummyData.php
DummyData.getStdClass
public function getStdClass($formatAble = false) { $object = new stdClass(); $object->testProperty = 'test'; $object->nullProperty = null; $object->arrayProperty = [ 'level1' => [ 'level2a' => null, 'level2' => [ 'level3' => 'value', 'level3b' => null, ], ], ]; if ($formatAble) { $object = Manager::formatAble($object); } return $object; }
php
public function getStdClass($formatAble = false) { $object = new stdClass(); $object->testProperty = 'test'; $object->nullProperty = null; $object->arrayProperty = [ 'level1' => [ 'level2a' => null, 'level2' => [ 'level3' => 'value', 'level3b' => null, ], ], ]; if ($formatAble) { $object = Manager::formatAble($object); } return $object; }
[ "public", "function", "getStdClass", "(", "$", "formatAble", "=", "false", ")", "{", "$", "object", "=", "new", "stdClass", "(", ")", ";", "$", "object", "->", "testProperty", "=", "'test'", ";", "$", "object", "->", "nullProperty", "=", "null", ";", "$", "object", "->", "arrayProperty", "=", "[", "'level1'", "=>", "[", "'level2a'", "=>", "null", ",", "'level2'", "=>", "[", "'level3'", "=>", "'value'", ",", "'level3b'", "=>", "null", ",", "]", ",", "]", ",", "]", ";", "if", "(", "$", "formatAble", ")", "{", "$", "object", "=", "Manager", "::", "formatAble", "(", "$", "object", ")", ";", "}", "return", "$", "object", ";", "}" ]
Get stdClass dummy data. @param bool $formatAble @return stdClass
[ "Get", "stdClass", "dummy", "data", "." ]
f00e566d682a66796f3f8a68b348920fadd9ee87
https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/spec/DummyData.php#L20-L40
13,996
kriskbx/mikado
spec/DummyData.php
DummyData.getStdClassWithArray
public function getStdClassWithArray($formatAble = false) { $object = new stdClass(); $object->array = [ [ 'key' => 'value', 'key2' => 'value2', ], ]; if ($formatAble) { $object = Manager::formatAble($object); } return $object; }
php
public function getStdClassWithArray($formatAble = false) { $object = new stdClass(); $object->array = [ [ 'key' => 'value', 'key2' => 'value2', ], ]; if ($formatAble) { $object = Manager::formatAble($object); } return $object; }
[ "public", "function", "getStdClassWithArray", "(", "$", "formatAble", "=", "false", ")", "{", "$", "object", "=", "new", "stdClass", "(", ")", ";", "$", "object", "->", "array", "=", "[", "[", "'key'", "=>", "'value'", ",", "'key2'", "=>", "'value2'", ",", "]", ",", "]", ";", "if", "(", "$", "formatAble", ")", "{", "$", "object", "=", "Manager", "::", "formatAble", "(", "$", "object", ")", ";", "}", "return", "$", "object", ";", "}" ]
Get stdClass dummy data with array. @param bool|false $formatAble @return stdClass
[ "Get", "stdClass", "dummy", "data", "with", "array", "." ]
f00e566d682a66796f3f8a68b348920fadd9ee87
https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/spec/DummyData.php#L49-L64
13,997
kriskbx/mikado
spec/DummyData.php
DummyData.getPost
public function getPost($formatAble = false) { $post = Post::published()->first(); $post = self::fix($post); if ($formatAble) { $post = Manager::formatAble($post); } return $post; }
php
public function getPost($formatAble = false) { $post = Post::published()->first(); $post = self::fix($post); if ($formatAble) { $post = Manager::formatAble($post); } return $post; }
[ "public", "function", "getPost", "(", "$", "formatAble", "=", "false", ")", "{", "$", "post", "=", "Post", "::", "published", "(", ")", "->", "first", "(", ")", ";", "$", "post", "=", "self", "::", "fix", "(", "$", "post", ")", ";", "if", "(", "$", "formatAble", ")", "{", "$", "post", "=", "Manager", "::", "formatAble", "(", "$", "post", ")", ";", "}", "return", "$", "post", ";", "}" ]
Get WordPress dummy data. @param bool $formatAble @return object
[ "Get", "WordPress", "dummy", "data", "." ]
f00e566d682a66796f3f8a68b348920fadd9ee87
https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/spec/DummyData.php#L73-L83
13,998
kriskbx/mikado
spec/DummyData.php
DummyData.getMultiplePosts
public function getMultiplePosts($formatAble = false) { $posts = Post::published()->get(); foreach ($posts as $key => $post) { $posts[$key] = self::fix($post); if ($formatAble) { $posts[$key] = Manager::formatAble($posts[$key]); } } return $posts; }
php
public function getMultiplePosts($formatAble = false) { $posts = Post::published()->get(); foreach ($posts as $key => $post) { $posts[$key] = self::fix($post); if ($formatAble) { $posts[$key] = Manager::formatAble($posts[$key]); } } return $posts; }
[ "public", "function", "getMultiplePosts", "(", "$", "formatAble", "=", "false", ")", "{", "$", "posts", "=", "Post", "::", "published", "(", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "posts", "as", "$", "key", "=>", "$", "post", ")", "{", "$", "posts", "[", "$", "key", "]", "=", "self", "::", "fix", "(", "$", "post", ")", ";", "if", "(", "$", "formatAble", ")", "{", "$", "posts", "[", "$", "key", "]", "=", "Manager", "::", "formatAble", "(", "$", "posts", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "posts", ";", "}" ]
Get multiple WordPress data. @param bool|false $formatAble @return mixed
[ "Get", "multiple", "WordPress", "data", "." ]
f00e566d682a66796f3f8a68b348920fadd9ee87
https://github.com/kriskbx/mikado/blob/f00e566d682a66796f3f8a68b348920fadd9ee87/spec/DummyData.php#L92-L105
13,999
Stratadox/ImmutableCollection
src/ImmutableCollection.php
ImmutableCollection.offsetSet
final public function offsetSet($index, $value): void { if (is_null($index)) { throw CannotAlterCollection::byAddingTo($this); } throw CannotAlterCollection::byOverWriting($this, $index); }
php
final public function offsetSet($index, $value): void { if (is_null($index)) { throw CannotAlterCollection::byAddingTo($this); } throw CannotAlterCollection::byOverWriting($this, $index); }
[ "final", "public", "function", "offsetSet", "(", "$", "index", ",", "$", "value", ")", ":", "void", "{", "if", "(", "is_null", "(", "$", "index", ")", ")", "{", "throw", "CannotAlterCollection", "::", "byAddingTo", "(", "$", "this", ")", ";", "}", "throw", "CannotAlterCollection", "::", "byOverWriting", "(", "$", "this", ",", "$", "index", ")", ";", "}" ]
Disallows use of the offsetSet method. @param int|mixed $index The index that may not be mutated. @param mixed $value The value that will not be written. @throws NotAllowed Whenever called upon.
[ "Disallows", "use", "of", "the", "offsetSet", "method", "." ]
eac441bc1762eefda6da25354b4e8f91f48bd733
https://github.com/Stratadox/ImmutableCollection/blob/eac441bc1762eefda6da25354b4e8f91f48bd733/src/ImmutableCollection.php#L60-L66