diff --git a/src/CachingStrategies/BaseCachingStrategy.php b/src/CachingStrategies/BaseCachingStrategy.php deleted file mode 100644 index 5f6b25a..0000000 --- a/src/CachingStrategies/BaseCachingStrategy.php +++ /dev/null @@ -1,15 +0,0 @@ -driftManager ->configs() ->firstWhere('name', $configName); @@ -28,8 +34,8 @@ public function __invoke( 'Config not found', ); - /** @var \Flowframe\Drift\CachingStrategies\BaseCachingStrategy $cachingStrategy */ - $cachingStrategy = app($config->cachingStrategy); + /** @var \Flowframe\Drift\Contracts\CachingStrategy $cachingStrategy */ + $cachingStrategy = new $config->cachingStrategy(); if ($cachingStrategy->validate($path, $signature, $config)) { $cachedImage = $cachingStrategy->resolve($path, $signature, $config); @@ -51,10 +57,7 @@ public function __invoke( Storage::disk($config->filesystemDisk)->get($path), ); - /** @var \Flowframe\Drift\ManipulationsTransformer $transformer */ - $transformer = app(ManipulationsTransformer::class); - - foreach ($transformer->decode($manipulations) as $method => $arguments) { + foreach ($this->manipulationsTransformer->decode($manipulations) as $method => $arguments) { is_array($arguments) ? $image->{$method}(...$arguments) : $image->{$method}($arguments); diff --git a/src/UrlBuilder.php b/src/UrlBuilder.php index 1d54823..8eba8c5 100644 --- a/src/UrlBuilder.php +++ b/src/UrlBuilder.php @@ -6,13 +6,18 @@ class UrlBuilder { + public function __construct( + public ManipulationsTransformer $manipulationsTransformer, + ) { + } + public function url(string $configName, string $path, array $manipulations = []): string { if (! isset($manipulations['encode'])) { $manipulations['encode'] = 'webp'; } - $encodedManipulations = app(ManipulationsTransformer::class)->encode($manipulations); + $encodedManipulations = $this->manipulationsTransformer->encode($manipulations); return URL::signedRoute('__images.manipulate', [ $configName,