Skip to content

Commit

Permalink
Merge pull request #5 from vladyslavstartsev/dev.bc4
Browse files Browse the repository at this point in the history
updated package to browscap version 4
  • Loading branch information
kulbakin authored Aug 2, 2018
2 parents 66debb6 + ab8a3ec commit 532d3cb
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 45 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "^5.0,<5.7",
"browscap/browscap-php": "^3.1"
"php": ">=7.1.0,<7.3.0",
"illuminate/support": "~5.0",
"browscap/browscap-php": "~4.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion config/browscap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| Full_PHP_BrowscapINI
|
*/
'remote-file' => 'PHP_BrowscapINI',
'remote-file' => env('BROWSCAP_REMOTE_FILE', 'PHP_BrowscapINI'),

/*
|--------------------------------------------------------------------------
Expand Down
28 changes: 19 additions & 9 deletions src/BrowscapServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP;

use BrowscapPHP\Browscap;
use BrowscapPHP\BrowscapInterface;
use Doctrine\Common\Cache\FilesystemCache;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
use Roave\DoctrineSimpleCache\SimpleCacheAdapter;
use WurflCache\Adapter\File;

/**
Expand All @@ -20,7 +26,7 @@ class BrowscapServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->setupConfig();
}
Expand All @@ -30,22 +36,26 @@ public function boot()
*
* @return void
*/
public function register()
public function register(): void
{
$this->app->singleton('browscap', function () {
$bc = new Browscap();
$adapter = new File([File::DIR => config('browscap.cache')]);
$bc->setCache($adapter);
$this->app->singleton('browscap', function (ApplicationContract $app) {
$cache = new SimpleCacheAdapter(
new FilesystemCache(config('browscap.cache'))
);
$bc = new Browscap(
$cache,
$app->make('log')->driver()
);

return $bc;
});
$this->app->bind(BrowscapInterface::class, 'browscap');

if ($this->app->runningInConsole()) {
$this->commands([
Console\CheckUpdateCommand::class,
Console\ConvertCommand::class,
Console\FetchCommand::class,
Console\LogfileCommand::class,
Console\ParserCommand::class,
Console\UpdateCommand::class,
]);
Expand All @@ -57,14 +67,14 @@ public function register()
*
* @return array
*/
public function provides()
public function provides(): array
{
return ['browscap'];
}

protected function setupConfig()
{
$source = dirname(__DIR__) . '/config/browscap.php';
$source = realpath($raw = __DIR__.'/../config/browscap.php') ?: $raw;

if ($this->app instanceof LaravelApplication) {
$this->publishes([$source => config_path('browscap.php')]);
Expand Down
6 changes: 5 additions & 1 deletion src/Console/CheckUpdateCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Console;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Console;

use BrowscapPHP\Command\CheckUpdateCommand as Command;

Expand Down
6 changes: 5 additions & 1 deletion src/Console/ConvertCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Console;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Console;

use BrowscapPHP\Command\ConvertCommand as Command;

Expand Down
8 changes: 6 additions & 2 deletions src/Console/FetchCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Console;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Console;

use BrowscapPHP\Command\FetchCommand as Command;

Expand All @@ -16,7 +20,7 @@ class FetchCommand extends Command
*/
public function __construct()
{
parent::__construct(config('browscap.file'));
parent::__construct(config('browscap.cache'), config('browscap.file'));

// set default option according to config option
$this->getDefinition()->getOption('remote-file')->setDefault(config('browscap.remote-file'));
Expand Down
24 changes: 0 additions & 24 deletions src/Console/LogfileCommand.php

This file was deleted.

6 changes: 5 additions & 1 deletion src/Console/ParserCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Console;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Console;

use BrowscapPHP\Command\ParserCommand as Command;

Expand Down
6 changes: 5 additions & 1 deletion src/Console/UpdateCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Console;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Console;

use BrowscapPHP\Command\UpdateCommand as Command;

Expand Down
8 changes: 6 additions & 2 deletions src/Facades/Browscap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Propa\BrowscapPHP\Facades;
<?php

declare(strict_types=1);

namespace Propa\BrowscapPHP\Facades;

/**
* Facade for Browscap
Expand All @@ -13,7 +17,7 @@ class Browscap extends \Illuminate\Support\Facades\Facade
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'browscap';
}
Expand Down

0 comments on commit 532d3cb

Please sign in to comment.