_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q260100 | IPhoneImageDocument.getLongitude | test | public function getLongitude()
{
if (isset($this->exif)) {
return (float)$this->getGps($this->exif['GPSLongitude'], $this->exif['GPSLongitudeRef']);
} else {
return null;
}
} | php | {
"resource": ""
} |
q260101 | RESTResponse.getBodyType | test | public function getBodyType()
{
$result = '';
if (json_decode($this->body)) {
$result = 'json';
} else if (substr(trim($this->body), 0, 1) === '<') {
$result = 'xml';
} else {
$result = 'other';
}
return $result;
} | php | {
"resource": ""
} |
q260102 | RESTResponse.getErrorMessage | test | public function getErrorMessage()
{
$result = '';
switch ($this->getBodyType())
{
case 'json':
$obj = json_decode($this->body);
$statusCode = $obj->errorResponse->statusCode;
$status = $obj->errorResponse->status;
$message = $obj->errorResponse->message;
$result = 'Error ' . $statusCode . ': ' . $status . ' - ' . $message;
break;
case 'xml':
$dom = new \DOMDocument($this->body);
$dom->loadXML($this->body);
// $statusCode = $dom->getElementsByTagNameNS('http://marklogic.com/rest-api', 'status-code')->item(0)->nodeValue;
// $status = $dom->getElementsByTagNameNS('http://marklogic.com/rest-api', 'status')->item(0)->nodeValue;
// $message = $dom->getElementsByTagNameNS('http://marklogic.com/rest-api', 'message')->item(0)->nodeValue;
// $result = 'Error ' . $statusCode . ': ' . $status . ' - ' . $message;
// @todo XML won't necessarily be http://marklogic.com/rest-api format
// For now, just return body of response
$result = 'Error: ' . $this->body;
break;
default:
$result = 'Error: ' . $this->body;
}
return $result;
} | php | {
"resource": ""
} |
q260103 | RESTRequest.getUrlStr | test | public function getUrlStr()
{
$str = (!empty($this->resource)) ? $this->resource : '';
/* x-www-form-encoded posts encodes query params in the body */
if (!$this->isWWWFormURLEncodedPost()) {
$str .= (!empty($this->params)) ? ('?' . $this->buildQuery()) : '';
}
return $str;
} | php | {
"resource": ""
} |
q260104 | RESTAPI.create | test | public function create($client = null)
{
if ($this->exists()) {
$this->logger->debug(
'A REST API named "' . $this->name . '" already exists'
);
return $this;
}
$this->client = $client ?: $this->client;
$params = array();
$headers = array('Content-type' => 'application/json');
$body = '
{
"rest-api": {
"name": "' . $this->name . '",
"database": "' . $this->db . '",
"modules-database": "' . $this->db . '-modules",
"port": "' . $this->port . '",
"forests-per-host": 1,
"error-format": "json"
}
}
';
$request = new RESTRequest('POST', 'rest-apis', $params, $body, $headers);
$this->logger->debug(
"Setting up REST API: " . $this->name .
' (' . $this->db . ') port ' . $this->port
);
$this->client->send($request); // Set up REST API
return $this;
} | php | {
"resource": ""
} |
q260105 | RESTAPI.delete | test | public function delete($client = null)
{
$this->client = $client ?: $this->client;
// Delete content and modules as well
$params = array('include' => array('content', 'modules'));
$body = null;
$headers = array();
$request = new RESTRequest(
'DELETE', 'rest-apis/' . $this->name, $params, $body, $headers
);
$this->client->send($request);
// Wait for server reboot
$requestWait = new RESTRequest('GET', 'rest-apis');
$this->waitUntilSuccess($requestWait, 3, 10);
} | php | {
"resource": ""
} |
q260106 | RESTAPI.waitUntilSuccess | test | protected function waitUntilSuccess($request, $secs, $limit)
{
sleep($secs);
$limit--;
try {
$response = $this->client->send($request);
} catch(\Exception $e) {
if ($limit > 0) {
$this->waitUntilSuccess($request, $secs, $limit);
} else {
throw new Exception('waitUntilSuccess() timed out');
}
}
return;
} | php | {
"resource": ""
} |
q260107 | RESTAPI.exists | test | public function exists()
{
try {
$params = array();
$body = null;
$headers = array();
$request = new RESTRequest(
'GET', 'rest-apis/' . $this->name, $params, $body, $headers
);
$response = $this->client->send($request);
} catch(\Exception $e) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q260108 | Term.getAsElem | test | public function getAsElem($dom)
{
$termElem = $dom->createElement('term');
$emptyElem = $dom->createElement('empty');
$emptyElem->setAttribute('apply', $this->empty);
$termElem->appendChild($emptyElem);
if (!empty($this->termOptions)) {
foreach($this->termOptions as $opt) {
$termOptElem = $dom->createElement('term-option');
$termOptElem->nodeValue = $opt;
$termElem->appendChild($termOptElem);
}
}
if (!empty($this->default)) {
$constraint = $this->default->getAsElem($dom);
/* pluck out child nodes of the <constraint/> */
if ($constraint->hasChildNodes()) {
$defElem = $dom->createElement('default');
foreach ($constraint->childNodes as $child) {
if ($child->nodeType == XML_ELEMENT_NODE) {
$defElem->appendChild($child);
}
}
$termElem->appendChild($defElem);
}
}
/* <term>
<empty apply="no-results" />
<term-option>diacritic-insensitive</term-option>
<term-option>unwildcarded</term-option>
<default>....</default>
</term> */
return $termElem;
} | php | {
"resource": ""
} |
q260109 | AbstractConstraint.addTermOptions | test | protected function addTermOptions($dom, $elem)
{
if (!empty($this->termOptions)) {
foreach ($this->termOptions as $opt) {
$termElem = $dom->createElement('term-option');
$termElem->nodeValue = $opt;
$elem->appendChild($termElem);
}
}
return $elem;
} | php | {
"resource": ""
} |
q260110 | AbstractConstraint.addFacetOptions | test | protected function addFacetOptions($dom, $elem)
{
if (!empty($this->facetOptions)) {
foreach ($this->facetOptions as $opt) {
$facetElem = $dom->createElement('facet-option');
$facetElem->nodeValue = $opt;
$elem->appendChild($facetElem);
}
}
return $elem;
} | php | {
"resource": ""
} |
q260111 | AbstractConstraint.addFragmentScope | test | protected function addFragmentScope($dom, $elem)
{
if (!empty($this->fragmentScope)) {
$fragScopeElem = $dom->createElement('fragment-scope');
$fragScopeElem->nodeValue = $this->fragmentScope;
$elem->appendChild($fragScopeElem);
}
return $elem;
} | php | {
"resource": ""
} |
q260112 | ImageDocument.setContentFile | test | public function setContentFile($file)
{
$type = $this->getFileMimeType($file);
// Check for $type === '' to address MIME check not working on XAMPP Windows
if ($type === 'image/jpeg' || $type === 'image/tiff' || $type === '') {
if (function_exists('exif_read_data')) {
$this->exif = exif_read_data((string)$file);
}
}
parent::setContentFile((string)$file);
} | php | {
"resource": ""
} |
q260113 | SearchResults.getResultByURI | test | public function getResultByURI($uri)
{
$res = null;
foreach ($this->results as $result) {
if ($result->getURI() === $uri) {
$res = $result;
}
}
return $res;
} | php | {
"resource": ""
} |
q260114 | SearchResults.getResultByIndex | test | public function getResultByIndex($index)
{
$res = null;
foreach ($this->results as $result) {
if ($result->getIndex() == $index) {
$res = $result;
}
}
return $res;
} | php | {
"resource": ""
} |
q260115 | SearchResults.getFacet | test | public function getFacet($name)
{
$result = null;
foreach ($this->facets as $facet) {
if ($facet->getName() === $name) {
$result = $facet;
}
}
return $result;
} | php | {
"resource": ""
} |
q260116 | Extracts.addConstraints | test | public function addConstraints($constraints) {
if (is_array($constraints)) {
$this->constraints = array_merge($this->constraints, $constraints);
} else {
$this->constraints[] = (string)$constraints;
}
} | php | {
"resource": ""
} |
q260117 | Extracts.getExtractsAsElem | test | public function getExtractsAsElem($dom) {
$extractsElem = $dom->createElement('extract-metadata');
// constraints
foreach ($this->constraints as $constraint) {
$constraintValElem = $dom->createElement('constraint-value');
$constraintValElem->setAttribute('ref', $constraint);
$extractsElem->appendChild($constraintValElem);
}
// qnames
foreach ($this->qnames as $qname) {
$qnameElem = $dom->createElement('qname');
$qnameElem->setAttribute('elem-name', $qname->getElement());
$qnameElem->setAttribute('elem-ns', $qname->getNs());
if($qname->getAttribute() !== '') {
$qnameElem->setAttribute('attr-name', $qname->getAttribute());
$qnameElem->setAttribute('attr-ns', $qname->getAttributeNs());
}
$extractsElem->appendChild($qnameElem);
}
return $extractsElem;
} | php | {
"resource": ""
} |
q260118 | TransformResults.addPreferredElements | test | public function addPreferredElements($elements)
{
if (is_array($elements)) {
$this->preferredElements = array_merge($this->preferredElements, $elements);
} else {
$this->preferredElements[] = $elements;
}
} | php | {
"resource": ""
} |
q260119 | TransformResults.getTransformResultsAsElem | test | public function getTransformResultsAsElem($dom)
{
$transElem = $dom->createElement('transform-results');
$transElem->setAttribute('apply', $this->apply);
$prefElem = $dom->createElement('preferred-elements');
// preferred elements
foreach ($this->preferredElements as $elem) {
$element = $dom->createElement('element');
$element->setAttribute('name', $elem->getElement());
$element->setAttribute('ns', $elem->getElementNs());
$prefElem->appendChild($element);
}
$transElem->appendChild($prefElem);
return $transElem;
} | php | {
"resource": ""
} |
q260120 | Metadata.addCollections | test | public function addCollections($collections)
{
if (is_array($collections)) {
$this->collections = array_merge($this->collections, $collections);
} else {
$this->collections[] = (string)$collections;
}
return $this;
} | php | {
"resource": ""
} |
q260121 | Metadata.deleteCollections | test | public function deleteCollections($collections)
{
if (is_array($collections)) {
foreach($collections as $coll) {
$pos = array_search($coll, $this->collections);
if($pos !== FALSE) {
array_splice($this->collections, $pos, 1);
}
}
} else {
$pos = array_search($collections, $this->collections);
if($pos !== FALSE) {
array_splice($this->collections, $pos, 1);
}
}
return $this;
} | php | {
"resource": ""
} |
q260122 | Metadata.addPermissions | test | public function addPermissions($permissions)
{
if (is_array($permissions)) {
foreach($permissions as $perm) {
$this->permissions[$perm->getRoleName()] = $perm;
}
} else {
$this->permissions[$permissions->getRoleName()] = $permissions;
}
return $this;
} | php | {
"resource": ""
} |
q260123 | Metadata.deletePermissions | test | public function deletePermissions($roleNames)
{
if (is_array($roleNames)) {
foreach($roleNames as $name) {
unset($this->permissions[$name]);
}
} else {
unset($this->permissions[$roleNames]);
}
return $this;
} | php | {
"resource": ""
} |
q260124 | Metadata.deleteProperties | test | public function deleteProperties($properties)
{
if (is_array($properties)) {
foreach($properties as $prop) {
unset($this->properties[$prop]);
}
} else {
unset($this->properties[$properties]);
}
return $this;
} | php | {
"resource": ""
} |
q260125 | Metadata.getAsXML | test | public function getAsXML()
{
// root
$dom = new \DOMDocument();
$root = $dom->createElement('metadata');
$root->setAttribute('xmlns', 'http://marklogic.com/rest-api');
$dom->appendChild($root);
// collections
$collElem = $dom->createElement('collections');
foreach($this->collections as $v) {
$collElem->appendChild($dom->createElement('collection', $v));
}
$root->appendChild($collElem);
// permissions
$permElem = $dom->createElement('permissions');
foreach($this->permissions as $rn => $p) {
$pElem = $dom->createElement('permission');
$pElem->appendChild($dom->createElement('role-name', $p->getRoleName()));
foreach($p->getCapabilities() as $c) {
$pElem->appendChild($dom->createElement('capability', $c));
}
$permElem->appendChild($pElem);
}
$root->appendChild($permElem);
// properties
$propElem = $dom->createElement('prop:properties');
$propElem->setAttribute('xmlns:prop', 'http://marklogic.com/xdmp/property');
foreach($this->properties as $k => $v) {
$pElem = $dom->createElement($k, $v);
$pElem->setAttribute('xmlns', '');
$propElem->appendChild($pElem);
}
$root->appendChild($propElem);
// quality
if(!empty($this->quality)) {
$qElem = $dom->createElement('quality', $this->quality);
$root->appendChild($qElem);
}
return $dom->saveXML();
} | php | {
"resource": ""
} |
q260126 | Metadata.loadFromXML | test | public function loadFromXML($xml)
{
// root
$dom = new \DOMDocument();
$dom->loadXML($xml);
// collections
$collElems = $dom->getElementsByTagName('collections')->item(0)->getElementsByTagName('collection');
foreach ($collElems as $elem) {
if($elem->nodeType === XML_ELEMENT_NODE) {
$this->addCollections($elem->nodeValue);
}
}
// permissions
$permElems = $dom->getElementsByTagName('permissions')->item(0)->getElementsByTagName('permission');
$permissions = array();
foreach($permElems as $elem) {
if($elem->nodeType === XML_ELEMENT_NODE) {
$role_name = $elem->getElementsByTagName('role-name')->item(0)->nodeValue;
$capElems = $elem->getElementsByTagName('capability');
$capabilities = array();
foreach($capElems as $c) {
$capabilities[] = $c->nodeValue;
}
$permission = new Permission($role_name, $capabilities);
$permissions[] = $permission;
}
}
$this->addPermissions($permissions);
// properties
$propElems = $dom->getElementsByTagName('properties')->item(0)->childNodes;
foreach($propElems as $elem) {
if($elem->nodeType === XML_ELEMENT_NODE) {
$this->addProperties(array($elem->tagName => $elem->nodeValue));
}
}
// quality
$qElem = $dom->getElementsByTagName('quality')->item(0);
$this->setQuality($qElem->nodeValue);
return $this;
} | php | {
"resource": ""
} |
q260127 | ProxyManager.enable | test | public function enable($rootNamespace = self::ROOT_NAMESPACE_GLOBAL)
{
// If XStatic is already enabled, this is a no-op
if ($this->aliasLoader->isRegistered()) {
return true;
}
// Register the loader to handle aliases and link the proxies to the container
if ($this->aliasLoader->register($rootNamespace)) {
StaticProxy::setContainer($this->container);
}
return $this->aliasLoader->isRegistered();
} | php | {
"resource": ""
} |
q260128 | ProxyManager.setContainer | test | public function setContainer(ContainerInterface $container)
{
$this->container = $container;
StaticProxy::setContainer($this->container);
return $this;
} | php | {
"resource": ""
} |
q260129 | FixtureCheckShell._compareConstraints | test | protected function _compareConstraints(array $fixtureConstraints, array $liveConstraints, $fixtureTable) {
if (!$fixtureConstraints && !$liveConstraints) {
return;
}
$fixtureConstraints = $this->normalizeConstraints($fixtureConstraints);
$liveConstraints = $this->normalizeConstraints($liveConstraints);
if ($fixtureConstraints === $liveConstraints) {
return;
}
$errors = [];
foreach ($liveConstraints as $key => $liveConstraint) {
if (!isset($fixtureConstraints[$key])) {
$errors[] = ' * ' . sprintf('Constraint %s is missing in fixture, but in live DB.', $this->_buildKey($key, $liveConstraint));
continue;
}
if ($liveConstraint === $fixtureConstraints[$key]) {
unset($fixtureConstraints[$key]);
continue;
}
$errors[] = ' * ' . sprintf('Live DB constraint %s is not matching fixture one: %s.', $this->_buildKey($key, $liveConstraint), json_encode($fixtureConstraints[$key], true));
unset($fixtureConstraints[$key]);
}
foreach ($fixtureConstraints as $key => $fixtureConstraint) {
$errors[] = ' * ' . sprintf('Constraint %s is in fixture, but not live DB.', $this->_buildKey($key, $fixtureConstraint));
}
if (!$errors) {
return;
}
$this->warn('The following constraints mismatch:');
$this->out($errors);
$this->_issuesFound[] = $fixtureTable;
$this->out($this->nl(0));
} | php | {
"resource": ""
} |
q260130 | FixtureCheckShell._compareIndexes | test | protected function _compareIndexes(array $fixtureIndexes, array $liveIndexes, $fixtureTable) {
if (!$fixtureIndexes && !$liveIndexes) {
return;
}
if ($fixtureIndexes === $liveIndexes) {
return;
}
$errors = [];
foreach ($liveIndexes as $key => $liveIndex) {
if (!isset($fixtureIndexes[$key])) {
$errors[] = ' * ' . sprintf('Index %s is missing in fixture', $this->_buildKey($key, $liveIndex));
continue;
}
if ($liveIndex === $fixtureIndexes[$key]) {
unset($fixtureIndexes[$key]);
continue;
}
$errors[] = ' * ' . sprintf('Live DB index %s is not matching fixture one.', $this->_buildKey($key, $liveIndex));
unset($fixtureIndexes[$key]);
}
foreach ($fixtureIndexes as $key => $fixtureIndex) {
$errors[] = ' * ' . sprintf('Index %s is in fixture, but not live DB.', $this->_buildKey($key, $fixtureIndex));
}
if (!$errors) {
return;
}
$this->warn('The following indexes mismatch:');
$this->out($errors);
$this->_issuesFound[] = $fixtureTable;
$this->out($this->nl(0));
} | php | {
"resource": ""
} |
q260131 | FixtureCheckShell._doCompareFieldPresence | test | protected function _doCompareFieldPresence($one, $two, $fixtureClass, $message, $fixtureTable) {
$diff = array_diff_key($one, $two);
if (!empty($diff)) {
$this->warn(sprintf($message, $fixtureClass));
foreach ($diff as $missingField => $type) {
$this->out(' * ' . $missingField);
}
$this->out($this->nl(0));
$this->_issuesFound[] = $fixtureTable;
}
} | php | {
"resource": ""
} |
q260132 | FixtureCheckShell._getFixtureFiles | test | protected function _getFixtureFiles() {
$fixtureFolder = TESTS . 'Fixture' . DS;
$plugin = $this->param('plugin');
if ($plugin) {
$fixtureFolder = Plugin::path($plugin) . 'tests' . DS . 'Fixture' . DS;
}
$folder = new Folder($fixtureFolder);
$content = $folder->read();
$fixtures = [];
foreach ($content[1] as $file) {
$fixture = substr($file, 0, -4);
if (substr($fixture, -7) !== 'Fixture') {
continue;
}
$fixtures[] = $fixture;
}
return $fixtures;
} | php | {
"resource": ""
} |
q260133 | FixtureCheckShell._compareFieldPresence | test | protected function _compareFieldPresence($fixtureFields, $liveFields, $fixtureClass, $fixtureTable) {
$message = '%s has fields that are not in the live DB:';
$this->_doCompareFieldPresence($fixtureFields, $liveFields, $fixtureClass, $message, $fixtureTable);
$message = 'Live DB has fields that are not in %s';
$this->_doCompareFieldPresence($liveFields, $fixtureFields, $fixtureClass, $message, $fixtureTable);
} | php | {
"resource": ""
} |
q260134 | BootstrapBase.form | test | protected function form($type = self::FORM_VERTICAL, $inputClass = '', $labelClass = '') {
$this->formType = $type;
$this->inputClass = $inputClass;
$this->labelClass = $labelClass;
} | php | {
"resource": ""
} |
q260135 | BootstrapBase.horizontal | test | public function horizontal($inputClass = '', $labelClass = '') {
$this->form(self::FORM_HORIZONTAL, $inputClass, $labelClass);
return $this;
} | php | {
"resource": ""
} |
q260136 | BootstrapBase.label | test | protected function label($name, $label = null, array $options = array(), $content = null) {
$return = '';
$options = array_merge(array('class' => 'control-label ' . $this->labelClass, 'for' => (!$content ? $name : null)), $options);
if ($label !== null) {
$return .= '<label' . $this->html->attributes($options) . '>' . $content . ucwords(str_replace('_', ' ', $label)) . '</label>' . "\n";
}
return $return;
} | php | {
"resource": ""
} |
q260137 | BootstrapBase.errors | test | protected function errors($name, $errors = null, $wrap = '<span class="help-block">:message</span>') {
$return = '';
if ($errors && $errors->has($name)) {
$return .= $errors->first($name, $wrap) . "\n";
}
return $return;
} | php | {
"resource": ""
} |
q260138 | BootstrapBase.group | test | protected function group($name, $errors = null, $class = 'form-group', array $options = array())
{
$options = array_merge(array('class' => $class), $options);
$options['class'] .= ($errors && $errors->has($name) ? ' has-error' : '');
$return = '<div' . $this->html->attributes($options) . '>' . "\n";
return $return;
} | php | {
"resource": ""
} |
q260139 | BootstrapBase.action | test | protected function action($type, $value, array $attributes = array())
{
$return = '';
$containerAttributes = $this->getContainerAttributes($attributes);
switch ($type) {
case 'submit':
$attributes = array_merge(array('class' => 'btn btn-primary pull-right'), $attributes);
break;
case 'button':
case 'reset':
default:
$attributes = array_merge(array('class' => 'btn btn-default'), $attributes);
}
if (!isset($containerAttributes['display'])) {
$return .= $this->group('', null, 'form-group', $containerAttributes);
}
if ($this->formType == self::FORM_HORIZONTAL) {
$return .= $this->group('', null, $this->inputClass);
}
$return .= $this->form->$type($value, $attributes) . "\n";
if ($this->formType == self::FORM_HORIZONTAL) {
$return .= '</div>' . "\n";
}
if (!isset($containerAttributes['display'])) {
$return .= '</div>' . "\n";
}
return $return;
} | php | {
"resource": ""
} |
q260140 | BootstrapBase.hyperlink | test | protected function hyperlink($type, $location, $title = null, array $parameters = array(), array $attributes = array(), $secure = null)
{
$attributes = array_merge(array('class' => 'btn btn-default'), $attributes);
switch ($type) {
case 'linkRoute':
case 'linkAction':
$return = $this->html->$type($location, $title, $parameters, $attributes);
break;
case 'mailto':
$return = $this->html->$type($location, $title, $attributes);
break;
case 'link':
case 'secureLink':
default:
$return = $this->html->$type($location, $title, $attributes, $secure);
}
return $return;
} | php | {
"resource": ""
} |
q260141 | BootstrapBase.alert | test | protected function alert($type = 'message', $content = null, $emphasis = null, $dismissible = false, array $attributes = array())
{
$attributes = array_merge(array('class' => 'alert' . ($dismissible ? ' alert-dismissable' : '') . ' alert-' . ($type != 'message' ? $type : 'default')), $attributes);
$return = '<div ' . $this->html->attributes($attributes) . '>';
if ($dismissible !== false) {
$return .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
}
$return .= ($emphasis !== null && is_string($emphasis) ? '<strong>' . $emphasis . '</strong> ' : '') . $content . '</div>';
return $return;
} | php | {
"resource": ""
} |
q260142 | Bootstrap.password | test | public function password($name, $label = null, $errors = null, array $options = array())
{
return $this->input('password', $name, $label, null, $errors, $options);
} | php | {
"resource": ""
} |
q260143 | Bootstrap.file | test | public function file($name, $label = null, $errors = null, array $options = array())
{
return $this->input('file', $name, $label, null, $errors, $options);
} | php | {
"resource": ""
} |
q260144 | Bootstrap.link | test | public function link($url, $title = null, array $attributes = array(), $secure = null)
{
return $this->hyperlink('link', $url, $title, $parameters = array(), $attributes, $secure);
} | php | {
"resource": ""
} |
q260145 | Bootstrap.secureLink | test | public function secureLink($url, $title = null, array $attributes = array(), $secure = null)
{
return $this->hyperlink('secureLink', $url, $title, array(), $attributes, $secure);
} | php | {
"resource": ""
} |
q260146 | Bootstrap.linkRoute | test | public function linkRoute($name, $title = null, array $parameters = array(), array $attributes = array())
{
return $this->hyperlink('linkRoute', $name, $title, $parameters, $attributes, null);
} | php | {
"resource": ""
} |
q260147 | Bootstrap.linkAction | test | public function linkAction($action, $title = null, array $parameters = array(), array $attributes = array())
{
return $this->hyperlink('linkAction', $action, $title, $parameters, $attributes, null);
} | php | {
"resource": ""
} |
q260148 | Bootstrap.mailto | test | public function mailto($email, $title = null, array $attributes = array())
{
return $this->hyperlink('mailto', $email, $title, array(), $attributes, null);
} | php | {
"resource": ""
} |
q260149 | Bootstrap.none | test | public function none($content = null, $emphasis = null, $dismissible = false, array $attributes = array())
{
return $this->alert('message', $content, $emphasis, $dismissible, $attributes);
} | php | {
"resource": ""
} |
q260150 | MbRegex.execReplace | test | private static function execReplace($pattern, $replacement, $subject, $option)
{
return (\is_object($replacement) || \is_array($replacement)) && \is_callable($replacement)
? \mb_ereg_replace_callback($pattern, $replacement, $subject, $option)
: \mb_ereg_replace($pattern, $replacement, $subject, $option);
} | php | {
"resource": ""
} |
q260151 | RegexException.getShortMessage | test | public function getShortMessage()
{
$msg = $this->getMessage();
if (\strpos($msg, '(): ') !== false) {
list(, $msg) = \explode('(): ', $msg);
}
return $msg;
} | php | {
"resource": ""
} |
q260152 | sspmod_redis_Store_Redis.get | test | public function get($type, $key)
{
$redisKey = "{$this->prefix}.$type.$key";
$value = $this->redis->get($redisKey);
if (is_null($value)) {
return null;
}
return unserialize($value);
} | php | {
"resource": ""
} |
q260153 | sspmod_redis_Store_Redis.set | test | public function set($type, $key, $value, $expire = null)
{
$redisKey = "{$this->prefix}.$type.$key";
$this->redis->set($redisKey, serialize($value));
if (is_null($expire)) {
$expire = time() + $this->lifeTime;
}
$this->redis->expireat($redisKey, $expire);
} | php | {
"resource": ""
} |
q260154 | CartController.actionRemoveBasket | test | public function actionRemoveBasket()
{
$rr = new RequestResponse();
if ($rr->isRequestAjaxPost()) {
$basket_id = \Yii::$app->request->post('basket_id');
$shopBasket = ShopOrderItem::find()->where(['id' => $basket_id])->one();
if ($shopBasket) {
if ($shopBasket->delete()) {
$rr->success = true;
$rr->message = \Yii::t('skeeks/shop/app', 'Position successfully removed');
}
}
\Yii::$app->shop->cart->shopOrder->link('cmsSite', \Yii::$app->cms->site);
$rr->data = \Yii::$app->shop->cart->shopOrder->jsonSerialize();
return (array)$rr;
} else {
return $this->goBack();
}
} | php | {
"resource": ""
} |
q260155 | CartController.actionClear | test | public function actionClear()
{
$rr = new RequestResponse();
if ($rr->isRequestAjaxPost()) {
foreach (\Yii::$app->shop->cart->shopOrder->shopOrderItems as $basket) {
$basket->delete();
}
\Yii::$app->shop->cart->shopOrder->link('cmsSite', \Yii::$app->cms->site);
$rr->data = \Yii::$app->shop->cart->shopOrder->jsonSerialize();
$rr->success = true;
$rr->message = "";
return (array)$rr;
} else {
return $this->goBack();
}
} | php | {
"resource": ""
} |
q260156 | CartController.actionUpdateBasket | test | public function actionUpdateBasket()
{
$rr = new RequestResponse();
if ($rr->isRequestAjaxPost()) {
$basket_id = (int)\Yii::$app->request->post('basket_id');
$quantity = (float)\Yii::$app->request->post('quantity');
/**
* @var $shopBasket ShopBasket
*/
$shopBasket = ShopOrderItem::find()->where(['id' => $basket_id])->one();
if ($shopBasket) {
if ($quantity > 0) {
$product = $shopBasket->product;
if ($product->measure_ratio > 1) {
if ($quantity % $product->measure_ratio != 0) {
$quantity = $product->measure_ratio;
}
}
$shopBasket->quantity = $quantity;
if ($shopBasket->recalculate()->save()) {
$rr->success = true;
$rr->message = \Yii::t('skeeks/shop/app', 'Postion successfully updated');
}
} else {
if ($shopBasket->delete()) {
$rr->success = true;
$rr->message = \Yii::t('skeeks/shop/app', 'Position successfully removed');
}
}
}
\Yii::$app->shop->cart->shopOrder->link('cmsSite', \Yii::$app->cms->site);
$rr->data = \Yii::$app->shop->cart->shopOrder->jsonSerialize();
return (array)$rr;
} else {
return $this->goBack();
}
} | php | {
"resource": ""
} |
q260157 | Util.getLiteralValue | test | public static function getLiteralValue ($literal)
{
preg_match("/^\"(.*)\"/", $literal, $match); //TODO: somehow the copied regex did not work. To be checked. Contained [^]
if (empty($match)) {
throw new \Exception($literal . ' is not a literal');
}
return $match[1];
} | php | {
"resource": ""
} |
q260158 | Util.getLiteralType | test | public static function getLiteralType ($literal)
{
preg_match('/^".*"(?:\^\^([^"]+)|(@)[^@"]+)?$/s',$literal,$match);//TODO: somehow the copied regex did not work. To be checked. Contained [^] instead of the .
if (empty($match))
throw new \Exception($literal . ' is not a literal');
if (!empty($match[1])) {
return $match[1];
} else {
return !empty($match[2]) ? self::RDFLANGSTRING : self::XSDSTRING;
}
} | php | {
"resource": ""
} |
q260159 | Util.getLiteralLanguage | test | public static function getLiteralLanguage ($literal)
{
preg_match('/^".*"(?:@([^@"]+)|\^\^[^"]+)?$/s', $literal, $match);
if (empty($match))
throw new \Exception($literal . ' is not a literal');
return isset($match[1]) ? strtolower($match[1]) : '';
} | php | {
"resource": ""
} |
q260160 | Util.createIRI | test | public static function createIRI ($iri)
{
return !empty($iri) && substr($iri,0,1) === '"' ? self::getLiteralValue($iri) : $iri;
} | php | {
"resource": ""
} |
q260161 | Util.createLiteral | test | public static function createLiteral ($value, $modifier = null)
{
if (!$modifier) {
switch (gettype($value)) {
case 'boolean':
$value = $value ? "true":"false";
$modifier = self::XSDBOOLEAN;
break;
case 'integer':
$modifier = self::XSDINTEGER;
break;
case 'double':
$modifier = self::XSDDOUBLE;
break;
case 'float':
$modifier = self::XSDFLOAT;
break;
default:
return '"' . $value . '"';
}
}
return '"' . $value . (preg_match("/^[a-z]+(-[a-z0-9]+)*$/i", $modifier) ? '"@' . strtolower($modifier) : '"^^' . $modifier);
} | php | {
"resource": ""
} |
q260162 | YandexKassaPaySystem.checkRequestMD5 | test | public function checkRequestMD5($request)
{
//return true;
$str = $request['action'].";".
$request['orderSumAmount'].";".$request['orderSumCurrencyPaycash'].";".
$request['orderSumBankPaycash'].";".$request['shopId'].";".
$request['invoiceId'].";".$request['customerNumber'].";".$this->shop_password;
\Yii::info("String to md5: ".$str, static::class);
$md5 = strtoupper(md5($str));
if ($md5 != strtoupper($request['md5'])) {
\Yii::error("Wait for md5:".$md5.", recieved md5: ".$request['md5'], self::class);
return false;
}
return true;
} | php | {
"resource": ""
} |
q260163 | YandexKassaPaySystem.buildResponse | test | public function buildResponse($functionName, $invoiceId, $result_code, $message = null)
{
try {
$performedDatetime = self::formatDate(new \DateTime());
$response = '<?xml version="1.0" encoding="UTF-8"?><'.$functionName.'Response performedDatetime="'.$performedDatetime.
'" code="'.$result_code.'" '.($message != null ? 'message="'.$message.'"' : "").' invoiceId="'.$invoiceId.'" shopId="'.$this->shop_id.'"/>';
return $response;
} catch (\Exception $e) {
\Yii::error($e->getMessage(), static::class);
}
return null;
} | php | {
"resource": ""
} |
q260164 | N3Lexer.initTokenize | test | private function initTokenize()
{
$this->_tokenize = function ($input, $finalize) {
// If the input is a string, continuously emit tokens through the callback until the end
if (!isset($this->input))
$this->input = "";
$this->input .= $input;
$tokens = [];
$error = "";
$this->input = $this->tokenizeToEnd(function ($e, $t) use (&$tokens,&$error) {
if (isset($e)) {
$error = $e;
}
array_push($tokens, $t);
}, $finalize);
if ($error) throw $error;
return $tokens;
};
} | php | {
"resource": ""
} |
q260165 | N3Lexer.tokenize | test | public function tokenize($input, $finalize = true) {
try {
return call_user_func($this->_tokenize, $input, $finalize);
} catch (\Exception $e) {
throw $e;
}
} | php | {
"resource": ""
} |
q260166 | Abc.deObfuscate | test | public static function deObfuscate(?string $code, string $alias): ?int
{
return self::$obfuscatorFactory->decode($code, $alias);
} | php | {
"resource": ""
} |
q260167 | Abc.obfuscate | test | public static function obfuscate(?int $id, string $alias): ?string
{
return self::$obfuscatorFactory->encode($id, $alias);
} | php | {
"resource": ""
} |
q260168 | ServerRequestFactory.default | test | public static function default(): self
{
return new self(
new Factory\Header\HeadersFactory(
Factories::default()
),
new Factory\Environment\EnvironmentFactory,
new Factory\Cookies\CookiesFactory,
new Factory\Query\QueryFactory,
new Factory\Form\FormFactory,
new Factory\Files\FilesFactory
);
} | php | {
"resource": ""
} |
q260169 | StatementFixtures.getStatementWithGroupActor | test | public static function getStatementWithGroupActor($id = self::DEFAULT_STATEMENT_ID)
{
if (null === $id) {
$id = UuidFixtures::getUniqueUuid();
}
$group = ActorFixtures::getTypicalGroup();
$verb = VerbFixtures::getTypicalVerb();
$activity = ActivityFixtures::getTypicalActivity();
return new Statement(StatementId::fromString($id), $group, $verb, $activity);
} | php | {
"resource": ""
} |
q260170 | StatementFixtures.getStatementWithStatementRef | test | public static function getStatementWithStatementRef($id = self::DEFAULT_STATEMENT_ID)
{
$minimalStatement = static::getMinimalStatement($id);
return new Statement(
$minimalStatement->getId(),
$minimalStatement->getActor(),
$minimalStatement->getVerb(),
new StatementReference(StatementId::fromString('8f87ccde-bb56-4c2e-ab83-44982ef22df0'))
);
} | php | {
"resource": ""
} |
q260171 | StatementFixtures.getStatementWithResult | test | public static function getStatementWithResult($id = self::DEFAULT_STATEMENT_ID)
{
if (null === $id) {
$id = UuidFixtures::getUniqueUuid();
}
return new Statement(StatementId::fromString($id), ActorFixtures::getTypicalAgent(), VerbFixtures::getTypicalVerb(), ActivityFixtures::getTypicalActivity(), ResultFixtures::getScoreAndDurationResult());
} | php | {
"resource": ""
} |
q260172 | StatementFixtures.getStatementWithSubStatement | test | public static function getStatementWithSubStatement($id = self::DEFAULT_STATEMENT_ID)
{
if (null === $id) {
$id = UuidFixtures::getUniqueUuid();
}
$actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
$verb = new Verb(IRI::fromString('http://example.com/visited'), LanguageMap::create(array('en-US' => 'will visit')));
$definition = new Definition(
LanguageMap::create(array('en-US' => 'Some Awesome Website')),
LanguageMap::create(array('en-US' => 'The visited website')),
IRI::fromString('http://example.com/definition-type')
);
$activity = new Activity(IRI::fromString('http://example.com/website'), $definition);
$subStatement = new SubStatement($actor, $verb, $activity);
$actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
$verb = new Verb(IRI::fromString('http://example.com/planned'), LanguageMap::create(array('en-US' => 'planned')));
return new Statement(StatementId::fromString($id), $actor, $verb, $subStatement);
} | php | {
"resource": ""
} |
q260173 | OptionFactory.create | test | public function create($option, $type = OptionInterface::TYPE_GET)
{
if (!isset($this->mapping[$option])) {
throw new \InvalidArgumentException(sprintf('The option "%s" does not exist.', $option));
}
return new $this->mapping[$option]($type);
} | php | {
"resource": ""
} |
q260174 | StatementResultFixtures.getStatementResult | test | public static function getStatementResult(IRL $urlPath = null)
{
$statement1 = StatementFixtures::getMinimalStatement();
$verb = new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/deleted'), LanguageMap::create(array('en-US' => 'deleted')));
$statement2 = new Statement(
StatementId::fromString('12345678-1234-5678-8234-567812345679'),
new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]'))),
$verb,
$statement1->getObject()
);
$statementResult = new StatementResult(array($statement1, $statement2), $urlPath);
return $statementResult;
} | php | {
"resource": ""
} |
q260175 | Module.attach | test | public function attach(EventManagerInterface $events)
{
$events->attach(ViewEvent::EVENT_RENDERER_POST, array($this, 'cleanLayout'), 1);
$events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'attachPDFtransformer'), 10);
} | php | {
"resource": ""
} |
q260176 | Module.initializeViewHelper | test | public function initializeViewHelper(MvcEvent $e)
{
$viewhelperManager = $this->serviceManager->get('ViewHelperManager');
if ($viewhelperManager->has('InsertFile')) {
$insertFile = $viewhelperManager->get('InsertFile');
$insertFile->attach(FileEvent::GETFILE, array($this, 'getFile'));
$insertFile->attach(FileEvent::RENDERFILE, array($this, 'renderFile'));
$insertFile->attach(FileEvent::INSERTFILE, array($this, 'collectFiles'));
}
} | php | {
"resource": ""
} |
q260177 | Module.getFile | test | public function getFile(FileEvent $e)
{
$lastFileName = $e->getLastFileName();
if (is_string($lastFileName)) {
$repository = $this->serviceManager->get('repositories')->get('Applications/Attachment');
$file = $repository->find($lastFileName);
if (isset($file)) {
$e->setFileObject($lastFileName, $file);
$e->stopPropagation();
return $file;
}
return null;
}
// if it is not a string i do presume it is already a file-Object
return $lastFileName;
} | php | {
"resource": ""
} |
q260178 | Module.collectFiles | test | public function collectFiles(FileEvent $e)
{
$this->appendPDF = array();
$files = $e->getAllFiles();
foreach ($files as $name => $file) {
if (!empty($file) && $file instanceof FileEntity) {
if (0 === strpos($file->getType(), 'image')) {
$this->appendImage[] = $file;
}
if (strtolower($file->getType()) == 'application/pdf') {
$this->appendPDF[] = $file;
}
}
}
return null;
} | php | {
"resource": ""
} |
q260179 | Module.cleanLayout | test | public function cleanLayout(ViewEvent $e)
{
$result = $e->getResult();
$response = $e->getResponse();
$model = $e->getModel();
if ($model->hasChildren()) {
$children = $model->getChildren();
$content = null;
foreach ($children as $child) {
if ($child->captureTo() == 'content') {
$content = $child;
$this->attachViewResolver();
}
}
if (!empty($content)) {
$e->setModel($content);
}
} else {
// attach the own resolver here too ?
// ...
}
} | php | {
"resource": ""
} |
q260180 | Module.attachViewResolver | test | public function attachViewResolver()
{
if (!$this->viewResolverAttached) {
$this->viewResolverAttached = true;
$resolver = $this->serviceManager->get('ViewResolver');
$resolver->attach($this, 100);
}
} | php | {
"resource": ""
} |
q260181 | Module.attachPDFtransformer | test | public function attachPDFtransformer(ViewEvent $e)
{
//$renderer = $e->getRenderer();
$result = $e->getResult();
$response = $e->getResponse();
// the handles are for temporary files
error_reporting(0);
foreach (array(self::RENDER_FULL, self::RENDER_WITHOUT_PDF, self::RENDER_WITHOUT_ATTACHMENTS ) as $render) {
$handles = array();
try {
$pdf = new extern\mPDFderive();
$pdf->SetImportUse();
// create bookmark list in Acrobat Reader
$pdf->h2bookmarks = array('H1' => 0, 'H2' => 1, 'H3' => 2);
$pdf->WriteHTML($result);
// Output of the Images
if (self::RENDER_FULL == $render || self::RENDER_WITHOUT_PDF == $render) {
if (is_array($this->appendImage) && !empty($this->appendImage)) {
foreach ($this->appendImage as $imageAttachment) {
$content = $imageAttachment->getContent();
$url = 'data:image/' . $imageAttachment->getType() . ';base64,' . base64_encode($content);
$html = '<a name="attachment_' . $imageAttachment->getId() . '"><img src="' . $url . '" /><br /></a>';
$pdf->WriteHTML($html);
}
}
}
// Temp Files PDF
if (self::RENDER_FULL == $render) {
if (is_array($this->appendPDF) && !empty($this->appendPDF)) {
foreach ($this->appendPDF as $pdfAttachment) {
$content = $pdfAttachment->getContent();
$tmpHandle = tmpfile();
$handles[] = $tmpHandle;
fwrite($tmpHandle, $content);
fseek($tmpHandle, 0);
}
}
}
// Output of the PDF
foreach ($handles as $handle) {
$meta_data = stream_get_meta_data($handle);
$filename = $meta_data["uri"];
$pdf->WriteHTML($filename);
$pagecount = $pdf->SetSourceFile($filename);
for ($pages = 0; $pages < $pagecount; $pages++) {
$pdf->AddPage();
$pdf->WriteHTML(' pages: ' . $pagecount);
$tx = $pdf->ImportPage($pages + 1);
$pdf->UseTemplate($tx);
}
}
$pdf_result = $pdf->Output();
$e->setResult($pdf_result);
// delete all temporary Files again
foreach ($handles as $handle) {
fclose($handle);
}
break;
} catch (\Exception $e) {
}
}
error_reporting(E_ALL);
} | php | {
"resource": ""
} |
q260182 | Module.resolve | test | public function resolve($name, Renderer $renderer = null)
{
if ($this->serviceManager->has('ViewTemplatePathStack')) {
// get all the Pases made up for the zend-provided resolver
// we won't get any closer to ALL than that
$viewTemplatePathStack = $this->serviceManager->get('ViewTemplatePathStack');
$paths = $viewTemplatePathStack->getPaths();
$defaultSuffix = $viewTemplatePathStack->getDefaultSuffix();
if (pathinfo($name, PATHINFO_EXTENSION) != $defaultSuffix) {
;
$name .= '.pdf.' . $defaultSuffix;
} else {
// TODO: replace Filename by Filename for PDF
}
foreach ($paths as $path) {
$file = new SplFileInfo($path . $name);
if ($file->isReadable()) {
// Found! Return it.
if (($filePath = $file->getRealPath()) === false && substr($path, 0, 7) === 'phar://') {
// Do not try to expand phar paths (realpath + phars == fail)
$filePath = $path . $name;
if (!file_exists($filePath)) {
break;
}
}
//if ($this->useStreamWrapper()) {
// // If using a stream wrapper, prepend the spec to the path
// $filePath = 'zend.view://' . $filePath;
//}
return $filePath;
}
}
}
// TODO: Resolving to an PDF has failed, this could have implications for the transformer
return false;
} | php | {
"resource": ""
} |
q260183 | OptionBag.register | test | public function register($option, $type = OptionInterface::TYPE_GET)
{
if (is_string($option)) {
$option = $this->factory->create($option, $type);
}
if (!$option instanceof OptionInterface) {
throw new \InvalidArgumentException(
'The option should be either a string or a "Widop\Twitter\Options\OptionInterface".'
);
}
$this->options[$option->getName()] = $option;
return $this;
} | php | {
"resource": ""
} |
q260184 | OptionBag.getOption | test | private function getOption($name)
{
if (!isset($this->options[$name])) {
throw new \InvalidArgumentException(sprintf('The option "%s" does not exist.', $name));
}
return $this->options[$name];
} | php | {
"resource": ""
} |
q260185 | DocumentFixtures.getActivityProfileDocument | test | public static function getActivityProfileDocument(DocumentData $documentData = null)
{
if (null === $documentData) {
$documentData = static::getDocumentData();
}
$activityProfile = new ActivityProfile('profile-id', new Activity(IRI::fromString('activity-id')));
return new ActivityProfileDocument($activityProfile, $documentData);
} | php | {
"resource": ""
} |
q260186 | DocumentFixtures.getAgentProfileDocument | test | public static function getAgentProfileDocument(DocumentData $documentData = null)
{
if (null === $documentData) {
$documentData = static::getDocumentData();
}
return new AgentProfileDocument(new AgentProfile('profile-id', new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')))), $documentData);
} | php | {
"resource": ""
} |
q260187 | DocumentFixtures.getStateDocument | test | public static function getStateDocument(DocumentData $documentData = null)
{
if (null === $documentData) {
$documentData = static::getDocumentData();
}
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
$activity = new Activity(IRI::fromString('activity-id'));
return new StateDocument(new State($activity, $agent, 'state-id'), $documentData);
} | php | {
"resource": ""
} |
q260188 | Builder.addBehavior | test | public function addBehavior($slug, $strategy, array $args = [])
{
$behavior = $this->getBehavior($slug, $strategy);
if ($this->bucket->enabled($behavior)) {
$this->setBehavior($behavior, $args);
}
return $this;
} | php | {
"resource": ""
} |
q260189 | Builder.addValue | test | public function addValue($slug, $value)
{
$behavior = $this->getBehavior($slug, function () use ($value) {
return $value;
});
if ($this->bucket->enabled($behavior)) {
$this->setBehavior($behavior);
}
return $this;
} | php | {
"resource": ""
} |
q260190 | Builder.defaultBehavior | test | public function defaultBehavior($strategy, array $args = [])
{
if ($this->defaultWaived) {
$exception = new \LogicException('Defined a default behavior after `noDefault` was called.');
$this->logger->critical('Swivel', compact('exception'));
throw $exception;
}
if (!$this->behavior) {
$this->setBehavior($this->getBehavior($strategy), $args);
}
return $this;
} | php | {
"resource": ""
} |
q260191 | Builder.defaultValue | test | public function defaultValue($value)
{
if ($this->defaultWaived) {
$exception = new \LogicException('Defined a default value after `noDefault` was called.');
$this->logger->critical('Swivel', compact('exception'));
throw $exception;
}
if (!$this->behavior) {
$callable = function () use ($value) {
return $value;
};
$this->setBehavior($this->getBehavior($callable));
}
return $this;
} | php | {
"resource": ""
} |
q260192 | Builder.execute | test | public function execute()
{
$behavior = $this->behavior ?: $this->getBehavior(function () {
return;
});
$behaviorSlug = $behavior->getSlug();
$this->metrics && $this->startMetrics($behaviorSlug);
$result = $behavior->execute($this->args ?: []);
$this->metrics && $this->stopMetrics($behaviorSlug);
return $result;
} | php | {
"resource": ""
} |
q260193 | Builder.getBehavior | test | public function getBehavior($slug, $strategy = self::DEFAULT_STRATEGY)
{
$this->logger->debug('Swivel - Creating new behavior.', compact('slug'));
if ($strategy === static::DEFAULT_STRATEGY) {
$strategy = $slug;
$slug = static::DEFAULT_SLUG;
}
if (!is_callable($strategy)) {
if (is_string($strategy)) {
$strategy = explode('::', $strategy);
}
if (!isset($strategy[0], $strategy[1]) || !method_exists($strategy[0], $strategy[1])) {
throw new \LogicException('Invalid callable passed to Zumba\Swivel\Builder::getBehavior');
}
$closure = function () use ($strategy) {
return call_user_func_array($strategy, func_get_args());
};
$strategy = $closure->bindTo(null, $strategy[0]);
}
$slug = empty($slug) ? $this->slug : $this->slug.Map::DELIMITER.$slug;
return new Behavior($slug, $strategy, $this->logger);
} | php | {
"resource": ""
} |
q260194 | Builder.noDefault | test | public function noDefault()
{
if ($this->behavior && $this->behavior->getSlug() === static::DEFAULT_SLUG) {
$exception = new \LogicException('Called `noDefault` after a default behavior was defined.');
$this->logger->critical('Swivel', compact('exception'));
throw $exception;
}
$this->defaultWaived = true;
return $this;
} | php | {
"resource": ""
} |
q260195 | Builder.setBehavior | test | protected function setBehavior(Behavior $behavior, array $args = [])
{
$slug = $behavior->getSlug();
$this->logger->debug('Swivel - Setting behavior.', compact('slug', 'args'));
$this->behavior = $behavior;
$this->args = $args;
} | php | {
"resource": ""
} |
q260196 | Builder.startMetrics | test | protected function startMetrics($behaviorSlug)
{
$metrics = $this->metrics;
$bucketIndex = $this->bucket->getIndex();
// Increment counters
$metrics->increment('Features', $behaviorSlug);
$metrics->increment('Buckets', $this->keys[$bucketIndex - 1], $behaviorSlug);
// Start timers
$metrics->startTiming('Features', $behaviorSlug);
$metrics->startMemoryProfile('Features', $behaviorSlug);
} | php | {
"resource": ""
} |
q260197 | Builder.stopMetrics | test | protected function stopMetrics($behaviorSlug)
{
$metrics = $this->metrics;
$metrics->endMemoryProfile('Features', $behaviorSlug);
$metrics->endTiming('Features', $behaviorSlug);
} | php | {
"resource": ""
} |
q260198 | Behavior.execute | test | public function execute(array $args = [])
{
$slug = $this->slug;
if ($this->logger) {
$this->logger->debug('Swivel - Executing behavior.', compact('slug', 'args'));
}
return call_user_func_array($this->strategy, $args);
} | php | {
"resource": ""
} |
q260199 | Collection.every | test | public function every($step, $offset = 0)
{
$new = [];
$position = 0;
foreach ($this->items as $key => $item) {
if ($position % $step === $offset) {
$new[] = $item;
}
$position++;
}
return new static($new);
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.