Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Dec 1, 2016
1 parent bd6de82 commit bbe7a5c
Show file tree
Hide file tree
Showing 40 changed files with 171 additions and 138 deletions.
2 changes: 1 addition & 1 deletion src/Data/Repositories/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private function getObjectName($event)
/**
* Get the system class id by object name.
*
* @param $objectName
* @param null|string $objectName
*
* @return null
*/
Expand Down
6 changes: 6 additions & 0 deletions src/Data/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public function getId()
return $this->getAttribute('id');
}

/**
* @param string $attribute
*/
public function getAttribute($attribute)
{
return $this->result ? $this->result->{$attribute} : null;
Expand All @@ -105,6 +108,9 @@ public function save()
return $this->result->save();
}

/**
* @param string[] $keys
*/
public function findOrCreate($attributes, $keys = null, &$created = false, $otherModel = null)
{
list($model, $cacheKey) = $this->cache->findCached($attributes, $keys, $this->className);
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Repositories/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ private function regenerateSystemSession($data = null)
return $this->sessionInfo;
}

/**
* @param string $variable
*/
private function getSessionData($variable = null)
{
$data = $this->session->get($this->getSessionKey());
Expand Down
10 changes: 9 additions & 1 deletion src/Data/RepositoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Routing\Router as IlluminateRouter;
use Illuminate\Session\Store as IlluminateSession;
use PragmaRX\Support\Config;
use PragmaRX\Support\GeoIp\GeoIp;
use PragmaRX\Tracker\Data\Repositories\Agent;
use PragmaRX\Tracker\Data\Repositories\Connection;
use PragmaRX\Tracker\Data\Repositories\Cookie;
Expand Down Expand Up @@ -143,6 +142,9 @@ class RepositoryManager implements RepositoryManagerInterface
*/
private $languageDetect;

/**
* @param \PragmaRX\Tracker\Support\UserAgentParser|null $userAgentParser
*/
public function __construct(
GeoIP $geoIp,
MobileDetect $mobileDetect,
Expand Down Expand Up @@ -522,6 +524,9 @@ private function getRouteAction($route)
return $route->currentRouteAction();
}

/**
* @param string $name
*/
private function getRouteId($name, $action)
{
return $this->routeRepository->findOrCreate(
Expand Down Expand Up @@ -558,6 +563,9 @@ private function getRouteName($route)
return '/'.$route->current()->getUri();
}

/**
* @param boolean $created
*/
private function getRoutePath($route_id, $path, &$created = null)
{
return $this->routePathRepository->findOrCreate(
Expand Down
5 changes: 4 additions & 1 deletion src/Support/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function extractKeys($attributes, $keys)
}

/**
* @param $key
* @param string $key
*
* @return array
*/
Expand All @@ -82,6 +82,9 @@ public function makeKeyAndPut($model, $key)
$this->cachePut($key, $model);
}

/**
* @param string $identifier
*/
public function findCached($attributes, $keys, $identifier = null)
{
if (!$this->config->get('cache_enabled')) {
Expand Down
13 changes: 7 additions & 6 deletions src/Support/RefererParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(Parser $parser)
/**
* Parse a referer.
*
* @return mixed
* @return RefererParser
*/
public function parse($refererUrl, $pageUrl)
{
Expand All @@ -45,7 +45,7 @@ public function parse($refererUrl, $pageUrl)
/**
* Get the search medium.
*
* @return mixed
* @return string|null
*/
public function getMedium()
{
Expand All @@ -57,7 +57,7 @@ public function getMedium()
/**
* Get the search source.
*
* @return mixed
* @return string|null
*/
public function getSource()
{
Expand All @@ -69,7 +69,7 @@ public function getSource()
/**
* Get the search term.
*
* @return mixed
* @return string|null
*/
public function getSearchTerm()
{
Expand All @@ -81,7 +81,7 @@ public function getSearchTerm()
/**
* Check if the referer is knwon.
*
* @return mixed
* @return boolean
*/
public function isKnown()
{
Expand All @@ -91,7 +91,8 @@ public function isKnown()
/**
* Set the referer.
*
* @return mixed
* @param \Snowplow\RefererParser\Referer $referer
* @return RefererParser
*/
public function setReferer($referer)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public function getUserId()
: null;
}

/**
* @param \Exception $exception
*/
public function handleException($exception)
{
if ($this->config->get('log_enabled')) {
Expand Down
105 changes: 54 additions & 51 deletions src/Vendor/Laravel/Controllers/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function index(Session $session)
return $this->showPage($session, $session->getValue('page'));
}

/**
* @param Session $session
*/
public function showPage($session, $page)
{
$me = $this;
Expand Down Expand Up @@ -105,30 +108,30 @@ public function apiLog($uuid)
$query = Tracker::sessionLog($uuid, false);

$query->select([
'id',
'session_id',
'method',
'path_id',
'query_id',
'route_path_id',
'is_ajax',
'is_secure',
'is_json',
'wants_json',
'error_id',
'updated_at',
]);
'id',
'session_id',
'method',
'path_id',
'query_id',
'route_path_id',
'is_ajax',
'is_secure',
'is_json',
'wants_json',
'error_id',
'updated_at',
]);

return Datatables::of($query)
->edit_column('route_name', function ($row) {
->edit_column('route_name', function($row) {
$path = $row->routePath;

return $row->routePath
? $row->routePath->route->name.'<br>'.$row->routePath->route->action
: ($row->path ? $row->path->path : '');
})

->edit_column('route', function ($row) {
->edit_column('route', function($row) {
$route = null;

if ($row->routePath) {
Expand All @@ -140,7 +143,7 @@ public function apiLog($uuid)
return $route;
})

->edit_column('query', function ($row) {
->edit_column('query', function($row) {
$query = null;

if ($row->logQuery) {
Expand All @@ -152,23 +155,23 @@ public function apiLog($uuid)
return $query;
})

->edit_column('is_ajax', function ($row) {
->edit_column('is_ajax', function($row) {
return $row->is_ajax ? 'yes' : '';
})

->edit_column('is_secure', function ($row) {
->edit_column('is_secure', function($row) {
return $row->is_secure ? 'yes' : '';
})

->edit_column('is_json', function ($row) {
->edit_column('is_json', function($row) {
return $row->is_json ? 'yes' : '';
})

->edit_column('wants_json', function ($row) {
->edit_column('wants_json', function($row) {
return $row->wants_json ? 'yes' : '';
})

->edit_column('error', function ($row) {
->edit_column('error', function($row) {
return $row->error ? 'yes' : '';
})

Expand Down Expand Up @@ -202,15 +205,15 @@ public function apiErrors(Session $session)
$query = Tracker::errors($session->getMinutes(), false);

$query->select([
'id',
'error_id',
'session_id',
'path_id',
'updated_at',
]);
'id',
'error_id',
'session_id',
'path_id',
'updated_at',
]);

return Datatables::of($query)
->edit_column('updated_at', function ($row) {
->edit_column('updated_at', function($row) {
return "{$row->updated_at->diffForHumans()}";
})
->make(true);
Expand All @@ -228,10 +231,10 @@ public function apiUsers(Session $session)
$username_column = Tracker::getConfig('authenticated_user_username_column');

return Datatables::of(Tracker::users($session->getMinutes(), false))
->edit_column('user_id', function ($row) use ($username_column) {
->edit_column('user_id', function($row) use ($username_column) {
return "{$row->user->$username_column}";
})
->edit_column('updated_at', function ($row) {
->edit_column('updated_at', function($row) {
return "{$row->updated_at->diffForHumans()}";
})
->make(true);
Expand All @@ -244,28 +247,28 @@ public function apiVisits(Session $session)
$query = Tracker::sessions($session->getMinutes(), false);

$query->select([
'id',
'uuid',
'user_id',
'device_id',
'agent_id',
'client_ip',
'referer_id',
'cookie_id',
'geoip_id',
'language_id',
'is_robot',
'updated_at',
'id',
'uuid',
'user_id',
'device_id',
'agent_id',
'client_ip',
'referer_id',
'cookie_id',
'geoip_id',
'language_id',
'is_robot',
'updated_at',
]);

return Datatables::of($query)
->edit_column('id', function ($row) use ($username_column) {
->edit_column('id', function($row) use ($username_column) {
$uri = route('tracker.stats.log', $row->uuid);

return '<a href="'.$uri.'">'.$row->id.'</a>';
})

->add_column('country', function ($row) {
->add_column('country', function($row) {
$cityName = $row->geoip && $row->geoip->city ? ' - '.$row->geoip->city : '';

$countryName = ($row->geoip ? $row->geoip->country_name : '').$cityName;
Expand All @@ -279,11 +282,11 @@ public function apiVisits(Session $session)
return "$flag $countryName";
})

->add_column('user', function ($row) use ($username_column) {
->add_column('user', function($row) use ($username_column) {
return $row->user ? $row->user->$username_column : 'guest';
})

->add_column('device', function ($row) use ($username_column) {
->add_column('device', function($row) use ($username_column) {
$model = ($row->device && $row->device->model && $row->device->model !== 'unavailable' ? '['.$row->device->model.']' : '');

$platform = ($row->device && $row->device->platform ? ' ['.trim($row->device->platform.' '.$row->device->platform_version).']' : '');
Expand All @@ -295,27 +298,27 @@ public function apiVisits(Session $session)
: '';
})

->add_column('browser', function ($row) use ($username_column) {
->add_column('browser', function($row) use ($username_column) {
return $row->agent && $row->agent
? $row->agent->browser.' ('.$row->agent->browser_version.')'
: '';
})

->add_column('language', function ($row) use ($username_column) {
->add_column('language', function($row) use ($username_column) {
return $row->language && $row->language
? $row->language->preference
: '';
})

->add_column('referer', function ($row) use ($username_column) {
->add_column('referer', function($row) use ($username_column) {
return $row->referer ? $row->referer->domain->name : '';
})

->add_column('pageViews', function ($row) use ($username_column) {
->add_column('pageViews', function($row) use ($username_column) {
return $row->page_views;
})

->add_column('lastActivity', function ($row) use ($username_column) {
->add_column('lastActivity', function($row) use ($username_column) {
return $row->updated_at->diffForHumans();
})

Expand Down
Loading

0 comments on commit bbe7a5c

Please sign in to comment.