Skip to content

Commit

Permalink
Fix deprecated array helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmuscnielsen committed Sep 30, 2019
1 parent dbb2154 commit bba1147
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ matrix:
- php: 7.3
env: LARAVEL='5.7.*' PHPUNIT='7.5.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2
env: LARAVEL='6.*' PHPUNIT='8.*' COMPOSER_FLAGS='--prefer-lowest'
env: LARAVEL='6.*' PHPUNIT='^8.3' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='6.*' PHPUNIT='8.*' COMPOSER_FLAGS='--prefer-stable'
env: LARAVEL='6.*' PHPUNIT='^8.3' COMPOSER_FLAGS='--prefer-stable'
- php: 7.3
env: LARAVEL='6.*' PHPUNIT='8.*' COMPOSER_FLAGS='--prefer-lowest'
env: LARAVEL='6.*' PHPUNIT='^8.3' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.3
env: LARAVEL='6.*' PHPUNIT='8.*' COMPOSER_FLAGS='--prefer-stable'
env: LARAVEL='6.*' PHPUNIT='^8.3' COMPOSER_FLAGS='--prefer-stable'

before_install:
- travis_retry composer self-update
Expand Down
5 changes: 3 additions & 2 deletions src/Console/Commands/GeneratePlaceholders.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Makeable\CloudImages\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Makeable\CloudImages\Image;

Expand Down Expand Up @@ -65,8 +66,8 @@ protected function maybeUpgrade(Image $image)
$headers = array_change_key_case(get_headers($original, true));

$image->size = $headers['content-length'];
$image->width = array_get($dim = getimagesize($original), 0);
$image->height = array_get($dim, 1);
$image->width = Arr::get($dim = getimagesize($original), 0);
$image->height = Arr::get($dim, 1);

$this->comment("Upgraded image {$image->id} - fetched dimensions");
}
Expand Down
4 changes: 2 additions & 2 deletions src/HasDimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getDimensions()
*/
public function getHeight()
{
return array_get($this->getDimensions(), 1);
return Arr::get($this->getDimensions(), 1);
}

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getNormalizedDimensions($originalWidth, $originalHeight)
*/
public function getWidth()
{
return array_get($this->getDimensions(), 0);
return Arr::get($this->getDimensions(), 0);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\File;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
use Makeable\CloudImages\Contracts\ResponsiveImage;
use Makeable\CloudImages\Jobs\DeleteCloudImage;

Expand Down Expand Up @@ -65,8 +66,8 @@ public static function upload($file, $path = null, $visibility = null)
'path' => $uploaded->path,
'url' => $uploaded->url,
'size' => $file->getSize(),
'width' => array_get($dim = getimagesize($file), 0),
'height' => array_get($dim, 1),
'width' => Arr::get($dim = getimagesize($file), 0),
'height' => Arr::get($dim, 1),
]);

if (config('cloud-images.read_exif')) {
Expand Down
4 changes: 2 additions & 2 deletions src/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function get()
}, ['sizing' => [], 'extra' => []]);

// No sizing transformation has been applied (scale, crop etc)
if (count(array_get($options, 'sizing', [])) === 0) {
if (count(Arr::get($options, 'sizing', [])) === 0) {
// No dimensions has been set whatsoever
if (count($this->getDimensions()) === 0) {
return $this->original()->get();
Expand Down Expand Up @@ -231,7 +231,7 @@ protected function transform(Closure $transformation)
*/
protected function addExtraOption($value, $options)
{
$options['extra'] = array_merge(array_get($options, 'extra', []), Arr::wrap($value));
$options['extra'] = array_merge(Arr::get($options, 'extra', []), Arr::wrap($value));

return $options;
}
Expand Down
3 changes: 2 additions & 1 deletion src/ResponsiveImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Makeable\CloudImages;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use JsonSerializable;
use Makeable\CloudImages\Contracts\DimensionCalculator;
Expand Down Expand Up @@ -121,7 +122,7 @@ public function toArray()
return [
'src' => $this->getSrc(),
'srcset' => $this->getSrcset(),
'width' => array_get($this->getDimensions(), 0),
'width' => Arr::get($this->getDimensions(), 0),
];
}

Expand Down
3 changes: 2 additions & 1 deletion src/TinyPlaceholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Makeable\CloudImages;

use Illuminate\Support\Arr;
use Makeable\CloudImages\Contracts\ResponsiveImage;
use Makeable\CloudImages\Contracts\ResponsiveImageVersion;

Expand Down Expand Up @@ -67,6 +68,6 @@ public function get()
*/
public function getDisplayWidth()
{
return array_get($this->factory()->getNormalizedDimensions(...$this->image->getDimensions()), 0);
return Arr::get($this->factory()->getNormalizedDimensions(...$this->image->getDimensions()), 0);
}
}
5 changes: 3 additions & 2 deletions tests/Feature/ResponsiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\File;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Makeable\CloudImages\Image;
use Makeable\CloudImages\ImageFactory;
use Makeable\CloudImages\Tests\TestCase;
Expand Down Expand Up @@ -51,11 +52,11 @@ public function it_applies_transformations_across_versions()

$full = $versions->first();
$this->assertEquals([500, 300], $full->getDimensions());
$this->assertEquals('n-w500-h300-fv', str_after($full->get(), '='));
$this->assertEquals('n-w500-h300-fv', Str::after($full->get(), '='));

$smallest = $versions->last();
$this->assertEquals([143, 85], $smallest->getDimensions());
$this->assertEquals('n-w143-h85-fv', str_after($smallest->get(), '='));
$this->assertEquals('n-w143-h85-fv', Str::after($smallest->get(), '='));
}

/** @test **/
Expand Down

0 comments on commit bba1147

Please sign in to comment.