sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function saturate($percent) { $color = $this->toHsl(); $saturation = $this->clamp(($color->saturation() + $percent) / 100); return $color->saturation($saturation * 100)->back($this); }
@param int $percent @return mixed
entailment
public function desaturate($percent) { $color = $this->toHsl(); $saturation = $this->clamp(($color->saturation() - $percent) / 100); return $color->saturation($saturation * 100)->back($this); }
@param int $percent @return mixed
entailment
public function brighten($percent) { $percent *= -1; $color = $this->toRgb(); $color->red(max(0, min(255, $color->red() - round(255 * ($percent / 100))))); $color->green(max(0, min(255, $color->green() - round(255 * ($percent / 100))))); $color->blue(max(0, min(255, $color->b...
@param int $percent @return mixed
entailment
public function lighten($percent) { $color = $this->toHsl(); $lightness = $this->clamp(($color->lightness() + $percent) / 100); return $color->lightness($lightness * 100)->back($this); }
@param int $percent @return mixed
entailment
public function darken($percent) { $color = $this->toHsl(); $lightness = $this->clamp(($color->lightness() - $percent) / 100); return $color->lightness($lightness * 100)->back($this); }
@param int $percent @return mixed
entailment
public function spin($percent) { $color = $this->toHsl(); $hue = ($color->hue() + $percent) % 360; return $color->hue($hue < 0 ? 360 + $hue : $hue)->back($this); }
@param int $percent @return mixed
entailment
public function mix(BaseColor $color, $percent = 50) { $first = $this->toRgb(); $second = $color->toRgb(); $weight = $percent / 100; $red = $first->red() * (1 - $weight) + $second->red() * $weight; $green = $first->green() * (1 - $weight) + $second->green() * $weight; ...
@param \OzdemirBurak\Iris\BaseColor $color @param int $percent @return mixed
entailment
public function tint($percent = 50) { $clone = clone $this; $white = $clone->toRgb()->red(255)->green(255)->blue(255); return $this->mix($white, $percent); }
@param int $percent @return mixed
entailment
public function shade($percent = 50) { $clone = clone $this; $black = $clone->toRgb()->red(0)->green(0)->blue(0); return $this->mix($black, $percent); }
@param int $percent @return mixed
entailment
public static function fromArray(array $data, $filter = false){ $class = get_called_class(); $object = new static(); foreach($data as $key => $value){ if(!$filter || property_exists($class, $key)){ $object->$key = $value; } } return $object...
Create a Struct from an associative array @param array $data associative array array('property'=>data) @param bool $filter (optional) if true, $data array keys which are not defined as properties in the Struct will be ignored @return Struct
entailment
public function reload() { // update application components to the latest version if (file_exists($this->lock_file)) { unlink($this->lock_file); } $this->composer = $this->factory->createComposer($this->getIO()); }
Reload Composer.
entailment
public function getPackageFromConfigFile($config) { if (!file_exists($config)) { throw new \RuntimeException('File "'.$config.'" not found'); } return $this->loader->load((new JsonFile($config))->read(), 'Composer\Package\RootPackage'); }
@throws \RuntimeException @param string $config @return RootPackage
entailment
public static function getVersionCompatible($version) { // {suffix:weight} $suffixes = [ 'dev' => 1, // composer suffix 'patch' => 2, 'alpha' => 3, 'beta' => 4, 'stable' => 5, // is not a real suffix. use it if suffix is not exists ...
Get version compatible. 3.2.1-RC2 => 3.2.1.6.2 @param string $version @return string|false
entailment
public static function find($code, $index = 0) { $code = strtolower($code); $colors = static::get(); return isset($colors[$code]) ? $colors[$code][$index] : $code; }
@param $code @param int $index @return string
entailment
public function boot() { $this->loadViewsFrom(__DIR__.'/../resources/views', 'Simplegrid'); $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'Simplegrid'); $this->publishes([ __DIR__.'/../config/rafwell-simplegrid.php' => config_path('rafwell-simplegrid.php'), ...
Bootstrap the application services. @return void
entailment
protected function createMemcachedDriver(array $config) { $prefix = $this->getPrefix($config); // Extract Plus features from config $persistentConnectionId = array_get($config, 'persistent_id'); $customOptions = array_get($config, 'options', []); $saslCredentials = array_fil...
Create an instance of the Memcached cache driver. @param array $config @return \Illuminate\Cache\MemcachedStore
entailment
public static function packageInKernel(PackageEvent $event) { self::addJobByOperationType( $event->getOperation(), function ($package) { return new AddKernel($package); }, function ($package) { return new RemoveKernel($package);...
Add or remove package in kernel. @param PackageEvent $event
entailment
public static function packageInRouting(PackageEvent $event) { self::addJobByOperationType( $event->getOperation(), function ($package) { return new AddRouting($package); }, function ($package) { return new RemoveRouting($packag...
Add or remove packages in routing. @param PackageEvent $event
entailment
public static function packageInConfig(PackageEvent $event) { self::addJobByOperationType( $event->getOperation(), function ($package) { return new AddConfig($package); }, function ($package) { return new RemoveConfig($package);...
Add or remove packages in config. @param PackageEvent $event
entailment
public static function migratePackage(PackageEvent $event) { self::addJobByOperationType( $event->getOperation(), function ($package) { return new UpMigrate($package); }, function ($package) { return new DownMigrate($package); ...
Migrate packages. @param PackageEvent $event
entailment
public static function notifyPackage(PackageEvent $event) { self::addJobByOperationType( $event->getOperation(), function ($package) { return new InstalledPackageNotify($package); }, function ($package) { return new RemovedPacka...
Notify listeners that the package has been installed/updated/removed. @param PackageEvent $event
entailment
protected static function addJobByOperationType( OperationInterface $operation, \Closure $install, \Closure $uninstall, \Closure $update = null ) { switch ($operation->getJobType()) { case 'install': self::getContainer()->addJob($install($operation...
Add job by operation type. @param OperationInterface $operation @param \Closure $install @param \Closure $update @param \Closure $uninstall
entailment
public static function notifyProjectInstall(Event $event) { self::getContainer()->addJob(new InstalledProjectNotify($event->getComposer()->getPackage())); }
Notify listeners that the project has been installed. @param Event $event
entailment
public static function notifyProjectUpdate(Event $event) { self::getContainer()->addJob(new UpdatedProjectNotify($event->getComposer()->getPackage())); }
Notify listeners that the project has been updated. @param Event $event
entailment
public static function installConfig() { if (!file_exists(self::getRootDir().'config/vendor_config.yml')) { file_put_contents(self::getRootDir().'config/vendor_config.yml', ''); } if (!file_exists(self::getRootDir().'config/routing.yml')) { file_put_contents(self::ge...
Install config files.
entailment
public static function generateSecretKey() { // make parameters file if not exists touch(self::getRootDir().'/config/parameters.yml'); /* @var $manipulator Parameters */ $manipulator = self::getContainer()->getManipulator('parameters'); if (!$manipulator->get('secret')) { ...
Make a unique secret key.
entailment
public static function migrateUp(Event $event) { $dir = self::getRootDir().'DoctrineMigrations'; if (self::isHaveMigrations($dir)) { self::repackMigrations($dir); self::executeCommand('doctrine:migrations:migrate --no-interaction', $event->getIO()); } }
Migrate all plugins to up. @param Event $event
entailment
public static function migrateDown(Event $event) { $dir = self::getRootDir().'cache/dev/DoctrineMigrations/'; if (self::isHaveMigrations($dir)) { file_put_contents( $dir.'migrations.yml', "migrations_namespace: 'Application\Migrations'\n". ...
Migrate all plugins to down. @param Event $event
entailment
protected static function isHaveMigrations($dir) { if (!is_dir($dir)) { return false; } return (bool) Finder::create() ->in($dir) ->files() ->name('/Version\d{14}.*\.php/') ->count() ; }
@param string $dir @return bool
entailment
public static function clearCache(Event $event) { // to avoid errors due to the encrypted container forcibly clean the cache directory $dir = self::getRootDir().'cache/prod'; if (is_dir($dir)) { (new Filesystem())->remove($dir); } self::executeCommand('cache:clea...
Clears the Symfony cache. @param \Composer\Script\Event $event
entailment
public function add($url, $description = NULL, array $events = array()){ return $this->request('add', array( 'url' => $url, 'description' => $description, 'events' => $events )); }
Add a new webhook @param string $url the URL to POST batches of events @param string $description an optional description of the webhook @param string[] $events an optional list of events that will be posted to the webhook valid events: send, hard_bounce, soft_bounce, open, click, spam, unsub, reject @return array @lin...
entailment
public function update($id, $url, $description = NULL, array $events = array()){ return $this->request('update', array( 'id' => $id, 'url' => $url, 'description' => $description, 'events' => $events )); }
Update an existing webhook @param int $id the unique identifier of a webhook belonging to this account @param string $url the URL to POST batches of events @param string $description an optional description of the webhook @param string[] $events an optional list of events that will be posted to the webhook valid events...
entailment
public function onBootstrap(EventInterface $event) { /* @var $application \Zend\Mvc\Application */ $application = $event->getTarget(); $serviceManager = $application->getServiceManager(); $eventManager = $application->getEventManager(); $eventManager->attachAggregate...
{@inheritDoc}
entailment
public function activity($notifyEmail = NULL, $dateFrom = NULL, $dateTo = NULL, array $tags = array(), array $senders = array(), array $states = array(), array $apiKeys = array()){ return $this->request('activity', array( 'notify_email' => $notifyEmail, 'date_from' => $dateFrom, ...
Begins an export of your activity history. @param string $notifyEmail an optional email address to notify when the export job has finished @param string $dateFrom start date as a UTC string in YYYY-MM-DD HH:MM:SS format @param string $dateTo end date as a UTC string in YYYY-MM-DD HH:MM:SS format @param string[] $tags a...
entailment
private function calculateVariablePercentOfMethods(array $methods, $variableName) { $methodCount = count($methods); if (0 === $methodCount) { return 0; } $methodsWithVariable = $this->getMethodsContainsVariable($methods, $variableName); return round(count($meth...
@param array $methods @param string $variableName @return float
entailment
private function getMethodsContainsVariable(array $methods, $variableName) { $methodsWithVariable = []; foreach ($methods as $method) { $propertyPostfixes = $method->findChildrenOfType('PropertyPostfix'); /** @var AbstractNode $propertyPostfix */ foreach ($prope...
@param AbstractNode[] $methods @param string $variableName @return AbstractNode[]
entailment
protected function getMemcached($connectionId, array $credentials, array $options) { $memcached = $this->createMemcachedInstance($connectionId); if (count($credentials) == 2) { $this->setCredentials($memcached, $credentials); } if (count($options)) { $memcac...
Get a new Memcached instance. @param string|null $connectionId @param array $credentials @param array $options @return \Memcached
entailment
protected function setCredentials($memcached, $credentials) { list($username, $password) = $credentials; $memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $memcached->setSaslAuthData($username, $password); }
Set the SASL credentials on the Memcached connection. @param \Memcached $memcached @param array $credentials @return void
entailment
public function add($id, $name = NULL, $notes = NULL, $customQuota = NULL){ return $this->request('add', array( 'id' => $id, 'name' => $name, 'notes' => $notes, 'custom_quota' => $customQuota )); }
Add a new subaccount @param string $id a unique identifier for the subaccount to be used in sending calls @param string $name an optional display name to further identify the subaccount @param string $notes optional extra text to associate with the subaccount @param int $customQuota an optional manual hourly quota for ...
entailment
public function update($id, $name = NULL, $notes = NULL, $customQuota = NULL){ return $this->request('update', array( 'id' => $id, 'name' => $name, 'notes' => $notes, 'custom_quota' => $customQuota )); }
Update an existing subaccount @param string $id he unique identifier of the subaccount to update @param string $name an optional display name to further identify the subaccount @param string $notes optional extra text to associate with the subaccount @param int $customQuota an optional manual hourly quota for the subac...
entailment
protected function request($url, array $body = array()){ $baseUrl = self::BASE_URL; if(isset($this->baseUrl)){ $baseUrl = $this->baseUrl; } $client = new Client($baseUrl); $body['key'] = $this->apiKey; $section = explode('\\', get_called_class()); $sec...
Send a request to Mandrill. All requests are sent via HTTP POST. @param string $url @param array $body @throws Exception\APIException @return array
entailment
public function prerenderPage(MvcEvent $event) { $originalRequest = $event->getRequest(); if (!$this->shouldPrerenderPage($originalRequest)) { return; } $event->stopPropagation(true); $eventManager = $this->getEventManager(); // Trigger a pre-event (for...
Pre-render the page @param MvcEvent $event @return void|ResponseInterface
entailment
public function shouldPrerenderPage(RequestInterface $request) { if (!$request instanceof HttpRequest) { return false; } // First, return false if User Agent is not a bot if (!$this->isCrawler($request)) { return false; } $uri = $request->get...
Is this request should be a prerender request? @param RequestInterface $request @return bool
entailment
protected function isCrawler(HttpRequest $request) { if (null !== $request->getQuery('_escaped_fragment_')) { return true; } $userAgent = strtolower($request->getHeader('User-Agent')->getFieldValue()); foreach ($this->moduleOptions->getCrawlerUserAgents() as $crawlerUse...
Check if the request is made from a crawler To detect if a request comes from a bot, we have two strategies: 1. We first check if the "_escaped_fragment_" query param is defined. This is only implemented by some search engines (Google, Yahoo and Bing among others) 2. If not, we use the User-Agent string @param HttpR...
entailment
protected function isWhitelisted($uri, array $whitelistUrls) { foreach ($whitelistUrls as $whitelistUrl) { $match = preg_match('`' . $whitelistUrl . '`i', $uri); if ($match > 0) { return true; } } return false; }
Check if the request is whitelisted @param string $uri @param array $whitelistUrls @return bool
entailment
protected function isBlacklisted($uri, $referer, array $blacklistUrls) { foreach ($blacklistUrls as $blacklistUrl) { $pattern = '`' . $blacklistUrl . '`i'; $match = preg_match($pattern, $uri) + preg_match($pattern, $referer); if ($match > 0) { return tr...
Check if the request is blacklisted @param string $uri @param string $referer @param array $blacklistUrls @return bool
entailment
public function addBundle($bundle) { $bundle = $this->getBundleString($bundle); // not root bundle if (strpos($this->getKernal(), $bundle) === false) { $bundles = $this->getBundles(); if (!in_array($bundle, $bundles)) { $bundles[] = $bundle; ...
Add bundle to kernal. @param string $bundle
entailment
public function removeBundle($bundle) { $bundles = $this->getBundles(); if (($key = array_search($this->getBundleString($bundle), $bundles)) !== false) { unset($bundles[$key]); $this->setBundles($bundles); } }
Remove bundle from kernal. @param string $bundle
entailment
protected function getKernal() { if (!$this->kernel) { $this->kernel = file_get_contents($this->kernel_filename); } return $this->kernel; }
Get AppKernal content. @return string
entailment
public function addPackage($package, $version) { $config = $this->getContent(); $config['require'][$package] = $version; $this->setContent($config); }
Add the package into composer requirements. @param string $package @param string $version
entailment
public function removePackage($package) { $config = $this->getContent(); if (isset($config['require'][$package])) { unset($config['require'][$package]); $this->setContent($config); } }
Remove the package from composer requirements. @param string $package
entailment
protected function getPackageOption($option) { $options = $this->package->getExtra(); if (isset($options[$option])) { return $options[$option]; } return ''; }
@param string $option @return string
entailment
protected function getPackageOptionFile($option) { $option = $this->getPackageOption($option); if ($option && file_exists($this->getPackageDir().$option)) { return $option; } return ''; }
@param string $option @return string
entailment
public function getPackageBundle() { // specific name if (($class = $this->getPackageOption('anime-db-bundle')) && class_exists($class)) { return $class; } // package with the bundle can contain the word a 'bundle' in the name $name = preg_replace('/(\/.+)[^a-z]b...
Get the bundle from package. For example package name 'demo-vendor/foo-bar-bundle' converted to: \DemoVendor\Bundle\FooBarBundle\DemoVendorFooBarBundle \DemoVendor\Bundle\FooBarBundle\FooBarBundle \Foo\Bundle\BarBundle\FooBarBundle \Foo\Bundle\BarBundle\BarBundle @return string|null
entailment
public function getPackageCopy() { $copy = new Package( $this->package->getName(), $this->package->getVersion(), $this->package->getPrettyVersion() ); $copy->setType($this->package->getType()); $copy->setExtra($this->package->getExtra()); ...
Get a simple copy of the package. @return Package
entailment
protected function getRoutingNodeName() { $name = strtolower($this->getPackage()->getName()); // package with the bundle can contain the word a 'bundle' in the name $name = preg_replace('/(\/.+)[^a-z]bundle$/', '$1', $name); $name = preg_replace('/[^a-z_]+/', '_', $name); re...
Get the routing node name from the package name. @return string
entailment
public function addResource($name, $bundle, $format, $path = 'routing') { $resource = '@'.$bundle.$path.'.'.$format; $yaml = $this->getContent(); if (!isset($yaml[$name]) || $yaml[$name]['resource'] != $resource) { $yaml[$name] = ['resource' => $resource]; $this->setC...
Add a routing resource. @param string $name @param string $bundle @param string $format @param string $path
entailment
public function removeResource($name) { $yaml = $this->getContent(); if (isset($yaml[$name])) { unset($yaml[$name]); $this->setContent($yaml); } }
Remove a routing resource. @param string $name
entailment
public function add($name, $fromEmail = NULL, $fromName = NULL, $subject = NULL, $code = NULL, $text = NULL, $publish = true){ return $this->request('add', array( 'name' => $name, 'from_email' => $fromEmail, 'from_name' => $fromName, 'subject'=> $subject, ...
Add a new template @param string $name the name for the new template - must be unique @param string $fromEmail a default sending address for emails sent using this template @param string $fromName a default from name to be used @param string $subject a default subject line to be used @param string $code the HTML code ...
entailment
protected function validate($code) { $color = str_replace(['rgb', '(', ')', ' '], '', DefinedColor::find($code, 1)); if (preg_match('/^(\d{1,3}),(\d{1,3}),(\d{1,3})$/', $color, $matches)) { if ($matches[1] > 255 || $matches[2] > 255 || $matches[3] > 255) { return false; ...
@param string $code @return string|bool
entailment
protected function initialize($color) { return list($this->red, $this->green, $this->blue) = explode(',', $color); }
@param string $color @return array
entailment
private function getH($max, $r, $g, $b, $d) { switch ($max) { case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; case $g: $h = ($b - $r) / $d + 2; break; case $b: $h = ($r - $g) / $d + 4...
@param float $max @param float $r @param float $g @param float $b @param float $d @return float
entailment
protected function createCacheHandler($driver) { $store = $this->app['config']->get('session.store') ?: $driver; $minutes = $this->app['config']['session.lifetime']; return new CacheBasedSessionHandler(clone $this->app['cache']->store($store), $minutes); }
Create the cache based session handler instance. @param string $driver @return \Illuminate\Session\CacheBasedSessionHandler
entailment
protected function isDataStructure(ClassNode $node) { if (!preg_match($this->getRegex('dataStructureNamespaceRegex'), $node->getNamespaceName())) { return false; } if (!preg_match($this->getRegex('dataStructureClassNameRegex'), $node->getName())) { return false; ...
@param ClassNode|ASTClass $node @return bool
entailment
public function red($red = null) { if ($red !== null) { $this->validateAndSet('red', $red); return $this; } return !empty($this->castsInteger) ? (int) $this->red : $this->red; }
@param int|string $red @return int|string|$this
entailment
public function green($green = null) { if ($green !== null) { $this->validateAndSet('green', $green); return $this; } return !empty($this->castsInteger) ? (int) $this->green : $this->green; }
@param float|int|string $green @return float|int|string|$this
entailment
public function blue($blue = null) { if ($blue !== null) { $this->validateAndSet('blue', $blue); return $this; } return !empty($this->castsInteger) ? (int) $this->blue : $this->blue; }
@param float|int|string $blue @return float|int|string|$this
entailment
public function sendRaw($rawMessage, array $to = array(), $mailFrom = NULL, $helo = NULL, $clientAddress = NULL){ return $this->request('send-raw', array( 'raw_message' => $rawMessage, 'to' => $to, 'mail_from' => $mailFrom, 'helo' => $helo, 'client_add...
Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP @param string $rawMessage the full MIME document of an email message @param string[] $to optionally define the recipients to receive the message - otherwise we'll use the ...
entailment
public function getTags($repository) { /* @var $response Response */ $response = $this->client->get('repos/'.$repository.'/tags')->send(); return json_decode($response->getBody(true), true); }
@param string $repository @return array
entailment
public function getLastRelease($repository) { $last_version = ''; $last_tag = []; foreach ($this->getTags($repository) as $tag) { if (($version = Composer::getVersionCompatible($tag['name'])) && (!$last_version || version_compare($version, $last_version, '>=')) &&...
@param string $repository @return array|false
entailment
protected function execute(InputInterface $input, OutputInterface $output) { /* @var $composer Composer */ $composer = $this->getContainer()->get('anime_db.composer'); $composer->setIO(new ConsoleIO($input, $output, $this->getHelperSet())); /* @var $github GitHub */ $github ...
@param InputInterface $input @param OutputInterface $output @return bool
entailment
protected function rewriting($from) { $fs = $this->getContainer()->get('filesystem'); try { $fs->remove( Finder::create() ->files() ->ignoreUnreadableDirs() ->in($this->getContainer()->getParameter('kernel.root_d...
Rewrite the application files. @param string $from
entailment
public function setGlobalMergeVars(array $vars){ $this->global_merge_vars = array(); foreach($vars as $name => $content){ $this->addGlobalMergeVar($name, $content); } return $this; }
Set all global merge variables. Will overwrite any currently set global merge variables. @param array $vars array('name1' => 'content1', 'name2' => 'content2') @return $this
entailment
public function addRecipient(Recipient $recipient){ $this->to[] = array( 'email' => $recipient->email, 'name' => $recipient->name, 'type' => $recipient->type ); $this->merge_vars[] = array( 'rcpt' => $recipient->email, 'vars' => $recipi...
Add a recipient to this message @param Recipient $recipient @return $this
entailment
public function getManipulator($name) { if (!isset($this->manipulators[$name])) { switch ($name) { case 'composer': $this->manipulators[$name] = new ComposerManipulator($this->root_dir.'/../composer.json'); break; case 'conf...
@param string $name @return ManipulatorInterface
entailment
public function execute() { // sort jobs by priority $jobs = []; ksort($this->jobs); foreach ($this->jobs as $priority_jobs) { $jobs = array_merge($jobs, $priority_jobs); } /* @var $job Job */ foreach ($jobs as $job) { $job->execute();...
Execute all jobs.
entailment
public function executeCommand($cmd, $timeout = 300) { $php = escapeshellarg($this->getPhp()); $process = new Process($php.' '.$this->root_dir.'console '.$cmd, $this->root_dir.'/../', null, null, $timeout); $process->run(function ($type, $buffer) { echo $buffer; }); ...
@throws \RuntimeException @param string $cmd @param int $timeout
entailment
protected function getPhp() { if (is_null($this->php_path)) { $finder = new PhpExecutableFinder(); if (!($this->php_path = $finder->find())) { throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment vari...
Get path to php executable. @throws \RuntimeException @return string
entailment
public function start($args = null, $scheduler = false) { if ($args === null) { $this->outputTitle($scheduler ? 'Creating the scheduler worker' : 'Creating workers'); } else { $this->runtime = $args; } if ($scheduler) { if ($this->runtime['Schedul...
Start workers @return void
entailment
public function stop() { $ResqueStatus = $this->ResqueStatus; $this->debug('Searching for active workers'); $options = new SendSignalCommandOptions(); $options->title = 'Stopping workers'; $options->noWorkersMessage = 'There is no workers to stop'; $options->allOptio...
Stop workers @return void
entailment
public function pause() { $ResqueStatus = $this->ResqueStatus; $activeWorkers = call_user_func(self::$Resque_Worker . '::all'); array_walk( $activeWorkers, function (&$worker) { return $worker = (string)$worker; } ); $pause...
Pause workers @return void
entailment
public function resume() { $ResqueStatus = $this->ResqueStatus; $this->debug('Searching for paused workers'); $options = new SendSignalCommandOptions(); $options->title = 'Resuming workers'; $options->noWorkersMessage = 'There is no paused workers to resume'; $option...
Resume workers @return void
entailment
public function sendSignal($options) { $this->outputTitle($options->title); $force = $this->input->getOption('force')->value; $all = $this->input->getOption('all')->value; if ($force) { $this->debug("'FORCE' option detected"); } if ($all) { ...
Send a Signal to a worker system process @since 1.2.0 @return void
entailment
public function load() { $this->outputTitle('Loading predefined workers'); $debug = $this->debug; if (!isset($this->runtime['Queues']) || empty($this->runtime['Queues'])) { $this->output->outputLine("You have no configured workers to load.\n", 'failure'); } else { ...
Load workers from configuration @return void
entailment
public function restart() { $workers = $this->ResqueStatus->getWorkers(); $this->outputTitle('Restarting workers'); if (!empty($workers)) { $this->stop(); foreach ($workers as $worker) { if (isset($worker['type']) && $worker['type'] === 'scheduler')...
Restart all workers @return void
entailment
public function tail() { $logs = array(); $i = 1; $workers = $this->ResqueStatus->getWorkers(); foreach ($workers as $worker) { if ($worker['Log']['filename'] != '') { $logs[] = $worker['Log']['filename']; } if ($worker['Log']['han...
Tail a log file If more than one log file exists, will display a menu dialog with a list of log files to choose from. @return void
entailment
public function enqueue() { $this->outputTitle('Queuing a job'); $args = $this->input->getArguments(); if (count($args) >= 2) { $queue = array_shift($args); $class = array_shift($args); $result = call_user_func_array(self::$Resque . '::enqueue', array($...
Add a job to a queue @return void
entailment
public function stats() { $workers = call_user_func(array($this->ResqueStats, 'getWorkers')); // List of all queues $queues = array_unique(call_user_func(array($this->ResqueStats, 'getQueues'))); // List of queues monitored by a worker $activeQueues = array(); foreac...
Print some stats about the workers @return void
entailment
public function reset() { $this->debug('Emptying the worker database'); $this->ResqueStatus->clearWorkers(); $this->debug('Unregistering the scheduler worker'); $this->ResqueStatus->unregisterSchedulerWorker(); $this->output->outputLine('Fresque state has been reseted', 'succ...
Reset worker statuses @since 1.2.0 @return void
entailment
public function loadSettings($command, $args = null) { $options = ($args === null) ? $this->input->getOptionValues(true) : $args; $this->config = isset($options['config']) ? $options['config'] : '.'.DS.'fresque.ini'; if (!file_exists($this->config)) { $this->output->outputLine("...
Convert options from various source to formatted options understandable by Fresque @return bool true if settings contains no errors
entailment
public function help($command = null) { $this->outputTitle('Welcome to Fresque'); $this->output->outputLine('Fresque '. Fresque::VERSION .' by Wan Chen (Kamisama) (2013)'); if (!array_key_exists($command, $this->commandTree) && $command !== null && ($command !== '--h...
Print help/welcome message @since 1.2.0 @return void
entailment
public function outputTitle($title, $primary = true) { $l = strlen($title); if ($primary) { $this->output->outputLine(str_repeat('-', $l), 'title'); } $this->output->outputLine($title, $primary ? 'title' : 'subtitle'); if ($primary) { $this->output->ou...
Print a pretty title @param string $title The title to print @param bool $primary True to print a big title, else print a small title @since 1.0.0 @return void
entailment
public function formatDateDiff($start, $end = null) { if (!($start instanceof \DateTime)) { $start = new \DateTime($start); } if ($end === null) { $end = new \DateTime(); } if (!($end instanceof \DateTime)) { $end = new \DateTime($start);...
A sweet interval formatting, will use the two biggest interval parts. On small intervals, you get minutes and seconds. On big intervals, you get months and days. Only the two biggest parts are used. @param \DateTime $start @param \DateTime|null $end @codeCoverageIgnore @link http://www.php.net/manual/en/dateinterval....
entailment
private function absolutePath($path) { if (substr($path, 0, 2) === './') { $path = dirname(__DIR__) . DS . substr($path, 2); } elseif (substr($path, 0, 1) !== '/' || substr($path, 0, 3) === '../') { $path = dirname(__DIR__) . DS . $path; } return rtrim($path, ...
Return the absolute path to a file @param string $path Path to convert @return string Absolute path to the file
entailment
protected function getResqueBinFile($base) { $paths = array( 'bin' . DS . 'resque', 'bin' . DS . 'resque.php', 'resque.php' ); foreach ($paths as $path) { if (file_exists($base . DS . $path)) { return '.' . DS . $path; ...
Return the php-resque executable file Maintain backward compatibility, as newer version of php-resque has that file in another location @param String $base Php-resque folder path @since 1.1.6 @return String Relative path to php-resque executable file
entailment
protected function kill($signal, $pid) { $output = array(); $message = exec(sprintf(($this->runtime['Default']['user'] !== $this->getProcessOwner() ? ('sudo -u '. escapeshellarg($this->runtime['Default']['user'])) . ' ' : "") . '/bin/kill -%s %s 2>&1', $signal, $pid), $output, $code); return...
Send a signal to a process @param String $signal Signal to send @param int $pid PID of the process @codeCoverageIgnore @since 1.2.0 @return array with the code and message returned by the command
entailment
protected function checkStartedWorker($pidFile) { $pid = false; if (file_exists($pidFile) && false !== $pid = file_get_contents($pidFile)) { unlink($pidFile); return (int)$pid; } return false; }
Check the content of the PID file created by the worker to retrieve its process PID @param string $path Path to the PID file @codeCoverageIgnore @since 1.2.0 @return false|int The worker process ID, or false if error
entailment
protected function getUserChoice($listTitle, $selectMessage, $menuItems) { $menuOptions = new \ezcConsoleMenuDialogOptions( array( 'text' => $listTitle, 'selectText' => $selectMessage, 'validator' => new DialogMenuValidator($menuItems) ...
Display a Dialog menu, and retrieve the user selection @param string $listTitle Title of the menu dialog @param string $selectMessage Select option message @param array $menuItems The menu contents @codeCoverageIgnore @since 1.2.0 @return int The index in the menu that was selected
entailment
protected function initialize($color) { return list($this->hue, $this->saturation, $this->lightness) = explode(',', $color); }
@param string $color @return array
entailment
public function setPool($ip, $pool, $createPool = false){ return $this->request('set-pool', array( 'ip' => $ip, 'pool' => $pool, 'create_pool' => $createPool )); }
Moves a dedicated IP to a different pool. @param string $ip a dedicated ip address @param string $pool the name of the new pool to add the dedicated ip to @param bool $createPool whether to create the pool if it does not exist; if false and the pool does not exist, an Unknown_Pool will be thrown. @return array @link ht...
entailment