Skip to content

Commit cfdc3a9

Browse files
committed
- Yet another code cleaning
1 parent 4ef0408 commit cfdc3a9

File tree

18 files changed

+32
-38
lines changed

18 files changed

+32
-38
lines changed

src/IPub/MobileDetect/DI/MobileDetectExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage DI
1010
* @since 1.0.0
@@ -19,7 +19,6 @@
1919
use Nette;
2020
use Nette\Bridges;
2121
use Nette\DI;
22-
use Nette\PhpGenerator as Code;
2322

2423
use Tracy;
2524

src/IPub/MobileDetect/Diagnostics/Panel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Diagnostics
1010
* @since 1.0.0

src/IPub/MobileDetect/Events/OnRequestHandler.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Events
1010
* @since 1.0.0
@@ -299,7 +299,7 @@ private function hasMobileRedirect() : bool
299299
private function needPhoneResponseModify() : bool
300300
{
301301
if (($this->deviceView->getViewType() === NULL || $this->deviceView->isPhoneView()) && $this->mobileDetect->isMobile() && !$this->mobileDetect->isTablet()) {
302-
$this->onResponseHandler->modifyResponseClosure = function ($deviceView) {
302+
$this->onResponseHandler->modifyResponseClosure = function (Helpers\DeviceView $deviceView) : Http\IResponse {
303303
return $deviceView->modifyPhoneResponse();
304304
};
305305

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

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

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

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

392392
/**
393393
* Gets the device RedirectResponse
394-
*
394+
*
395395
* @param string $device
396396
*
397-
* @return Responses\RedirectResponse
397+
* @return Responses\RedirectResponse|NULL
398398
*/
399-
private function getDeviceRedirectResponse(string $device) : Responses\RedirectResponse
399+
private function getDeviceRedirectResponse(string $device) : ?Responses\RedirectResponse
400400
{
401401
if ($host = $this->getRedirectUrl($device)) {
402402
return $this->deviceView->getMobileRedirectResponse(
403403
$host,
404404
$this->redirectConf[$device]['statusCode']
405405
);
406406
}
407+
408+
return NULL;
407409
}
408410

409411
/**
410412
* Gets the redirect url
411413
*
412414
* @param string $platform
413415
*
414-
* @return string
416+
* @return string|NULL
415417
*/
416-
private function getRedirectUrl(string $platform) : string
418+
private function getRedirectUrl(string $platform) : ?string
417419
{
418420
if ($routingOption = $this->getRoutingOption($platform)) {
419421
switch ($routingOption) {
@@ -424,6 +426,8 @@ private function getRedirectUrl(string $platform) : string
424426
return $this->redirectConf[$platform]['host'];
425427
}
426428
}
429+
430+
return NULL;
427431
}
428432

429433
/**

src/IPub/MobileDetect/Events/OnResponseHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Events
1010
* @since 1.0.0
@@ -17,7 +17,6 @@
1717
namespace IPub\MobileDetect\Events;
1818

1919
use Nette\Application;
20-
use Nette\Http;
2120

2221
use IPub\MobileDetect\Helpers\DeviceView;
2322

@@ -74,8 +73,6 @@ public function __invoke(Application\Application $application) : void
7473
if ($this->needModifyResponse && $this->modifyResponseClosure instanceof \Closure) {
7574
$modifyClosure = $this->modifyResponseClosure;
7675
$modifyClosure($this->deviceView);
77-
78-
return;
7976
}
8077
}
8178
}

src/IPub/MobileDetect/Exceptions/CompileException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Exceptions
1010
* @since 2.0.0

src/IPub/MobileDetect/Exceptions/IException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Exceptions
1010
* @since 2.0.0

src/IPub/MobileDetect/Exceptions/InvalidArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Exceptions
1010
* @since 2.0.0

src/IPub/MobileDetect/Helpers/CookieSettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Helpers
1010
* @since 1.0.0

src/IPub/MobileDetect/Helpers/DeviceView.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Helpers
1010
* @since 1.0.0
@@ -19,7 +19,6 @@
1919
use Nette;
2020
use Nette\Application;
2121
use Nette\Http;
22-
use Nette\Utils;
2322

2423
/**
2524
* Device view detector helper
@@ -194,7 +193,7 @@ public function setNotMobileView() : void
194193
*/
195194
public function getSwitchParameterName() : string
196195
{
197-
$this->switchParameterName;
196+
return $this->switchParameterName;
198197
}
199198

200199
/**

src/IPub/MobileDetect/Latte/Macros.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @copyright More in license.md
66
* @license https://www.ipublikuj.eu
7-
* @author Adam Kadlec https://www.ipublikuj.eu
7+
* @author Adam Kadlec <adam.kadlec@ipublikuj.eu>
88
* @package iPublikuj:MobileDetect!
99
* @subpackage Latte
1010
* @since 1.0.0
@@ -16,9 +16,6 @@
1616

1717
namespace IPub\MobileDetect\Latte;
1818

19-
use Nette;
20-
21-
use Latte;
2219
use Latte\Compiler;
2320
use Latte\MacroNode;
2421
use Latte\PhpWriter;

0 commit comments

Comments
 (0)