sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function setUserAccess($userLogin, $access, $idSites, array $optional = [])
{
return $this->_request('UsersManager.setUserAccess', [
'userLogin' => $userLogin,
'access' => $access,
'idSites' => $idSites,
], $optional);
} | Grant access to multiple sites
@param string $userLogin Username
@param string $access
@param array $idSites
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getTokenAuth($userLogin, $md5Password, array $optional = [])
{
return $this->_request('UsersManager.getTokenAuth', [
'userLogin' => $userLogin,
'md5Password' => md5($md5Password),
], $optional);
} | Get the token for a user
@param string $userLogin Username
@param string $md5Password Password in clear text
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function read($n)
{
$n = (int) $n;
$raw = substr($this->bytes, $this->position, $n);
$this->position += $n;
return $raw;
} | @param int $n
@return string | entailment |
public function forward($n)
{
$n = (int) $n;
if (($this->position + $n) > $this->getLength()) {
throw new \OutOfBoundsException(sprintf('No more bytes to read'));
}
$this->position += $n;
} | @param int $n
@throws \OutOfBoundsException | entailment |
public function setPosition($n)
{
$n = (int) $n;
if ($n > $this->getLength()) {
throw new \OutOfBoundsException(sprintf('Require position out of bound'));
}
$this->position = $n;
} | @param int $n
@throws \OutOfBoundsException | entailment |
public function rewind($n)
{
$n = (int) $n;
if ($n > $this->position) {
throw new \InvalidArgumentException(sprintf('You try to rewind %d characters, but current position is %d',
$n,
$this->position
));
}
$this->position -= $n;... | @param int $n
@throws \InvalidArgumentException | entailment |
public static function newInstance()
{
$config = self::create();
$config->username = 'null';
$config->password = 'null';
$config->credentials = ['null', 'null'];
$config->bindtoInterface = 'null';
$config->timeout = 5;
return $config;
} | @return Configuration
@deprecated Will be removed in 2.0. Use Configuration::create | entailment |
public function withCredentials($username, $password)
{
if (null === $username || null === $password) {
// No change if credentials or null
return $this;
}
$new = $this->setValue('username', $username)
->setValue('password', $password)
->setVa... | @param string $username
@param string $password
@return Configuration | entailment |
public function getSession($version, array $credentials)
{
$v = (int) $version;
if (!$this->supportsVersion($v)) {
throw new \InvalidArgumentException(sprintf('No session registered supporting Version %d', $v));
}
$class = $this->sessions[$v];
return new $class(... | @param int $version
@param array $credentials
@return SessionInterface | entailment |
public function getRequestOptions()
{
return [
\GuzzleHttp\RequestOptions::FORM_PARAMS => [
$this->options['form_fields'][0] => $this->options['username'],
$this->options['form_fields'][1] => $this->options['password'],
],
];
} | {@inheritdoc} | entailment |
public function get($key, $defaultValue = null)
{
if (!isset($this->keyToIndexMap[$key]) && 2 === func_num_args()) {
return $defaultValue;
}
return $this->value($key);
} | @param string $key
@param mixed $defaultValue
@return \GraphAware\Bolt\Result\Type\Node|\GraphAware\Bolt\Result\Type\Path|\GraphAware\Bolt\Result\Type\Relationship|mixed | entailment |
public function nodeValue($key)
{
if (!isset($this->keyToIndexMap[$key]) || !$this->values[$this->keyToIndexMap[$key]] instanceof Node) {
throw new \InvalidArgumentException(sprintf('value for %s is not of type %s', $key, 'NODE'));
}
return $this->value($key);
} | Returns the Node for value <code>$key</code>. Ease IDE integration.
@param $key
@return \GraphAware\Bolt\Result\Type\Node
@throws \InvalidArgumentException When the value is not null or instance of Node | entailment |
public function relationshipValue($key)
{
if (!isset($this->keyToIndexMap[$key]) || !$this->values[$this->keyToIndexMap[$key]] instanceof Relationship) {
throw new \InvalidArgumentException(sprintf('value for %s is not of type %s', $key, 'RELATIONSHIP'));
}
return $this->value($... | @param $key
@return \GraphAware\Bolt\Result\Type\Relationship
@throws \InvalidArgumentException When the value is not null or instance of Relationship | entailment |
public function pathValue($key)
{
if (!isset($this->keyToIndexMap[$key]) || !$this->values[$this->keyToIndexMap[$key]] instanceof Path) {
throw new \InvalidArgumentException(sprintf('value for %s is not of type %s', $key, 'PATH'));
}
return $this->value($key);
} | @param $key
@return \GraphAware\Bolt\Result\Type\Path
@throws \InvalidArgumentException When the value is not null or instance of Path | entailment |
protected function getResourceClass()
{
if (array_key_exists('class', $this->options)) {
if ($this->options['class'] === false) {
return $this->getName();
} elseif (is_string($this->options['class'])) {
return studly_case($this->options['class']);
... | only be used for authorization, not loading since there's no class to load through. | entailment |
protected function getResourceBase()
{
if (array_key_exists('through', $this->options)) {
if ($this->getParentResource()) {
if (array_key_exists('singleton', $this->options)) {
return $this->getResourceClass();
} elseif (array_key_exists('throu... | The object that methods (such as "find", "new" or "build") are called on.
If the 'through' option is passed it will go through an association on that instance.
If the 'shallow' option is passed it will use the getResourceClass() method if there's no parent
If the 'singleton' option is passed it won't use the associatio... | entailment |
protected function getCreateActions()
{
// We keep the 'new' option to match CanCan API
$optionNew = array_key_exists('new', $this->options) ? $this->options['new'] : [];
$optionCreate = array_key_exists('create', $this->options) ? $this->options['create'] : [];
$options = array_merg... | And the Rails 'create' action is named 'store' in Laravel. | entailment |
public function register()
{
$this->app->singleton('parameters', function ($app) {
return new Parameters;
});
// Find the default Controller class of the current Laravel application
$controllerClass = $this->app['config']->get(
'authority-controller.controlle... | Register the service provider.
@return void | entailment |
public function push($query, array $parameters = array(), $tag = null)
{
if (null === $query) {
throw new BoltInvalidArgumentException('Statement cannot be null');
}
$this->messages[] = new RunMessage($query, $parameters, $tag);
} | {@inheritdoc} | entailment |
public function run()
{
$pullAllMessage = new PullAllMessage();
$batch = [];
$resultCollection = new ResultCollection();
foreach ($this->messages as $message) {
$result = $this->session->run($message->getStatement(), $message->getParams(), $message->getTag());
... | {@inheritdoc} | entailment |
public function can($action, $resource, $resourceValue = null)
{
if (is_object($resource)) {
$resourceValue = $resource;
$resource = get_classname($resourceValue);
} elseif (is_array($resource)) {
// Nested resources can be passed through an associative array, thi... | Determine if current user can access the given action and resource
@return boolean | entailment |
public function addRule($allow, $actions, $resources, $condition = null)
{
$actions = (array) $actions;
$resources = (array) $resources;
$rules = [];
foreach ($actions as $action) {
foreach ($resources as $resource) {
$rule = new Rule($allow, $action, $res... | Define rule(s) for a given action(s) and resource(s)
@param boolean $allow True if privilege, false if restriction
@param string|array $actions Action(s) for the rule(s)
@param mixed $resources Resource(s) for the rule(s)
@param Closure|null $condition Optional condition for the rule
@return array | entailment |
public function addRules($allow, $actions, $resources, $condition = null)
{
return $this->addRule($allow, $actions, $resources, $condition);
} | alias of addRule() | entailment |
public function addAlias($name, $actions)
{
$actions = (array) $actions;
$this->addAliasAction($name, $actions);
parent::addAlias($name, $this->getExpandActions($actions));
} | Define new alias for an action
$this->$authority->addAlias('read', ['index', 'show']);
$this->$authority->addAlias('create', 'new');
$this->$authority->addAlias('update', 'edit');
This way one can use $params['action'] in the controller to determine the permission.
@param string $name Name of action
@param string|ar... | entailment |
public function getRulesFor($action, $resource)
{
$aliases = array_merge((array) $action, $this->getAliasesForAction($action));
return $this->rules->getRelevantRules($aliases, $resource);
} | Returns all rules relevant to the given action and resource
@return RuleRepository | entailment |
public function getExpandActions($actions)
{
$actions = (array) $actions;
return array_flatten(array_map(function ($action) use ($actions) {
return array_key_exists($action, $this->getAliasedActions()) ? [$action, $this->getExpandActions($this->getAliasedActions()[$action])] : $action;
... | rely on the actions to be expanded. | entailment |
public function getAliasesForAction($action)
{
$action = (array) $action;
$results = [];
foreach ($this->getAliasedActions() as $aliasedAction => $actions) {
if (array_intersect($action, $actions)) {
$results = array_merge($results, parent::getAliasesForAction($al... | This does the opposite kind of lookup as 'getExpandActions()'. | entailment |
public function read($n)
{
if (0 === $n) {
return '';
}
$remaining = ($n - $this->length) + $this->position;
while ($remaining > 0) {
//$this->io->wait();
if ($this->io->shouldEnableCrypto()) {
$new = $this->io->read($remaining);
... | @param int $n
@return string | entailment |
public static function driver($uri, ConfigInterface $config = null)
{
return new Driver(self::formatUri($uri), $config);
} | @param string $uri
@param BaseConfiguration|null $config
@return Driver | entailment |
public function handshake()
{
$packer = new Packer();
if (!$this->io->isConnected()) {
$this->io->reconnect();
}
$msg = '';
$msg .= chr(0x60).chr(0x60).chr(0xb0).chr(0x17);
foreach (array(1, 0, 0, 0) as $v) {
$msg .= $packer->packBigEndian($... | @return int
@throws HandshakeException | entailment |
public function isRelevant($action, $resource)
{
// Nested resources can be passed through a associative array, this way conditions which are
// dependent upon the association will work when using a class.
$resource = is_array($resource) ? head(array_keys($resource)) : $resource;
ret... | Determine if current rule is relevant based on an action and resource
@param string|array $action Action in question
@param string|mixed $resource Name of resource or instance of object
@return boolean | entailment |
public function matchesAction($action)
{
$action = (array) $action;
return $this->action === 'manage' || in_array($this->action, $action);
} | Determine if the instance's action matches the one passed in
@param string|array $action Action in question
@return boolean | entailment |
public function fillController($controller)
{
$router = app('router');
$controllerClass = get_classname($controller);
$paramsFilterPrefix = "router.filter: ";
$paramsFilterName = "controller.parameters.".$controllerClass;
if (! Event::hasListeners($paramsFilterPrefix.$params... | Fill the $params property of the given Controller
@param \Illuminate\Routing\Controller $controller | entailment |
public function only($keys = null)
{
$keys = is_array($keys) ? $keys : func_get_args();
return array_only($this->params, $keys);
} | Get a subset of the items from the parameters.
@param array $keys
@return array | entailment |
public function except($keys = null)
{
$keys = is_array($keys) ? $keys : func_get_args();
return array_except($this->params, $keys);
} | Get all of the input except for a specified array of items.
@param array $keys
@return array | entailment |
protected function specialInputKeys($inputKeys = [])
{
$inputKeys = $inputKeys ?: array_keys(request()->all());
return array_filter($inputKeys, function ($value) {
return is_string($value) ? starts_with($value, '_') : false;
});
} | Returns all inputs keys who starts with an underscore character (<code>_</code>).
For exmaple '_method' and '_token' inputs
@param array $inputKeys
@return array | entailment |
public function write($data)
{
//echo \GraphAware\Bolt\Misc\Helper::prettyHex($data) . PHP_EOL;
$this->assertConnected();
$written = 0;
$len = mb_strlen($data, 'ASCII');
while ($written < $len) {
$buf = fwrite($this->sock, $data);
if ($buf === false)... | {@inheritdoc} | entailment |
public function read($n)
{
if (null === $n) {
return $this->readAll();
}
$this->assertConnected();
$read = 0;
$data = '';
while ($read < $n) {
$buffer = fread($this->sock, ($n - $read));
//var_dump(\GraphAware\Bolt\Misc\Helper::pre... | {@inheritdoc} | entailment |
public function select($sec, $usec)
{
$r = array($this->sock);
$w = $e = null;
$result = stream_select($r, $w, $e, $sec, $usec);
return $result;
} | {@inheritdoc} | entailment |
public function connect()
{
$errstr = $errno = null;
$remote = sprintf(
'%s://%s:%s',
$this->protocol,
$this->host,
$this->port
);
$this->sock = stream_socket_client(
$remote,
$errno,
$errstr,
... | {@inheritdoc} | entailment |
public function rollback()
{
$this->assertNotClosed();
$this->assertStarted();
$this->session->run('ROLLBACK');
$this->closed = true;
$this->state = self::ROLLED_BACK;
$this->session->transaction = null;
} | {@inheritdoc} | entailment |
public function begin()
{
$this->assertNotStarted();
$this->session->run('BEGIN');
$this->state = self::OPENED;
} | {@inheritdoc} | entailment |
public function run(Statement $statement)
{
try {
return $this->session->run($statement->text(), $statement->parameters(), $statement->getTag());
} catch (MessageFailureException $e) {
$spl = explode('.', $e->getStatusCode());
if (self::$NO_ROLLBACK_STATUS_CODE !=... | {@inheritdoc} | entailment |
public function runMultiple(array $statements)
{
$pipeline = $this->session->createPipeline();
foreach ($statements as $statement) {
$pipeline->push($statement->text(), $statement->parameters(), $statement->getTag());
}
return $pipeline->run();
} | @param Statement[] $statements
@return \GraphAware\Common\Result\ResultCollection | entailment |
public function run($statement, array $parameters = array(), $tag = null)
{
if (null === $statement) {
//throw new BoltInvalidArgumentException("Statement cannot be null");
}
$messages = array(
new RunMessage($statement, $parameters),
);
$messages[] =... | {@inheritdoc} | entailment |
public function recv($statement, array $parameters = array(), $tag = null)
{
$runResponse = new Response();
$r = $this->unpacker->unpack();
$shouldThrow = false;
if ($r->isFailure()) {
try {
$runResponse->onFailure($r);
} catch (MessageFailureE... | @param string $statement
@param array $parameters
@param null|string $tag
@return CypherResult | entailment |
public function validate($schema_config, $data)
{
$this->schema_config = $schema_config;
if (isset($schema_config['prefix'])) {
$this->prefix = $schema_config['prefix'];
}
return $this->validateNode('root',
$schema_config['root'][$this->getFullName('type')],... | main function | entailment |
public function validateNode($name, $type, $node, $data)
{
$validator = $this->factory->getValidator($name, $type, $this);
return $validator->validate($name, $node, $data);
} | validate nodes | entailment |
public function request($verb, array $params = array())
{
if (! $this->url) {
throw new RuntimeException("Cannot perform request when URL not set. Use setUrl() method");
}
//Build the URL
$params = array_merge(array('verb' => $verb), $params);
$url = $this->url ... | Perform a request and return a OAI SimpleXML Document
@param string $verb Which OAI-PMH verb to use
@param array $params An array of key/value parameters
@return \SimpleXMLElement An XML document | entailment |
private function checkForOaipmhException(HttpException $httpException)
{
try {
if ($resp = $httpException->getBody()) {
$this->decodeResponse($resp); // Throw OaipmhException in case of an error
}
} catch (MalformedResponseException $e) {
// There ... | Check for OAI-PMH Exception from HTTP Exception
Converts a HttpException into an OAI-PMH exception if there is an
OAI-PMH Error Code.
@param HttpException $httpException | entailment |
protected function decodeResponse($resp)
{
//Setup a SimpleXML Document
try {
$xml = @new \SimpleXMLElement($resp);
} catch (\Exception $e) {
throw new MalformedResponseException(sprintf("Could not decode XML Response: %s", $e->getMessage()));
}
//If ... | Decode the response into XML
@param string $resp The response body from a HTTP request
@return \SimpleXMLElement An XML document | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$formatter = $this->getHelper('formatter');
$call = $input->getOption('call');
if ($call == 'basic' || $call == 'all') {
$data = $this->example->getBasicInformation();
$output->writeln("Basi... | {@inheritdoc} | entailment |
public static function formatDate(\DateTimeInterface $dateTime, $format)
{
$phpFormats = array(
self::DATE => "Y-m-d",
self::DATE_AND_TIME => 'Y-m-d\TH:i:s\Z',
);
$phpFormat = $phpFormats[$format];
return $dateTime->format($phpFormat);
} | Format DateTime string based on granularity
@param \DateTimeInterface $dateTime
@param string $format Either self::DATE or self::DATE_AND_TIME
@return string | entailment |
public function createContext(Registry $registry)
{
// List of schemas can evolve, but we don't want to generate new schema dynamically added, so we "clone" the array
// to have a fixed list of schemas
$schemas = array_values($registry->getSchemas());
/** @var Schema $schema */
... | Return a list of class guessed.
@param $registry
@return Context | entailment |
public function generate($registry)
{
$context = $this->createContext($registry);
$prettyPrinter = new Standard();
$modelFiles = [];
$normalizerFiles = [];
foreach ($registry->getSchemas() as $schema) {
if (!file_exists(($schema->getDirectory().DIRECTORY_SEPARAT... | Generate code.
@param Registry $registry
@return array | entailment |
public function getBasicInformation()
{
$data = array();
$xml = $this->endpoint->identify();
$data['Base URL'] = $xml->Identify->baseURL;
$data['Repository Name'] = $xml->Identify->repositoryName;
$data['Administrator'] = $xml->Identify->adminEmail;
return $data;
... | Retrieves the basic information from the endpoint.
@return array An array of properties. | entailment |
public function getAvailableMetadataFormats()
{
$data = array();
// List identifiers
if (is_null($this->metadataIterator)) {
$this->metadataIterator = $this->endpoint->listMetadataFormats();
}
$data = array(
'header' => array('Metadata Prefix', 'Sche... | Retrieve a list of available metadata format schemas from the endpoint.
@return array An array containing data in a tabular format. | entailment |
public function getRecords()
{
$data = array();
// List identifiers
if (empty($this->metadataIterator)) {
$this->metadataIterator = $this->endpoint->listMetadataFormats();
} else {
$this->metadataIterator->rewind(); // rewind the iterator
}
/... | Get a list of the first 10 records from the first available metadata
format.
@return array An array containing data in a tabular format. | entailment |
public function tryAnException()
{
try {
$iterator = $this->endpoint->listRecords('foobardoesnotexist');
$iterator->current();
} catch (\Phpoaipmh\Exception\OaipmhException $e) {
throw $e;
}
} | Throws a deliberate exception for a non existing schema.
@return void | entailment |
public function generate($schema, $className, Context $context)
{
$files = [];
$classes = [];
foreach ($schema->getClasses() as $class) {
$methods = [];
$modelFqdn = $schema->getNamespace()."\\Model\\".$class->getName();
$methods[] = $this->createSupp... | Generate a set of files given a schema
@param Schema $schema Schema to generate from
@param string $className Class to generate
@param Context $context Context for generation
@return File[] | entailment |
protected function createSupportsNormalizationMethod($modelFqdn)
{
return new Stmt\ClassMethod('supportsNormalization', [
'type' => Stmt\Class_::MODIFIER_PUBLIC,
'params' => [
new Param('data'),
new Param('format', new Expr\ConstFetch(new Name('null'))... | Create method to check if denormalization is supported.
@param string $modelFqdn Fully Qualified name of the model class denormalized
@return Stmt\ClassMethod | entailment |
protected function createNormalizeMethod($modelFqdn, Context $context, $properties)
{
$context->refreshScope();
$dataVariable = new Expr\Variable('data');
$statements = [
new Expr\Assign($dataVariable, new Expr\New_(new Name('\\stdClass'))),
];
/** @var Property ... | Create the normalization method.
@param $modelFqdn
@param Context $context
@param $properties
@return Stmt\ClassMethod | entailment |
public function guessClass($object, $name, $reference, Registry $registry)
{
if (!$registry->hasClass($reference)) {
$registry->getSchema($reference)->addClass($reference, new ClassGuess($object, $reference, $this->naming->getClassName($name)));
}
foreach ($object->getProperties... | {@inheritdoc} | entailment |
public function guessProperties($object, $name, $reference, Registry $registry)
{
$properties = [];
foreach ($object->getProperties() as $key => $property) {
$propertyObj = $property;
if ($propertyObj instanceof Reference) {
$propertyObj = $this->resolve($pr... | {@inheritdoc} | entailment |
public function guessType($object, $name, $reference, Registry $registry)
{
$discriminants = [];
$required = $object->getRequired() ?: [];
foreach ($object->getProperties() as $key => $property) {
if (!in_array($key, $required)) {
continue;
}
... | {@inheritdoc} | entailment |
public function request($url)
{
try {
$resp = $this->guzzle->get($url);
return (string) $resp->getBody();
} catch (RequestException $e) {
$response = $e->getResponse();
throw new HttpException($response ? $response->getBody() : null, $e->getMessage(), ... | Do the request with GuzzleAdapter
@param string $url
@return string
@throws HttpException | entailment |
protected function createPath(Filesystem $filesystem, $type)
{
$customPath = $this->option('path');
$defaultPath = config("vue-generators.paths.{$type}s");
$path = $customPath !== null ? $customPath : $defaultPath;
$this->buildPathFromArray($path, $filesystem);
return $pa... | Create path for file.
@param Filesystem $filesystem
@param string $type File type.
@return string | entailment |
public function supportObject($object)
{
if (!($object instanceof JsonSchema)) {
return false;
}
if ($object->getType() !== 'object') {
return false;
}
if ($object->getAdditionalProperties() !== true && !is_object($object->getAdditionalProperties()))... | {@inheritDoc} | entailment |
public function guessType($object, $name, $reference, Registry $registry)
{
if ($object->getAdditionalProperties() === true) {
return new MapType($object, new Type($object, 'mixed'));
}
return new MapType($object, $this->chainGuesser->guessType($object->getAdditionalProperties()... | {@inheritDoc} | entailment |
public function setCurlOpts(array $opts, $merge = true)
{
$this->curlOpts = ($merge)
? array_replace($this->curlOpts, $opts)
: $opts;
} | Set cURL Options at runtime
Sets cURL options. If $merge is true, then merges desired params with existing.
If $merge is false, then clobbers the existing cURL options
@param array $opts
@param bool $merge | entailment |
public function request($url)
{
$curlOpts = array_replace($this->curlOpts, [CURLOPT_URL => $url]);
$ch = curl_init();
foreach ($curlOpts as $opt => $optVal) {
curl_setopt($ch, $opt, $optVal);
}
$resp = curl_exec($ch);
$info = (object) curl_getinfo($ch);
... | Do CURL Request
@param string $url The full URL
@return string The response body | entailment |
public function guessType($object, $name, $reference, Registry $registry)
{
$items = $object->getItems();
if ($items === null) {
return new ArrayType($object, new Type($object, 'mixed'));
}
if (!is_array($items)) {
return new ArrayType($object, $this->chainG... | {@inheritDoc} | entailment |
private function xmlToArray(\SimpleXMLIterator $sxi)
{
$a = array();
for ($sxi->rewind(); $sxi->valid(); $sxi->next()) {
$t = array();
$current = $sxi->current();
$attributes = $current->attributes();
$name = isset($attributes->_key) ? strval($attribu... | /*
Private
XML parser | entailment |
public function guessClass($object, $name, $reference, Registry $registry)
{
/**
* @var string $key
* @var JsonSchema $definition
*/
foreach ($object->getDefinitions() as $key => $definition) {
$this->chainGuesser->guessClass($definition, $key, $reference .... | {@inheritDoc} | entailment |
public function handle()
{
$filesystem = new Filesystem();
$name = $this->argument('name').'.vue';
$path = $this->createPath($filesystem, 'component');
$fullPath = resource_path("{$path}/{$name}");
$this->checkFileExists($filesystem, $fullPath, $name);
$stub = $t... | Execute the console command. | entailment |
protected function getStub(Filesystem $filesystem)
{
$fileName = $this->option('empty') ? 'EmptyComponent' : 'Component';
return $filesystem->get(__DIR__.'/../Stubs/'.$fileName.'.vue');
} | Get and return stub.
@param Filesystem $filesystem
@return string | entailment |
public function nextItem()
{
if ($this->batch === null) {
$this->batch = [];
}
//If no items in batch, and we have a resumptionToken or need to make initial request...
if (count($this->batch) == 0 && ($this->resumptionToken or $this->numRequests == 0)) {
... | Get the next item
Return an item from the currently-retrieved batch, get next batch and
return first record from it, or return false if no more records
@return \SimpleXMLElement|bool | entailment |
private function retrieveBatch()
{
// Set OAI-PMH parameters for request
// If resumptionToken, then we ignore params and just use that
$params = ($this->resumptionToken)
? ['resumptionToken' => $this->resumptionToken]
: $this->params;
// Node name and verb
... | Do a request to get the next batch of items
@return int The number of items in the batch after the retrieve | entailment |
private function getItemNodeName()
{
$mappings = array(
'ListMetadataFormats' => 'metadataFormat',
'ListSets' => 'set',
'ListIdentifiers' => 'header',
'ListRecords' => 'record'
);
return (isset($mappings[$this->verb])) ?... | Get Item Node Name
Map the item node name based on the verb
@return string|boolean The element name for the mapping, or false if unmapped | entailment |
public function reset()
{
$this->numRequests = 0;
$this->numProcessed = 0;
$this->currItem = null;
$this->resumptionToken = null;
$this->totalRecordsInCollection = null;
$this->expireDate = null;
$this->batch = [];
... | Reset the request state | entailment |
protected function registerCommands()
{
$this->app->singleton('command.vueg.component', function ($app) {
return $app[MakeComponent::class];
});
$this->app->singleton('command.vueg.mixin', function ($app) {
return $app[MakeMixin::class];
});
$this->c... | Register Artisan commands. | entailment |
public function execute(InputInterface $input, OutputInterface $output)
{
$options = [];
$configFile = null;
if (!$input->hasOption('config-file') && file_exists('.jane')) {
$configFile = '.jane';
} elseif($input->hasOption('config-file') && null !== $input->getOption('... | {@inheritdoc} | entailment |
public function guessClass($object, $name, $reference, Registry $registry)
{
$hasSubObject = false;
foreach ($object->getAllOf() as $allOf) {
if ($this->resolve($allOf, $this->getSchemaClass())->getType() === 'object') {
$hasSubObject = true;
break;
... | {@inheritdoc} | entailment |
protected function createProperty($name, Type $type, $namespace, $default = null)
{
$propertyName = $this->getNaming()->getPropertyName($name);
$property = new Stmt\PropertyProperty($propertyName);
if ($default !== null) {
$property->default = new Expr\ConstFetch(new Name($d... | Return a property stmt
@param string $name
@param Type $type
@param string|null $default
@return Stmt\Property | entailment |
public function getTypeHint($namespace)
{
// We have exactly two types: one null and an object
if (count($this->types) === 2) {
list($type1, $type2) = $this->types;
if ($this->isOptionalObjectType($type1, $type2)) {
return $type2->getTypeHint($namespace);
... | {@inheritdoc} | entailment |
public function createDenormalizationStatement(Context $context, Expr $input)
{
$output = new Expr\Variable($context->getUniqueVariableName('value'));
$statements = [
new Expr\Assign($output, $input)
];
foreach ($this->getTypes() as $type) {
list($typeSta... | {@inheritdoc} | entailment |
protected function buildPathFromArray($path, Filesystem $filesystem = null)
{
$pathArray = collect(explode('/', $path))->prepend('resources');
if (is_null($filesystem)) {
$filesystem = new Filesystem();
}
$base = base_path();
foreach ($pathArray as $path) {
... | Build directory tree from array of paths.
@param string $path
@param Filesystem|null $filesystem | entailment |
protected function createSupportsDenormalizationMethod($modelFqdn)
{
return new Stmt\ClassMethod('supportsDenormalization', [
'type' => Stmt\Class_::MODIFIER_PUBLIC,
'params' => [
new Param('data'),
new Param('type'),
new Param('format'... | Create method to check if denormalization is supported.
@param string $modelFqdn Fully Qualified name of the model class denormalized
@return Stmt\ClassMethod | entailment |
protected function createDenormalizeMethod($modelFqdn, Context $context, $properties)
{
$context->refreshScope();
$objectVariable = new Expr\Variable('object');
$assignStatement = new Expr\Assign($objectVariable, new Expr\New_(new Name('\\'.$modelFqdn)));
$statements = [$assignStatem... | Create the denormalization method.
@param $modelFqdn
@param Context $context
@param $properties
@return Stmt\ClassMethod | entailment |
protected function createModel($name, $properties, $methods)
{
return new Stmt\Class_(
new Name($this->getNaming()->getClassName($name)),
[
'stmts' => array_merge($properties, $methods)
]
);
} | Return a model class
@param string $name
@param Node[] $properties
@param Node[] $methods
@return Stmt\Class_ | entailment |
public function createConditionStatement(Expr $input)
{
return new Expr\FuncCall(
new Name($this->conditionMapping[$this->name]),
[
new Arg($input)
]
);
} | Create the condition Statement
@param Expr $input
@return Expr | entailment |
public function createNormalizationConditionStatement(Expr $input)
{
return new Expr\FuncCall(
new Name($this->normalizationConditionMapping[$this->name]),
[
new Arg($input)
]
);
} | Create the condition Statement
@param Expr $input
@return Expr | entailment |
public function avg($key = null)
{
if ($count = $this->count()) {
return $this->sum($key) / $count;
}
} | Get the average value of a given key.
@param string|null $key
@return mixed | entailment |
public function contains($key, $value = null): bool
{
if (func_num_args() == 2) {
return $this->contains(function ($k, $item) use ($key, $value) {
return ArrayHelper::getValue($item, $key) == $value;
});
}
if ($this->useAsCallable($key)) {
... | Determine if an item exists in the collection.
@param mixed $key
@param mixed $value
@return bool | entailment |
public function where($key, $value, $strict = true)
{
return $this->filter(function ($item) use ($key, $value, $strict) {
return $strict ? ArrayHelper::getValue($item, $key) === $value
: ArrayHelper::getValue($item, $key) == $value;
});
} | Filter items by the given key value pair.
@param string $key
@param mixed $value
@param bool $strict
@return static | entailment |
public function whereIn($key, array $values, $strict = true)
{
return $this->filter(function ($item) use ($key, $values, $strict) {
return in_array(ArrayHelper::getValue($item, $key), $values, $strict);
});
} | Filter items by the given key value pair.
@param string $key
@param array $values
@param bool $strict
@return static | entailment |
public function implode($value, $glue = ', ')
{
$first = $this->first();
if (is_array($first) || is_object($first)) {
return implode($glue, $this->pluck($value)->all());
}
return implode($value, $this->items);
} | Concatenate values of a given key as a string.
@param string $value
@param string $glue
@return string | entailment |
public function pluck($value, $key = null)
{
return new static(ArrayHelper::pluck($this->items, $value, $key));
} | Get the values of a given key.
@param string $value
@param string|null $key
@return static | entailment |
public function max($key = null)
{
return $this->reduce(function ($result, $item) use ($key) {
$value = ArrayHelper::getValue($item, $key);
return is_null($result) || $value > $result ? $value : $result;
});
} | Get the max value of a given key.
@param string|null $key
@return mixed | entailment |
public function forPage(int $page, int $perPage)
{
return $this->slice(($page - 1) * $perPage, $perPage);
} | "Paginate" the collection by slicing it into a smaller collection.
@param int $page
@param int $perPage
@return static | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.