Skip to content

Commit

Permalink
Update Rokka client & small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Seeow committed Feb 17, 2023
1 parent 38c39bf commit 57a989d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor
/vendor
/composer.lock
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 0.5.0
- Update Rokka client to 1.19.0
- Update Rokka client cli to 1.9.10
- Removed support for PHP 7

## Version 0.4.3
- Added Laravel 9.0 compatibility

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"homepage": "https://github.com/rokka-io/rokka-laravel",
"keywords": ["Laravel", "Rokka", "image", "resizing"],
"require": {
"php": "^8.0",
"illuminate/support": "^5|^6|^7|^8|^9",
"rokka/client": "^1.8",
"rokka/client-cli": "^1.7"
"rokka/client": "^1.19.0",
"rokka/client-cli": "^1.9.10"
},
"autoload": {
"files": [
Expand Down
10 changes: 6 additions & 4 deletions src/Facades/Rokka.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
namespace Rokka\RokkaLaravel\Facades;

use Illuminate\Support\Facades\Facade;
use Rokka\Client\Image;
use Rokka\Client\User;
use Rokka\RokkaLaravel\RokkaLaravelServiceProvider;

/**
* @see https://rokka.io/client-php-api/master/Rokka/Client/TemplateHelper.html
*
* @method static string getOrganization() Get the organization name.
* @method static string getPublicRokkaDomain(string $org = null) Get the public Rokka domain.
* @method static \Rokka\Client\Image images() Returns an instance of the Rokka image client
* @method static \Rokka\Client\User manage() Returns an instance of the Rokka user management client.
* @method static string getPublicRokkaDomain(?string $org = null) Get the public Rokka domain.
* @method static Image images() Returns an instance of the Rokka image client
* @method static User manage() Returns an instance of the Rokka user management client.
*/
class Rokka extends Facade
{
Expand All @@ -20,7 +22,7 @@ class Rokka extends Facade
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return RokkaLaravelServiceProvider::ALIAS;
}
Expand Down
59 changes: 22 additions & 37 deletions src/RokkaLaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,27 @@
namespace Rokka\RokkaLaravel;

use InvalidArgumentException;
use Rokka\Client\Image;
use Rokka\Client\TemplateHelper;
use Rokka\Client\Factory as RokkaClientFactory;
use Rokka\Client\User;

/**
* Class RokkaLaravel
* @package Rokka\RokkaLaravel
*/
class RokkaLaravel
{
/**
* @var string
*/
protected $organization;

/**
* @var string
*/
protected $apiKey;

/**
* @var array
*/
protected $requestOptions;
protected string $organization;
protected string $apiKey;
protected array $requestOptions;
protected string $publicRokkaDomain;
protected TemplateHelper $templateHelper;

/**
* @var string
*/
protected $publicRokkaDomain;

/**
* @var TemplateHelper
*/
protected $templateHelper;

/**
* RokkaLaravel constructor.
* @param string $env
*/
public function __construct($env = 'default')
public function __construct(string $env = 'default')
{
$config = config('rokka', false);
if (!$config) {
Expand Down Expand Up @@ -72,25 +54,28 @@ public function __construct($env = 'default')
* Forward all other method calls to an instance of Rokka\Client\TemplateHelper
*
* @see https://rokka.io/client-php-api/master/Rokka/Client/TemplateHelper.html
* @param $methodName
* @param $arguments
* @param string $methodName
* @param array $arguments
* @return mixed
*/
public function __call($methodName, $arguments)
public function __call(string $methodName, array $arguments): mixed
{
return call_user_func_array([$this->templateHelper, $methodName], $arguments);
}

public function getOrganization()
/**
* @return string
*/
public function getOrganization(): string
{
return $this->organization;
}

/**
* @param null $org
* @return null|string
* @param string|null $org
* @return string|null
*/
public function getPublicRokkaDomain($org = null)
public function getPublicRokkaDomain(?string $org = null): ?string
{
if (!$org) {
return $this->publicRokkaDomain;
Expand All @@ -103,9 +88,9 @@ public function getPublicRokkaDomain($org = null)
* Returns an instance of the Rokka image
*
* @see https://rokka.io/client-php-api/master/Rokka/Client/Image.html
* @return \Rokka\Client\Image
* @return Image
*/
public function images()
public function images(): Image
{
return RokkaClientFactory::getImageClient($this->organization, $this->apiKey, $this->requestOptions);
}
Expand All @@ -114,9 +99,9 @@ public function images()
* Returns an instance of the Rokka user management client
*
* @see https://rokka.io/client-php-api/master/Rokka/Client/User.html
* @return \Rokka\Client\User
* @return User
*/
public function manage()
public function manage(): User
{
return RokkaClientFactory::getUserClient($this->organization, $this->apiKey, $this->requestOptions);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RokkaLaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

class RokkaLaravelServiceProvider extends ServiceProvider
{
const ALIAS = 'rokka';
public const ALIAS = 'rokka';

/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
public function boot(): void
{
// Publishing is only necessary when using the CLI.
if ($this->app->runningInConsole()) {
Expand All @@ -29,7 +29,7 @@ public function boot()
*
* @return void
*/
public function register()
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/rokka.php', 'rokka');

Expand All @@ -44,7 +44,7 @@ public function register()
*
* @return array
*/
public function provides()
public function provides(): array
{
return [self::ALIAS];
}
Expand Down

0 comments on commit 57a989d

Please sign in to comment.