sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function boot(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/amigrid.php', GridView::NAME);
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', GridView::NAME);
$this->loadViewsFrom(__DIR__ . '/../resources/views', GridView::NAME);
$this->publishes([
__DIR__ . '/../config/amigrid.php' => config_path('amigrid.php'),
], 'configs');
$this->publishes([
__DIR__ . '/../public/css' => base_path('public/vendor/grid-view/css'),
__DIR__ . '/../public/js' => base_path('public/vendor/grid-view/js'),
], 'assets');
$this->registerProviders();
} | Bootstrap the application services.
@return void | entailment |
public function register(): void
{
$this->app->bind(\Assurrussa\GridView\Interfaces\GridInterface::class, function ($app) {
/** @var Container $app */
return $app->make(GridView::class);
});
$this->app->alias(\Assurrussa\GridView\GridView::class, GridView::NAME);
$this->app->alias(\Assurrussa\GridView\GridView::class, \Assurrussa\GridView\Interfaces\GridInterface::class);
} | Register the application services.
Use a Helpers service provider that loads all .php files from a folder.
@return void | entailment |
protected function registerProviders(): void
{
foreach ($this->providers as $provider) {
$this->app->register($provider);
}
} | Register the providers. | entailment |
public function set($key, $value)
{
KeyUtil::validate($key);
$this->array[$key] = call_user_func($this->serialize, $value);
} | {@inheritdoc} | entailment |
public function get($key, $default = null)
{
KeyUtil::validate($key);
if (!array_key_exists($key, $this->array)) {
return $default;
}
return call_user_func($this->unserialize, $this->array[$key]);
} | {@inheritdoc} | entailment |
public function getOrFail($key)
{
KeyUtil::validate($key);
if (!array_key_exists($key, $this->array)) {
throw NoSuchKeyException::forKey($key);
}
return call_user_func($this->unserialize, $this->array[$key]);
} | {@inheritdoc} | entailment |
public function getMultiple(array $keys, $default = null)
{
KeyUtil::validateMultiple($keys);
$values = array();
foreach ($keys as $key) {
$values[$key] = array_key_exists($key, $this->array)
? call_user_func($this->unserialize, $this->array[$key])
: $default;
}
return $values;
} | {@inheritdoc} | entailment |
public function getMultipleOrFail(array $keys)
{
KeyUtil::validateMultiple($keys);
$notFoundKeys = array_diff($keys, array_keys($this->array));
if (count($notFoundKeys) > 0) {
throw NoSuchKeyException::forKeys($notFoundKeys);
}
return $this->getMultiple($keys);
} | {@inheritdoc} | entailment |
public function remove($key)
{
KeyUtil::validate($key);
$removed = array_key_exists($key, $this->array);
unset($this->array[$key]);
return $removed;
} | {@inheritdoc} | entailment |
public static function flushAuthorityEvents($controllerName = null)
{
$controllerName = $controllerName ?: get_called_class();
$events = app('events');
$listeners = (array) get_property($events, 'listeners');
foreach ($listeners as $eventName => $listener) {
$remove = false; // flag
if ($controllerName === "*") { // All Controllers
if (starts_with($eventName, "router.filter: controller.")) {
$remove = true;
}
} elseif (preg_match("/^router\.filter: controller\.[^.]+?\.$controllerName/", $eventName)) {
$remove = true;
}
if ($remove) {
$events->forget($eventName);
}
}
} | Remove all of the Authority-Controller event listeners of the specified controller.
If $controllerName == '*', it removes all the Authority-Controller events
of every Controllers of the application.
\App\Http\Controllers\Controller::flushAuthorityEvents('*'); // Remove all Authority-Controller events of every Controllers
\App\Http\Controllers\ProjectsController::flushAuthorityEvents(); // Remove all Authority-Controller events of ProjectsController
@param string Controller name. If null it get the current Controller name.
@return void | entailment |
public function callAction($method, $parameters)
{
$route = app('router')->current();
$request = app('request');
$this->assignAfter($route, $request, $method);
$response = $this->before($route, $request, $method);
if (is_null($response)) {
$response = call_user_func_array([$this, $method], $parameters);
}
return $response;
} | Execute an action on the controller.
@param string $method
@param array $parameters
@return \Symfony\Component\HttpFoundation\Response | entailment |
protected function filterApplies($filter, $request, $method)
{
if ($this->filterFailsMethod($filter, $request, $method)) {
return false;
}
return true;
} | Determine if the given filter applies to the request.
@param array $filter
@param \Illuminate\Http\Request $request
@param string $method
@return bool | entailment |
protected function callFilter($filter, $route, $request)
{
return $this->callRouteFilter(
$filter['filter'], $filter['parameters'], $route, $request
);
} | Call the given controller filter method.
@param array $filter
@param \Illuminate\Routing\Route $route
@param \Illuminate\Http\Request $request
@return mixed | entailment |
public function prependBeforeFilter($filter, array $options = [])
{
array_unshift($this->beforeFilters, $this->parseFilter($filter, $options));
} | Register a new "before" filter before any "before" filters on the controller.
@param string $filter
@param array $options
@return void | entailment |
public function prependAfterFilter($filter, array $options = [])
{
array_unshift($this->afterFilters, $this->parseFilter($filter, $options));
} | Register a new "after" filter before any "after" filters on the controller.
@param string $filter
@param array $options
@return void | entailment |
public function loadAndAuthorizeResource($args = null)
{
$args = is_array($args) ? $args : func_get_args();
ControllerResource::addBeforeFilter($this, __METHOD__, $args);
} | Sets up a before filter which loads and authorizes the current resource. This performs both
loadResource() and authorizeResource() and accepts the same arguments. See those methods for details.
class BooksController extends Controller
{
public function __construct()
{
$this->loadAndAuthorizeResource();
}
} | entailment |
public function authorize($args = null)
{
$args = is_array($args) ? $args : func_get_args();
$this->_authorized = true;
return call_user_func_array([$this->getCurrentAuthority(), 'authorize'], $args);
} | Throws a Efficiently\AuthorityController\Exceptions\AccessDenied exception if the currentAuthority cannot
perform the given action. This is usually called in a controller action or
before filter to perform the authorization.
public function show($id)
{
$this->article = Article::find($id); // Tips: instead of $id, you can use $this->params['id']
$this->authorize('read', $this->article);
// But you still need to return the view
// return view('articles.show', compact_property($this, 'article'));
}
A 'message' option can be passed to specify a different message.
$this->authorize('read', $this->article, ['message' => "Not authorized to read ".$this->article->name]);
You can also use I18n to customize the message. Action aliases defined in Authority work here.
return [
'unauthorized' => [
'manage' => [
'all' => "Not authorized to :action :subject.",
'user' => "Not allowed to manage other user accounts.",
],
'update' => [
'project' => "Not allowed to update this project."
],
],
];
You can catch the exception and modify its behavior in the report() method of the app/Exceptions/Handler.php file.
For example here we set the error message to a flash and redirect to the home page.
public function report(Exception $e)
{
if ($e instanceof \Efficiently\AuthorityController\Exceptions\AccessDenied) {
$msg = $e->getMessage();
\Log::error('Access denied! '.$msg);
return redirect()->route('home')->with('flash_alert', $msg);
}
return parent::report($e);
}
//code...
See the Efficiently\AuthorityController\Exceptions\AccessDenied exception for more details on working with the exception.
See the loadAndAuthorizeResource() method to automatically add the authorize() behavior
to the default RESTful actions. | entailment |
public function can($args = null)
{
$args = is_array($args) ? $args : func_get_args();
return call_user_func_array([$this->getCurrentAuthority(), 'can'], $args);
} | Use in the controller or view to check the user's permission for a given action
and object.
$this->can('destroy', $this->project);
You can also pass the class instead of an instance (if you don't have one handy).
@if (Authority::can('create', 'Project'))
{{ link_to_route('projects.create', "New Project") }}
@endif
If it's a nested resource, you can pass the parent instance in an associative array. This way it will
check conditions which reach through that association.
@if (Authority::can('create', ['Project' => $category]))
{{ link_to_route('categories.projects.create', "New Project") }}
@endif
This simply calls "can()" on the <code>$this->currentAuthority</code>. See Authority::can(). | entailment |
public function cannot($args = null)
{
$args = is_array($args) ? $args : func_get_args();
return call_user_func_array([$this->getCurrentAuthority(), 'cannot'], $args);
} | Convenience method which works the same as "can()" but returns the opposite value.
$this->cannot('destroy', $this->project); | entailment |
public function pack($v)
{
$stream = '';
if (is_string($v)) {
$stream .= $this->packText($v);
} elseif ($v instanceof CollectionInterface && $v instanceof Map) {
$stream .= $this->packMap($v->getElements());
} elseif ($v instanceof CollectionInterface && $v instanceof ArrayList) {
$stream .= $this->packList($v->getElements());
}
elseif (is_array($v)) {
$stream .= ($this->isList($v) && !empty($v)) ? $this->packList($v) : $this->packMap($v);
} elseif (is_float($v)) {
$stream .= $this->packFloat($v);
} elseif (is_int($v)) {
$stream .= $this->packInteger($v);
} elseif (is_null($v)) {
$stream .= chr(Constants::MARKER_NULL);
} elseif (true === $v) {
$stream .= chr(Constants::MARKER_TRUE);
} elseif (false === $v) {
$stream .= chr(Constants::MARKER_FALSE);
} elseif (is_float($v)) {
// if it is 64 bit integers casted to float
$r = $v + $v;
if ('double' === gettype($r)) {
$stream .= $this->packInteger($v);
}
} else {
throw new BoltInvalidArgumentException(sprintf('Could not pack the value %s', $v));
}
return $stream;
} | @param $v
@return string | entailment |
public function packStructureHeader($length, $signature)
{
$stream = '';
$packedSig = chr($signature);
if ($length < Constants::SIZE_TINY) {
$stream .= chr(Constants::STRUCTURE_TINY + $length);
$stream .= $packedSig;
return $stream;
}
if ($length < Constants::SIZE_MEDIUM) {
$stream .= chr(Constants::STRUCTURE_MEDIUM);
$stream .= $this->packUnsignedShortShort($length);
$stream .= $packedSig;
return $stream;
}
if ($length < Constants::SIZE_LARGE) {
$stream .= chr(Constants::STRUCTURE_LARGE);
$stream .= $this->packSignedShort($length);
$stream .= $packedSig;
return $stream;
}
throw new SerializationException(sprintf('Unable pack the size "%d" of the structure, Out of bound !', $length));
} | @param int $length
@param $signature
@return string | entailment |
public function getStructureMarker($length)
{
$length = (int) $length;
$bytes = '';
if ($length < Constants::SIZE_TINY) {
$bytes .= chr(Constants::STRUCTURE_TINY + $length);
} elseif ($length < Constants::SIZE_MEDIUM) {
// do
} elseif ($length < Constants::SIZE_LARGE) {
// do
} else {
throw new SerializationException(sprintf('Unable to get a Structure Marker for size %d', $length));
}
return $bytes;
} | @param int $length
@return string | entailment |
public function packList(array $array)
{
$size = count($array);
$b = $this->getListSizeMarker($size);
foreach ($array as $k => $v) {
$b .= $this->pack($v);
}
return $b;
} | @param array $array
@return string | entailment |
public function getListSizeMarker($size)
{
$b = '';
if ($size < Constants::SIZE_TINY) {
$b .= chr(Constants::LIST_TINY + $size);
return $b;
}
if ($size < Constants::SIZE_8) {
$b .= chr(Constants::LIST_8);
$b .= $this->packUnsignedShortShort($size);
return $b;
}
if ($b < Constants::SIZE_16) {
$b .= chr(Constants::LIST_16);
$b .= $this->packUnsignedShort($size);
return $b;
}
if ($b < Constants::SIZE_32) {
$b .= chr(Constants::LIST_32);
$b .= $this->packUnsignedLong($size);
return $b;
}
throw new SerializationException(sprintf('Unable to create marker for List size %d', $size));
} | @param $size
@return string | entailment |
public function packMap(array $array)
{
$size = count($array);
$b = '';
$b .= $this->getMapSizeMarker($size);
foreach ($array as $k => $v) {
$b .= $this->pack($k);
$b .= $this->pack($v);
}
return $b;
} | @param array $array
@return string | entailment |
public function packFloat($v)
{
$str = chr(Constants::MARKER_FLOAT);
return $str.strrev(pack('d', $v));
} | @param $v
@return int|string | entailment |
public function getMapSizeMarker($size)
{
$b = '';
if ($size < Constants::SIZE_TINY) {
$b .= chr(Constants::MAP_TINY + $size);
return $b;
}
if ($size < Constants::SIZE_8) {
$b .= chr(Constants::MAP_8);
$b .= $this->packUnsignedShortShort($size);
return $b;
}
if ($size < Constants::SIZE_16) {
$b .= chr(Constants::MAP_16);
$b .= $this->packUnsignedShort($size);
return $b;
}
if ($size < Constants::SIZE_32) {
$b .= chr(Constants::MAP_32);
$b .= $this->packUnsignedLong($size);
return $b;
}
throw new SerializationException(sprintf('Unable to pack Array with size %d. Out of bound !', $size));
} | @param int $size
@return string | entailment |
public function packText($value)
{
$length = strlen($value);
$b = '';
if ($length < 16) {
$b .= chr(Constants::TEXT_TINY + $length);
$b .= $value;
return $b;
}
if ($length < 256) {
$b .= chr(Constants::TEXT_8);
$b .= $this->packUnsignedShortShort($length);
$b .= $value;
return $b;
}
if ($length < 65536) {
$b .= chr(Constants::TEXT_16);
$b .= $this->packUnsignedShort($length);
$b .= $value;
return $b;
}
if ($length < 2147483643) {
$b .= chr(Constants::TEXT_32);
$b .= $this->packUnsignedLong($length);
$b .= $value;
return $b;
}
throw new \OutOfBoundsException(sprintf('String size overflow, Max PHP String size is %d, you gave a string of size %d',
2147483647,
$length));
} | @param $value
@return string
@throws \OutOfBoundsException | entailment |
public function packInteger($value)
{
$pow15 = pow(2, 15);
$pow31 = pow(2, 31);
$b = '';
if ($value > -16 && $value < 128) {
//$b .= chr(Constants::INT_8);
//$b .= $this->packBigEndian($value, 2);
return $this->packSignedShortShort($value);
}
if ($value > -129 && $value < -16) {
$b .= chr(Constants::INT_8);
$b .= $this->packSignedShortShort($value);
return $b;
}
if ($value < -16 && $value > -129) {
$b .= chr(Constants::INT_8);
$b .= $this->packSignedShortShort($value);
return $b;
}
if ($value < -128 && $value > -32769) {
$b .= chr(Constants::INT_16);
$b .= $this->packBigEndian($value, 2);
return $b;
}
if ($value >= -16 && $value < 128) {
return $this->packSignedShortShort($value);
}
if ($value > 127 && $value < $pow15) {
$b .= chr(Constants::INT_16);
$b .= pack('n', $value);
return $b;
}
if ($value > 32767 && $value < $pow31) {
$b .= chr(Constants::INT_32);
$b .= pack('N', $value);
return $b;
}
// 32 INTEGERS MINUS
if ($value >= (-1 * abs(pow(2, 31))) && $value < (-1 * abs(pow(2, 15)))) {
$b .= chr(Constants::INT_32);
$b .= pack('N', $value);
return $b;
}
// 64 INTEGERS POS
if ($value >= pow(2, 31) && $value < pow(2, 63)) {
$b .= chr(Constants::INT_64);
//$b .= $this->packBigEndian($value, 8);
$b .= pack('J', $value);
return $b;
}
// 64 INTEGERS MINUS
if ($value >= ((-1 * abs(pow(2, 63))) - 1) && $value < (-1 * abs(pow(2, 31)))) {
$b .= chr(Constants::INT_64);
$b .= pack('J', $value);
return $b;
}
throw new BoltOutOfBoundsException(sprintf('Out of bound value, max is %d and you give %d', PHP_INT_MAX, $value));
} | @param $value
@return string
@throws BoltOutOfBoundsException | entailment |
public function isShort($integer)
{
$min = 128;
$max = 32767;
$minMin = -129;
$minMax = -32768;
return in_array($integer, range($min, $max)) || in_array($integer, range($minMin, $minMax));
} | @param int $integer
@return bool | entailment |
public function packBigEndian($x, $bytes)
{
if (($bytes <= 0) || ($bytes % 2)) {
throw new BoltInvalidArgumentException(sprintf('Expected bytes count must be multiply of 2, %s given', $bytes));
}
if (!is_int($x)) {
throw new BoltInvalidArgumentException('Only integer values are supported');
}
$ox = $x;
$isNeg = false;
if ($x < 0) {
$isNeg = true;
$x = abs($x);
}
if ($isNeg) {
$x = bcadd($x, -1, 0);
} //in negative domain starting point is -1, not 0
$res = array();
for ($b = 0; $b < $bytes; $b += 2) {
$chnk = (int) bcmod($x, 65536);
$x = bcdiv($x, 65536, 0);
$res[] = pack('n', $isNeg ? ~$chnk : $chnk);
}
if ($x || ($isNeg && ($chnk & 0x8000))) {
throw new BoltOutOfBoundsException(sprintf('Overflow detected while attempting to pack %s into %s bytes', $ox, $bytes));
}
return implode(array_reverse($res));
} | @param int $x
@param int $bytes
@return array
@throws BoltInvalidArgumentException | entailment |
public function value($key, $default = null)
{
if (!array_key_exists($key, $this->properties) && 1 === func_num_args()) {
throw new \InvalidArgumentException(sprintf('this object has no property with key %s', $key));
}
return array_key_exists($key, $this->properties) ? $this->properties[$key] : $default;
} | {@inheritdoc} | entailment |
public function getJwtToken()
{
if ($this->token && $this->token->isValid()) {
return $this->token;
}
$url = $this->options['token_url'];
$requestOptions = array_merge(
$this->getDefaultHeaders(),
$this->auth->getRequestOptions()
);
$response = $this->client->request('POST', $url, $requestOptions);
$body = json_decode($response->getBody(), true);
$expiresIn = isset($body[$this->options['expire_key']]) ? $body[$this->options['expire_key']] : null;
if ($expiresIn) {
$expiration = new \DateTime('now + ' . $expiresIn . ' seconds');
} elseif (count($jwtParts = explode('.', $body[$this->options['token_key']])) === 3
&& is_array($payload = json_decode(base64_decode($jwtParts[1]), true))
// https://tools.ietf.org/html/rfc7519.html#section-4.1.4
&& array_key_exists('exp', $payload)
) {
// Manually process the payload part to avoid having to drag in a new library
$expiration = new \DateTime('@' . $payload['exp']);
} else {
$expiration = null;
}
$this->token = new JwtToken($body[$this->options['token_key']], $expiration);
return $this->token;
} | getToken.
@return JwtToken | entailment |
public function onFailure($metadata)
{
$this->completed = true;
$e = new MessageFailureException($metadata->getElements()['message']);
$e->setStatusCode($metadata->getElements()['code']);
throw $e;
} | @param $metadata
@throws MessageFailureException | entailment |
public function getRequestOptions()
{
return [
\GuzzleHttp\RequestOptions::QUERY => [
$this->options['query_fields'][0] => $this->options['username'],
$this->options['query_fields'][1] => $this->options['password'],
],
];
} | {@inheritdoc} | entailment |
public function connect()
{
$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!socket_connect($this->socket, $this->host, $this->port)) {
$errno = socket_last_error($this->socket);
$errstr = socket_strerror($errno);
throw new IOException(
sprintf('Error connecting to server "%s": %s',
$errno,
$errstr
), $errno
);
}
socket_set_block($this->socket);
socket_set_option($this->socket, SOL_TCP, TCP_NODELAY, 1);
//socket_set_option($this->socket, SOL_SOCKET, SO_PASSCRED
socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $this->timeout, 'usec' => 0));
socket_set_option($this->socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $this->timeout, 'usec' => 0));
return true;
} | {@inheritdoc} | entailment |
public function close()
{
if (is_resource($this->socket)) {
echo 'closing';
socket_close($this->socket);
}
$this->socket = null;
return true;
} | {@inheritdoc} | entailment |
public function write($data)
{
$len = mb_strlen($data, 'ASCII');
while (true) {
// Null sockets are invalid, throw exception
if (is_null($this->socket)) {
throw new IOException(sprintf(
'Socket was null! Last SocketError was: %s',
socket_strerror(socket_last_error())
));
}
$sent = socket_write($this->socket, $data, $len);
if ($sent === false) {
throw new IOException(sprintf(
'Error sending data. Last SocketError: %s',
socket_strerror(socket_last_error())
));
}
// Check if the entire message has been sent
if ($sent < $len) {
// If not sent the entire message.
// Get the part of the message that has not yet been sent as message
$data = mb_substr($data, $sent, mb_strlen($data, 'ASCII') - $sent, 'ASCII');
// Get the length of the not sent part
$len -= $sent;
} else {
break;
}
}
} | {@inheritdoc} | entailment |
public function read($n)
{
$res = '';
$read = 0;
$buf = socket_read($this->socket, $n);
while ($read < $n && $buf !== '' && $buf !== false) {
$read += mb_strlen($buf, 'ASCII');
$res .= $buf;
$buf = socket_read($this->socket, $n - $read);
}
if (mb_strlen($res, 'ASCII') != $n) {
throw new IOException(sprintf(
'Error reading data. Received %s instead of expected %s bytes',
mb_strlen($res, 'ASCII'),
$n
));
}
return $res;
} | {@inheritdoc} | entailment |
public function register()
{
$this->app['laraveleasyrec'] = $this->app->share(function($app) {
$config = [];
foreach (['baseURL', 'apiKey', 'tenantID', 'apiVersion'] as $value)
$config[$value] = $this->app->config->get('easyrec.'.$value);
return new Easyrec($config);
});
} | Register the service provider.
@return void | entailment |
public function convertStructureToSuccessMessage(MessageStructure $structure, RawMessage $rawMessage)
{
$message = new SuccessMessage($structure->getElements()[0]);
$message->setSerialization($rawMessage->getBytes());
return $message;
} | @param MessageStructure $structure
@param RawMessage $rawMessage
@return SuccessMessage | entailment |
public function convertStructureToRecordMessage(MessageStructure $structure, RawMessage $rawMessage)
{
$message = new RecordMessage($structure->getElements()[0]);
$message->setSerialization($rawMessage->getBytes());
return $message;
} | @param MessageStructure $structure
@param RawMessage $rawMessage
@return RecordMessage | entailment |
public function convertStructureToFailureMessage(MessageStructure $structure, RawMessage $rawMessage)
{
$message = new FailureMessage($structure->getElements()[0]);
$message->setSerialization($rawMessage->getBytes());
return $message;
} | @param MessageStructure $structure
@param RawMessage $rawMessage
@return FailureMessage | entailment |
public function getRequestOptions()
{
return [
\GuzzleHttp\RequestOptions::JSON => [
$this->options['json_fields'][0] => $this->options['username'],
$this->options['json_fields'][1] => $this->options['password'],
],
];
} | {@inheritdoc} | entailment |
public function unpackElement(BytesWalker $walker)
{
$marker = $walker->read(1);
$byte = hexdec(bin2hex($marker));
$ordMarker = ord($marker);
$markerHigh = $ordMarker & 0xf0;
$markerLow = $ordMarker & 0x0f;
// Structures
if (0xb0 <= $ordMarker && $ordMarker <= 0xbf) {
$walker->rewind(1);
$structureSize = $this->getStructureSize($walker);
$sig = $this->getSignature($walker);
$str = new Structure($sig, $structureSize);
$done = 0;
while ($done < $structureSize) {
$elt = $this->unpackElement($walker);
$str->addElement($elt);
++$done;
}
return $str;
}
if ($markerHigh === Constants::MAP_TINY) {
$size = $markerLow;
$map = [];
for ($i = 0; $i < $size; ++$i) {
$identifier = $this->unpackElement($walker);
$value = $this->unpackElement($walker);
$map[$identifier] = $value;
}
return $map;
}
if (Constants::MAP_8 === $byte) {
$size = $this->readUnsignedShortShort($walker);
return $this->unpackMap($size, $walker);
}
if ($byte === Constants::MAP_16) {
$size = $this->readUnsignedShort($walker);
return $this->unpackMap($size, $walker);
}
if ($markerHigh === Constants::TEXT_TINY) {
$textSize = $this->getLowNibbleValue($marker);
return $this->unpackText($textSize, $walker);
}
if ($byte === Constants::TEXT_8) {
$textSize = $this->readUnsignedShortShort($walker);
return $this->unpackText($textSize, $walker);
}
if ($byte === Constants::TEXT_16) {
$textSize = $this->readUnsignedShort($walker);
return $this->unpackText($textSize, $walker);
}
if ($byte === Constants::TEXT_32) {
$textSize = $this->readUnsignedLong($walker);
return $this->unpackText($textSize, $walker);
}
if ($byte === Constants::INT_8) {
$integer = $this->readSignedShortShort($walker);
return $this->unpackInteger($integer);
}
if ($byte === Constants::INT_16) {
$integer = $this->readSignedShort($walker);
return $this->unpackInteger($integer);
}
if ($byte === Constants::INT_32) {
$integer = $this->readSignedLong($walker);
return $this->unpackInteger($integer);
}
if ($byte === Constants::INT_64) {
$integer = $this->readSignedLongLong($walker);
return $this->unpackInteger($integer);
}
if ($markerHigh === Constants::LIST_TINY) {
$size = $this->getLowNibbleValue($marker);
return $this->unpackList($size, $walker);
}
if ($byte === Constants::LIST_8) {
$size = $this->readUnsignedShortShort($walker);
return $this->unpackList($size, $walker);
}
if ($byte === Constants::LIST_16) {
$size = $this->readUnsignedShort($walker);
return $this->unpackList($size, $walker);
}
if ($byte === Constants::LIST_32) {
$size = $this->readUnsignedLong($walker);
return $this->unpackList($size, $walker);
}
// Checks for TINY INTS
if ($this->isInRange(0x00, 0x7f, $marker) || $this->isInRange(0xf0, 0xff, $marker)) {
$walker->rewind(1);
$integer = $this->readSignedShortShort($walker);
return $this->unpackInteger($integer);
}
// Checks for floats
if ($byte === Constants::MARKER_FLOAT) {
list(, $v) = unpack('d', strrev($walker->read(8)));
return (float) $v;
}
// Checks Primitive Values NULL, TRUE, FALSE
if ($byte === Constants::MARKER_NULL) {
return;
}
if ($byte === Constants::MARKER_TRUE) {
return true;
}
if ($byte === Constants::MARKER_FALSE) {
return false;
}
throw new SerializationException(sprintf('Unable to find serialization type for marker %s', Helper::prettyHex($marker)));
} | @param \GraphAware\Bolt\PackStream\BytesWalker $walker
@return \GraphAware\Bolt\PackStream\Structure\Structure | entailment |
public function unpackNode(BytesWalker $walker)
{
$identity = $this->unpackElement($walker);
$labels = $this->unpackElement($walker);
$properties = $this->unpackElement($walker);
return new Node($identity, $labels, $properties);
} | @param BytesWalker $walker
@return Node | entailment |
public function unpackRelationship(BytesWalker $walker)
{
$identity = $this->unpackElement($walker);
$startNode = $this->unpackElement($walker);
$endNode = $this->unpackElement($walker);
$type = $this->unpackElement($walker);
$properties = $this->unpackElement($walker);
return new Relationship($identity, $startNode, $endNode, $type, $properties);
} | @param BytesWalker $walker
@return Relationship | entailment |
public function unpackMap($size, BytesWalker $walker)
{
$map = [];
for ($i = 0; $i < $size; ++$i) {
$identifier = $this->unpackElement($walker);
$value = $this->unpackElement($walker);
$map[$identifier] = $value;
}
return $map;
} | @param int $size
@param BytesWalker $walker
@return array | entailment |
public function unpackList($size, BytesWalker $walker)
{
$size = (int) $size;
$list = [];
for ($i = 0; $i < $size; ++$i) {
$list[] = $this->unpackElement($walker);
}
return $list;
} | @param int $size
@param BytesWalker $walker
@return array | entailment |
public function getStructureSize(BytesWalker $walker)
{
$marker = $walker->read(1);
// if tiny size, no more bytes to read, the size is encoded in the low nibble
if ($this->isMarkerHigh($marker, Constants::STRUCTURE_TINY)) {
return $this->getLowNibbleValue($marker);
}
} | @param BytesWalker $walker
@return int | entailment |
public function getSignature(BytesWalker $walker)
{
static $signatures = [
Constants::SIGNATURE_SUCCESS => self::SUCCESS,
Constants::SIGNATURE_FAILURE => self::FAILURE,
Constants::SIGNATURE_RECORD => self::RECORD,
Constants::SIGNATURE_IGNORE => self::IGNORED,
Constants::SIGNATURE_UNBOUND_RELATIONSHIP => 'UNBOUND_RELATIONSHIP',
Constants::SIGNATURE_NODE => 'NODE',
Constants::SIGNATURE_PATH => 'PATH',
Constants::SIGNATURE_RELATIONSHIP => 'RELATIONSHIP',
];
$sigMarker = $walker->read(1);
$ordMarker = ord($sigMarker);
return $signatures[$ordMarker];
// if (Constants::SIGNATURE_SUCCESS === $ordMarker) {
// return self::SUCCESS;
// }
//
// if ($this->isSignature(Constants::SIGNATURE_FAILURE, $sigMarker)) {
// return self::FAILURE;
// }
//
// if ($this->isSignature(Constants::SIGNATURE_RECORD, $sigMarker)) {
// return self::RECORD;
// }
//
// if ($this->isSignature(Constants::SIGNATURE_IGNORE, $sigMarker)) {
// return self::IGNORED;
// }
//
// if ($this->isSignature(Constants::SIGNATURE_UNBOUND_RELATIONSHIP, $sigMarker)) {
// return "UNBOUND_RELATIONSHIP";
// }
//
// if ($this->isSignature(Constants::SIGNATURE_NODE, $sigMarker)) {
// return "NODE";
// }
//
// if ($this->isSignature(Constants::SIGNATURE_PATH, $sigMarker)) {
// return "PATH";
// }
//
// if ($this->isSignature(Constants::SIGNATURE_RELATIONSHIP, $sigMarker)) {
// return "RELATIONSHIP";
// }
//
// throw new SerializationException(sprintf('Unable to guess the signature for byte "%s"', Helper::prettyHex($sigMarker)));
} | @param BytesWalker $walker
@return string | entailment |
public function isMarkerHigh($byte, $nibble)
{
$marker_raw = ord($byte);
$marker = $marker_raw & 0xF0;
return $marker === $nibble;
} | @param $byte
@param $nibble
@return bool | entailment |
public function readSignedShort(BytesWalker $walker)
{
list(, $v) = unpack('s', $this->correctEndianness($walker->read(2)));
return $v;
} | @param BytesWalker $walker
@return mixed | entailment |
public function readUnsignedLong(BytesWalker $walker)
{
list(, $v) = unpack('N', $walker->read(4));
return sprintf('%u', $v);
} | @param BytesWalker $walker
@return mixed | entailment |
public function readSignedLongLong(BytesWalker $walker)
{
list(, $high, $low) = unpack('N2', $walker->read(8));
return (int) bcadd($high << 32, $low, 0);
} | @param BytesWalker $walker
@return int | entailment |
public function isInRange($start, $end, $byte)
{
$range = range($start, $end);
return in_array(ord($byte), $range);
} | @param int $start
@param int $end
@param string $byte
@return mixed | entailment |
public function read_longlong(BytesWalker $walker)
{
$this->bitcount = $this->bits = 0;
list(, $hi, $lo) = unpack('N2', $walker->read(8));
$msb = self::getLongMSB($hi);
if (!$this->is64bits) {
if ($msb) {
$hi = sprintf('%u', $hi);
}
if (self::getLongMSB($lo)) {
$lo = sprintf('%u', $lo);
}
}
return bcadd($this->is64bits && !$msb ? $hi << 32 : bcmul($hi, '4294967296', 0), $lo, 0);
} | @param BytesWalker $walker
@return string | entailment |
private function correctEndianness($byteString)
{
$tmp = unpack('S', "\x01\x00");
$isLittleEndian = $tmp[1] == 1;
return $isLittleEndian ? strrev($byteString) : $byteString;
} | @param string $byteString
@return string | entailment |
public function setDate(string $date = null): Matomo
{
$this->_date = $date;
$this->_rangeStart = null;
$this->_rangeEnd = null;
return $this;
} | Set date
@param string $date Format Y-m-d or class constant:
DATE_TODAY
DATE_YESTERDAY
@return $this | entailment |
public function getRange(): string
{
if (empty($this->_rangeEnd)) {
return $this->_rangeStart;
} else {
return $this->_rangeStart . ',' . $this->_rangeEnd;
}
} | Get the date range comma separated
@return string | entailment |
public function setRange(string $rangeStart = null, string $rangeEnd = null): Matomo
{
$this->_date = '';
$this->_rangeStart = $rangeStart;
$this->_rangeEnd = $rangeEnd;
if (is_null($rangeEnd)) {
if (strpos($rangeStart, 'last') !== false || strpos($rangeStart, 'previous') !== false) {
$this->setDate($rangeStart);
} else {
$this->_rangeEnd = self::DATE_TODAY;
}
}
return $this;
} | Set date range
@param string $rangeStart e.g. 2012-02-10 (YYYY-mm-dd) or last5(lastX), previous12(previousY)...
@param string $rangeEnd e.g. 2012-02-12. Leave this parameter empty to request all data from
$rangeStart until now
@return $this | entailment |
public function reset(): Matomo
{
$this->_period = self::PERIOD_DAY;
$this->_date = '';
$this->_rangeStart = 'yesterday';
$this->_rangeEnd = null;
return $this;
} | Reset all default variables. | entailment |
private function _request(string $method, array $params = [], array $optional = [])
{
$url = $this->_parseUrl($method, $params + $optional);
if ($url === false) {
throw new InvalidRequestException('Could not parse URL!');
}
$req = Request::get($url);
$req->strict_ssl = $this->_verifySsl;
$req->max_redirects = $this->_maxRedirects;
$req->setConnectionTimeout(5);
try {
$buffer = $req->send();
} catch (ConnectionErrorException $e) {
throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e);
}
if (!empty($buffer)) {
try {
return $this->_finishResponse($this->_parseResponse($buffer), $method, $params + $optional);
} catch (InvalidResponseException $e) {
throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e);
}
}
throw new InvalidRequestException('Empty response!');
} | Make API request
@param string $method
@param array $params
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
private function _finishResponse($response, string $method, array $params)
{
$valid = $this->_isValidResponse($response);
if ($valid === true) {
if (isset($response->value)) {
return $response->value;
} else {
return $response;
}
} else {
throw new InvalidResponseException($valid . ' (' . $this->_parseUrl($method, $params) . ')');
}
} | Validate request and return the values.
@param mixed $response
@param string $method
@param array $params
@return bool|object
@throws InvalidResponseException | entailment |
private function _parseUrl(string $method, array $params = [])
{
$params = [
'module' => 'API',
'method' => $method,
'token_auth' => $this->_token,
'idSite' => $this->_siteId,
'period' => $this->_period,
'format' => $this->_format,
'language' => $this->_language,
'filter_limit' => $this->_filter_limit
] + $params;
foreach ($params as $key => $value) {
$params[$key] = urlencode($value);
}
if (!empty($this->_rangeStart) && !empty($this->_rangeEnd)) {
$params = $params + [
'date' => $this->_rangeStart . ',' . $this->_rangeEnd,
];
} elseif (!empty($this->_date)) {
$params = $params + [
'date' => $this->_date,
];
} else {
throw new InvalidArgumentException('Specify a date or a date range!');
}
$url = $this->_site;
$i = 0;
foreach ($params as $param => $val) {
if (!empty($val)) {
$i++;
if ($i > 1) {
$url .= '&';
} else {
$url .= '?';
}
if (is_array($val)) {
$val = implode(',', $val);
}
$url .= $param . '=' . $val;
}
}
return $url;
} | Create request url with parameters
@param string $method The request method
@param array $params Request params
@return string|false
@throws \InvalidArgumentException | entailment |
private function _isValidResponse($response)
{
if (is_null($response)) {
return self::ERROR_EMPTY;
}
if (!isset($response->result) or ($response->result != 'error')) {
return true;
}
return $response->message;
} | Check if the request was successfull.
@param mixed $response
@return bool|int | entailment |
private function _parseResponse(Response $response)
{
switch ($this->_format) {
case self::FORMAT_JSON:
return json_decode($response, $this->_isJsonDecodeAssoc);
break;
default:
return $response;
}
} | Parse request result
@param Response $response
@return mixed | entailment |
public function getMetadata($apiModule, $apiAction, $apiParameters = [], array $optional = [])
{
return $this->_request('API.getMetadata', [
'apiModule' => $apiModule,
'apiAction' => $apiAction,
'apiParameters' => $apiParameters,
], $optional);
} | Get metadata from the API
@param string $apiModule Module
@param string $apiAction Action
@param array $apiParameters Parameters
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getReportMetadata(
array $idSites,
$hideMetricsDoc = '',
$showSubtableReports = '',
array $optional = []
)
{
return $this->_request('API.getReportMetadata', [
'idSites' => $idSites,
'hideMetricsDoc' => $hideMetricsDoc,
'showSubtableReports' => $showSubtableReports,
], $optional);
} | Get metadata from a report
@param array $idSites Array with the ID's of the sites
@param string $hideMetricsDoc
@param string $showSubtableReports
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getProcessedReport(
$apiModule,
$apiAction,
$segment = '',
$apiParameters = '',
$idGoal = '',
$showTimer = '1',
$hideMetricsDoc = '',
array $optional = []
)
{
return $this->_request('API.getProcessedReport', [
'apiModule' => $apiModule,
'apiAction' => $apiAction,
'segment' => $segment,
'apiParameters' => $apiParameters,
'idGoal' => $idGoal,
'showTimer' => $showTimer,
'hideMetricsDoc' => $hideMetricsDoc,
], $optional);
} | Get processed report
@param string $apiModule Module
@param string $apiAction Action
@param string $segment
@param string $apiParameters
@param int|string $idGoal
@param bool|string $showTimer
@param string $hideMetricsDoc
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getRowEvolution(
$apiModule,
$apiAction,
$segment = '',
$column = '',
$idGoal = '',
$legendAppendMetric = '1',
$labelUseAbsoluteUrl = '1',
array $optional = []
)
{
return $this->_request('API.getRowEvolution', [
'apiModule' => $apiModule,
'apiAction' => $apiAction,
'segment' => $segment,
'column' => $column,
'idGoal' => $idGoal,
'legendAppendMetric' => $legendAppendMetric,
'labelUseAbsoluteUrl' => $labelUseAbsoluteUrl,
], $optional);
} | Get row evolution
@param $apiModule
@param $apiAction
@param string $segment
@param $column
@param string $idGoal
@param string $legendAppendMetric
@param string $labelUseAbsoluteUrl
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getBulkRequest($methods = [], array $optional = [])
{
$urls = [];
foreach ($methods as $key => $method) {
$urls['urls[' . $key . ']'] = urlencode('method=' . $method);
}
return $this->_request('API.getBulkRequest', $urls, $optional);
} | Get the result of multiple requests bundled together
Take as an argument an array of the API methods to send together
For example, ['API.get', 'Action.get', 'DeviceDetection.getType']
@param array $methods
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function saveAnnotation($idNote, $note = '', $starred = '', array $optional = [])
{
return $this->_request('Annotations.save', [
'idNote' => $idNote,
'note' => $note,
'starred' => $starred,
], $optional);
} | Save annotation
@param int $idNote
@param string $note
@param string $starred
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function addAlert(
$name,
$idSites,
$emailMe,
$additionalEmails,
$phoneNumbers,
$metric,
$metricCondition,
$metricValue,
$comparedTo,
$reportUniqueId,
$reportCondition = '',
$reportValue = '',
array $optional = []
)
{
return $this->_request('CustomAlerts.addAlert', [
'name' => $name,
'idSites' => $idSites,
'emailMe' => $emailMe,
'additionalEmails' => $additionalEmails,
'phoneNumbers' => $phoneNumbers,
'metric' => $metric,
'metricCondition' => $metricCondition,
'metricValue' => $metricValue,
'comparedTo' => $comparedTo,
'reportUniqueId' => $reportUniqueId,
'reportCondition' => $reportCondition,
'reportValue' => $reportValue,
], $optional);
} | Add alert
@param string $name
@param array $idSites Array of site IDs
@param int $emailMe
@param string $additionalEmails
@param string $phoneNumbers
@param string $metric
@param string $metricCondition
@param string $metricValue
@param string $comparedTo
@param string $reportUniqueId
@param string $reportCondition
@param string $reportValue
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function configureNewCustomDimension($name, $scope, $active, array $optional = [])
{
return $this->_request('CustomDimensions.configureNewCustomDimension', [
'name' => $name,
'scope' => $scope,
'active' => $active,
], $optional);
} | Configures a new Custom Dimension. Note that Custom Dimensions cannot be deleted, be careful when creating one
as you might run quickly out of available Custom Dimension slots. Requires at least Admin access for the
specified website. A current list of available `$scopes` can be fetched via the API method
`CustomDimensions.getAvailableScopes()`. This method will also contain information whether actually Custom
Dimension slots are available or whether they are all already in use.
@param string $name The name of the dimension
@param string $scope Either 'visit' or 'action'. To get an up to date list of available scopes fetch the
API method `CustomDimensions.getAvailableScopes`
@param int $active '0' if dimension should be inactive, '1' if dimension should be active
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function configureExistingCustomDimension($idDimension, $name, $active, array $optional = [])
{
return $this->_request('CustomDimensions.configureExistingCustomDimension', [
'idDimension' => $idDimension,
'name' => $name,
'active' => $active,
], $optional);
} | Updates an existing Custom Dimension. This method updates all values, you need to pass existing values of the
dimension if you do not want to reset any value. Requires at least Admin access for the specified website.
@param int $idDimension The id of a Custom Dimension.
@param string $name The name of the dimension
@param int $active '0' if dimension should be inactive, '1' if dimension should be active
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function sendFeedbackForFeature($featureName, $like, $message = '', array $optional = [])
{
return $this->_request('Feedback.sendFeedbackForFeature', [
'featureName' => $featureName,
'like' => $like,
'message' => $message,
], $optional);
} | Get a multidimensional array
@param string $featureName
@param string $like
@param string $message
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function addGoal(
$name,
$matchAttribute,
$pattern,
$patternType,
$caseSensitive = '',
$revenue = '',
$allowMultipleConversionsPerVisit = '',
array $optional = []
)
{
return $this->_request('Goals.addGoal', [
'name' => $name,
'matchAttribute' => $matchAttribute,
'pattern' => $pattern,
'patternType' => $patternType,
'caseSensitive' => $caseSensitive,
'revenue' => $revenue,
'allowMultipleConversionsPerVisit' => $allowMultipleConversionsPerVisit,
], $optional);
} | Add a goal
@param string $name
@param string $matchAttribute
@param string $pattern
@param string $patternType
@param string $caseSensitive
@param string $revenue
@param string $allowMultipleConversionsPerVisit
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function updateGoal(
$idGoal,
$name,
$matchAttribute,
$pattern,
$patternType,
$caseSensitive = '',
$revenue = '',
$allowMultipleConversionsPerVisit = '',
array $optional = []
)
{
return $this->_request('Goals.updateGoal', [
'idGoal' => $idGoal,
'name' => $name,
'matchAttribute' => $matchAttribute,
'pattern' => $pattern,
'patternType' => $patternType,
'caseSensitive' => $caseSensitive,
'revenue' => $revenue,
'allowMultipleConversionsPerVisit' => $allowMultipleConversionsPerVisit,
], $optional);
} | Update a goal
@param int $idGoal
@param string $name
@param string $matchAttribute
@param string $pattern
@param string $patternType
@param string $caseSensitive
@param string $revenue
@param string $allowMultipleConversionsPerVisit
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getGoal($segment = '', $idGoal = '', $columns = [], array $optional = [])
{
return $this->_request('Goals.get', [
'segment' => $segment,
'idGoal' => $idGoal,
'columns' => $columns,
], $optional);
} | Get conversion rates from a goal
@param string $segment
@param string $idGoal
@param array $columns
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getImageGraph(
$apiModule,
$apiAction,
$graphType = '',
$outputType = '0',
$columns = '',
$labels = '',
$showLegend = '1',
$width = '',
$height = '',
$fontSize = '9',
$legendFontSize = '',
$aliasedGraph = '1',
$idGoal = '',
$colors = [],
array $optional = []
)
{
return $this->_request('ImageGraph.get', [
'apiModule' => $apiModule,
'apiAction' => $apiAction,
'graphType' => $graphType,
'outputType' => $outputType,
'columns' => $columns,
'labels' => $labels,
'showLegend' => $showLegend,
'width' => $width,
'height' => $height,
'fontSize' => $fontSize,
'legendFontSize' => $legendFontSize,
'aliasedGraph' => $aliasedGraph,
'idGoal ' => $idGoal,
'colors' => $colors,
], $optional);
} | Generate a png report
@param string $apiModule Module
@param string $apiAction Action
@param string $graphType 'evolution', 'verticalBar', 'pie' or '3dPie'
@param string $outputType
@param string $columns
@param string $labels
@param string $showLegend
@param int|string $width
@param int|string $height
@param int|string $fontSize
@param string $legendFontSize
@param bool|string $aliasedGraph "by default, Graphs are "smooth" (anti-aliased). If you are
generating hundreds of graphs and are concerned with performance,
you can set aliasedGraph=0. This will disable anti aliasing and
graphs will be generated faster, but look less pretty."
@param string $idGoal
@param array $colors Use own colors instead of the default. The colors has to be in hexadecimal
value without '#'
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getMoversAndShakers(
$reportUniqueId,
$segment,
$comparedToXPeriods = 1,
$limitIncreaser = 4,
$limitDecreaser = 4,
array $optional = []
)
{
return $this->_request('Insights.getMoversAndShakers', [
'reportUniqueId' => $reportUniqueId,
'segment' => $segment,
'comparedToXPeriods' => $comparedToXPeriods,
'limitIncreaser' => $limitIncreaser,
'limitDecreaser' => $limitDecreaser,
], $optional);
} | Get movers and shakers
@param int $reportUniqueId
@param string $segment
@param int $comparedToXPeriods
@param int $limitIncreaser
@param int $limitDecreaser
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getInsights(
$reportUniqueId,
$segment,
$limitIncreaser = 5,
$limitDecreaser = 5,
$filterBy = '',
$minImpactPercent = 2,
$minGrowthPercent = 20,
$comparedToXPeriods = 1,
$orderBy = 'absolute',
array $optional = []
)
{
return $this->_request('Insights.getInsights', [
'reportUniqueId' => $reportUniqueId,
'segment' => $segment,
'limitIncreaser' => $limitIncreaser,
'limitDecreaser' => $limitDecreaser,
'filterBy' => $filterBy,
'minImpactPercent' => $minImpactPercent,
'minGrowthPercent' => $minGrowthPercent,
'comparedToXPeriods' => $comparedToXPeriods,
'orderBy' => $orderBy,
], $optional);
} | Get insights
@param int $reportUniqueId
@param string $segment
@param int $limitIncreaser
@param int $limitDecreaser
@param string $filterBy
@param int $minImpactPercent (0-100)
@param int $minGrowthPercent (0-100)
@param int $comparedToXPeriods
@param string $orderBy
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getLastVisitsDetails($segment = '', $minTimestamp = '', $doNotFetchActions = '', array $optional = [])
{
return $this->_request('Live.getLastVisitsDetails', [
'segment' => $segment,
'minTimestamp' => $minTimestamp,
'doNotFetchActions' => $doNotFetchActions,
], $optional);
} | Get information about the last visits
@param string $segment
@param string $minTimestamp
@param string $doNotFetchActions
@param array $optional
@return bool|object
@throws InvalidRequestException
@internal param int $maxIdVisit
@internal param int $filterLimit | entailment |
public function addReport(
$description,
$period,
$hour,
$reportType,
$reportFormat,
$reports,
$parameters,
$idSegment = '',
array $optional = []
)
{
return $this->_request('ScheduledReports.addReport', [
'description' => $description,
'period' => $period,
'hour' => $hour,
'reportType' => $reportType,
'reportFormat' => $reportFormat,
'reports' => $reports,
'parameters' => $parameters,
'idSegment' => $idSegment,
], $optional);
} | Add scheduled report
@param string $description
@param string $period
@param string $hour
@param string $reportType
@param string $reportFormat
@param array $reports
@param string $parameters
@param string $idSegment
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function updateReport(
$idReport,
$description,
$period,
$hour,
$reportType,
$reportFormat,
$reports,
$parameters,
$idSegment = '',
array $optional = []
)
{
return $this->_request('ScheduledReports.updateReport', [
'idReport' => $idReport,
'description' => $description,
'period' => $period,
'hour' => $hour,
'reportType' => $reportType,
'reportFormat' => $reportFormat,
'reports' => $reports,
'parameters' => $parameters,
'idSegment' => $idSegment,
], $optional);
} | Updated scheduled report
@param int $idReport
@param string $description
@param string $period
@param string $hour
@param string $reportType
@param string $reportFormat
@param array $reports
@param string $parameters
@param string $idSegment
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getReports(
$idReport = '',
$ifSuperUserReturnOnlySuperUserReports = '',
$idSegment = '',
array $optional = []
)
{
return $this->_request('ScheduledReports.getReports', [
'idReport' => $idReport,
'ifSuperUserReturnOnlySuperUserReports' => $ifSuperUserReturnOnlySuperUserReports,
'idSegment' => $idSegment,
], $optional);
} | Get list of scheduled reports
@param string $idReport
@param string $ifSuperUserReturnOnlySuperUserReports
@param string $idSegment
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function generateReport(
$idReport,
$language = '',
$outputType = '',
$reportFormat = '',
$parameters = '',
array $optional = []
)
{
return $this->_request('ScheduledReports.generateReport', [
'idReport' => $idReport,
'language' => $language,
'outputType' => $outputType,
'reportFormat' => $reportFormat,
'parameters' => $parameters,
], $optional);
} | Get list of scheduled reports
@param int $idReport
@param string $language
@param string $outputType
@param string $reportFormat
@param string $parameters
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function updateSegment(
$idSegment,
$name,
$definition,
$autoArchive = '',
$enableAllUsers = '',
array $optional = []
)
{
return $this->_request('SegmentEditor.update', [
'idSegment' => $idSegment,
'name' => $name,
'definition' => $definition,
'autoArchive' => $autoArchive,
'enableAllUsers' => $enableAllUsers,
], $optional);
} | Updates a segment
@param int $idSegment
@param string $name
@param string $definition
@param string $autoArchive
@param string $enableAllUsers
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function addSegment($name, $definition, $autoArchive = '', $enableAllUsers = '', array $optional = [])
{
return $this->_request('SegmentEditor.add', [
'name' => $name,
'definition' => $definition,
'autoArchive' => $autoArchive,
'enableAllUsers' => $enableAllUsers,
], $optional);
} | Updates a segment
@param string $name
@param string $definition
@param string $autoArchive
@param string $enableAllUsers
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getJavascriptTag(
$matomoUrl,
$mergeSubdomains = '',
$groupPageTitlesByDomain = '',
$mergeAliasUrls = '',
$visitorCustomVariables = '',
$pageCustomVariables = '',
$customCampaignNameQueryParam = '',
$customCampaignKeywordParam = '',
$doNotTrack = '',
$disableCookies = '',
array $optional = []
)
{
return $this->_request('SitesManager.getJavascriptTag', [
'piwikUrl' => $matomoUrl,
'mergeSubdomains' => $mergeSubdomains,
'groupPageTitlesByDomain' => $groupPageTitlesByDomain,
'mergeAliasUrls' => $mergeAliasUrls,
'visitorCustomVariables' => $visitorCustomVariables,
'pageCustomVariables' => $pageCustomVariables,
'customCampaignNameQueryParam' => $customCampaignNameQueryParam,
'customCampaignKeywordParam' => $customCampaignKeywordParam,
'doNotTrack' => $doNotTrack,
'disableCookies' => $disableCookies,
], $optional);
} | Get the JS tag of the current site
@param string $matomoUrl
@param string $mergeSubdomains
@param string $groupPageTitlesByDomain
@param string $mergeAliasUrls
@param string $visitorCustomVariables
@param string $pageCustomVariables
@param string $customCampaignNameQueryParam
@param string $customCampaignKeywordParam
@param string $doNotTrack
@param string $disableCookies
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getImageTrackingCode(
$matomoUrl,
$actionName = '',
$idGoal = '',
$revenue = '',
array $optional = []
)
{
return $this->_request('SitesManager.getImageTrackingCode', [
'piwikUrl' => $matomoUrl,
'actionName' => $actionName,
'idGoal' => $idGoal,
'revenue' => $revenue,
], $optional);
} | Get image tracking code of the current site
@param string $matomoUrl
@param string $actionName
@param string $idGoal
@param string $revenue
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function addSite(
$siteName,
$urls,
$ecommerce = '',
$siteSearch = '',
$searchKeywordParameters = '',
$searchCategoryParameters = '',
$excludeIps = '',
$excludedQueryParameters = '',
$timezone = '',
$currency = '',
$group = '',
$startDate = '',
$excludedUserAgents = '',
$keepURLFragments = '',
$settingValues = '',
$type = '',
$excludeUnknownUrls = '',
array $optional = []
)
{
return $this->_request('SitesManager.addSite', [
'siteName' => $siteName,
'urls' => $urls,
'ecommerce' => $ecommerce,
'siteSearch' => $siteSearch,
'searchKeywordParameters' => $searchKeywordParameters,
'searchCategoryParameters' => $searchCategoryParameters,
'excludeIps' => $excludeIps,
'excludedQueryParameters' => $excludedQueryParameters,
'timezone' => $timezone,
'currency' => $currency,
'group' => $group,
'startDate' => $startDate,
'excludedUserAgents' => $excludedUserAgents,
'keepURLFragments' => $keepURLFragments,
'settingValues' => $settingValues,
'type' => $type,
'excludeUnknownUrls' => $excludeUnknownUrls,
], $optional);
} | Add a website.
Requires Super User access.
The website is defined by a name and an array of URLs.
@param string $siteName Site name
@param string $urls Comma separated list of urls
@param string $ecommerce Is Ecommerce Reporting enabled for this website?
@param string $siteSearch
@param string $searchKeywordParameters Comma separated list of search keyword parameter names
@param string $searchCategoryParameters Comma separated list of search category parameter names
@param string $excludeIps Comma separated list of IPs to exclude from the reports (allows wildcards)
@param string $excludedQueryParameters
@param string $timezone Timezone string, eg. 'Europe/London'
@param string $currency Currency, eg. 'EUR'
@param string $group Website group identifier
@param string $startDate Date at which the statistics for this website will start. Defaults to today's date in YYYY-MM-DD format
@param string $excludedUserAgents
@param string $keepURLFragments If 1, URL fragments will be kept when tracking. If 2, they
will be removed. If 0, the default global behavior will be used.
@param string $settingValues JSON serialized settings eg {settingName: settingValue, ...}
@param string $type The website type, defaults to "website" if not set.
@param string $excludeUnknownUrls Track only URL matching one of website URLs
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function updateSite(
$siteName,
$urls,
$ecommerce = '',
$siteSearch = '',
$searchKeywordParameters = '',
$searchCategoryParameters = '',
$excludeIps = '',
$excludedQueryParameters = '',
$timezone = '',
$currency = '',
$group = '',
$startDate = '',
$excludedUserAgents = '',
$keepURLFragments = '',
$type = '',
$settings = '',
array $optional = []
)
{
return $this->_request('SitesManager.updateSite', [
'siteName' => $siteName,
'urls' => $urls,
'ecommerce' => $ecommerce,
'siteSearch' => $siteSearch,
'searchKeywordParameters' => $searchKeywordParameters,
'searchCategoryParameters' => $searchCategoryParameters,
'excludeIps' => $excludeIps,
'excludedQueryParameters' => $excludedQueryParameters,
'timezone' => $timezone,
'currency' => $currency,
'group' => $group,
'startDate' => $startDate,
'excludedUserAgents' => $excludedUserAgents,
'keepURLFragments' => $keepURLFragments,
'type' => $type,
'settings' => $settings,
], $optional);
} | Update current site
@param string $siteName
@param array $urls
@param bool|string $ecommerce
@param bool|string $siteSearch
@param string $searchKeywordParameters
@param string $searchCategoryParameters
@param array|string $excludeIps
@param array|string $excludedQueryParameters
@param string $timezone
@param string $currency
@param string $group
@param string $startDate
@param string $excludedUserAgents
@param string $keepURLFragments
@param string $type
@param string $settings
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getTransitionsForPageTitle($pageTitle, $segment = '', $limitBeforeGrouping = '', array $optional = [])
{
return $this->_request('Transitions.getTransitionsForPageTitle', [
'pageTitle' => $pageTitle,
'segment' => $segment,
'limitBeforeGrouping' => $limitBeforeGrouping,
], $optional);
} | Get transitions for a page title
@param $pageTitle
@param string $segment
@param string $limitBeforeGrouping
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getTransitionsForPageUrl($pageUrl, $segment = '', $limitBeforeGrouping = '', array $optional = [])
{
return $this->_request('Transitions.getTransitionsForPageTitle', [
'pageUrl' => $pageUrl,
'segment' => $segment,
'limitBeforeGrouping' => $limitBeforeGrouping,
], $optional);
} | Get transitions for a page URL
@param $pageUrl
@param string $segment
@param string $limitBeforeGrouping
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function getTransitionsForAction(
$actionName,
$actionType,
$segment = '',
$limitBeforeGrouping = '',
$parts = 'all',
$returnNormalizedUrls = '',
array $optional = []
)
{
return $this->_request('Transitions.getTransitionsForAction', [
'actionName' => $actionName,
'actionType' => $actionType,
'segment' => $segment,
'limitBeforeGrouping' => $limitBeforeGrouping,
'parts' => $parts,
'returnNormalizedUrls' => $returnNormalizedUrls,
], $optional);
} | Get transitions for a page URL
@param $actionName
@param $actionType
@param string $segment
@param string $limitBeforeGrouping
@param string $parts
@param string $returnNormalizedUrls
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function setUserPreference($userLogin, $preferenceName, $preferenceValue, array $optional = [])
{
return $this->_request('UsersManager.setUserPreference', [
'userLogin' => $userLogin,
'preferenceName' => $preferenceName,
'preferenceValue' => $preferenceValue,
], $optional);
} | Set user preference
@param string $userLogin Username
@param string $preferenceName
@param string $preferenceValue
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function addUser($userLogin, $password, $email, $alias = '', array $optional = [])
{
return $this->_request('UsersManager.addUser', [
'userLogin' => $userLogin,
'password' => $password,
'email' => $email,
'alias' => $alias,
], $optional);
} | Add a user
@param string $userLogin Username
@param string $password Password in clear text
@param string $email
@param string $alias
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
public function updateUser($userLogin, $password = '', $email = '', $alias = '', array $optional = [])
{
return $this->_request('UsersManager.updateUser', [
'userLogin' => $userLogin,
'password' => $password,
'email' => $email,
'alias' => $alias,
], $optional);
} | Update a user
@param string $userLogin Username
@param string $password Password in clear text
@param string $email
@param string $alias
@param array $optional
@return bool|object
@throws InvalidRequestException | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.