RobBrazier/Laravel_Piwik

View on GitHub
src/RobBrazier/Piwik/Module/UserCountryModule.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace RobBrazier\Piwik\Module;

/**
 * Class UserCountryModule.
 *
 * @see https://developer.matomo.org/api-reference/reporting-api#UserCountry for arguments
 */
class UserCountryModule extends Module
{
    /**
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getCountry($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }

    /**
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getContinent($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }

    /**
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getRegion($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }

    /**
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getCity($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }

    /**
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getCountryCodeMapping($format = null)
    {
        $options = $this->getOptions($format)
            ->useSiteId(false)
            ->usePeriod(false);

        return $this->request->send($options);
    }

    /**
     * @param string             $ip        The IP to search for a location from
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getLocationFromIP($ip, $arguments = [], $format = null)
    {
        $arguments += ['ip' => $ip];
        $options = $this->getOptions($format)
            ->useSiteId(false)
            ->usePeriod(false)
            ->setArguments($arguments);

        return $this->request->send($options);
    }

    /**
     * @param array[string]mixed $arguments extra arguments to be passed to the api call
     * @param string             $format    override format (defaults to one specified in config file)
     *
     * @return mixed
     */
    public function getNumberOfDistinctCountries($arguments = [], $format = null)
    {
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }
}