sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function run() { // Get 'onlyMimes' value from GET parameter $filter = Yii::$app->request->getQueryParam('filter'); if (!empty($filter)) { $this->settings['onlyMimes'] = is_string($filter) ? StringHelper::explode($filter) : $filter; } // disable resize in ...
{@inheritdoc}
entailment
public function getHolidaysByYear($year) { $easter = $this->getEasterDates($year); $holidays = array( // National Fixed '01-01' => $this->createData('Confraternização Universal'), '04-21' => $this->createData('Tiradentes'), '05-01' => $this->createDat...
{@inheritdoc}
entailment
private function setHolidayForState(&$holidays, $day, $state, $name) { // Exists? if (! array_key_exists($day, $holidays)) { // Initialized as State Holiday $holidays[$day] = $this->createData($name, []); } // Is a state holiday? if (is_array($holidays...
Set Holiday for State This method was created because Brazilian national holidays may conflict with state holidays. For example, "2017-06-15" is a national variable holiday called "Corpus Christi", and is an Acre state fixed holiday called "Aniversário do Estado". In these cases, national holiday will be consider more...
entailment
public function timezone() { $params = array( $this->database, $this->user, $this->password ); return $this->getClient('common')->call('timezone_get', $params); }
Get timezone @return string Current timezone
entailment
public function search($model, $data, $offset = 0, $limit = 100) { $params = $this->buildParams(array( $model, 'search', $data, $offset, $limit )); $response = $this->getClient('object')->call('execute', $params); return $response; }
Search models @param string $model Model @param array $data Array of criteria @param integer $offset Offset @param integer $limit Max results @return array Array of model id's
entailment
public function create($model, $data) { $params = $this->buildParams(array( $model, 'create', $data )); $response = $this->getClient('object')->call('execute', $params); return $response; }
Create model @param string $model Model @param array $data Array of fields with data (format: ['field' => 'value']) @return integer Created model id
entailment
public function read($model, $ids, $fields = array()) { $params = $this->buildParams(array( $model, 'read', $ids, $fields )); $response = $this->getClient('object')->call('execute', $params); return $response; }
Read model(s) @param string $model Model @param array $ids Array of model id's @param array $fields Index array of fields to fetch, an empty array fetches all fields @return array An array of models
entailment
public function unlink($model, $ids) { $params = $this->buildParams(array( $model, 'unlink', $ids )); return $this->getClient('object')->call('execute', $params); }
Unlink model(s) @param string $model Model @param array $ids Array of model id's @return boolean True is successful
entailment
public function getReport($model, $ids, $type = 'qweb-pdf') { $params = $this->buildParams(array( $model, $ids, array( 'model' => $model, 'id' => $ids[0], 'report_type' => $type ) )); $client = $this->getClient('report'); $reportId = $client->call('report', $params); $state = false...
Get report for model @param string $model Model @param array $ids Array of id's, for this method it should typically be an array with one id @param string $type Report type @return mixed A report file
entailment
protected function buildParams(array $params) { return array_merge(array( $this->database, $this->uid(), $this->password ), $params); }
Build parameters @param array $params Array of params to append to the basic params @return array
entailment
protected function getClient($path = null) { if ($path === null) { return $this->client; } if ($this->path === $path) { return $this->client; } $this->path = $path; $this->client = new XmlRpcClient($this->host . '/' . $path, $this->httpClient); // The introspection done by the Zend XmlRpc clien...
Get XmlRpc Client This method returns an XmlRpc Client for the requested endpoint. If no endpoint is specified or if a client for the requested endpoint is already initialized, the last used client will be returned. @param null|string $path The api endpoint @return XmlRpcClient
entailment
protected function uid() { if ($this->uid === null) { $client = $this->getClient('common'); $this->uid = $client->call('login', array( $this->database, $this->user, $this->password )); } return $this->uid; }
Get uid @return int $uid
entailment
public function getHolidaysByYear($year) { $easter = $this->getEasterDates($year); $midSummerDay = $this->getMidSummerDay($year); $allSaintsDay = $this->getAllSaintsDay($year); return array( '01-01' => $this->createData('Nyårsdagen'), '01-05' => $this->crea...
@param int $year @return array
entailment
public function init() { parent::init(); if ($this->clientRoute === null) { throw new InvalidConfigException('Client route must be specified.'); } if (empty($this->buttonOptions['id'])) { $this->buttonOptions['id'] = $this->options['id'] . '_button'; ...
{@inheritdoc} @throws InvalidConfigException
entailment
public function run() { if ($this->textarea) { $this->template = $this->textareaTemplate; if (!isset($this->options['rows'])) { $this->options['rows'] = $this->textareaRows; } } $replace = []; if ($this->hasModel()) { i...
{@inheritdoc}
entailment
protected function createRoute() { $route = (array)$this->clientRoute; $route['id'] = $this->options['id']; if (!empty($this->filter)) { $route['filter'] = $this->filter; } if ($this->multiple) { $route['multiple'] = 1; } return $route;...
Creates route to elFinder client @return array
entailment
public function build($name, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) { $class = $this->getClass($name); if ($class) { return new $class($arg1, $arg2, $arg3, $arg4); } return null; }
Create an instance of some class
entailment
public function getDirectives() { return array( new Directives\Dummy, new Directives\CodeBlock, new Directives\Raw, new Directives\Replace, new Directives\Toctree, new Directives\Document, new Directives\RedirectionTitle, ...
Gets the available directives
entailment
public function renderRenderable(RootRenderableInterface $formRuntime): string { if (!$formRuntime instanceof FormRuntime) { throw new FusionException(sprintf('Expected instance of FormRuntime, got %s', is_object($formRuntime) ? get_class($formRuntime) : gettype($formRuntime)), 1503932881); ...
Renders the given $formRuntime using Fusion If the $formRuntime specifies a "_fusionRuntime" rendering option that FusionRuntime will be used, otherwise a new FusionView is instantiated. @param RootRenderableInterface $formRuntime @return string @throws FusionException
entailment
public function getHolidaysByYear($year) { $easter = $this->getEasterDates($year); $greatPrayerDay = clone $easter['easterSunday']; $greatPrayerDay->modify('+26 days'); $holidays = array( '01-01' => $this->createData('Nytår'), '12-25' => $this->createData('1...
@param int $year @return mixed
entailment
public function getHolidaysByYear($year) { $easter = $this->getEasterDates($year); $mothersDay = date('m-d', strtotime('second Sunday of May '. $year)); $holidays = array( '01-01' => $this->createData('Jaunais Gads'), '05-01' => $this->createData('Darba svētki'), ...
Getting non-working holidays @param int $year @return mixed
entailment
public function process(Parser $parser, $node, $variable, $data, array $options) { $document = $parser->getDocument(); $processNode = $this->processNode($parser, $variable, $data, $options); if ($processNode) { if ($variable) { $environment = $parser->getEnviron...
This is the function called by the parser to process the directive, it can be overloaded to do anything with the document, like tweaking nodes or change the environment The node that directly follows the directive is also passed to it @param $parser the calling parser @param $node the node that follows the directive ...
entailment
public function processNode(Parser $parser, $variable, $data, array $options) { $this->processAction($parser, $variable, $data, $options); return null; }
This can be overloaded to write a directive that just create one node for the document, which is common The arguments are the same that process
entailment
public function parseLink($line) { // Links if (preg_match('/^\.\. _`(.+)`: (.+)$/mUsi', $line, $match)) { $this->environment->setLink($match[1], $match[2]); return true; } if (preg_match('/^\.\. _(.+): (.+)$/mUsi', $line, $match)) { $this->enviro...
Try to parse a link definition @param string $line @return bool
entailment
protected function prepareCode() { if (!$this->buffer) { return false; } $lastLine = trim($this->buffer[count($this->buffer)-1]); if (strlen($lastLine) >= 2) { if (substr($lastLine, -2) == '::') { if (trim($lastLine) == '::') { ...
Tells if the current buffer is announcing a block of code @return bool
entailment
protected function isSpecialLine($line) { if (strlen($line) < 3) { return false; } $letter = $line[0]; $environment = $this->environment; if (!in_array($letter, $environment::$letters)) { return false; } for ($i=1; $i<strlen($line); ...
Tell if a line is a special separating line for title and separators, returns the depth of the special line @param string $line @return bool
entailment
protected function findTableChars($line) { $lineChar = $line[0]; $spaceChar = null; for ($i=0; $i<strlen($line); $i++) { if ($line[$i] != $lineChar) { if ($spaceChar == null) { $spaceChar = $line[$i]; } else { ...
Finding the table chars @param string $line @return array|bool
entailment
protected function parseTableLine($line) { $header = false; $pretty = false; $line = trim($line); if (!strlen($line)) { return false; } // Finds the table chars $chars = $this->findTableChars($line); if (!$chars) { return fal...
If the given line is a table line, this will returns the parts of the given line, i.e the offset of the separators ====================== ========= =========== 0 23 33 +---------------------+---------+-----------+ 1 23 33 @param string $line @return mixed
entailment
protected function parseListLine($line) { $depth = 0; for ($i=0; $i<strlen($line); $i++) { $char = $line[$i]; if ($char == ' ') { $depth++; } else if ($char == "\t") { $depth += 2; } else { break; ...
Parses a list line @param string $line the string line @return array containing: - true if the list is ordered, false else - the depth of the list - the text of the first line without the tick
entailment
protected function isListLine($line) { // A buffer is a list if at least the first line is a list-style $listLine = $this->parseListLine($line); if ($listLine) { return $listLine['depth'] == 0 || !$this->isCode; } return false; }
Is the given line a list line ? @param string $line @return bool true if the given line is a list line
entailment
public function pushListLine($line, $flush = false) { if (trim($line)) { $infos = $this->parseListLine($line); if ($infos) { if ($this->lineInfo) { $this->lineInfo['text'] = $this->createSpan($this->lineInfo['text']); $this->bu...
Push a line to the current list node buffer @param string $line @param bool $flush @return bool
entailment
protected function initDirective($line) { if (preg_match('/^\.\. (\|(.+)\| |)([^\s]+)::( (.*)|)$/mUsi', $line, $match)) { $this->directive = array( 'variable' => $match[2], 'name' => $match[3], 'data' => trim($match[4]), 'options' =...
Get current directive if the buffer contains one .. |variable| name:: data :option: value :otherOption: otherValue @param string $line @return false if this is not a directive, else an array containing : - variable: the variable name of the directive - name: the directive name - data: the data of the directive - opti...
entailment
protected function directiveAddOption($line) { if (preg_match('/^(\s+):(.+): (.*)$/mUsi', $line, $match)) { $this->directive['options'][$match[2]] = trim($match[3]); return true; } else if (preg_match('/^(\s+):(.+):(\s*)$/mUsi', $line, $match)) { $value = trim($ma...
Try to add an option line to the current directive, returns true if sucess and false if failure @param string $line
entailment
protected function getCurrentDirective() { if (!$this->directive) { $this->getEnvironment()->getErrorManager()->error('Asking for current directive, but there is not'); } $name = $this->directive['name']; if (isset($this->directives[$name])) { return $this->d...
Gets the current directive @return Directive
entailment
protected function flush() { $node = null; $this->isCode = false; if ($this->buffer) { switch ($this->state) { case self::STATE_TITLE: $data = implode("\n", $this->buffer); $level = $this->environment->getLevel($this->specialLetter); ...
Flushes the current buffer to create a node
entailment
protected function parseLine(&$line) { switch ($this->state) { case self::STATE_BEGIN: if (trim($line)) { if ($this->isListLine($line)) { $this->state = self::STATE_LIST; $this->buffer = $this->kernel->build('Nodes\ListNode'); ...
Process one line @param string $line the line string
entailment
public function includeFileAllowed($path) { if (!$this->includeAllowed) { return false; } if (!@is_readable($path)) { return false; } if (empty($this->includeRoot)) { return true; } $real = realpath($path); foreach (...
Is this file allowed to be included? @param $path @return bool
entailment
public function includeFiles($document) { $environment = $this->getEnvironment(); $parser = $this; return preg_replace_callback('/^\.\. include:: (.+)$/m', function($match) use ($parser, $environment) { $path = $environment->absoluteRelativePath($match[1]); if ($pars...
Include all files described in $document and returns the new string of the given document with includes processed
entailment
protected function parseLines($document) { // Including files $document = str_replace("\r\n", "\n", $document); $document = "\n$document\n"; $document = $this->includeFiles($document); // Removing UTF-8 BOM $bom = "\xef\xbb\xbf"; $document = str_repla...
Process all the lines of a document string @param string $document the string (content) of the document
entailment
public function setIncludePolicy($allow, $directory = null) { $this->includeAllowed = !empty($allow); if ($directory !== null) { $this->includeRoot = (string) $directory; } return $this; }
Allow/disallow includes, or restrict them to a directory @param bool $allow @param string $directory @return self
entailment
public function getHolidaysByYear($year) { $easter = $this->getEasterDates($year); $repentanceDay = $this->getDayOfRepentance($year); // 500th anniversay of the Reformation // @see https://de.wikipedia.org/wiki/Reformationstag#Deutschland if (2017 === $year) { $...
@param int $year @return array
entailment
public function getTocs() { $tocs = array(); $nodes = $this->getNodes(function($node) { return $node instanceof TocNode; }); foreach ($nodes as $toc) { $files = $toc->getFiles(); foreach ($files as &$file) { $file = $this->enviro...
Get the table of contents of the document
entailment
public function getTitles() { $titles = array(); $levels = array(&$titles); foreach ($this->nodes as $node) { if ($node instanceof TitleNode) { $level = $node->getLevel(); $text = (string)$node->getValue(); $redirection = $node->ge...
Gets the titles hierarchy in arrays, for instance : array( array('Main title', array( array('Sub title', array()), array('Sub title 2', array(), array(array('Redirection', 'target'), array(), ) )
entailment
public function getHolidayByDate(\DateTime $date, $state = null) { $day = $date->format(self::DATE_FORMAT); $holidays = $this->getHolidaysByYear(intval($date->format('Y'))); if (isset($holidays[$day])) { $holiday = $this->createModelFromData($holidays[$day], $date); ...
@param \DateTime $date @param string $state @return Holiday
entailment
protected function createModelFromData(array $data, \DateTime $date) { $holiday = new Holiday( $data['name'], $date, $data['states'] ); return $holiday; }
@param array $data @param \DateTime $date @return Holiday
entailment
protected function hasState(Holiday $holiday, $state = null) { if ($state === null) { return true; } $states = $holiday->getStates(); if (empty($states)) { return true; } if (is_array($states) && in_array($state, $states)) { retur...
@param Holiday $holiday @param string $state @return bool
entailment
public function isHoliday($iso, $date = 'now', $state = null) { return ($this->getHoliday($iso, $date, $state) !== null); }
Checks wether a given date is a holiday This method can be used to check whether a specific date is a holiday in a specified country and state @param string $iso @param \DateTime|string $date @param string $state @return bool
entailment
public function getHoliday($iso, $date = 'now', $state = null) { $iso = $this->getIsoCode($iso); $date = $this->getDateTime($date); $provider = $this->getProvider($iso); $holiday = $provider->getHolidayByDate($date, $state); return $holiday; }
Provides detailed information about a specific holiday @param string $iso @param \DateTime|string $date @param string $state @return Holiday|null
entailment
public function pre_commit() { if ( file_exists( self::MARKER_FILE ) ) { unlink( self::MARKER_FILE ); } $hash = md5( file_get_contents( 'README.md' ) ); shell_exec( 'vendor/bin/wp scaffold package-readme . --force > /dev/null 2>&1' ); if ( $hash === md5( file_get_contents( 'README.md' ) ) ) { return; ...
Try to regenerate the README.md file and memorize whether changes were detected. @since 0.1.0
entailment
public function validate($entity, $context = null) : bool { if (!$entity instanceof AuditEvent) { throw new \LogicException('The Entity to validate must be an instance of \Fei\Service\Audit\Entity\AuditEvent'); } return parent::validate($entity, $context); }
@param mixed $entity @param null $context @return bool @throws \LogicException @throws \ObjectivePHP\Validation\Exception\ValidationException
entailment
public function transform(AuditEvent $auditEvent): array { return array( 'id' => $auditEvent->getId(), 'reported_at' => $auditEvent->getReportedAt()->format(\DateTime::ISO8601), 'level' => (int) $auditEvent->getLevel(), 'namespace' => $auditEv...
@param AuditEvent $auditEvent @return array
entailment
public function setReportedAt($reportedAt) : AuditEvent { if (\is_string($reportedAt)) { $reportedAt = new \DateTime($reportedAt); } $this->reportedAt = $reportedAt; return $this; }
@param $reportedAt @return AuditEvent
entailment
public function setNamespace($namespace) : AuditEvent { $parts = explode('/', $namespace); foreach ($parts as &$part) { $part = Snake::case($part, '-'); } $namespace = implode('/', $parts); $namespace = '/' . trim($namespace, '/'); $this->namespace = $na...
@param string $namespace @return AuditEvent
entailment
public static function fromV1ToV2(array $context): array { if (array_key_exists('key', $context) && !\is_array($context['key']) && array_key_exists('value', $context) ) { $context = [$context]; } if (count($context) === 1 && !\is_int(key($context)...
@param array $context @return array
entailment
public static function fromV2ToV1(array $context): array { $result = []; foreach ($context as $key => $value) { $result[] = ['key' => $key, 'value' => $value]; } return $result; }
@param array $context @return array
entailment
protected function orderHandler($order_parameter) { list($order, $seed) = $this->getOrderAndSeed($order_parameter); $this->arguments['order'] = $order; $this->arguments['seed'] = $seed; }
Only called when 'order' argument is used. @param string $order_parameter The order argument passed in command line.
entailment
private function getOrderAndSeed($order) { @list($order, $seed) = explode(':', $order, 2); if (empty($seed)) { $seed = $this->getRandomSeed(); } if (!is_numeric($seed)) { $this->showError("Could not use '$seed' as seed."); } return array($or...
Parses arguments to know if random order is desired, and if seed was chosen. @param string $order String from command line parameter. @return array
entailment
public function isAllowed(RolesAwareInterface $client) { return ($this->acl) ? $this->acl->isAllowed($client) : false; }
Convenience/Shortcut authorization method for services: Checks if the role-aware client passed is allowed (authorized) to use the service. @param RolesAwareInterface $client @return bool
entailment
protected function extractCompletions($response) { $aggregations = isset($response['aggregations']) ? $response['aggregations'] : []; return array_map(function ($option) { return $option['key']; }, $aggregations['autocomplete']['buckets']); }
Extract autocomplete options @param $response @return array
entailment
protected function printFooter(\PHPUnit\Framework\TestResult $result): void { parent::printFooter($result); $this->writeNewLine(); $this->write("Randomized with seed: {$this->seed}"); $this->writeNewLine(); }
Just add to the output the seed used to randomize the test suite. @param PHPUnit\Framework\TestResult $result
entailment
public function getPermissions() { if ($this->permissions instanceOf PermissionsStorageInterface) { return $this->permissions; } elseif ( is_array($this->permissions) ) { $this->setPermissions( new PermissionsStorage($this->permissions) ); } else { ...
Returns an instance of PermissionsStorageInterface If none is set, a blank PermissionsStorage will be set and returned. @return \tomkyle\Permissions\PermissionsStorage @uses $permissions @uses setPermissions() @uses \tomkyle\Permissions\PermissionsStorage
entailment
public function parse($input) { $this->inValuePath = false; $this->lexer->setInput($input); $this->lexer->moveNext(); $node = null; if ($this->mode->equals(Mode::FILTER)) { $node = $this->disjunction(); } else { $node = $this->path(); ...
@param string $input @return Ast\Node
entailment
private function isName($value, $token) { if (!$token) { return false; } if (!$token->is(Tokens::T_NAME)) { return false; } if (is_array($value)) { foreach ($value as $v) { if (strcasecmp($token->getValue(), $v) === 0) { ...
@param string|string[] $value @param Token|null $token @return bool
entailment
private function randomizeSuiteThatContainsOtherSuites($suite, $seed) { $order = 0; foreach ($suite->tests() as $test) { if ($test instanceof \PHPUnit\Framework\TestSuite && $this->testSuiteContainsOtherSuites($test)) { $this->randomizeSuiteThatContainsOtherSuites($test, ...
Randomize each Test Suite inside the main Test Suite. @param [type] $suite Main Test Suite to randomize. @param [type] $seed Seed to use. @return \PHPUnit\Framework\Test
entailment
private function randomizeSuite($suite, $seed, $order = 0, $fix_depends = true) { $reflected = new \ReflectionObject($suite); $property = $reflected->getProperty('tests'); $property->setAccessible(true); $property->setValue($suite, $this->randomizeTestsCases($suite->tests(), $seed, $...
Randomize the test cases inside a TestSuite, with the given seed. @param \PHPUnit\Framework\Test $suite Test suite to randomize. @param integer $seed Seed to be used for the random funtion. @param integer $order Arbitrary value to "salt" the seed. @param bool ...
entailment
private function fixDependencies(array $tests) { $tests_dependencies = $tests_methods = []; foreach ($tests as $i => $test) { $reflected = new \ReflectionObject($test); $name_field = $dependencies_field = null; while ($reflected = $reflected->getParentClass()) {...
fix tests order because of @depends annotations @param array $tests TestCases to randomize. @return array Fixed randomized array
entailment
private function setOrder($tests_dependencies, $tests_methods) { $new_order = []; foreach ($tests_methods as $method_name => $order) { if (isset($tests_dependencies[$method_name]) && !in_array($tests_dependencies[$method_name], $new_order)) { $new_order[] = $tests_depende...
preapare test methods required order @param array $tests_dependencies tests dependencies array @param array $tests_methods tests (shuffled) array @return array array
entailment
private function isDependant(&$new_order, $tests_dependencies, $tests_methods, $method) { foreach ($tests_dependencies as $dependant => $depends) { if ($method == $dependant && !in_array($depends, $new_order)) { array_splice($new_order, array_search($method, $new_order), 0, [$dep...
check if dependant method has another dependant method (recursive) @param array $new_order tests fixed (shuflled, with dependencies) array @param array $tests_dependencies tests dependencies array @param array $tests_methods tests (shuffled) array @return void
entailment
public static function fromString($string) { $string = trim($string); if (!$string) { throw new \InvalidArgumentException('Empty attribute path'); } $colonPos = strrpos($string, ':'); if ($colonPos !== false) { $schema = substr($string, 0, $colonPos);...
@param string $string @return AttributePath
entailment
public function setId($id) { // blacklist if (!(is_string($id) and filter_var($id, \FILTER_VALIDATE_INT) !== false) and !is_int($id)) { throw new \InvalidArgumentException( "Integer ID expected." ); } $this->id = (int) trim($id); return $this; }
Sets the role ID. @param int $id @return RoleAbstract Fluent Interface @uses $id @throws InvalidArgumentException If parameter is not integer-like.
entailment
public function intersect(RolesStorageInterface $roles) { $res = array_intersect($roles->getArrayCopy(), $this->getArrayCopy()); return (!empty($res)); }
Checks if the given RolesStorage has any intersections with this RolesStorage, i.e. if the user has one of the roles stored in this object. @param RolesStorageInterface $roles RolesStorage @return bool @uses RolesStorageInterface::getRoles()
entailment
public function contains( $id ) { $iterator = $this->getIterator(); $role_id = ($id instanceOf RoleInterface) ? $id->getId() : $id; while ($iterator->valid()) { if ($iterator->current() == $role_id) { return true; } $iterator->next(); ...
Checks if the given Role ID exists in the RolesStorage ArrayObject, i.e. if the client is assigned to this role. @param int|RoleInterface $id RoleInterface instance or role ID @return bool
entailment
public function searchAction(NodeInterface $node) { /* @var FusionView $view */ $view = $this->view; $view->setFusionPath('ajaxSearch'); $view->assign('value', $node); }
@param NodeInterface $node @return void
entailment
public function get($key, $default = null) { $this->validateKey($key); $value = $this->doctrineCache->fetch($key); if ($value === false) { // Doctrine cache returns `false` when cache doesn't contain, but also `false` if the value stored is // `false`, so check to se...
{@inheritDoc}
entailment
public function set($key, $value, $ttl = null) : bool { $this->validateKey($key); if ($ttl === null) { return $this->doctrineCache->save($key, $value); } if ($ttl instanceof \DateInterval) { $ttl = $this->convertDateIntervalToInteger($ttl); } ...
{@inheritDoc}
entailment
public function delete($key) : bool { $this->validateKey($key); return $this->doctrineCache->delete($key); }
{@inheritDoc}
entailment
public function has($key) : bool { $this->validateKey($key); return $this->doctrineCache->contains($key); }
{@inheritDoc}
entailment
public function getRoles() { if ($this->roles instanceOf RolesStorageInterface) { return $this->roles; } $this->setRoles( new RolesStorage( $this->roles ) ); return $this->roles; }
Returns an instance of RolesStorageInterface containing all roles the client is assigned to. Id none is defined, an (empty) RolesStorage will be set, configured with the roles refined in `$roles` member array. @return RolesStorageInterface @uses $roles
entailment
private function startServer() { if ($this->resource !== null) { return; } $this->writeln(PHP_EOL); $this->writeln('Starting PhantomJS Server.'); $command = $this->getCommand(); if ($this->config['debug']) { $this->writeln(PHP_EOL); ...
Start PhantomJS server. @throws \Codeception\Exception\ExtensionException
entailment
private function stopServer() { if ($this->resource !== null) { $this->write('Stopping PhantomJS Server.'); // Wait till the server has been stopped. $max_checks = 10; for ($i = 0; $i < $max_checks; $i++) { // If we're on the last loop, and it...
Stop PhantomJS server.
entailment
private function getCommandParameters() { // Map our config options to PhantomJS options. $mapping = [ 'port' => '--webdriver', 'proxy' => '--proxy', 'proxyType' => '--proxy-type', 'proxyAuth' => '--proxy-auth', 'webSecurity' => '--web-secu...
Build the parameters for our command. @return string All parameters separated by spaces.
entailment
private function getCommand() { // Prefix command with exec on non Windows systems to ensure that we // receive the correct pid. // See http://php.net/manual/en/function.proc-get-status.php#93382 $commandPrefix = $this->isWindows() ? '' : 'exec '; return $commandPrefix . esca...
Get PhantomJS command. @return string Command to execute.
entailment
public function suiteInit(SuiteEvent $e) { // Check if PhantomJS should only be started for specific suites. if (isset($this->config['suites'])) { if (is_string($this->config['suites'])) { $suites = [$this->config['suites']]; } else { $suites =...
Suite Init. @param \Codeception\Event\SuiteEvent $e The event with suite, result and settings. @throws \Codeception\Exception\ExtensionException
entailment
public function handle(Request $request, Closure $next, MediaTypeGuard $guard = null) { // $guard = $guard ?? app(MediaTypeGuard::class); if (!$guard->validateExistingContentType($request) || !$guard->hasCorrectHeadersForData($request)) { $errors = (new ErrorCollection())->add(E...
Adds support for the Server Responsibilities section of content negotiation spec for json-api. @see http://jsonapi.org/format/#content-negotiation
entailment
public function filter(ProxyQueryInterface $query, $alias, $field, $data) { if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { return; } if (\is_array($data['value'])) { $values = []; foreach ($da...
{@inheritdoc}
entailment
public function asJavascript() { return implode("\n ", array_map(function ($push) { return '_paq.push([' . implode(', ', array_map(function ($item) { if ($item instanceof RawExpression) { return $item->value; } ...
Creates the javascript output for the _paq.push() calls @return string
entailment
public function execute(array $params = [], $hydrationMode = null) { // TODO find method names // Sorted field and sort order $sortBy = $this->getSortBy(); $sortOrder = $this->getSortOrder(); if ($sortBy && $sortOrder) { $this->query->setSort([$sortBy => ['order...
{@inheritdoc}
entailment
public function setSortBy($parentAssociationMappings, $fieldMapping) { $alias = ''; foreach ((array) $parentAssociationMappings as $associationMapping) { $alias .= $associationMapping['fieldName'].'.'; } $this->sortBy = $alias.$fieldMapping['fieldName']; return...
{@inheritdoc}
entailment
public function addShould($args) { $this->boolQuery->addShould($args); $this->query = new \Elastica\Query($this->boolQuery); }
Add should part to query. @param AbstractQuery|array $args Should query @return ElasticaProxyQuery
entailment
public static function displayFilename (FtpFile $file, FtpWidget $context) { if ($context->allowNavigation && self::isDir($file)) { $dir = $context->baseFolder."/".$file->filename; if ($context->baseFolder == "/") { $dir = "/".$file->filename; } if ($file->filename == '..') { $dir = str_replace('\...
Build filename for FtpWidget. @param FtpFile $file Current {@link FtpFile} @param FtpWidget $context Current displayable widget @return string Displayed filename
entailment
public function setExpiry(int $expires = null):AccessToken{ $now = time(); if($expires!== null){ $expires = intval($expires); } $this->expires = self::EOL_UNKNOWN; if($expires === 0 || $expires === self::EOL_NEVER_EXPIRES){ $this->expires = self::EOL_NEVER_EXPIRES; } elseif($expires > $now){ ...
@param int $expires @return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface
entailment
protected function checkState(string $state = null):void{ if(empty($state) || !$this->storage->hasCSRFState($this->serviceName)){ throw new ProviderException('invalid state for '.$this->serviceName); } $knownState = $this->storage->getCSRFState($this->serviceName); if(!hash_equals($knownState, $state)){ ...
@param string|null $state @return void @throws \chillerlan\OAuth\Core\ProviderException
entailment
protected function setState(array $params):array{ if(!isset($params['state'])){ $params['state'] = sha1(random_bytes(256)); } $this->storage->storeCSRFState($this->serviceName, $params['state']); return $params; }
@param array $params @return array
entailment
public function getAuthURL(array $params = null):UriInterface{ $params = array_merge( $params ?? [], ['oauth_token' => $this->getRequestToken()->accessToken] ); return $this->uriFactory->createUri(Psr7\merge_query($this->authURL, $params)); }
@param array $params @return \Psr\Http\Message\UriInterface
entailment
protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{ parse_str(Psr7\decompress_content($response), $data); if(!$data || !is_array($data)){ throw new ProviderException('unable to parse token response'); } elseif(isset($data['error'])){ throw ...
@param \Psr\Http\Message\ResponseInterface $response @param bool|null $checkCallbackConfirmed @return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface @throws \chillerlan\OAuth\Core\ProviderException
entailment
protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ $parseURL = parse_url($url); if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){ throw new ProviderException('getSignature: i...
@param string $url @param array $params @param string $method @param string $accessTokenSecret @return string @throws \chillerlan\OAuth\Core\ProviderException
entailment
public function getAccessToken(string $token, string $verifier):AccessToken{ $request = $this->requestFactory ->createRequest('POST', Psr7\merge_query($this->accessTokenURL, ['oauth_verifier' => $verifier])) ->withHeader('Accept-Encoding', 'identity') ; $request = $this->getRequestAuthorization($request, $...
@param string $token @param string $verifier @return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface
entailment
public function getRequestAuthorization(RequestInterface $request, AccessToken $token):RequestInterface{ $uri = $request->getUri(); parse_str($uri->getQuery(), $query); $parameters = [ 'oauth_consumer_key' => $this->options->key, 'oauth_nonce' => $this->nonce(), 'oauth_signature_method' ...
@param \Psr\Http\Message\RequestInterface $request @param \chillerlan\OAuth\Core\AccessToken $token @return \Psr\Http\Message\RequestInterface
entailment
public function authorize( string $action, $object, array $source = null ) { if ($this->request()->user()->cant($action, $object)) { throw new RequestFailedAuthorization( new Error( $id = null, $link = new Link('http...
Ensure that a requested operation is authorized. If not, throw an exception. This requires a registered Policy. If no policy is defined, the framework will throw InvalidArgumentException. See also: https://laravel.com/docs/master/authorization http://jsonapi.org/format/#errors @param string $action Desired action; m...
entailment
public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin) { return $this->getAdminDatagridBuilder($admin, $datagrid instanceof Datagrid)->addFilter( $datagrid, $type, $fieldDescription, $a...
{@inheritdoc}
entailment