Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
- Yet another code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Mar 18, 2018
1 parent 4ef0408 commit cfdc3a9
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/IPub/MobileDetect/DI/MobileDetectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage DI
* @since 1.0.0
Expand All @@ -19,7 +19,6 @@
use Nette;
use Nette\Bridges;
use Nette\DI;
use Nette\PhpGenerator as Code;

use Tracy;

Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/Diagnostics/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Diagnostics
* @since 1.0.0
Expand Down
24 changes: 14 additions & 10 deletions src/IPub/MobileDetect/Events/OnRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Events
* @since 1.0.0
Expand Down Expand Up @@ -299,7 +299,7 @@ private function hasMobileRedirect() : bool
private function needPhoneResponseModify() : bool
{
if (($this->deviceView->getViewType() === NULL || $this->deviceView->isPhoneView()) && $this->mobileDetect->isMobile() && !$this->mobileDetect->isTablet()) {
$this->onResponseHandler->modifyResponseClosure = function ($deviceView) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) : Http\IResponse {
return $deviceView->modifyPhoneResponse();
};

Expand All @@ -317,7 +317,7 @@ private function needPhoneResponseModify() : bool
private function needTabletResponseModify() : bool
{
if (($this->deviceView->getViewType() === NULL || $this->deviceView->isTabletView()) && $this->mobileDetect->isTablet()) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) : Http\IResponse {
return $deviceView->modifyTabletResponse();
};

Expand All @@ -335,7 +335,7 @@ private function needTabletResponseModify() : bool
private function needMobileResponseModify() : bool
{
if (($this->deviceView->getViewType() === NULL || $this->deviceView->isMobileView()) && $this->mobileDetect->isMobile()) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) : Http\IResponse {
return $deviceView->modifyMobileResponse();
};

Expand All @@ -353,7 +353,7 @@ private function needMobileResponseModify() : bool
private function needNotMobileResponseModify() : bool
{
if ($this->deviceView->getViewType() === NULL || $this->deviceView->isNotMobileView()) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) {
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) : Http\IResponse {
return $deviceView->modifyNotMobileResponse();
};

Expand Down Expand Up @@ -391,29 +391,31 @@ private function getRedirectResponseBySwitchParam() : Responses\RedirectResponse

/**
* Gets the device RedirectResponse
*
*
* @param string $device
*
* @return Responses\RedirectResponse
* @return Responses\RedirectResponse|NULL
*/
private function getDeviceRedirectResponse(string $device) : Responses\RedirectResponse
private function getDeviceRedirectResponse(string $device) : ?Responses\RedirectResponse
{
if ($host = $this->getRedirectUrl($device)) {
return $this->deviceView->getMobileRedirectResponse(
$host,
$this->redirectConf[$device]['statusCode']
);
}

return NULL;
}

/**
* Gets the redirect url
*
* @param string $platform
*
* @return string
* @return string|NULL
*/
private function getRedirectUrl(string $platform) : string
private function getRedirectUrl(string $platform) : ?string
{
if ($routingOption = $this->getRoutingOption($platform)) {
switch ($routingOption) {
Expand All @@ -424,6 +426,8 @@ private function getRedirectUrl(string $platform) : string
return $this->redirectConf[$platform]['host'];
}
}

return NULL;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/IPub/MobileDetect/Events/OnResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Events
* @since 1.0.0
Expand All @@ -17,7 +17,6 @@
namespace IPub\MobileDetect\Events;

use Nette\Application;
use Nette\Http;

use IPub\MobileDetect\Helpers\DeviceView;

Expand Down Expand Up @@ -74,8 +73,6 @@ public function __invoke(Application\Application $application) : void
if ($this->needModifyResponse && $this->modifyResponseClosure instanceof \Closure) {
$modifyClosure = $this->modifyResponseClosure;
$modifyClosure($this->deviceView);

return;
}
}
}
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/Exceptions/CompileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Exceptions
* @since 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/Exceptions/IException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Exceptions
* @since 2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Exceptions
* @since 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/Helpers/CookieSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Helpers
* @since 1.0.0
Expand Down
5 changes: 2 additions & 3 deletions src/IPub/MobileDetect/Helpers/DeviceView.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Helpers
* @since 1.0.0
Expand All @@ -19,7 +19,6 @@
use Nette;
use Nette\Application;
use Nette\Http;
use Nette\Utils;

/**
* Device view detector helper
Expand Down Expand Up @@ -194,7 +193,7 @@ public function setNotMobileView() : void
*/
public function getSwitchParameterName() : string
{
$this->switchParameterName;
return $this->switchParameterName;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/IPub/MobileDetect/Latte/Macros.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Latte
* @since 1.0.0
Expand All @@ -16,9 +16,6 @@

namespace IPub\MobileDetect\Latte;

use Nette;

use Latte;
use Latte\Compiler;
use Latte\MacroNode;
use Latte\PhpWriter;
Expand Down
4 changes: 1 addition & 3 deletions src/IPub/MobileDetect/MobileDetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage common
* @since 1.0.0
Expand All @@ -16,11 +16,9 @@

namespace IPub\MobileDetect;

use Nette;
use Nette\Http;

use IPub\MobileDetect\Helpers;
use IPub\MobileDetect\Templating;

use Jenssegers\Agent;

Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/TMobileDetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage common
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MobileDetect/Templating/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Templating
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/MobileDetect/DeviceViewTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Tests
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/MobileDetect/ExtensionTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Tests
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/MobileDetect/MobileDetectTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Tests
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/MobileDetect/TemplateTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Tests
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/MobileDetect/libs/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright More in license.md
* @license https://www.ipublikuj.eu
* @author Adam Kadlec https://www.ipublikuj.eu
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
* @package iPublikuj:MobileDetect!
* @subpackage Tests
* @since 2.1.1
Expand Down

0 comments on commit cfdc3a9

Please sign in to comment.