repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_documentation_string
stringlengths 1
47.2k
| func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|
infusephp/auth | src/Jobs/GarbageCollection.php | GarbageCollection.gcUserLinks | private function gcUserLinks()
{
return (bool) $this->app['database']->getDefault()
->delete('UserLinks')
->where('type', UserLink::FORGOT_PASSWORD)
->where('created_at', U::unixToDb(time() - UserLink::$forgotLinkTimeframe), '<')
->execute();
} | php | private function gcUserLinks()
{
return (bool) $this->app['database']->getDefault()
->delete('UserLinks')
->where('type', UserLink::FORGOT_PASSWORD)
->where('created_at', U::unixToDb(time() - UserLink::$forgotLinkTimeframe), '<')
->execute();
} | Clears out expired user links.
@return bool | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Jobs/GarbageCollection.php#L73-L80 |
borobudur-php/borobudur | src/Borobudur/Component/Messaging/Metadata/Registry.php | Registry.get | public function get(string $alias): MetadataInterface
{
if (!array_key_exists($alias, $this->metadata)) {
throw new \InvalidArgumentException(
sprintf('Resource "%s" does not exist', $alias)
);
}
return $this->metadata[$alias];
} | php | public function get(string $alias): MetadataInterface
{
if (!array_key_exists($alias, $this->metadata)) {
throw new \InvalidArgumentException(
sprintf('Resource "%s" does not exist', $alias)
);
}
return $this->metadata[$alias];
} | {@inheritdoc} | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Messaging/Metadata/Registry.php#L41-L50 |
borobudur-php/borobudur | src/Borobudur/Component/Messaging/Metadata/Registry.php | Registry.getByMessage | public function getByMessage(string $message): MetadataInterface
{
if (!array_key_exists($message, $this->aliases)) {
throw new \InvalidArgumentException(
sprintf('Resource with message "%s" does not exist', $message)
);
}
return $this->get($this->aliases[$message]);
} | php | public function getByMessage(string $message): MetadataInterface
{
if (!array_key_exists($message, $this->aliases)) {
throw new \InvalidArgumentException(
sprintf('Resource with message "%s" does not exist', $message)
);
}
return $this->get($this->aliases[$message]);
} | {@inheritdoc} | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Messaging/Metadata/Registry.php#L55-L64 |
borobudur-php/borobudur | src/Borobudur/Component/Messaging/Metadata/Registry.php | Registry.add | public function add(MetadataInterface $metadata): void
{
$this->metadata[$metadata->getAlias()] = $metadata;
$this->aliases[$metadata->getMessageClass()] = $metadata->getAlias();
} | php | public function add(MetadataInterface $metadata): void
{
$this->metadata[$metadata->getAlias()] = $metadata;
$this->aliases[$metadata->getMessageClass()] = $metadata->getAlias();
} | {@inheritdoc} | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Messaging/Metadata/Registry.php#L69-L73 |
andyburton/Sonic-Framework | src/Resource/Session.php | Session.singleton | public static function singleton ($sessionID = FALSE)
{
// If no instance is set
if (self::$_instance === FALSE)
{
// Create an instance
self::$_instance = new static ($sessionID);
}
// Return instance
return self::$_instance;
} | php | public static function singleton ($sessionID = FALSE)
{
// If no instance is set
if (self::$_instance === FALSE)
{
// Create an instance
self::$_instance = new static ($sessionID);
}
// Return instance
return self::$_instance;
} | Return a single object instance
@param string $sessionID Session ID
@return \Sonic\Resource\Session | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Session.php#L78-L96 |
andyburton/Sonic-Framework | src/Resource/Session.php | Session.Create | public function Create ($sessionID = FALSE)
{
// If there is no session
if (!session_id ())
{
// If there is a session ID
if ($sessionID)
{
// Set it
session_id ($sessionID);
}
// Start session
session_start ();
}
// Send cache headers
header ('Expires: Sun, 23 Nov 1984 03:13:37 GMT');
header ('Last-Modified: ' . gmdate ('D, d M Y H:i:s') . ' GMT');
header ('Cache-Control: no-store, no-cache, must-revalidate');
header ('Cache-Control: post-check=0, pre-check=0', FALSE);
header ('Pragma: no-cache');
// Set session ID
$this->_sessionID = session_id ();
} | php | public function Create ($sessionID = FALSE)
{
// If there is no session
if (!session_id ())
{
// If there is a session ID
if ($sessionID)
{
// Set it
session_id ($sessionID);
}
// Start session
session_start ();
}
// Send cache headers
header ('Expires: Sun, 23 Nov 1984 03:13:37 GMT');
header ('Last-Modified: ' . gmdate ('D, d M Y H:i:s') . ' GMT');
header ('Cache-Control: no-store, no-cache, must-revalidate');
header ('Cache-Control: post-check=0, pre-check=0', FALSE);
header ('Pragma: no-cache');
// Set session ID
$this->_sessionID = session_id ();
} | Start a new session
@param string $sessionID Session ID
@return void | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Session.php#L105-L143 |
andyburton/Sonic-Framework | src/Resource/Session.php | Session.Destroy | public function Destroy ()
{
// If no session has been started, bail here before session_destroy() errors
$sessionID = session_id ();
if (empty ($sessionID))
{
return FALSE;
}
// Cookie Destruction
$cookie = session_get_cookie_params ();
if ((empty ($cookie['domain'])) && (empty ($cookie['secure'])))
{
setcookie (session_name (), '', time () -99999, $cookie['path']);
}
elseif (empty ($cookie['secure']))
{
setcookie (session_name (), '', time () -99999, $cookie['path'], $cookie['domain']);
}
else
{
setcookie (session_name (), '', time () -99999, $cookie['path'], $cookie['domain'], $cookie['secure']);
}
// Session Destruction
$_SESSION = array ();
return session_destroy ();
} | php | public function Destroy ()
{
// If no session has been started, bail here before session_destroy() errors
$sessionID = session_id ();
if (empty ($sessionID))
{
return FALSE;
}
// Cookie Destruction
$cookie = session_get_cookie_params ();
if ((empty ($cookie['domain'])) && (empty ($cookie['secure'])))
{
setcookie (session_name (), '', time () -99999, $cookie['path']);
}
elseif (empty ($cookie['secure']))
{
setcookie (session_name (), '', time () -99999, $cookie['path'], $cookie['domain']);
}
else
{
setcookie (session_name (), '', time () -99999, $cookie['path'], $cookie['domain'], $cookie['secure']);
}
// Session Destruction
$_SESSION = array ();
return session_destroy ();
} | Destroy the session
@return boolean | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Session.php#L213-L248 |
x2ts/x2ts | src/db/SQLite.php | SQLite.query | public function query(string $sql, array $params = []) {
X::logger()->trace("$sql with params " . $this->serializeArray($params));
try {
$st = $this->pdo->prepare($sql);
if ($st === false) {
$e = $this->pdo->errorInfo();
throw new DataBaseException($e[2], $e[1]);
}
if ($st->execute($params)) {
$this->_affectedRows = $st->rowCount();
$this->_lastInsertId = $this->pdo->lastInsertId();
return $st->fetchAll(PDO::FETCH_ASSOC);
}
$e = $st->errorInfo();
throw new DataBaseException($e[2], $e[1]);
} catch (PDOException $ex) {
X::logger()->trace($ex);
throw new DataBaseException($ex->getMessage(), $ex->getCode());
}
} | php | public function query(string $sql, array $params = []) {
X::logger()->trace("$sql with params " . $this->serializeArray($params));
try {
$st = $this->pdo->prepare($sql);
if ($st === false) {
$e = $this->pdo->errorInfo();
throw new DataBaseException($e[2], $e[1]);
}
if ($st->execute($params)) {
$this->_affectedRows = $st->rowCount();
$this->_lastInsertId = $this->pdo->lastInsertId();
return $st->fetchAll(PDO::FETCH_ASSOC);
}
$e = $st->errorInfo();
throw new DataBaseException($e[2], $e[1]);
} catch (PDOException $ex) {
X::logger()->trace($ex);
throw new DataBaseException($ex->getMessage(), $ex->getCode());
}
} | run sql and return the result
@param string $sql
@param array $params
@throws DataBaseException
@return array | https://github.com/x2ts/x2ts/blob/65e43952ab940ab05696a34d31a1c3ab91545090/src/db/SQLite.php#L62-L82 |
3ev/wordpress-core | src/Tev/Author/Model/Author.php | Author.getAvatarTag | public function getAvatarTag($size = 96, $alt = null)
{
return get_avatar($this->getId(), $size, null, $alt ?: $this->getDisplayName());
} | php | public function getAvatarTag($size = 96, $alt = null)
{
return get_avatar($this->getId(), $size, null, $alt ?: $this->getDisplayName());
} | Get an image tag for this author's avatar.
@param int $size Avatar size. Max 512, default 96
@param string $alt Alt text. Defaults to display name
@return string | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Author/Model/Author.php#L142-L145 |
tarsana/syntax | src/ArraySyntax.php | ArraySyntax.syntax | public function syntax(Syntax $value = null) : Syntax
{
if (null === $value) {
return $this->syntax;
}
$this->syntax = $value;
return $this;
} | php | public function syntax(Syntax $value = null) : Syntax
{
if (null === $value) {
return $this->syntax;
}
$this->syntax = $value;
return $this;
} | Item syntax getter and setter.
@param Tarsana\Syntax\Syntax $value
@return Tarsana\Syntax\Syntax | https://github.com/tarsana/syntax/blob/fd3f8a25e3be0e391c8fd486ccfcffe913ade534/src/ArraySyntax.php#L49-L56 |
tarsana/syntax | src/ArraySyntax.php | ArraySyntax.separator | public function separator(string $value = null)
{
if (null === $value) {
return $this->separator;
}
$this->separator = $value;
return $this;
} | php | public function separator(string $value = null)
{
if (null === $value) {
return $this->separator;
}
$this->separator = $value;
return $this;
} | Separator getter and setter.
@param string $value
@return self|string | https://github.com/tarsana/syntax/blob/fd3f8a25e3be0e391c8fd486ccfcffe913ade534/src/ArraySyntax.php#L64-L71 |
tarsana/syntax | src/ArraySyntax.php | ArraySyntax.parse | public function parse(string $text) : array
{
$index = 0;
$items = Text::split($text, $this->separator);
$array = [];
try {
foreach ($items as $item) {
$array[] = $this->syntax->parse($item);
$index += strlen($item) + 1;
}
} catch (ParseException $e) {
$extra = [
'type' => 'invalid-item',
'item' => $item,
'position' => $e->position()
];
throw new ParseException($this, $text, $index + $e->position(),
"Unable to parse the item '{$item}'", $extra, $e
);
}
return $array;
} | php | public function parse(string $text) : array
{
$index = 0;
$items = Text::split($text, $this->separator);
$array = [];
try {
foreach ($items as $item) {
$array[] = $this->syntax->parse($item);
$index += strlen($item) + 1;
}
} catch (ParseException $e) {
$extra = [
'type' => 'invalid-item',
'item' => $item,
'position' => $e->position()
];
throw new ParseException($this, $text, $index + $e->position(),
"Unable to parse the item '{$item}'", $extra, $e
);
}
return $array;
} | Transforms a string to array based on
the syntax or throws a ParseException.
@param string $text the string to parse
@return array
@throws Tarsana\Syntax\Exceptions\ParseException | https://github.com/tarsana/syntax/blob/fd3f8a25e3be0e391c8fd486ccfcffe913ade534/src/ArraySyntax.php#L92-L114 |
tarsana/syntax | src/ArraySyntax.php | ArraySyntax.dump | public function dump($values) : string
{
if (! is_array($values))
throw new DumpException($this, $values, self::ERROR);
$items = [];
$index = 0;
try {
foreach ($values as $key => $value) {
$index = $key;
$items[] = $this->syntax->dump($value);
}
} catch (DumpException $e) {
throw new DumpException($this, $values, "Unable to dump item at key {$index}", [], $e);
}
return Text::join($items, $this->separator);
} | php | public function dump($values) : string
{
if (! is_array($values))
throw new DumpException($this, $values, self::ERROR);
$items = [];
$index = 0;
try {
foreach ($values as $key => $value) {
$index = $key;
$items[] = $this->syntax->dump($value);
}
} catch (DumpException $e) {
throw new DumpException($this, $values, "Unable to dump item at key {$index}", [], $e);
}
return Text::join($items, $this->separator);
} | Converts the given array to a string based
on the syntax or throws a DumpException.
@param array $values the data to encode
@return string
@throws Tarsana\Syntax\Exceptions\DumpException | https://github.com/tarsana/syntax/blob/fd3f8a25e3be0e391c8fd486ccfcffe913ade534/src/ArraySyntax.php#L125-L141 |
RowlandOti/ooglee-blogmodule | src/OoGlee/Application/Entities/Post/PostContent.php | PostContent.make | public function make(IPost $post)
{
//$post->setContent($this->view->make($post->getLayoutViewPath(), compact('post'))->render());
$post->setContent($this->view->make(\OogleeBConfig::get('config.post_view.view'), compact('post'))->render());
} | php | public function make(IPost $post)
{
//$post->setContent($this->view->make($post->getLayoutViewPath(), compact('post'))->render());
$post->setContent($this->view->make(\OogleeBConfig::get('config.post_view.view'), compact('post'))->render());
} | Make the view content.
@param PostInterface $p | https://github.com/RowlandOti/ooglee-blogmodule/blob/d9c0fe4745bb09f8b94047b0cda4fd7438cde16a/src/OoGlee/Application/Entities/Post/PostContent.php#L42-L46 |
payapi/payapi-sdk-php | src/payapi/core/core.controller.php | controller.arguments | protected function arguments($key)
{
//-> to filter
if (isset($this->arguments[0][$key])) {
return $this->arguments[0][$key];
}
return $this->serialize->undefined();
} | php | protected function arguments($key)
{
//-> to filter
if (isset($this->arguments[0][$key])) {
return $this->arguments[0][$key];
}
return $this->serialize->undefined();
} | -> SDK passed argument(s) | https://github.com/payapi/payapi-sdk-php/blob/6a675749c88742b261178d7977f2436d540132b4/src/payapi/core/core.controller.php#L222-L229 |
payapi/payapi-sdk-php | src/payapi/core/core.controller.php | controller.settings | protected function settings($key = false)
{
if ($this->settings == false) {
return false;
}
if ($key == false) {
return $this->settings;
}
if (isset($this->settings[$key])) {
return $this->settings[$key];
}
return false;
} | php | protected function settings($key = false)
{
if ($this->settings == false) {
return false;
}
if ($key == false) {
return $this->settings;
}
if (isset($this->settings[$key])) {
return $this->settings[$key];
}
return false;
} | -> merchantSettings | https://github.com/payapi/payapi-sdk-php/blob/6a675749c88742b261178d7977f2436d540132b4/src/payapi/core/core.controller.php#L231-L243 |
schpill/thin | src/Tool.php | Tool.bind | public function bind($abstract, $concrete = null, $shared = false)
{
// If the given types are actually an array, we will assume an alias is being
// defined and will grab this "real" abstract class name and register this
// alias with the container so that it can be used as a shortcut for it.
if (Arrays::is($abstract)) {
list($abstract, $alias) = $this->extractAlias($abstract);
$this->alias($abstract, $alias);
}
// If no concrete type was given, we will simply set the concrete type to the
// abstract type. This will allow concrete type to be registered as shared
// without being forced to state their classes in both of the parameter.
$this->dropStaleInstances($abstract);
if (is_null($concrete)) {
$concrete = $abstract;
}
// If the factory is not a Closure, it means it is just a class name which is
// is bound into this container to the abstract type and we will just wrap
// it up inside a Closure to make things more convenient when extending.
if ( ! $concrete instanceof Closure) {
$concrete = $this->getClosure($abstract, $concrete);
}
$bound = $this->bound($abstract);
$this->bindings[$abstract] = compact('concrete', 'shared');
// If the abstract type was already bound in this container, we will fire the
// rebound listener so that any objects which have already gotten resolved
// can have their copy of the object updated via the listener callbacks.
if ($bound) {
$this->rebound($abstract);
}
} | php | public function bind($abstract, $concrete = null, $shared = false)
{
// If the given types are actually an array, we will assume an alias is being
// defined and will grab this "real" abstract class name and register this
// alias with the container so that it can be used as a shortcut for it.
if (Arrays::is($abstract)) {
list($abstract, $alias) = $this->extractAlias($abstract);
$this->alias($abstract, $alias);
}
// If no concrete type was given, we will simply set the concrete type to the
// abstract type. This will allow concrete type to be registered as shared
// without being forced to state their classes in both of the parameter.
$this->dropStaleInstances($abstract);
if (is_null($concrete)) {
$concrete = $abstract;
}
// If the factory is not a Closure, it means it is just a class name which is
// is bound into this container to the abstract type and we will just wrap
// it up inside a Closure to make things more convenient when extending.
if ( ! $concrete instanceof Closure) {
$concrete = $this->getClosure($abstract, $concrete);
}
$bound = $this->bound($abstract);
$this->bindings[$abstract] = compact('concrete', 'shared');
// If the abstract type was already bound in this container, we will fire the
// rebound listener so that any objects which have already gotten resolved
// can have their copy of the object updated via the listener callbacks.
if ($bound) {
$this->rebound($abstract);
}
} | Register a binding with the container.
@param string $abstract
@param Closure|string|null $concrete
@param bool $shared
@return void | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Tool.php#L112-L149 |
schpill/thin | src/Tool.php | Tool.getExtender | protected function getExtender($abstract, Closure $closure)
{
// To "extend" a binding, we will grab the old "resolver" Closure and pass it
// into a new one. The old resolver will be called first and the result is
// handed off to the "new" resolver, along with this container instance.
$resolver = $this->bindings[$abstract]['concrete'];
return function($container) use ($resolver, $closure) {
$args = array();
$res = call_user_func_array($resolver, array($container));
array_push($args, $res);
array_push($args, $container);
return call_user_func_array($closure, $args);
};
} | php | protected function getExtender($abstract, Closure $closure)
{
// To "extend" a binding, we will grab the old "resolver" Closure and pass it
// into a new one. The old resolver will be called first and the result is
// handed off to the "new" resolver, along with this container instance.
$resolver = $this->bindings[$abstract]['concrete'];
return function($container) use ($resolver, $closure) {
$args = array();
$res = call_user_func_array($resolver, array($container));
array_push($args, $res);
array_push($args, $container);
return call_user_func_array($closure, $args);
};
} | Get an extender Closure for resolving a type.
@param string $abstract
@param \Closure $closure
@return \Closure | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Tool.php#L259-L273 |
schpill/thin | src/Tool.php | Tool.instance | public function instance($abstract, $instance)
{
// First, we will extract the alias from the abstract if it is an array so we
// are using the correct name when binding the type. If we get an alias it
// will be registered with the container so we can resolve it out later.
if (Arrays::is($abstract)) {
list($abstract, $alias) = $this->extractAlias($abstract);
$this->alias($abstract, $alias);
}
unset($this->aliases[$abstract]);
// We'll check to determine if this type has been bound before, and if it has
// we will fire the rebound callbacks registered with the container and it
// can be updated with consuming classes that have gotten resolved here.
$bound = $this->bound($abstract);
$this->instances[$abstract] = $instance;
if ($bound) {
$this->rebound($abstract);
}
} | php | public function instance($abstract, $instance)
{
// First, we will extract the alias from the abstract if it is an array so we
// are using the correct name when binding the type. If we get an alias it
// will be registered with the container so we can resolve it out later.
if (Arrays::is($abstract)) {
list($abstract, $alias) = $this->extractAlias($abstract);
$this->alias($abstract, $alias);
}
unset($this->aliases[$abstract]);
// We'll check to determine if this type has been bound before, and if it has
// we will fire the rebound callbacks registered with the container and it
// can be updated with consuming classes that have gotten resolved here.
$bound = $this->bound($abstract);
$this->instances[$abstract] = $instance;
if ($bound) {
$this->rebound($abstract);
}
} | Register an existing instance as shared in the container.
@param string $abstract
@param mixed $instance
@return void | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Tool.php#L282-L302 |
as3io/modlr | src/Rest/RestKernel.php | RestKernel.handle | public function handle(Request $request)
{
try {
$restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
$restResponse = $this->adapter->processRequest($restRequest);
} catch (\Exception $e) {
if (true === $this->debugEnabled()) {
throw $e;
}
$restResponse = $this->adapter->handleException($e);
}
return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
} | php | public function handle(Request $request)
{
try {
$restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
$restResponse = $this->adapter->processRequest($restRequest);
} catch (\Exception $e) {
if (true === $this->debugEnabled()) {
throw $e;
}
$restResponse = $this->adapter->handleException($e);
}
return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
} | Processes an incoming Request object, routes it to the adapter, and returns a response.
@param Request $request
@return Response $response | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestKernel.php#L62-L74 |
hal-platform/hal-core | src/Database/DoctrineUtility/DoctrineProxyGenerator.php | DoctrineProxyGenerator.generateProxies | public static function generateProxies(EntityManager $em)
{
$metas = $em->getMetadataFactory()->getAllMetadata();
$proxy = $em->getProxyFactory();
$proxyDir = $em->getConfiguration()->getProxyDir();
if (count($metas) === 0) {
echo "No entities to process.\n";
return true;
}
if (!is_dir($proxyDir)) {
mkdir($proxyDir, 0777, true);
}
$proxyDir = realpath($proxyDir);
if (!file_exists($proxyDir)) {
echo sprintf('Proxies destination directory "%s" does not exist.', $proxyDir) . "\n";
return false;
}
if (!is_writable($proxyDir)) {
echo sprintf('Proxies destination directory "%s" does not have write permissions.', $proxyDir) . "\n";
return false;
}
foreach ($metas as $metadata) {
echo sprintf('Processing "%s"', $metadata->getName()) . "\n";
}
// Generate Proxies
$proxy->generateProxyClasses($metas);
echo "\n";
echo sprintf('Proxy classes generated to "%s"', $proxyDir) . "\n";
return true;
} | php | public static function generateProxies(EntityManager $em)
{
$metas = $em->getMetadataFactory()->getAllMetadata();
$proxy = $em->getProxyFactory();
$proxyDir = $em->getConfiguration()->getProxyDir();
if (count($metas) === 0) {
echo "No entities to process.\n";
return true;
}
if (!is_dir($proxyDir)) {
mkdir($proxyDir, 0777, true);
}
$proxyDir = realpath($proxyDir);
if (!file_exists($proxyDir)) {
echo sprintf('Proxies destination directory "%s" does not exist.', $proxyDir) . "\n";
return false;
}
if (!is_writable($proxyDir)) {
echo sprintf('Proxies destination directory "%s" does not have write permissions.', $proxyDir) . "\n";
return false;
}
foreach ($metas as $metadata) {
echo sprintf('Processing "%s"', $metadata->getName()) . "\n";
}
// Generate Proxies
$proxy->generateProxyClasses($metas);
echo "\n";
echo sprintf('Proxy classes generated to "%s"', $proxyDir) . "\n";
return true;
} | @param EntityManager $em
@return bool | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Database/DoctrineUtility/DoctrineProxyGenerator.php#L26-L64 |
weavephp/container-league | src/League.php | League.loadContainer | protected function loadContainer(array $config = [], $environment = null)
{
$this->container = new Container;
$this->configureContainerInternal();
$this->configureContainer($this->container, $config, $environment);
return $this->container->get('instantiator');
} | php | protected function loadContainer(array $config = [], $environment = null)
{
$this->container = new Container;
$this->configureContainerInternal();
$this->configureContainer($this->container, $config, $environment);
return $this->container->get('instantiator');
} | Setup the Dependency Injection Container
@param array $config Optional config array as provided from loadConfig().
@param string $environment Optional indication of the runtime environment.
@return callable A callable that can instantiate instances of classes from the DIC. | https://github.com/weavephp/container-league/blob/14227536569eccd8376b38429e7762a4caebe282/src/League.php#L31-L37 |
weavephp/container-league | src/League.php | League.configureContainerInternal | protected function configureContainerInternal()
{
$this->container->add(
'instantiator',
function () {
return function ($name) {
return $this->container->get($name);
};
}
);
$this->container->add(\Weave\Middleware\Middleware::class)
->withArgument(\Weave\Middleware\MiddlewareAdaptorInterface::class)
->withArgument(
function ($pipelineName) {
return $this->provideMiddlewarePipeline($pipelineName);
}
)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class)
->withArgument(\Weave\Http\RequestFactoryInterface::class)
->withArgument(\Weave\Http\ResponseFactoryInterface::class)
->withArgument(\Weave\Http\ResponseEmitterInterface::class);
$this->container->add(
\Weave\Resolve\ResolveAdaptorInterface::class,
\Weave\Resolve\Resolve::class
)
->withArgument('instantiator');
$this->container->add(
\Weave\Dispatch\DispatchAdaptorInterface::class,
\Weave\Dispatch\Dispatch::class
);
$this->container->add(\Weave\Middleware\Dispatch::class)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class);
$this->container->add(\Weave\Router\Router::class)
->withArgument(\Weave\Router\RouterAdaptorInterface::class)
->withArgument(
function ($router) {
return $this->provideRouteConfiguration($router);
}
)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class);
} | php | protected function configureContainerInternal()
{
$this->container->add(
'instantiator',
function () {
return function ($name) {
return $this->container->get($name);
};
}
);
$this->container->add(\Weave\Middleware\Middleware::class)
->withArgument(\Weave\Middleware\MiddlewareAdaptorInterface::class)
->withArgument(
function ($pipelineName) {
return $this->provideMiddlewarePipeline($pipelineName);
}
)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class)
->withArgument(\Weave\Http\RequestFactoryInterface::class)
->withArgument(\Weave\Http\ResponseFactoryInterface::class)
->withArgument(\Weave\Http\ResponseEmitterInterface::class);
$this->container->add(
\Weave\Resolve\ResolveAdaptorInterface::class,
\Weave\Resolve\Resolve::class
)
->withArgument('instantiator');
$this->container->add(
\Weave\Dispatch\DispatchAdaptorInterface::class,
\Weave\Dispatch\Dispatch::class
);
$this->container->add(\Weave\Middleware\Dispatch::class)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class);
$this->container->add(\Weave\Router\Router::class)
->withArgument(\Weave\Router\RouterAdaptorInterface::class)
->withArgument(
function ($router) {
return $this->provideRouteConfiguration($router);
}
)
->withArgument(\Weave\Resolve\ResolveAdaptorInterface::class)
->withArgument(\Weave\Dispatch\DispatchAdaptorInterface::class);
} | Configure's the internal Weave requirements.
@return null | https://github.com/weavephp/container-league/blob/14227536569eccd8376b38429e7762a4caebe282/src/League.php#L55-L103 |
wandersonwhcr/illuminate-romans | src/Providers/RomansProvider.php | RomansProvider.register | public function register()
{
$this->app->singleton(Grammar::class);
$this->app->singleton(Lexer::class);
$this->app->singleton(Parser::class);
$this->app->singleton(IntToRomanFilter::class);
$this->app->singleton(RomanToIntFilter::class);
$this->app->resolving(RomanToIntFilter::class, function ($element, $app) {
$element->setLexer($app->make(Lexer::class));
$element->setParser($app->make(Parser::class));
return $element;
});
$this->app->alias(IntToRomanFilter::class, 'intToRoman');
$this->app->alias(RomanToIntFilter::class, 'romanToInt');
} | php | public function register()
{
$this->app->singleton(Grammar::class);
$this->app->singleton(Lexer::class);
$this->app->singleton(Parser::class);
$this->app->singleton(IntToRomanFilter::class);
$this->app->singleton(RomanToIntFilter::class);
$this->app->resolving(RomanToIntFilter::class, function ($element, $app) {
$element->setLexer($app->make(Lexer::class));
$element->setParser($app->make(Parser::class));
return $element;
});
$this->app->alias(IntToRomanFilter::class, 'intToRoman');
$this->app->alias(RomanToIntFilter::class, 'romanToInt');
} | Register Romans Services
@return void | https://github.com/wandersonwhcr/illuminate-romans/blob/7025e39c633cb30a10eff27c7cfa756ce91026a6/src/Providers/RomansProvider.php#L41-L60 |
newup/core | src/Providers/RendererServiceProvider.php | RendererServiceProvider.register | public function register()
{
$this->app->singleton(InputCollector::class, function() {
return new InputCollector;
});
$this->app->singleton(Renderer::class, function () {
return $this->app->make(TemplateRenderer::class);
});
} | php | public function register()
{
$this->app->singleton(InputCollector::class, function() {
return new InputCollector;
});
$this->app->singleton(Renderer::class, function () {
return $this->app->make(TemplateRenderer::class);
});
} | Register the service provider.
@return void | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Providers/RendererServiceProvider.php#L18-L27 |
phpalchemy/phpalchemy | Alchemy/Mvc/Adapter/HaangaView.php | HaangaView.render | public function render()
{
$config = array(
'template_dir' => $this->getTemplateDir(),
'cache_dir' => $this->getCacheDir(),
'debug' => $this->debug,
'compiler' => array(
'allow_exec' => true,
),
);
if ($this->cache && is_callable('xcache_isset')) {
/* don't check for changes in the template for the next 5 min */
$config['check_ttl'] = 300;
$config['check_get'] = 'xcache_get';
$config['check_set'] = 'xcache_set';
}
\Haanga::configure($config);
\Haanga::Load($this->getTpl(), $this->data);
} | php | public function render()
{
$config = array(
'template_dir' => $this->getTemplateDir(),
'cache_dir' => $this->getCacheDir(),
'debug' => $this->debug,
'compiler' => array(
'allow_exec' => true,
),
);
if ($this->cache && is_callable('xcache_isset')) {
/* don't check for changes in the template for the next 5 min */
$config['check_ttl'] = 300;
$config['check_get'] = 'xcache_get';
$config['check_set'] = 'xcache_set';
}
\Haanga::configure($config);
\Haanga::Load($this->getTpl(), $this->data);
} | Wrapped | https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Mvc/Adapter/HaangaView.php#L17-L38 |
mlocati/concrete5-translation-library | src/Parser/DynamicItem/AttributeKeyCategory.php | AttributeKeyCategory.parseManual | public function parseManual(\Gettext\Translations $translations, $concrete5version)
{
$akcNameMap = array(
'collection' => 'Page attributes',
'user' => 'User attributes',
'file' => 'File attributes',
);
if (version_compare($concrete5version, '5.7') < 0) {
$akcClass = '\AttributeKeyCategory';
} else {
$akcClass = '\Concrete\Core\Attribute\Key\Category';
}
if (class_exists($akcClass, true) && method_exists($akcClass, 'getList')) {
foreach (call_user_func($akcClass.'::getList') as $akc) {
$akcHandle = $akc->getAttributeKeyCategoryHandle();
$this->addTranslation($translations, isset($akcNameMap[$akcHandle]) ? $akcNameMap[$akcHandle] : ucwords(str_replace(array('_', '-', '/'), ' ', $akcHandle)));
}
}
} | php | public function parseManual(\Gettext\Translations $translations, $concrete5version)
{
$akcNameMap = array(
'collection' => 'Page attributes',
'user' => 'User attributes',
'file' => 'File attributes',
);
if (version_compare($concrete5version, '5.7') < 0) {
$akcClass = '\AttributeKeyCategory';
} else {
$akcClass = '\Concrete\Core\Attribute\Key\Category';
}
if (class_exists($akcClass, true) && method_exists($akcClass, 'getList')) {
foreach (call_user_func($akcClass.'::getList') as $akc) {
$akcHandle = $akc->getAttributeKeyCategoryHandle();
$this->addTranslation($translations, isset($akcNameMap[$akcHandle]) ? $akcNameMap[$akcHandle] : ucwords(str_replace(array('_', '-', '/'), ' ', $akcHandle)));
}
}
} | {@inheritdoc}
@see \C5TL\Parser\DynamicItem\DynamicItem::parseManual() | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/DynamicItem/AttributeKeyCategory.php#L35-L53 |
mover-io/belt | lib/Text.php | Text.ensureSuffix | static public function ensureSuffix($string, $suffix) {
if(Text::endsWith($string, $suffix)) {
return $string;
} else {
return $string . $suffix;
}
} | php | static public function ensureSuffix($string, $suffix) {
if(Text::endsWith($string, $suffix)) {
return $string;
} else {
return $string . $suffix;
}
} | /*
Ensure a string ends with a suffix
Will return the original string if it already is terminated by the desired
suffix, or will add the suffix if it is not. This is a case sensitive
function.
@param string $string the string that should be suffix terminated
@param string $suffix the desired suffix that should terminate the string
@return string returns the suffix terminated form of the string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L16-L22 |
mover-io/belt | lib/Text.php | Text.ensureNoSuffix | static public function ensureNoSuffix($string, $prefix) {
if(!Text::endsWith($string, $prefix)) {
return $string;
} else {
return mb_substr($string, 0, -mb_strlen($prefix)) ?: '';
}
} | php | static public function ensureNoSuffix($string, $prefix) {
if(!Text::endsWith($string, $prefix)) {
return $string;
} else {
return mb_substr($string, 0, -mb_strlen($prefix)) ?: '';
}
} | /*
Ensure a string does not start with a prefix
Will return the original string if it already is not started by the provided
prefix , or will remove the prefix if it is present. This is a case
sensitive function.
@param string $string the string that should not be prefix started
@param string $prefix the desired prefix that should be removed if present
@return string returns the non-prefix started form of the string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L36-L42 |
mover-io/belt | lib/Text.php | Text.ensureNoPrefix | static public function ensureNoPrefix($string, $prefix) {
if(!Text::startsWith($string, $prefix)) {
return $string;
} else {
return mb_substr($string, mb_strlen($prefix)) ?: '';
}
} | php | static public function ensureNoPrefix($string, $prefix) {
if(!Text::startsWith($string, $prefix)) {
return $string;
} else {
return mb_substr($string, mb_strlen($prefix)) ?: '';
}
} | /*
Ensure a string does not start with a prefix
Will return the original string if it already is not started by the provided
prefix , or will remove the prefix if it is present. This is a case
sensitive function.
@param string $string the string that should not be prefix started
@param string $prefix the desired prefix that should be removed if present
@return string returns the non-prefix started form of the string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L56-L62 |
mover-io/belt | lib/Text.php | Text.ensurePrefix | static public function ensurePrefix($string, $prefix) {
if(Text::startsWith($string, $prefix)) {
return $string;
} else {
return $prefix . $string;
}
} | php | static public function ensurePrefix($string, $prefix) {
if(Text::startsWith($string, $prefix)) {
return $string;
} else {
return $prefix . $string;
}
} | /*
Ensure a string starts with a prefix.
Will return the original string if it already is started by the desired
prefix, or will add the prefix if it is not. This is a case sensitive
function.
@param string $string the string that should be prefix terminated
@param string $prefix the desired prefix that should start the string
@return string returns the prefix started form of the string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L76-L82 |
mover-io/belt | lib/Text.php | Text.randomString | static public function randomString( $length ) {
$transactionhars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $transactionhars );
$str = '';
for( $i = 0; $i < $length; $i++ )
$str .= $transactionhars[ rand( 0, $size - 1 ) ];
return $str;
} | php | static public function randomString( $length ) {
$transactionhars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $transactionhars );
$str = '';
for( $i = 0; $i < $length; $i++ )
$str .= $transactionhars[ rand( 0, $size - 1 ) ];
return $str;
} | Generates a random string using [a-Z0-9]. | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L114-L122 |
mover-io/belt | lib/Text.php | Text.shellColor | static public function shellColor($color, $string, $conditional=true) {
if(!$conditional) {
return $string;
}
$color = self::shellColorCode($color);
return $color.$string.self::shellColorCode('plain');
} | php | static public function shellColor($color, $string, $conditional=true) {
if(!$conditional) {
return $string;
}
$color = self::shellColorCode($color);
return $color.$string.self::shellColorCode('plain');
} | Wraps string in bash shell color escape sequences for the provided color.
@param $color string|integer If a string is provided, we lookup the colors
using the $colors table in the function body below. For precise control,
an integer will yield a precise color code.
@param $string string The string to colorize.
@param $conditional A flag parameter which may be passed in to
transparently enable/disable colorization.
@return The colorized string. | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L136-L142 |
mover-io/belt | lib/Text.php | Text.fromCamel | static public function fromCamel($str) {
$str[0] = strtolower($str[0]);
return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
} | php | static public function fromCamel($str) {
$str[0] = strtolower($str[0]);
return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
} | Converts camel-case to corresponding underscores.
@param $str
@example helloWorld -> hello_world
@return string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L213-L216 |
mover-io/belt | lib/Text.php | Text.toCamel | static public function toCamel($str, $capitalise_first_char = false) {
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
return preg_replace_callback('/_([a-z])/',function($char) {return strtoupper($char[1]);}, $str);
} | php | static public function toCamel($str, $capitalise_first_char = false) {
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
return preg_replace_callback('/_([a-z])/',function($char) {return strtoupper($char[1]);}, $str);
} | Converts underscores to a corresponding camel-case string.
@param $str
@param $capitalise_first_char
@example this_is_a_test -> thisIsATest
@return string | https://github.com/mover-io/belt/blob/c966a70aa0f4eb51be55bbb86c89b1e85b773d68/lib/Text.php#L227-L232 |
ZeinEddin/ZeDoctrineExtensions | lib/ZeDoctrineExtensions/Query/Oracle/Translate.php | Translate.getSql | public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return sprintf(
'TRANSLATE(%s, %s, %s)',
$sqlWalker->walkArithmeticPrimary($this->expr),
$sqlWalker->walkArithmeticPrimary($this->fromString),
$sqlWalker->walkArithmeticPrimary($this->toString)
);
} | php | public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return sprintf(
'TRANSLATE(%s, %s, %s)',
$sqlWalker->walkArithmeticPrimary($this->expr),
$sqlWalker->walkArithmeticPrimary($this->fromString),
$sqlWalker->walkArithmeticPrimary($this->toString)
);
} | {@inheritDoc} | https://github.com/ZeinEddin/ZeDoctrineExtensions/blob/3e9d8b022395122a39a7115ce02b20203d0e1dae/lib/ZeDoctrineExtensions/Query/Oracle/Translate.php#L46-L54 |
ZeinEddin/ZeDoctrineExtensions | lib/ZeDoctrineExtensions/Query/Oracle/Translate.php | Translate.parse | public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->expr = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->fromString = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->toString = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
} | php | public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->expr = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->fromString = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->toString = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
} | {@inheritDoc} | https://github.com/ZeinEddin/ZeDoctrineExtensions/blob/3e9d8b022395122a39a7115ce02b20203d0e1dae/lib/ZeDoctrineExtensions/Query/Oracle/Translate.php#L59-L69 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.createSession | public function createSession($clientId, $ownerType, $ownerId)
{
return DB::table('oauth_sessions')->insertGetId(array(
'client_id' => $clientId,
'owner_type' => $ownerType,
'owner_id' => $ownerId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function createSession($clientId, $ownerType, $ownerId)
{
return DB::table('oauth_sessions')->insertGetId(array(
'client_id' => $clientId,
'owner_type' => $ownerType,
'owner_id' => $ownerId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Create a new session
Example SQL query:
<code>
INSERT INTO oauth_sessions (client_id, owner_type, owner_id)
VALUE (:clientId, :ownerType, :ownerId)
</code>
@param string $clientId The client ID
@param string $ownerType The type of the session owner (e.g. "user")
@param string $ownerId The ID of the session owner (e.g. "123")
@return int The session ID | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L35-L44 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.deleteSession | public function deleteSession($clientId, $ownerType, $ownerId)
{
DB::table('oauth_sessions')
->where('client_id', $clientId)
->where('owner_type', $ownerType)
->where('owner_id', $ownerId)
->delete();
} | php | public function deleteSession($clientId, $ownerType, $ownerId)
{
DB::table('oauth_sessions')
->where('client_id', $clientId)
->where('owner_type', $ownerType)
->where('owner_id', $ownerId)
->delete();
} | Delete a session
Example SQL query:
<code>
DELETE FROM oauth_sessions WHERE client_id = :clientId AND owner_type = :type AND owner_id = :typeId
</code>
@param string $clientId The client ID
@param string $ownerType The type of the session owner (e.g. "user")
@param string $ownerId The ID of the session owner (e.g. "123")
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L60-L67 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateRedirectUri | public function associateRedirectUri($sessionId, $redirectUri)
{
DB::table('oauth_session_redirects')->insert(array(
'session_id' => $sessionId,
'redirect_uri' => $redirectUri,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function associateRedirectUri($sessionId, $redirectUri)
{
DB::table('oauth_session_redirects')->insert(array(
'session_id' => $sessionId,
'redirect_uri' => $redirectUri,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Associate a redirect URI with a session
Example SQL query:
<code>
INSERT INTO oauth_session_redirects (session_id, redirect_uri) VALUE (:sessionId, :redirectUri)
</code>
@param int $sessionId The session ID
@param string $redirectUri The redirect URI
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L82-L90 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateAccessToken | public function associateAccessToken($sessionId, $accessToken, $expireTime)
{
return DB::table('oauth_session_access_tokens')->insertGetId(array(
'session_id' => $sessionId,
'access_token' => $accessToken,
'access_token_expires' => $expireTime,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function associateAccessToken($sessionId, $accessToken, $expireTime)
{
return DB::table('oauth_session_access_tokens')->insertGetId(array(
'session_id' => $sessionId,
'access_token' => $accessToken,
'access_token_expires' => $expireTime,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Associate an access token with a session
Example SQL query:
<code>
INSERT INTO oauth_session_access_tokens (session_id, access_token, access_token_expires)
VALUE (:sessionId, :accessToken, :accessTokenExpire)
</code>
@param int $sessionId The session ID
@param string $accessToken The access token
@param int $expireTime Unix timestamp of the access token expiry time
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L107-L116 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateRefreshToken | public function associateRefreshToken($accessTokenId, $refreshToken, $expireTime, $clientId)
{
DB::table('oauth_session_refresh_tokens')->insert(array(
'session_access_token_id' => $accessTokenId,
'refresh_token' => $refreshToken,
'refresh_token_expires' => $expireTime,
'client_id' => $clientId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function associateRefreshToken($accessTokenId, $refreshToken, $expireTime, $clientId)
{
DB::table('oauth_session_refresh_tokens')->insert(array(
'session_access_token_id' => $accessTokenId,
'refresh_token' => $refreshToken,
'refresh_token_expires' => $expireTime,
'client_id' => $clientId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Associate a refresh token with a session
Example SQL query:
<code>
INSERT INTO oauth_session_refresh_tokens (session_access_token_id, refresh_token, refresh_token_expires,
client_id) VALUE (:accessTokenId, :refreshToken, :expireTime, :clientId)
</code>
@param int $accessTokenId The access token ID
@param string $refreshToken The refresh token
@param int $expireTime Unix timestamp of the refresh token expiry time
@param string $clientId The client ID
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L134-L144 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateAuthCode | public function associateAuthCode($sessionId, $authCode, $expireTime)
{
$id = DB::table('oauth_session_authcodes')->insertGetId(array(
'session_id' => $sessionId,
'auth_code' => $authCode,
'auth_code_expires' => $expireTime,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
return $id;
} | php | public function associateAuthCode($sessionId, $authCode, $expireTime)
{
$id = DB::table('oauth_session_authcodes')->insertGetId(array(
'session_id' => $sessionId,
'auth_code' => $authCode,
'auth_code_expires' => $expireTime,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
return $id;
} | Assocate an authorization code with a session
Example SQL query:
<code>
INSERT INTO oauth_session_authcodes (session_id, auth_code, auth_code_expires)
VALUE (:sessionId, :authCode, :authCodeExpires)
</code>
@param int $sessionId The session ID
@param string $authCode The authorization code
@param int $expireTime Unix timestamp of the access token expiry time
@return int The auth code ID | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L161-L172 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.validateAuthCode | public function validateAuthCode($clientId, $redirectUri, $authCode)
{
$result = DB::table('oauth_sessions')
->select('oauth_sessions.id as session_id', 'oauth_session_authcodes.id as authcode_id')
->join('oauth_session_authcodes', 'oauth_sessions.id', '=', 'oauth_session_authcodes.session_id')
->join('oauth_session_redirects', 'oauth_sessions.id', '=', 'oauth_session_redirects.session_id')
->where('oauth_sessions.client_id', $clientId)
->where('oauth_session_authcodes.auth_code', $authCode)
->where('oauth_session_authcodes.auth_code_expires', '>=', time())
->where('oauth_session_redirects.redirect_uri', $redirectUri)
->first();
return (is_null($result)) ? false : (array) $result;
} | php | public function validateAuthCode($clientId, $redirectUri, $authCode)
{
$result = DB::table('oauth_sessions')
->select('oauth_sessions.id as session_id', 'oauth_session_authcodes.id as authcode_id')
->join('oauth_session_authcodes', 'oauth_sessions.id', '=', 'oauth_session_authcodes.session_id')
->join('oauth_session_redirects', 'oauth_sessions.id', '=', 'oauth_session_redirects.session_id')
->where('oauth_sessions.client_id', $clientId)
->where('oauth_session_authcodes.auth_code', $authCode)
->where('oauth_session_authcodes.auth_code_expires', '>=', time())
->where('oauth_session_redirects.redirect_uri', $redirectUri)
->first();
return (is_null($result)) ? false : (array) $result;
} | Validate an authorization code
Example SQL query:
<code>
SELECT oauth_sessions.id AS session_id, oauth_session_authcodes.id AS authcode_id FROM oauth_sessions
JOIN oauth_session_authcodes ON oauth_session_authcodes.`session_id` = oauth_sessions.id
JOIN oauth_session_redirects ON oauth_session_redirects.`session_id` = oauth_sessions.id WHERE
oauth_sessions.client_id = :clientId AND oauth_session_authcodes.`auth_code` = :authCode
AND `oauth_session_authcodes`.`auth_code_expires` >= :time AND
`oauth_session_redirects`.`redirect_uri` = :redirectUri
</code>
Expected response:
<code>
array(
'session_id' => (int)
'authcode_id' => (int)
)
</code>
@param string $clientId The client ID
@param string $redirectUri The redirect URI
@param string $authCode The authorization code
@return array|bool False if invalid or array as above | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L221-L234 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.validateAccessToken | public function validateAccessToken($accessToken)
{
$result = DB::table('oauth_session_access_tokens')
->select('oauth_session_access_tokens.session_id as session_id',
'oauth_sessions.client_id as client_id',
'oauth_clients.secret as client_secret',
'oauth_sessions.owner_id as owner_id',
'oauth_sessions.owner_type as owner_type')
->join('oauth_sessions', 'oauth_session_access_tokens.session_id', '=', 'oauth_sessions.id')
->join('oauth_clients', 'oauth_sessions.client_id', '=', 'oauth_clients.id')
->where('access_token', $accessToken)
->where('access_token_expires', '>=', time())
->first();
return (is_null($result)) ? false : (array) $result;
} | php | public function validateAccessToken($accessToken)
{
$result = DB::table('oauth_session_access_tokens')
->select('oauth_session_access_tokens.session_id as session_id',
'oauth_sessions.client_id as client_id',
'oauth_clients.secret as client_secret',
'oauth_sessions.owner_id as owner_id',
'oauth_sessions.owner_type as owner_type')
->join('oauth_sessions', 'oauth_session_access_tokens.session_id', '=', 'oauth_sessions.id')
->join('oauth_clients', 'oauth_sessions.client_id', '=', 'oauth_clients.id')
->where('access_token', $accessToken)
->where('access_token_expires', '>=', time())
->first();
return (is_null($result)) ? false : (array) $result;
} | Validate an access token
Example SQL query:
<code>
SELECT session_id, oauth_sessions.`client_id`, oauth_sessions.`owner_id`, oauth_sessions.`owner_type`
FROM `oauth_session_access_tokens` JOIN oauth_sessions ON oauth_sessions.`id` = session_id WHERE
access_token = :accessToken AND access_token_expires >= UNIX_TIMESTAMP(NOW())
</code>
Expected response:
<code>
array(
'session_id' => (int),
'client_id' => (string),
'owner_id' => (string),
'owner_type' => (string)
)
</code>
@param string $accessToken The access token
@return array|bool False if invalid or an array as above | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L261-L276 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.validateRefreshToken | public function validateRefreshToken($refreshToken, $clientId)
{
$result = DB::table('oauth_session_refresh_tokens')
->where('refresh_token', $refreshToken)
->where('client_id', $clientId)
->where('refresh_token_expires', '>=', time())
->first();
return (is_null($result)) ? false : $result->session_access_token_id;
} | php | public function validateRefreshToken($refreshToken, $clientId)
{
$result = DB::table('oauth_session_refresh_tokens')
->where('refresh_token', $refreshToken)
->where('client_id', $clientId)
->where('refresh_token_expires', '>=', time())
->first();
return (is_null($result)) ? false : $result->session_access_token_id;
} | Validate a refresh token
Example SQL query:
<code>
SELECT session_access_token_id FROM `oauth_session_refresh_tokens` WHERE refresh_token = :refreshToken
AND refresh_token_expires >= UNIX_TIMESTAMP(NOW()) AND client_id = :clientId
</code>
@param string $refreshToken The access token
@param string $clientId The client ID
@return int|bool The ID of the access token the refresh token is linked to (or false if invalid) | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L292-L301 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.getAccessToken | public function getAccessToken($accessTokenId)
{
$result = DB::table('oauth_session_access_tokens')
->where('id', $accessTokenId)
->first();
return (is_null($result)) ? false : (array) $result;
} | php | public function getAccessToken($accessTokenId)
{
$result = DB::table('oauth_session_access_tokens')
->where('id', $accessTokenId)
->first();
return (is_null($result)) ? false : (array) $result;
} | Get an access token by ID
Example SQL query:
<code>
SELECT * FROM `oauth_session_access_tokens` WHERE `id` = :accessTokenId
</code>
Expected response:
<code>
array(
'id' => (int),
'session_id' => (int),
'access_token' => (string),
'access_token_expires' => (int)
)
</code>
@param int $accessTokenId The access token ID
@return array | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L326-L333 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateScope | public function associateScope($accessTokenId, $scopeId)
{
DB::table('oauth_session_token_scopes')->insert(array(
'session_access_token_id' => $accessTokenId,
'scope_id' => $scopeId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function associateScope($accessTokenId, $scopeId)
{
DB::table('oauth_session_token_scopes')->insert(array(
'session_access_token_id' => $accessTokenId,
'scope_id' => $scopeId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Associate a scope with an access token
Example SQL query:
<code>
INSERT INTO `oauth_session_token_scopes` (`session_access_token_id`, `scope_id`) VALUE (:accessTokenId, :scopeId)
</code>
@param int $accessTokenId The ID of the access token
@param int $scopeId The ID of the scope
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L348-L356 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.getScopes | public function getScopes($accessToken)
{
$scopeResults = DB::table('oauth_session_token_scopes')
->select('oauth_scopes.*')
->join('oauth_session_access_tokens', 'oauth_session_token_scopes.session_access_token_id', '=', 'oauth_session_access_tokens.id')
->join('oauth_scopes', 'oauth_session_token_scopes.scope_id', '=', 'oauth_scopes.id')
->where('access_token', $accessToken)
->get();
$scopes = array();
foreach($scopeResults as $key=>$scope)
{
$scopes[$key] = get_object_vars($scope);
}
return $scopes;
} | php | public function getScopes($accessToken)
{
$scopeResults = DB::table('oauth_session_token_scopes')
->select('oauth_scopes.*')
->join('oauth_session_access_tokens', 'oauth_session_token_scopes.session_access_token_id', '=', 'oauth_session_access_tokens.id')
->join('oauth_scopes', 'oauth_session_token_scopes.scope_id', '=', 'oauth_scopes.id')
->where('access_token', $accessToken)
->get();
$scopes = array();
foreach($scopeResults as $key=>$scope)
{
$scopes[$key] = get_object_vars($scope);
}
return $scopes;
} | Get all associated access tokens for an access token
Example SQL query:
<code>
SELECT oauth_scopes.* FROM oauth_session_token_scopes JOIN oauth_session_access_tokens
ON oauth_session_access_tokens.`id` = `oauth_session_token_scopes`.`session_access_token_id`
JOIN oauth_scopes ON oauth_scopes.id = `oauth_session_token_scopes`.`scope_id`
WHERE access_token = :accessToken
</code>
Expected response:
<code>
array (
array(
'key' => (string),
'name' => (string),
'description' => (string)
),
...
...
)
</code>
@param string $accessToken The access token
@return array | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L387-L405 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.associateAuthCodeScope | public function associateAuthCodeScope($authCodeId, $scopeId)
{
DB::table('oauth_session_authcode_scopes')->insert(array(
'oauth_session_authcode_id' => $authCodeId,
'scope_id' => $scopeId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | php | public function associateAuthCodeScope($authCodeId, $scopeId)
{
DB::table('oauth_session_authcode_scopes')->insert(array(
'oauth_session_authcode_id' => $authCodeId,
'scope_id' => $scopeId,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
));
} | Associate scopes with an auth code (bound to the session)
Example SQL query:
<code>
INSERT INTO `oauth_session_authcode_scopes` (`oauth_session_authcode_id`, `scope_id`) VALUES
(:authCodeId, :scopeId)
</code>
@param int $authCodeId The auth code ID
@param int $scopeId The scope ID
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L421-L429 |
feelinc/laravel-api | src/Sule/Api/OAuth2/Repositories/FluentSession.php | FluentSession.getAuthCodeScopes | public function getAuthCodeScopes($oauthSessionAuthCodeId)
{
$scopesResults = DB::table('oauth_session_authcode_scopes')
->where('oauth_session_authcode_id', '=', $oauthSessionAuthCodeId)
->get();
$scopes = array();
foreach($scopesResults as $key=>$scope)
{
$scopes[$key] = get_object_vars($scope);
}
return $scopes;
} | php | public function getAuthCodeScopes($oauthSessionAuthCodeId)
{
$scopesResults = DB::table('oauth_session_authcode_scopes')
->where('oauth_session_authcode_id', '=', $oauthSessionAuthCodeId)
->get();
$scopes = array();
foreach($scopesResults as $key=>$scope)
{
$scopes[$key] = get_object_vars($scope);
}
return $scopes;
} | Get the scopes associated with an auth code
Example SQL query:
<code>
SELECT scope_id FROM `oauth_session_authcode_scopes` WHERE oauth_session_authcode_id = :authCodeId
</code>
Expected response:
<code>
array(
array(
'scope_id' => (int)
),
array(
'scope_id' => (int)
),
...
)
</code>
@param int $oauthSessionAuthCodeId The session ID
@return array | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/OAuth2/Repositories/FluentSession.php#L457-L473 |
acacha/forge-publish | src/Console/Commands/Traits/AborstIfEnvVariableIsnotInstalled.php | AborstIfEnvVariableIsnotInstalled.abortsIfEnvVarIsNotInstalled | protected function abortsIfEnvVarIsNotInstalled($env_var)
{
if (! $this->fp_env($env_var)) {
$this->info("No $env_var key found in .env file.");
$this->info('Please configure this .env variable manually or run php artisan publish:init. Skipping...');
throw new EnvironmentVariableNotFoundException($env_var);
}
} | php | protected function abortsIfEnvVarIsNotInstalled($env_var)
{
if (! $this->fp_env($env_var)) {
$this->info("No $env_var key found in .env file.");
$this->info('Please configure this .env variable manually or run php artisan publish:init. Skipping...');
throw new EnvironmentVariableNotFoundException($env_var);
}
} | Skip if env var is not installed. | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/AborstIfEnvVariableIsnotInstalled.php#L17-L24 |
hal-platform/hal-core | src/Database/PhinxMigration.php | PhinxMigration.blobOptions | protected function blobOptions($size = '64kb')
{
$limit = (strtolower($size) === '16mb') ? MysqlAdapter::BLOB_MEDIUM : MysqlAdapter::BLOB_REGULAR;
$adapter = $this->getAdapter();
if ($adapter instanceof AdapterWrapper) {
$adapter = $adapter->getAdapter();
}
return $adapter instanceof MysqlAdapter ? ['limit' => $limit] : [];
} | php | protected function blobOptions($size = '64kb')
{
$limit = (strtolower($size) === '16mb') ? MysqlAdapter::BLOB_MEDIUM : MysqlAdapter::BLOB_REGULAR;
$adapter = $this->getAdapter();
if ($adapter instanceof AdapterWrapper) {
$adapter = $adapter->getAdapter();
}
return $adapter instanceof MysqlAdapter ? ['limit' => $limit] : [];
} | Only supported options:
- 64kb (default)
- 16mb
@param string $size
@return array | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Database/PhinxMigration.php#L74-L85 |
hal-platform/hal-core | src/Database/PhinxMigration.php | PhinxMigration.textOptions | protected function textOptions($size = '64kb')
{
$limit = (strtolower($size) === '16mb') ? MysqlAdapter::TEXT_MEDIUM : MysqlAdapter::TEXT_REGULAR;
$adapter = $this->getAdapter();
if ($adapter instanceof AdapterWrapper) {
$adapter = $adapter->getAdapter();
}
return $adapter instanceof MysqlAdapter ? ['limit' => $limit] : [];
} | php | protected function textOptions($size = '64kb')
{
$limit = (strtolower($size) === '16mb') ? MysqlAdapter::TEXT_MEDIUM : MysqlAdapter::TEXT_REGULAR;
$adapter = $this->getAdapter();
if ($adapter instanceof AdapterWrapper) {
$adapter = $adapter->getAdapter();
}
return $adapter instanceof MysqlAdapter ? ['limit' => $limit] : [];
} | Only supported options:
- 64kb (default)
- 16mb
@param string $size
@return array | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Database/PhinxMigration.php#L96-L107 |
tokenly/counterparty-sender | src/Tokenly/CounterpartySender/CounterpartySender.php | CounterpartySender.createSendTransactionHex | protected function createSendTransactionHex($public_key, $private_key, $source, $destination, $quantity, $asset, $other_counterparty_vars=[]) {
$vars = [
'pubkey' => $public_key,
'privkey' => $private_key,
'source' => $source,
'destination' => $destination,
'quantity' => $quantity,
'asset' => $asset,
];
$vars = array_merge($vars, $other_counterparty_vars);
$raw_transaction_hex = $this->xcpd_client->create_send($vars);
return $raw_transaction_hex;
} | php | protected function createSendTransactionHex($public_key, $private_key, $source, $destination, $quantity, $asset, $other_counterparty_vars=[]) {
$vars = [
'pubkey' => $public_key,
'privkey' => $private_key,
'source' => $source,
'destination' => $destination,
'quantity' => $quantity,
'asset' => $asset,
];
$vars = array_merge($vars, $other_counterparty_vars);
$raw_transaction_hex = $this->xcpd_client->create_send($vars);
return $raw_transaction_hex;
} | ////////////////////////////////////////////////////////////////////// | https://github.com/tokenly/counterparty-sender/blob/aad0570f7d23e496cce1b7ea7efe9db071794737/src/Tokenly/CounterpartySender/CounterpartySender.php#L50-L63 |
chilimatic/chilimatic-framework | lib/file/File.php | File.append | public function append($content, $create = false)
{
if ($this->writeable !== true || empty($content)) return false;
if (strpos($this->_option, 'a') === false) {
// close open filepoint
if (!empty($this->fp)) fclose($this->fp);
// opens fp for writing with file lock
$this->open_fp((is_bool($create) && $create === true ? 'a+' : 'a'));
}
if ($this->file_lock !== true && !$this->lock(LOCK_EX)) return false;
// writes to file
fputs($this->fp, $content, strlen($content));
// releases lock
$this->lock(LOCK_UN);
return true;
} | php | public function append($content, $create = false)
{
if ($this->writeable !== true || empty($content)) return false;
if (strpos($this->_option, 'a') === false) {
// close open filepoint
if (!empty($this->fp)) fclose($this->fp);
// opens fp for writing with file lock
$this->open_fp((is_bool($create) && $create === true ? 'a+' : 'a'));
}
if ($this->file_lock !== true && !$this->lock(LOCK_EX)) return false;
// writes to file
fputs($this->fp, $content, strlen($content));
// releases lock
$this->lock(LOCK_UN);
return true;
} | appends to a file based + create if wanted
@param $content string
@param $create bool
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L220-L240 |
chilimatic/chilimatic-framework | lib/file/File.php | File.lock | public function lock($mode = LOCK_SH)
{
if (!is_resource($this->fp)) return false;
if (flock($this->fp, $mode) === false) return false;
if ($mode != LOCK_UN) $this->file_lock = true;
else $this->file_lock = false;
return true;
} | php | public function lock($mode = LOCK_SH)
{
if (!is_resource($this->fp)) return false;
if (flock($this->fp, $mode) === false) return false;
if ($mode != LOCK_UN) $this->file_lock = true;
else $this->file_lock = false;
return true;
} | file lock
@param int|string $mode string
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L250-L261 |
chilimatic/chilimatic-framework | lib/file/File.php | File.change_owner | public function change_owner($owner)
{
if (empty($owner) || !is_int($owner) || $this->owner != getmyuid()) return false;
if (!empty($this->fp)) fclose($this->fp);
if (chown($this->path . $this->filename, $owner)) {
return $this->open($this->path . $this->filename);
}
return false;
} | php | public function change_owner($owner)
{
if (empty($owner) || !is_int($owner) || $this->owner != getmyuid()) return false;
if (!empty($this->fp)) fclose($this->fp);
if (chown($this->path . $this->filename, $owner)) {
return $this->open($this->path . $this->filename);
}
return false;
} | changes file owner
@param $owner int
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L283-L295 |
chilimatic/chilimatic-framework | lib/file/File.php | File.change_permission | public function change_permission($mode)
{
if (empty($mode) || !is_int($mode)) return false;
if (chmod($this->path . $this->filename, $mode)) {
return $this->open($this->path . $this->filename);
}
return false;
} | php | public function change_permission($mode)
{
if (empty($mode) || !is_int($mode)) return false;
if (chmod($this->path . $this->filename, $mode)) {
return $this->open($this->path . $this->filename);
}
return false;
} | changes the file user/group permissions
@param $mode int
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L305-L315 |
chilimatic/chilimatic-framework | lib/file/File.php | File.change_group | public function change_group($group)
{
if (empty($group) || !is_int($group)) return false;
if (chgrp($this->path . $this->filename, $group)) {
return $this->open($this->path . $this->filename);
}
return false;
} | php | public function change_group($group)
{
if (empty($group) || !is_int($group)) return false;
if (chgrp($this->path . $this->filename, $group)) {
return $this->open($this->path . $this->filename);
}
return false;
} | changes the group
@param $group int
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L325-L335 |
chilimatic/chilimatic-framework | lib/file/File.php | File._extract_file_extension | private function _extract_file_extension()
{
if (empty($this->filename)) return false;
if (!empty($this->mime_type)) {
$array = explode('/', $this->mime_type);
$this->file_extension = array_pop($array);
} else {
if (strpos($this->filename, '.') !== false) {
$array = explode('/', $this->mime_type);
$this->file_extension = array_pop($array);
} else {
$this->file_extension = 'unknown';
}
}
return true;
} | php | private function _extract_file_extension()
{
if (empty($this->filename)) return false;
if (!empty($this->mime_type)) {
$array = explode('/', $this->mime_type);
$this->file_extension = array_pop($array);
} else {
if (strpos($this->filename, '.') !== false) {
$array = explode('/', $this->mime_type);
$this->file_extension = array_pop($array);
} else {
$this->file_extension = 'unknown';
}
}
return true;
} | extracts the extension of the current file | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L357-L375 |
chilimatic/chilimatic-framework | lib/file/File.php | File._extract_filename | private function _extract_filename()
{
if (empty($this->file)) return false;
$tmp_array = explode('/', $this->file);
$count = (int)count($tmp_array);
for ($i = 0; $i < $count; $i++) {
if ($i + 1 == $count) {
$this->filename = (string)$tmp_array[0];
}
array_shift($tmp_array);
}
unset($tmp_array);
return true;
} | php | private function _extract_filename()
{
if (empty($this->file)) return false;
$tmp_array = explode('/', $this->file);
$count = (int)count($tmp_array);
for ($i = 0; $i < $count; $i++) {
if ($i + 1 == $count) {
$this->filename = (string)$tmp_array[0];
}
array_shift($tmp_array);
}
unset($tmp_array);
return true;
} | gets the filename of the file | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L381-L397 |
chilimatic/chilimatic-framework | lib/file/File.php | File._get_path | private function _get_path()
{
if (empty($this->file) && is_string($this->file)) return false;
if (strpos($this->file, '/') !== false) {
$path = explode('/', $this->file);
array_pop($path);
$this->path = (string)implode('/', $path) . '/';
} elseif (strpos('\\', $this->file) !== false) {
$path = explode('\\', $this->file);
array_pop($path);
$this->path = (string)implode('\\', $path) . '\\';
} else {
$this->path = getcwd() . '/';
}
return true;
} | php | private function _get_path()
{
if (empty($this->file) && is_string($this->file)) return false;
if (strpos($this->file, '/') !== false) {
$path = explode('/', $this->file);
array_pop($path);
$this->path = (string)implode('/', $path) . '/';
} elseif (strpos('\\', $this->file) !== false) {
$path = explode('\\', $this->file);
array_pop($path);
$this->path = (string)implode('\\', $path) . '\\';
} else {
$this->path = getcwd() . '/';
}
return true;
} | gets the filename out of the entered path
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L405-L423 |
chilimatic/chilimatic-framework | lib/file/File.php | File.open | public function open($filename)
{
if (!is_file($filename)) return false;
$this->file = @(string)$filename;
$this->group = @(int)filegroup($filename);
$this->owner = @(int)fileowner($filename);
$this->size = @(int)filesize($filename);
$this->type = @(string)filetype($filename);
$this->accessed = @(int)fileatime($filename);
$this->changed = @(int)filectime($filename);
$this->modified = @(int)filemtime($filename);
$this->permission = @(int)fileperms($filename);
$this->f_inode = @ fileinode($filename);
$this->writeable = @(bool)is_writable($filename);
$this->readable = @(bool)is_readable($filename);
$this->mime_type = @(string)mime_content_type($filename);
$this->_get_path();
$this->_extract_filename();
$this->_extract_file_extension();
return true;
} | php | public function open($filename)
{
if (!is_file($filename)) return false;
$this->file = @(string)$filename;
$this->group = @(int)filegroup($filename);
$this->owner = @(int)fileowner($filename);
$this->size = @(int)filesize($filename);
$this->type = @(string)filetype($filename);
$this->accessed = @(int)fileatime($filename);
$this->changed = @(int)filectime($filename);
$this->modified = @(int)filemtime($filename);
$this->permission = @(int)fileperms($filename);
$this->f_inode = @ fileinode($filename);
$this->writeable = @(bool)is_writable($filename);
$this->readable = @(bool)is_readable($filename);
$this->mime_type = @(string)mime_content_type($filename);
$this->_get_path();
$this->_extract_filename();
$this->_extract_file_extension();
return true;
} | gets all the information about the file
@param $filename string
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L433-L456 |
chilimatic/chilimatic-framework | lib/file/File.php | File.open_fp | function open_fp($option = 'r')
{
if (empty($option) || !is_string($option)) return false;
switch (true) {
case (strpos($option, 'r') !== false) :
$mode = LOCK_SH;
break;
case (strpos($option, 'a') !== false || strpos($option, 'w') !== false) :
$mode = LOCK_EX;
break;
default :
$mode = LOCK_EX;
break;
}
$this->readable = true;
if (($this->fp = fopen($this->file, $option)) !== false) {
$this->lock($mode);
// sets the fopen option based on it reduces
// reopening of a file
$this->_option = (string)$option;
return true;
}
return false;
} | php | function open_fp($option = 'r')
{
if (empty($option) || !is_string($option)) return false;
switch (true) {
case (strpos($option, 'r') !== false) :
$mode = LOCK_SH;
break;
case (strpos($option, 'a') !== false || strpos($option, 'w') !== false) :
$mode = LOCK_EX;
break;
default :
$mode = LOCK_EX;
break;
}
$this->readable = true;
if (($this->fp = fopen($this->file, $option)) !== false) {
$this->lock($mode);
// sets the fopen option based on it reduces
// reopening of a file
$this->_option = (string)$option;
return true;
}
return false;
} | opens a filepointer
@param $option string
@return bool | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L466-L494 |
chilimatic/chilimatic-framework | lib/file/File.php | File.read | public function read()
{
// if file is readable
if ($this->readable !== true) return false;
if (!empty($this->fp) && is_resource($this->fp)) fclose($this->fp);
$this->open_fp('r');
if (filesize($this->file) == 0) return false;
$this->lock(LOCK_SH);
$content = (string)fread($this->fp, ($this->size >= 0) ? $this->size : 1);
$this->lock(LOCK_UN);
return $content;
} | php | public function read()
{
// if file is readable
if ($this->readable !== true) return false;
if (!empty($this->fp) && is_resource($this->fp)) fclose($this->fp);
$this->open_fp('r');
if (filesize($this->file) == 0) return false;
$this->lock(LOCK_SH);
$content = (string)fread($this->fp, ($this->size >= 0) ? $this->size : 1);
$this->lock(LOCK_UN);
return $content;
} | read the current content of the file
@return string | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L502-L520 |
phramework/testphase | src/Binary.php | Binary.getArgumentSpecifications | public static function getArgumentSpecifications()
{
$specs = new OptionCollection;
$specs->add('d|dir:', 'Tests directory path')
->isa('String');
$specs->add('s|subdir+', 'Optional, subdirectory pattern, can be used multiple times as OR expression')
->isa('String')
->defaultValue(null);
$specs->add('b|bootstrap?', 'Bootstrap file path')
->isa('File')
->defaultValue(null);
$specs->add('v|verbose', 'Verbose output')
->defaultValue(false);
$specs->add('show-globals', 'Show values of global variables')->defaultValue(false);
$specs->add('debug', 'Show debug messages')->defaultValue(false);
$specs->add('h|help', 'Show help')->defaultValue(false);
$specs->add('no-colors', 'No colors')->defaultValue(false);
$specs->add('i|immediate', 'Show error output immediately as it appears')->defaultValue(false);
$specs->add('server-host?', 'Server host')->defaultValue(null);
$specs->add('server-root', 'Server root path, default is ./public')->defaultValue('./public');
return $specs;
} | php | public static function getArgumentSpecifications()
{
$specs = new OptionCollection;
$specs->add('d|dir:', 'Tests directory path')
->isa('String');
$specs->add('s|subdir+', 'Optional, subdirectory pattern, can be used multiple times as OR expression')
->isa('String')
->defaultValue(null);
$specs->add('b|bootstrap?', 'Bootstrap file path')
->isa('File')
->defaultValue(null);
$specs->add('v|verbose', 'Verbose output')
->defaultValue(false);
$specs->add('show-globals', 'Show values of global variables')->defaultValue(false);
$specs->add('debug', 'Show debug messages')->defaultValue(false);
$specs->add('h|help', 'Show help')->defaultValue(false);
$specs->add('no-colors', 'No colors')->defaultValue(false);
$specs->add('i|immediate', 'Show error output immediately as it appears')->defaultValue(false);
$specs->add('server-host?', 'Server host')->defaultValue(null);
$specs->add('server-root', 'Server root path, default is ./public')->defaultValue('./public');
return $specs;
} | Get argument specifications
@return OptionCollection | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Binary.php#L52-L79 |
phramework/testphase | src/Binary.php | Binary.invoke | public function invoke()
{
$arguments = $this->arguments;
if (($serverHost = $arguments->{'server-host'}) !== null) {
$this->server = new Server($serverHost, $arguments->{'server-root'});
$this->server->start();
}
//Include bootstrap file if set
if (($bootstrapFile = $arguments->bootstrap)) {
require $bootstrapFile;
}
echo 'testphase v' . Testphase::getVersion() . PHP_EOL;
if ($arguments->help) {
echo 'Help:' . PHP_EOL;
$printer = new ConsoleOptionPrinter;
echo $printer->render(static::getArgumentSpecifications());
return 0;
} elseif ($arguments->debug) {
echo 'Enabled options: ' . PHP_EOL;
foreach ($arguments as $key => $spec) {
echo $spec;
}
}
try {
$testParserCollection = $this->getTestParserCollection();
} catch (\Exception $e) {
echo $e->getMessage();
return $this->stop(1);
}
//Statistics object
$stats = (object)[
'tests' => count($testParserCollection),
'success' => 0,
'error' => 0,
'failure' => 0,
'ignore' => 0,
'incomplete' => 0,
'errors' => []
];
$testIndex = 0;
foreach ($testParserCollection as $test) {
//Check if subdir argument is set
if (isset($arguments->subdir) && $arguments->subdir !== null) {
//If so check if file name passes the given pattern
//Remove base dir from filename
$cleanFilename = trim(
str_replace(
$arguments->dir,
'',
$test->getFilename()
),
'/'
);
$match = false;
//Check if file name matches any of the subdir patterns
foreach ($arguments->subdir as $pattern) {
$pattern = '@' . $pattern . '@';
if (!!preg_match($pattern, $cleanFilename)) {
$match = $match || true;
break;
}
}
if (!$match) {
//Ignore
$stats->ignore += 1;
if ($arguments->verbose) {
echo sprintf(
'I %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'I';
}
continue;
}
}
$meta = $test->getMeta();
if (isset($meta->ignore) && $meta->ignore) {
if ($arguments->verbose) {
echo sprintf(
'I %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'I';
}
$stats->ignore += 1;
continue;
}
if (isset($meta->incomplete) && $meta->incomplete !== false) {
$stats->incomplete += 1;
}
try {
//Complete test's testphase collection
$test->createTest();
} catch (\Exception $e) {
echo sprintf(
'Unable to create test from file "%s" %s With message: "%s"',
$test->getFilename(),
PHP_EOL,
$e->getMessage()
) . PHP_EOL;
return $this->stop(1);
}
$testphaseCollection = $test->getTest();
//Include number of additional testphase collections
$stats->tests += count($testphaseCollection) - 1;
//Iterate though test parser's testphase collection
foreach ($testphaseCollection as $testphase) {
try {
$testphase->run(function (
$responseStatusCode,
$responseHeaders,
$responseBody,
$responseBodyObject = null
) use (
$test,
$arguments
) {
//todo move to TestParser
$export = $test->getExport();
//Fetch all test exports and add them as globals
foreach ($export as $key => $value) {
$path = explode('.', $value);
$pathValue = $responseBodyObject;
foreach ($path as $p) {
//@todo implement array index
$arrayIndex = 0;
if (is_array($pathValue)) {
$pathValue = $pathValue[$arrayIndex]->{$p};
} else {
$pathValue = $pathValue->{$p};
}
}
Globals::set($key, $pathValue);
}
if ($arguments->debug) {
echo 'Response Status Code:' . PHP_EOL;
echo $responseStatusCode . PHP_EOL;
echo 'Response Headers:' . PHP_EOL;
print_r($responseHeaders);
echo PHP_EOL;
echo 'Response Body:' . PHP_EOL;
echo json_encode($responseBodyObject, JSON_PRETTY_PRINT) . PHP_EOL;
}
});
//Echo successful char
if ($arguments->verbose) {
echo sprintf(
'. %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo '.';
}
$stats->success += 1;
} catch (UnsetGlobalException $e) {
//Error message
$message = $e->getMessage();
$message = sprintf(
self::colored('Test "%s" failed with message', 'red') . PHP_EOL . ' %s' . PHP_EOL,
$test->getFilename(),
$message
);
//push message to error message
$stats->errors[] = $message;
//Echo unsuccessful char
if ($arguments->verbose) {
echo sprintf(
'F %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'F';
}
//print if immediate
if ($arguments->immediate) {
echo PHP_EOL . $message . PHP_EOL;
}
//Error message
$stats->error += 1;
} catch (\Exception $e) {
//Error message
$message = $e->getMessage();
if ($arguments->debug) {
$message .= PHP_EOL . $testphase->getResponseBody();
}
$message = sprintf(
self::colored('Test "%s" failed with message', 'red') . PHP_EOL . ' %s' . PHP_EOL,
$test->getFilename(),
$message
);
if (get_class($e) == IncorrectParametersException::class) {
$message .= 'Incorrect:' . PHP_EOL
. json_encode($e->getParameters(), JSON_PRETTY_PRINT) . PHP_EOL;
} elseif (get_class($e) == MissingParametersException::class) {
$message .= 'Missing:' . PHP_EOL
. json_encode($e->getParameters(), JSON_PRETTY_PRINT) . PHP_EOL;
}
//push message to error message
$stats->errors[] = $message;
//Echo unsuccessful char
if ($arguments->verbose) {
echo sprintf(
'F %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'F';
}
//print if immediate
if ($arguments->immediate) {
echo PHP_EOL . $message . PHP_EOL;
}
$stats->failure += 1;
}
++$testIndex;
//Show only 80 characters per line
if (!($testIndex % 79)) {
echo PHP_EOL;
}
}
}
echo PHP_EOL;
if ($arguments->{'show-globals'}) {
echo 'Globals:' . PHP_EOL;
echo Globals::toString() . PHP_EOL;
}
//don't print if immediate is true
if (!$arguments->immediate && !empty($stats->errors)) {
echo 'Errors:' . PHP_EOL;
foreach ($stats->errors as $e) {
echo $e . PHP_EOL;
}
}
echo 'Complete!' . PHP_EOL;
echo 'Tests:' . $stats->tests . ', ';
Binary::output('Successful: ' . $stats->success, 'green');
echo ', ';
Binary::output('Ignored: ' . $stats->ignore, 'yellow');
echo ', ';
Binary::output('Incomplete: ' . $stats->incomplete, 'yellow');
echo ', ';
Binary::output('Error: ' . $stats->error, 'red');
echo ', ';
Binary::output('Failure: ' . $stats->failure . PHP_EOL, 'red');
echo 'Memory usage: ' . (int)(memory_get_usage(true)/1048576) . ' MB' . PHP_EOL;
echo 'Elapsed time: ' . (time() - $_SERVER['REQUEST_TIME']) . ' s' . PHP_EOL;
if ($stats->error > 0) {
return $this->stop(1);
}
if ($stats->failure > 0) {
return $this->stop(2);
}
return $this->stop(0);
} | php | public function invoke()
{
$arguments = $this->arguments;
if (($serverHost = $arguments->{'server-host'}) !== null) {
$this->server = new Server($serverHost, $arguments->{'server-root'});
$this->server->start();
}
//Include bootstrap file if set
if (($bootstrapFile = $arguments->bootstrap)) {
require $bootstrapFile;
}
echo 'testphase v' . Testphase::getVersion() . PHP_EOL;
if ($arguments->help) {
echo 'Help:' . PHP_EOL;
$printer = new ConsoleOptionPrinter;
echo $printer->render(static::getArgumentSpecifications());
return 0;
} elseif ($arguments->debug) {
echo 'Enabled options: ' . PHP_EOL;
foreach ($arguments as $key => $spec) {
echo $spec;
}
}
try {
$testParserCollection = $this->getTestParserCollection();
} catch (\Exception $e) {
echo $e->getMessage();
return $this->stop(1);
}
//Statistics object
$stats = (object)[
'tests' => count($testParserCollection),
'success' => 0,
'error' => 0,
'failure' => 0,
'ignore' => 0,
'incomplete' => 0,
'errors' => []
];
$testIndex = 0;
foreach ($testParserCollection as $test) {
//Check if subdir argument is set
if (isset($arguments->subdir) && $arguments->subdir !== null) {
//If so check if file name passes the given pattern
//Remove base dir from filename
$cleanFilename = trim(
str_replace(
$arguments->dir,
'',
$test->getFilename()
),
'/'
);
$match = false;
//Check if file name matches any of the subdir patterns
foreach ($arguments->subdir as $pattern) {
$pattern = '@' . $pattern . '@';
if (!!preg_match($pattern, $cleanFilename)) {
$match = $match || true;
break;
}
}
if (!$match) {
//Ignore
$stats->ignore += 1;
if ($arguments->verbose) {
echo sprintf(
'I %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'I';
}
continue;
}
}
$meta = $test->getMeta();
if (isset($meta->ignore) && $meta->ignore) {
if ($arguments->verbose) {
echo sprintf(
'I %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'I';
}
$stats->ignore += 1;
continue;
}
if (isset($meta->incomplete) && $meta->incomplete !== false) {
$stats->incomplete += 1;
}
try {
//Complete test's testphase collection
$test->createTest();
} catch (\Exception $e) {
echo sprintf(
'Unable to create test from file "%s" %s With message: "%s"',
$test->getFilename(),
PHP_EOL,
$e->getMessage()
) . PHP_EOL;
return $this->stop(1);
}
$testphaseCollection = $test->getTest();
//Include number of additional testphase collections
$stats->tests += count($testphaseCollection) - 1;
//Iterate though test parser's testphase collection
foreach ($testphaseCollection as $testphase) {
try {
$testphase->run(function (
$responseStatusCode,
$responseHeaders,
$responseBody,
$responseBodyObject = null
) use (
$test,
$arguments
) {
//todo move to TestParser
$export = $test->getExport();
//Fetch all test exports and add them as globals
foreach ($export as $key => $value) {
$path = explode('.', $value);
$pathValue = $responseBodyObject;
foreach ($path as $p) {
//@todo implement array index
$arrayIndex = 0;
if (is_array($pathValue)) {
$pathValue = $pathValue[$arrayIndex]->{$p};
} else {
$pathValue = $pathValue->{$p};
}
}
Globals::set($key, $pathValue);
}
if ($arguments->debug) {
echo 'Response Status Code:' . PHP_EOL;
echo $responseStatusCode . PHP_EOL;
echo 'Response Headers:' . PHP_EOL;
print_r($responseHeaders);
echo PHP_EOL;
echo 'Response Body:' . PHP_EOL;
echo json_encode($responseBodyObject, JSON_PRETTY_PRINT) . PHP_EOL;
}
});
//Echo successful char
if ($arguments->verbose) {
echo sprintf(
'. %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo '.';
}
$stats->success += 1;
} catch (UnsetGlobalException $e) {
//Error message
$message = $e->getMessage();
$message = sprintf(
self::colored('Test "%s" failed with message', 'red') . PHP_EOL . ' %s' . PHP_EOL,
$test->getFilename(),
$message
);
//push message to error message
$stats->errors[] = $message;
//Echo unsuccessful char
if ($arguments->verbose) {
echo sprintf(
'F %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'F';
}
//print if immediate
if ($arguments->immediate) {
echo PHP_EOL . $message . PHP_EOL;
}
//Error message
$stats->error += 1;
} catch (\Exception $e) {
//Error message
$message = $e->getMessage();
if ($arguments->debug) {
$message .= PHP_EOL . $testphase->getResponseBody();
}
$message = sprintf(
self::colored('Test "%s" failed with message', 'red') . PHP_EOL . ' %s' . PHP_EOL,
$test->getFilename(),
$message
);
if (get_class($e) == IncorrectParametersException::class) {
$message .= 'Incorrect:' . PHP_EOL
. json_encode($e->getParameters(), JSON_PRETTY_PRINT) . PHP_EOL;
} elseif (get_class($e) == MissingParametersException::class) {
$message .= 'Missing:' . PHP_EOL
. json_encode($e->getParameters(), JSON_PRETTY_PRINT) . PHP_EOL;
}
//push message to error message
$stats->errors[] = $message;
//Echo unsuccessful char
if ($arguments->verbose) {
echo sprintf(
'F %s',
$test->getFilename()
) . PHP_EOL;
} else {
echo 'F';
}
//print if immediate
if ($arguments->immediate) {
echo PHP_EOL . $message . PHP_EOL;
}
$stats->failure += 1;
}
++$testIndex;
//Show only 80 characters per line
if (!($testIndex % 79)) {
echo PHP_EOL;
}
}
}
echo PHP_EOL;
if ($arguments->{'show-globals'}) {
echo 'Globals:' . PHP_EOL;
echo Globals::toString() . PHP_EOL;
}
//don't print if immediate is true
if (!$arguments->immediate && !empty($stats->errors)) {
echo 'Errors:' . PHP_EOL;
foreach ($stats->errors as $e) {
echo $e . PHP_EOL;
}
}
echo 'Complete!' . PHP_EOL;
echo 'Tests:' . $stats->tests . ', ';
Binary::output('Successful: ' . $stats->success, 'green');
echo ', ';
Binary::output('Ignored: ' . $stats->ignore, 'yellow');
echo ', ';
Binary::output('Incomplete: ' . $stats->incomplete, 'yellow');
echo ', ';
Binary::output('Error: ' . $stats->error, 'red');
echo ', ';
Binary::output('Failure: ' . $stats->failure . PHP_EOL, 'red');
echo 'Memory usage: ' . (int)(memory_get_usage(true)/1048576) . ' MB' . PHP_EOL;
echo 'Elapsed time: ' . (time() - $_SERVER['REQUEST_TIME']) . ' s' . PHP_EOL;
if ($stats->error > 0) {
return $this->stop(1);
}
if ($stats->failure > 0) {
return $this->stop(2);
}
return $this->stop(0);
} | Invoke scripts
@return integer Returns indicate how the script exited.
Normal exit is generally represented by a 0 return. | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Binary.php#L108-L414 |
phramework/testphase | src/Binary.php | Binary.colored | public function colored($text, $color)
{
$colors = [
'black' => '0;30',
'red' => '0;31',
'green' => '0;32',
'blue' => '1;34',
'yellow' => '1;33'
];
$c = (
array_key_exists($color, $colors)
? $colors[$color]
: $colors['black']
);
if ($this->arguments->{'no-colors'}) {
return $text;
} else {
return "\033[". $c . 'm' . $text . "\033[0m";
}
} | php | public function colored($text, $color)
{
$colors = [
'black' => '0;30',
'red' => '0;31',
'green' => '0;32',
'blue' => '1;34',
'yellow' => '1;33'
];
$c = (
array_key_exists($color, $colors)
? $colors[$color]
: $colors['black']
);
if ($this->arguments->{'no-colors'}) {
return $text;
} else {
return "\033[". $c . 'm' . $text . "\033[0m";
}
} | Returned colored text
@param string $text
@param string $color
@return string | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Binary.php#L504-L525 |
strident/Aegis | src/Aegis/Authorization/Voter/RoleVoter.php | RoleVoter.vote | public function vote(TokenInterface $token, array $attributes, $object = null)
{
$roles = $token->getRoles();
$result = VoterInterface::ACCESS_ABSTAIN;
foreach ($attributes as $attribute) {
if ( ! $this->supportsAttribute($attribute)) {
continue;
}
$result = VoterInterface::ACCESS_DENIED;
if (in_array($attribute, $roles)) {
$result = VoterInterface::ACCESS_GRANTED;
}
}
return $result;
} | php | public function vote(TokenInterface $token, array $attributes, $object = null)
{
$roles = $token->getRoles();
$result = VoterInterface::ACCESS_ABSTAIN;
foreach ($attributes as $attribute) {
if ( ! $this->supportsAttribute($attribute)) {
continue;
}
$result = VoterInterface::ACCESS_DENIED;
if (in_array($attribute, $roles)) {
$result = VoterInterface::ACCESS_GRANTED;
}
}
return $result;
} | {@inheritDoc} | https://github.com/strident/Aegis/blob/954bd3d24808d77271844276ae31b41f4f039bd5/src/Aegis/Authorization/Voter/RoleVoter.php#L27-L45 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergePackageLoader | public function mergePackageLoader($directory)
{
if ($vendor = $this->findVendor($directory)) {
$this->mergeComposerNamespaces($vendor);
$this->mergeComposerPsr4($vendor);
$this->mergeComposerClassMap($vendor);
}
} | php | public function mergePackageLoader($directory)
{
if ($vendor = $this->findVendor($directory)) {
$this->mergeComposerNamespaces($vendor);
$this->mergeComposerPsr4($vendor);
$this->mergeComposerClassMap($vendor);
}
} | Autoloads a packages dependencies by merging them with the current auto-loader.
@param $directory | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L48-L55 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerNamespaces | private function mergeComposerNamespaces($vendor)
{
if ($namespaceFile = $this->findComposerDirectory($vendor, 'autoload_namespaces.php')) {
$this->log->debug('Located autoload_namespaces.php file', ['path' => $namespaceFile]);
$map = require $namespaceFile;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->set($namespace, $path);
}
}
} | php | private function mergeComposerNamespaces($vendor)
{
if ($namespaceFile = $this->findComposerDirectory($vendor, 'autoload_namespaces.php')) {
$this->log->debug('Located autoload_namespaces.php file', ['path' => $namespaceFile]);
$map = require $namespaceFile;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->set($namespace, $path);
}
}
} | Merges the dependencies namespaces.
@param $vendor | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L62-L72 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerPsr4 | private function mergeComposerPsr4($vendor)
{
if ($psr4Autoload = $this->findComposerDirectory($vendor, 'autoload_psr4.php')) {
$this->log->debug('Located autoload_psr4.php file', ['path' => $psr4Autoload]);
$map = require $psr4Autoload;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading PSR-4 namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->setPsr4($namespace, $path);
}
}
} | php | private function mergeComposerPsr4($vendor)
{
if ($psr4Autoload = $this->findComposerDirectory($vendor, 'autoload_psr4.php')) {
$this->log->debug('Located autoload_psr4.php file', ['path' => $psr4Autoload]);
$map = require $psr4Autoload;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading PSR-4 namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->setPsr4($namespace, $path);
}
}
} | Merges the dependencies PSR-4 namespaces.
@param $vendor | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L79-L89 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerClassMap | private function mergeComposerClassMap($vendor)
{
if ($composerClassMap = $this->findComposerDirectory($vendor, 'autoload_classmap.php')) {
$this->log->debug('Located autoload_classmap.php file', ['path' => $composerClassMap]);
$classMap = require $composerClassMap;
if ($classMap) {
$this->app->getLoader()->addClassMap($classMap);
}
}
} | php | private function mergeComposerClassMap($vendor)
{
if ($composerClassMap = $this->findComposerDirectory($vendor, 'autoload_classmap.php')) {
$this->log->debug('Located autoload_classmap.php file', ['path' => $composerClassMap]);
$classMap = require $composerClassMap;
if ($classMap) {
$this->app->getLoader()->addClassMap($classMap);
}
}
} | Merges the dependencies class maps.
@param $vendor | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L96-L105 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.findComposerDirectory | private function findComposerDirectory($vendor, $file = '')
{
$composerDirectory = $this->normalizePath($vendor . '/composer/' . $file);
if ($this->files->exists($composerDirectory)) {
return $composerDirectory;
}
return false;
} | php | private function findComposerDirectory($vendor, $file = '')
{
$composerDirectory = $this->normalizePath($vendor . '/composer/' . $file);
if ($this->files->exists($composerDirectory)) {
return $composerDirectory;
}
return false;
} | Finds the composer directory.
Returns false if the directory does not exist.
@param $vendor The vendor directory.
@param string $file An optional file to look for.
@return bool|string | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L116-L125 |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.findVendor | private function findVendor($directory)
{
$vendorDirectory = $this->normalizePath($directory . '/_newup_vendor');
if ($this->files->exists($vendorDirectory) && $this->files->isDirectory($vendorDirectory)) {
return $vendorDirectory;
}
return false;
} | php | private function findVendor($directory)
{
$vendorDirectory = $this->normalizePath($directory . '/_newup_vendor');
if ($this->files->exists($vendorDirectory) && $this->files->isDirectory($vendorDirectory)) {
return $vendorDirectory;
}
return false;
} | Gets the vendor directory location if it exists.
Returns false if the vendor directory does not exist.
@param $directory
@return bool|string | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L135-L144 |
Elephant418/Staq | src/Staq/Core/Data/Stack/Storage/File/Entity.php | Entity.fetchById | public function fetchById($id)
{
$data = [];
foreach ($this->globDataFile($id) as $filename) {
$data = array_merge($data, $this->fetchFileData($id, $filename));
}
return $this->resultAsModel($data);
} | php | public function fetchById($id)
{
$data = [];
foreach ($this->globDataFile($id) as $filename) {
$data = array_merge($data, $this->fetchFileData($id, $filename));
}
return $this->resultAsModel($data);
} | /* FETCHING METHODS
*********************************************************************** | https://github.com/Elephant418/Staq/blob/b96110eb069a2b3fd992d3e56327a54a308b68b2/src/Staq/Core/Data/Stack/Storage/File/Entity.php#L38-L45 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Bundle/Entity/Orm/Template.php | Template.setContent | public function setContent(Content $content)
{
$this->contentTypeName = $content->getType()->getName();
$this->contentId = $content->getContentId();
return parent::setContent($content);
} | php | public function setContent(Content $content)
{
$this->contentTypeName = $content->getType()->getName();
$this->contentId = $content->getContentId();
return parent::setContent($content);
} | Override to store database required fields data.
{@inheritdoc} | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Entity/Orm/Template.php#L43-L49 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Bundle/Entity/Orm/Template.php | Template.setContentType | public function setContentType(ContentType $contentType)
{
$this->contentTypeName = $contentType->getName();
$this->contentTypeId = null;
return parent::setContentType($contentType);
} | php | public function setContentType(ContentType $contentType)
{
$this->contentTypeName = $contentType->getName();
$this->contentTypeId = null;
return parent::setContentType($contentType);
} | Override to store database required fields data.
{@inheritdoc} | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Entity/Orm/Template.php#L66-L72 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Bundle/Entity/Orm/Template.php | Template.setTemplateType | public function setTemplateType(TemplateTypeInterface $templateType)
{
$this->templateTypeId = $templateType->getId();
return parent::setTemplateType($templateType);
} | php | public function setTemplateType(TemplateTypeInterface $templateType)
{
$this->templateTypeId = $templateType->getId();
return parent::setTemplateType($templateType);
} | Override to store database required fields data.
{@inheritdoc} | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Entity/Orm/Template.php#L89-L94 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Bundle/Entity/Orm/Template.php | Template.setZones | public function setZones(ZoneCollection $components)
{
return parent::setZones($components->map(function (Zone $zone) {
return $zone->setTemplate($this);
}));
} | php | public function setZones(ZoneCollection $components)
{
return parent::setZones($components->map(function (Zone $zone) {
return $zone->setTemplate($this);
}));
} | Doctrine needs to cross reference fks.
{@inheritdoc} | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Entity/Orm/Template.php#L115-L120 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.handleWebSocketException | protected function handleWebSocketException(Exception $e)
{
$code = ($e instanceof WebSocketException) ? $e->getCode() : DataFrame::CODE_ABNORMAL;
$respondPayload = pack("n", $code) . $e->getMessage();
$this->logger->warning("WebSocket exception occurred #" . $e->getCode() . " for " . $this . " client");
$this->handler->onException($this, $code);
$error = new DataFrame($this->logger);
$error->setOpcode(DataFrame::OPCODE_CLOSE);
$error->setPayload($respondPayload);
$this->pushData($error);
$this->disconnect();
} | php | protected function handleWebSocketException(Exception $e)
{
$code = ($e instanceof WebSocketException) ? $e->getCode() : DataFrame::CODE_ABNORMAL;
$respondPayload = pack("n", $code) . $e->getMessage();
$this->logger->warning("WebSocket exception occurred #" . $e->getCode() . " for " . $this . " client");
$this->handler->onException($this, $code);
$error = new DataFrame($this->logger);
$error->setOpcode(DataFrame::OPCODE_CLOSE);
$error->setPayload($respondPayload);
$this->pushData($error);
$this->disconnect();
} | {@inheritdoc} | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L28-L41 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.disconnect | public function disconnect($drop = false)
{
$this->handler->onClose($this);
parent::disconnect($drop);
} | php | public function disconnect($drop = false)
{
$this->handler->onClose($this);
parent::disconnect($drop);
} | Disconnects client from server.
It also notifies clients handler about that fact.
@param bool $drop By default client is disconnected after delivering output buffer contents. Set to true to drop
it immediately.
@return void | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L52-L56 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.ping | public function ping($payload = null)
{
if ($payload === null) {
$payload = microtime(true);
} elseif (isset($payload[125])) { //Much faster than strlen($payload) > 125
throw new LengthException("Ping payload cannot be larger than 125 bytes");
}
$this->currentPingFrame = new DataFrame($this->logger);
$this->currentPingFrame->setOpcode(DataFrame::OPCODE_PING);
$this->currentPingFrame->setPayload($payload);
$this->pushData($this->currentPingFrame);
return $payload;
} | php | public function ping($payload = null)
{
if ($payload === null) {
$payload = microtime(true);
} elseif (isset($payload[125])) { //Much faster than strlen($payload) > 125
throw new LengthException("Ping payload cannot be larger than 125 bytes");
}
$this->currentPingFrame = new DataFrame($this->logger);
$this->currentPingFrame->setOpcode(DataFrame::OPCODE_PING);
$this->currentPingFrame->setPayload($payload);
$this->pushData($this->currentPingFrame);
return $payload;
} | Sends "PING" frame to connected client.
@param mixed|null $payload Maximum of 125 bytes. If set to null current time will be used. It's possible to use
empty string.
@return string Used payload value
@throws LengthException In case of payload exceed 125 bytes. | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L81-L96 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.handleClientCloseFrame | protected function handleClientCloseFrame(NetworkFrame $frame)
{
$this->logger->debug("Client sent close frame, parsing");
//TODO strict
$code = $frame->getPayloadPart(0, 2);
if (!empty($code)) { //Code is optional BUT it can't be 0
if (!isset($code[1])) { // payload have to be at least 2 bytes
throw new WebSocketException("Invalid closing payload", DataFrame::CODE_PROTOCOL_ERROR);
}
$code = unpack("n", $code);
$code = $code[1]; //Array dereference on call is allowed from 5.4
$this->logger->debug("Client disconnected with code: " . $code);
if (!DataFrame::validateCloseCode($code)) {
throw new WebSocketException("Invalid close code", DataFrame::CODE_PROTOCOL_ERROR);
}
if (!mb_check_encoding($frame->getPayloadPart(2), 'UTF-8')) {
throw new WebSocketException("Close frame payload is not valid UTF-8",
NetworkFrame::CODE_DATA_TYPE_INCONSISTENT);
}
}
$this->logger->debug("Converting client close frame into server close frame");
$frame->setOpcode(DataFrame::OPCODE_CLOSE);
$frame->setMasking(false);
$frame->setPayload(pack("n", DataFrame::CODE_CLOSE_NORMAL) . "Client closed connection");
$this->pushData($frame);
$this->disconnect();
} | php | protected function handleClientCloseFrame(NetworkFrame $frame)
{
$this->logger->debug("Client sent close frame, parsing");
//TODO strict
$code = $frame->getPayloadPart(0, 2);
if (!empty($code)) { //Code is optional BUT it can't be 0
if (!isset($code[1])) { // payload have to be at least 2 bytes
throw new WebSocketException("Invalid closing payload", DataFrame::CODE_PROTOCOL_ERROR);
}
$code = unpack("n", $code);
$code = $code[1]; //Array dereference on call is allowed from 5.4
$this->logger->debug("Client disconnected with code: " . $code);
if (!DataFrame::validateCloseCode($code)) {
throw new WebSocketException("Invalid close code", DataFrame::CODE_PROTOCOL_ERROR);
}
if (!mb_check_encoding($frame->getPayloadPart(2), 'UTF-8')) {
throw new WebSocketException("Close frame payload is not valid UTF-8",
NetworkFrame::CODE_DATA_TYPE_INCONSISTENT);
}
}
$this->logger->debug("Converting client close frame into server close frame");
$frame->setOpcode(DataFrame::OPCODE_CLOSE);
$frame->setMasking(false);
$frame->setPayload(pack("n", DataFrame::CODE_CLOSE_NORMAL) . "Client closed connection");
$this->pushData($frame);
$this->disconnect();
} | {@inheritdoc}
@throws NodeDisconnectException
@throws WebSocketException WebSocketClient provided invalid closing code or whole payload | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L104-L136 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.handlePingFrame | protected function handlePingFrame(NetworkFrame $frame)
{
$this->logger->debug("Sending pong frame...");
$frame->setOpcode(DataFrame::OPCODE_PONG);
$frame->setMasking(false);
$this->pushData($frame);
} | php | protected function handlePingFrame(NetworkFrame $frame)
{
$this->logger->debug("Sending pong frame...");
$frame->setOpcode(DataFrame::OPCODE_PONG);
$frame->setMasking(false);
$this->pushData($frame);
} | {@inheritdoc} | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L141-L147 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.handlePongFrame | protected function handlePongFrame(NetworkFrame $frame)
{
if ($this->currentPingFrame === null) {
$this->logger->warning("Got unsolicited pong packet from $this - ignoring");
return;
}
if ($this->currentPingFrame->getPayload() !== $frame->getPayload()) {
throw new WebSocketException("Invalid pong payload", DataFrame::CODE_PROTOCOL_ERROR);
}
$this->handler->onPong($this, $this->currentPingFrame);
$this->currentPingFrame = null;
} | php | protected function handlePongFrame(NetworkFrame $frame)
{
if ($this->currentPingFrame === null) {
$this->logger->warning("Got unsolicited pong packet from $this - ignoring");
return;
}
if ($this->currentPingFrame->getPayload() !== $frame->getPayload()) {
throw new WebSocketException("Invalid pong payload", DataFrame::CODE_PROTOCOL_ERROR);
}
$this->handler->onPong($this, $this->currentPingFrame);
$this->currentPingFrame = null;
} | {@inheritdoc}
@throws WebSocketException Invalid pong payload | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L154-L168 |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.handleMessage | protected function handleMessage(Message $message)
{
$this->logger->debug("Got message from router - notifying API");
$this->handler->onMessage($this, $message);
} | php | protected function handleMessage(Message $message)
{
$this->logger->debug("Got message from router - notifying API");
$this->handler->onMessage($this, $message);
} | {@inheritdoc} | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L173-L177 |
cityware/city-format | src/Stringy.php | Stringy.camelize | public function camelize() {
$encoding = $this->encoding;
$stringy = self::create($this->str, $this->encoding);
$camelCase = preg_replace_callback(
'/[-_\s]+(.)?/u', function ($match) use (&$encoding) {
return $match[1] ? mb_strtoupper($match[1], $encoding) : "";
}, $stringy->trim()->lowerCaseFirst()->str
);
$stringy->str = preg_replace_callback(
'/[\d]+(.)?/u', function ($match) use (&$encoding) {
return mb_strtoupper($match[0], $encoding);
}, $camelCase
);
return $stringy;
} | php | public function camelize() {
$encoding = $this->encoding;
$stringy = self::create($this->str, $this->encoding);
$camelCase = preg_replace_callback(
'/[-_\s]+(.)?/u', function ($match) use (&$encoding) {
return $match[1] ? mb_strtoupper($match[1], $encoding) : "";
}, $stringy->trim()->lowerCaseFirst()->str
);
$stringy->str = preg_replace_callback(
'/[\d]+(.)?/u', function ($match) use (&$encoding) {
return mb_strtoupper($match[0], $encoding);
}, $camelCase
);
return $stringy;
} | Returns a camelCase version of the supplied string. Trims surrounding
spaces, capitalizes letters following digits, spaces, dashes and
underscores, and removes spaces, dashes, underscores.
@return Stringy Object with $str in camelCase | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L124-L141 |
cityware/city-format | src/Stringy.php | Stringy.dasherize | public function dasherize() {
// Save current regex encoding so we can reset it after
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding)->trim();
$dasherized = mb_ereg_replace('\B([A-Z])', '-\1', $stringy->str);
$dasherized = mb_ereg_replace('[-_\s]+', '-', $dasherized);
mb_regex_encoding($regexEncoding);
$stringy->str = mb_strtolower($dasherized, $stringy->encoding);
return $stringy;
} | php | public function dasherize() {
// Save current regex encoding so we can reset it after
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding)->trim();
$dasherized = mb_ereg_replace('\B([A-Z])', '-\1', $stringy->str);
$dasherized = mb_ereg_replace('[-_\s]+', '-', $dasherized);
mb_regex_encoding($regexEncoding);
$stringy->str = mb_strtolower($dasherized, $stringy->encoding);
return $stringy;
} | Returns a lowercase and trimmed string separated by dashes. Dashes are
inserted before uppercase characters (with the exception of the first
character of the string), and in place of spaces as well as underscores.
@return Stringy Object with a dasherized $str | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L161-L174 |
cityware/city-format | src/Stringy.php | Stringy.underscored | public function underscored() {
// Save current regex encoding so we can reset it after
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding)->trim();
$underscored = mb_ereg_replace('\B([A-Z])', '_\1', $stringy->str);
$underscored = mb_ereg_replace('[-_\s]+', '_', $underscored);
mb_regex_encoding($regexEncoding);
$stringy->str = mb_strtolower($underscored, $stringy->encoding);
return $stringy;
} | php | public function underscored() {
// Save current regex encoding so we can reset it after
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding)->trim();
$underscored = mb_ereg_replace('\B([A-Z])', '_\1', $stringy->str);
$underscored = mb_ereg_replace('[-_\s]+', '_', $underscored);
mb_regex_encoding($regexEncoding);
$stringy->str = mb_strtolower($underscored, $stringy->encoding);
return $stringy;
} | Returns a lowercase and trimmed string separated by underscores.
Underscores are inserted before uppercase characters (with the exception
of the first character of the string), and in place of spaces as well as
dashes.
@return Stringy Object with an underscored $str | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L184-L197 |
cityware/city-format | src/Stringy.php | Stringy.swapCase | public function swapCase() {
$stringy = self::create($this->str, $this->encoding);
$encoding = $stringy->encoding;
$stringy->str = preg_replace_callback(
'/[\S]/u', function ($match) use (&$encoding) {
if ($match[0] == mb_strtoupper($match[0], $encoding))
return mb_strtolower($match[0], $encoding);
else
return mb_strtoupper($match[0], $encoding);
}, $stringy->str
);
return $stringy;
} | php | public function swapCase() {
$stringy = self::create($this->str, $this->encoding);
$encoding = $stringy->encoding;
$stringy->str = preg_replace_callback(
'/[\S]/u', function ($match) use (&$encoding) {
if ($match[0] == mb_strtoupper($match[0], $encoding))
return mb_strtolower($match[0], $encoding);
else
return mb_strtoupper($match[0], $encoding);
}, $stringy->str
);
return $stringy;
} | Returns a case swapped version of the string.
@return Stringy Object whose $str has each character's case swapped | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L204-L218 |
cityware/city-format | src/Stringy.php | Stringy.titleize | public function titleize($ignore = null) {
$buffer = $this->trim();
$encoding = $this->encoding;
$buffer = preg_replace_callback(
'/([\S]+)/u', function ($match) use (&$encoding, &$ignore) {
if ($ignore && in_array($match[0], $ignore)) {
return $match[0];
} else {
$stringy = new Stringy($match[0], $encoding);
return (string) $stringy->upperCaseFirst();
}
}, $buffer
);
return new Stringy($buffer, $encoding);
} | php | public function titleize($ignore = null) {
$buffer = $this->trim();
$encoding = $this->encoding;
$buffer = preg_replace_callback(
'/([\S]+)/u', function ($match) use (&$encoding, &$ignore) {
if ($ignore && in_array($match[0], $ignore)) {
return $match[0];
} else {
$stringy = new Stringy($match[0], $encoding);
return (string) $stringy->upperCaseFirst();
}
}, $buffer
);
return new Stringy($buffer, $encoding);
} | Returns a trimmed string with the first letter of each word capitalized.
Ignores the case of other letters, allowing for the use of acronyms.
Also accepts an array, $ignore, allowing you to list words not to be
capitalized.
@param array $ignore An array of words not to capitalize
@return Stringy Object with a titleized $str | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L229-L246 |
cityware/city-format | src/Stringy.php | Stringy.humanize | public function humanize() {
$stringy = self::create($this->str, $this->encoding);
$humanized = str_replace('_id', '', $stringy->str);
$stringy->str = str_replace('_', ' ', $humanized);
return $stringy->trim()->upperCaseFirst();
} | php | public function humanize() {
$stringy = self::create($this->str, $this->encoding);
$humanized = str_replace('_id', '', $stringy->str);
$stringy->str = str_replace('_', ' ', $humanized);
return $stringy->trim()->upperCaseFirst();
} | Capitalizes the first word of the string, replaces underscores with
spaces, and strips '_id'.
@return Stringy Object with a humanized $str | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L254-L261 |
cityware/city-format | src/Stringy.php | Stringy.tidy | public function tidy() {
$stringy = self::create($this->str, $this->encoding);
$stringy->str = preg_replace('/\x{2026}/u', '...', $stringy->str);
$stringy->str = preg_replace('/[\x{201C}\x{201D}]/u', '"', $stringy->str);
$stringy->str = preg_replace('/[\x{2018}\x{2019}]/u', "'", $stringy->str);
$stringy->str = preg_replace('/[\x{2013}\x{2014}]/u', '-', $stringy->str);
return $stringy;
} | php | public function tidy() {
$stringy = self::create($this->str, $this->encoding);
$stringy->str = preg_replace('/\x{2026}/u', '...', $stringy->str);
$stringy->str = preg_replace('/[\x{201C}\x{201D}]/u', '"', $stringy->str);
$stringy->str = preg_replace('/[\x{2018}\x{2019}]/u', "'", $stringy->str);
$stringy->str = preg_replace('/[\x{2013}\x{2014}]/u', '-', $stringy->str);
return $stringy;
} | Returns a string with smart quotes, ellipsis characters, and dashes from
Windows-1252 (commonly used in Word documents) replaced by their ASCII
equivalents.
@return Stringy Object whose $str has those characters removed | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L270-L279 |
cityware/city-format | src/Stringy.php | Stringy.collapseWhitespace | public function collapseWhitespace() {
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding);
$stringy->str = mb_ereg_replace('[[:space:]]+', ' ', $stringy);
mb_regex_encoding($regexEncoding);
return $stringy->trim();
} | php | public function collapseWhitespace() {
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$stringy = self::create($this->str, $this->encoding);
$stringy->str = mb_ereg_replace('[[:space:]]+', ' ', $stringy);
mb_regex_encoding($regexEncoding);
return $stringy->trim();
} | Trims the string and replaces consecutive whitespace characters with a
single space. This includes tabs and newline characters, as well as
multibyte whitespace such as the thin space and ideographic space.
@return Stringy Object with a trimmed $str and condensed whitespace | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L288-L297 |
cityware/city-format | src/Stringy.php | Stringy.toAscii | public function toAscii() {
$stringy = self::create($this->str, $this->encoding);
$charsArray = array(
'a' => array('à', 'á', 'â', 'ã', 'ā', 'ą', 'ă', 'å', 'α', 'ά', 'ἀ',
'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ',
'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ',
'ᾶ', 'ᾷ', 'а', 'ъ'),
'b' => array('б', 'β'),
'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ'),
'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д'),
'e' => array('è', 'é', 'ê', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ',
'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є'),
'f' => array('ф'),
'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ'),
'h' => array('ĥ', 'ħ'),
'i' => array('ì', 'í', 'î', 'ï', 'ī', 'ĩ', 'ĭ', 'į', 'ı', 'ι', 'ί',
'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ',
'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и'),
'j' => array('ĵ'),
'k' => array('ķ', 'ĸ', 'к'),
'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л'),
'm' => array('м'),
'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н'),
'o' => array('ò', 'ó', 'ô', 'õ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ό', 'ὀ',
'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'ö', 'о'),
'p' => array('п'),
'r' => array('ŕ', 'ř', 'ŗ', 'р'),
's' => array('ś', 'š', 'ş', 'с'),
't' => array('ť', 'ţ', 'т'),
'u' => array('ü', 'ù', 'ú', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ũ', 'ų', 'µ', 'у'),
'v' => array('в'),
'w' => array('ŵ'),
'y' => array('ÿ', 'ý', 'ŷ', 'й', 'ы'),
'z' => array('ź', 'ž', 'ż', 'з'),
'ch' => array('ч'),
'kh' => array('х'),
'oe' => array('œ'),
'sh' => array('ш'),
'shch' => array('щ'),
'ts' => array('ц'),
'ya' => array('я'),
'yu' => array('ю'),
'zh' => array('ж'),
'A' => array('Á', 'Â', 'Ã', 'Å', 'Ā', 'Ą', 'Ă', 'Α', 'Ά', 'Ἀ', 'Ἁ',
'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ',
'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ъ'),
'B' => array('Б'),
'C' => array('Ć', 'Č', 'Ĉ', 'Ċ'),
'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д'),
'E' => array('É', 'Ê', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ',
'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', 'Є'),
'F' => array('Ф'),
'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ'),
'I' => array('Í', 'Î', 'Ï', 'Ī', 'Ĩ', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ',
'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί',
'И', 'І', 'Ї'),
'K' => array('К'),
'L' => array('Ĺ', 'Ł', 'Л'),
'M' => array('М'),
'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н'),
'O' => array('Ó', 'Ô', 'Õ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ',
'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О'),
'P' => array('П'),
'R' => array('Ř', 'Ŕ', 'Р'),
'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С'),
'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т'),
'U' => array('Ù', 'Ú', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ũ', 'Ų', 'У'),
'V' => array('В'),
'Y' => array('Ý', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й'),
'Z' => array('Ź', 'Ž', 'Ż', 'З'),
'CH' => array('Ч'),
'KH' => array('Х'),
'SH' => array('Ш'),
'SHCH' => array('Щ'),
'TS' => array('Ц'),
'YA' => array('Я'),
'YU' => array('Ю'),
'ZH' => array('Ж')
);
foreach ($charsArray as $key => $value) {
$stringy->str = str_replace($value, $key, $stringy->str);
}
return $stringy;
} | php | public function toAscii() {
$stringy = self::create($this->str, $this->encoding);
$charsArray = array(
'a' => array('à', 'á', 'â', 'ã', 'ā', 'ą', 'ă', 'å', 'α', 'ά', 'ἀ',
'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ',
'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ',
'ᾶ', 'ᾷ', 'а', 'ъ'),
'b' => array('б', 'β'),
'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ'),
'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д'),
'e' => array('è', 'é', 'ê', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ',
'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є'),
'f' => array('ф'),
'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ'),
'h' => array('ĥ', 'ħ'),
'i' => array('ì', 'í', 'î', 'ï', 'ī', 'ĩ', 'ĭ', 'į', 'ı', 'ι', 'ί',
'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ',
'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и'),
'j' => array('ĵ'),
'k' => array('ķ', 'ĸ', 'к'),
'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л'),
'm' => array('м'),
'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н'),
'o' => array('ò', 'ó', 'ô', 'õ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ό', 'ὀ',
'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'ö', 'о'),
'p' => array('п'),
'r' => array('ŕ', 'ř', 'ŗ', 'р'),
's' => array('ś', 'š', 'ş', 'с'),
't' => array('ť', 'ţ', 'т'),
'u' => array('ü', 'ù', 'ú', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ũ', 'ų', 'µ', 'у'),
'v' => array('в'),
'w' => array('ŵ'),
'y' => array('ÿ', 'ý', 'ŷ', 'й', 'ы'),
'z' => array('ź', 'ž', 'ż', 'з'),
'ch' => array('ч'),
'kh' => array('х'),
'oe' => array('œ'),
'sh' => array('ш'),
'shch' => array('щ'),
'ts' => array('ц'),
'ya' => array('я'),
'yu' => array('ю'),
'zh' => array('ж'),
'A' => array('Á', 'Â', 'Ã', 'Å', 'Ā', 'Ą', 'Ă', 'Α', 'Ά', 'Ἀ', 'Ἁ',
'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ',
'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ъ'),
'B' => array('Б'),
'C' => array('Ć', 'Č', 'Ĉ', 'Ċ'),
'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д'),
'E' => array('É', 'Ê', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ',
'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', 'Є'),
'F' => array('Ф'),
'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ'),
'I' => array('Í', 'Î', 'Ï', 'Ī', 'Ĩ', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ',
'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί',
'И', 'І', 'Ї'),
'K' => array('К'),
'L' => array('Ĺ', 'Ł', 'Л'),
'M' => array('М'),
'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н'),
'O' => array('Ó', 'Ô', 'Õ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ',
'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О'),
'P' => array('П'),
'R' => array('Ř', 'Ŕ', 'Р'),
'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С'),
'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т'),
'U' => array('Ù', 'Ú', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ũ', 'Ų', 'У'),
'V' => array('В'),
'Y' => array('Ý', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й'),
'Z' => array('Ź', 'Ž', 'Ż', 'З'),
'CH' => array('Ч'),
'KH' => array('Х'),
'SH' => array('Ш'),
'SHCH' => array('Щ'),
'TS' => array('Ц'),
'YA' => array('Я'),
'YU' => array('Ю'),
'ZH' => array('Ж')
);
foreach ($charsArray as $key => $value) {
$stringy->str = str_replace($value, $key, $stringy->str);
}
return $stringy;
} | Returns an ASCII version of the string. A set of non-ASCII characters are
replaced with their closest ASCII counterparts, and the rest are removed.
@return Stringy Object whose $str contains only ASCII characters | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L305-L390 |
cityware/city-format | src/Stringy.php | Stringy.pad | public function pad($length, $padStr = ' ', $padType = 'right') {
if (!in_array($padType, array('left', 'right', 'both'))) {
throw new \InvalidArgumentException('Pad expects $padType ' .
"to be one of 'left', 'right' or 'both'");
}
$stringy = self::create($this->str, $this->encoding);
$strLength = $stringy->length();
$padStrLength = mb_strlen($padStr, $stringy->encoding);
if ($length <= $strLength || $padStrLength <= 0)
return $stringy;
// Number of times to repeat the padStr if left or right
$times = ceil(($length - $strLength) / $padStrLength);
$paddedStr = '';
if ($padType == 'left') {
// Repeat the pad, cut it, and prepend
$leftPad = str_repeat($padStr, $times);
$leftPad = mb_substr($leftPad, 0, $length - $strLength, $this->encoding);
$stringy->str = $leftPad . $stringy->str;
} elseif ($padType == 'right') {
// Append the repeated pad and get a substring of the given length
$stringy->str = $stringy->str . str_repeat($padStr, $times);
$stringy->str = mb_substr($stringy->str, 0, $length, $this->encoding);
} else {
// Number of times to repeat the padStr on both sides
$paddingSize = ($length - $strLength) / 2;
$times = ceil($paddingSize / $padStrLength);
// Favour right padding over left, as with str_pad()
$rightPad = str_repeat($padStr, $times);
$rightPad = mb_substr($rightPad, 0, ceil($paddingSize), $this->encoding);
$leftPad = str_repeat($padStr, $times);
$leftPad = mb_substr($leftPad, 0, floor($paddingSize), $this->encoding);
$stringy->str = $leftPad . $stringy->str . $rightPad;
}
return $stringy;
} | php | public function pad($length, $padStr = ' ', $padType = 'right') {
if (!in_array($padType, array('left', 'right', 'both'))) {
throw new \InvalidArgumentException('Pad expects $padType ' .
"to be one of 'left', 'right' or 'both'");
}
$stringy = self::create($this->str, $this->encoding);
$strLength = $stringy->length();
$padStrLength = mb_strlen($padStr, $stringy->encoding);
if ($length <= $strLength || $padStrLength <= 0)
return $stringy;
// Number of times to repeat the padStr if left or right
$times = ceil(($length - $strLength) / $padStrLength);
$paddedStr = '';
if ($padType == 'left') {
// Repeat the pad, cut it, and prepend
$leftPad = str_repeat($padStr, $times);
$leftPad = mb_substr($leftPad, 0, $length - $strLength, $this->encoding);
$stringy->str = $leftPad . $stringy->str;
} elseif ($padType == 'right') {
// Append the repeated pad and get a substring of the given length
$stringy->str = $stringy->str . str_repeat($padStr, $times);
$stringy->str = mb_substr($stringy->str, 0, $length, $this->encoding);
} else {
// Number of times to repeat the padStr on both sides
$paddingSize = ($length - $strLength) / 2;
$times = ceil($paddingSize / $padStrLength);
// Favour right padding over left, as with str_pad()
$rightPad = str_repeat($padStr, $times);
$rightPad = mb_substr($rightPad, 0, ceil($paddingSize), $this->encoding);
$leftPad = str_repeat($padStr, $times);
$leftPad = mb_substr($leftPad, 0, floor($paddingSize), $this->encoding);
$stringy->str = $leftPad . $stringy->str . $rightPad;
}
return $stringy;
} | Pads the string to a given length with $padStr. If length is less than
or equal to the length of the string, no padding takes places. The default
string used for padding is a space, and the default type (one of 'left',
'right', 'both') is 'right'. Throws an InvalidArgumentException if
$padType isn't one of those 3 values.
@param int $length Desired string length after padding
@param string $padStr String used to pad, defaults to space
@param string $padType One of 'left', 'right', 'both'
@return Stringy Object with a padded $str
@throws InvalidArgumentException If $padType isn't one of 'right',
'left' or 'both' | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L406-L448 |
cityware/city-format | src/Stringy.php | Stringy.toLowerCase | public function toLowerCase() {
$str = mb_strtolower($this->str, $this->encoding);
return self::create($str, $this->encoding);
} | php | public function toLowerCase() {
$str = mb_strtolower($this->str, $this->encoding);
return self::create($str, $this->encoding);
} | Converts all characters in the string to lowercase. An alias for PHP's
mb_strtolower().
@return Stringy Object with all characters of $str being lowercase | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L569-L573 |
cityware/city-format | src/Stringy.php | Stringy.toUpperCase | public function toUpperCase() {
$str = mb_strtoupper($this->str, $this->encoding);
return self::create($str, $this->encoding);
} | php | public function toUpperCase() {
$str = mb_strtoupper($this->str, $this->encoding);
return self::create($str, $this->encoding);
} | Converts all characters in the string to uppercase. An alias for PHP's
mb_strtoupper().
@return Stringy Object with all characters of $str being uppercase | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L581-L585 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.