Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimGee authored and github-actions[bot] committed May 30, 2023
1 parent f879f7d commit 138a9a7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion config/bytepoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// config for FlixtechsLabs/Bytepoint
return [
'token' => env('BYTEPOINT_TOKEN', 'Mg.XeviY1dxjW7zrgUGoIKf4aWkCJ7gsnh5mY-7U10hOMAp363A_mAnumdkyJnP'),
'url' => env('BYTEPOINT_URL', 'https://bytepoint.flixtechs.co.zw/api/v1/images')
'url' => env('BYTEPOINT_URL', 'https://bytepoint.flixtechs.co.zw/api/v1/images'),
];
14 changes: 2 additions & 12 deletions src/Bytepoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ class Bytepoint
{
/**
* Send image to bytepoint and retrieve optimized image
*
* @param string $source
* @param string $destination
* @param string $fileName
* @param array $options
* @return void
*/
public function optimize(string $source, string $destination, string $fileName = '', array $options = []): void
{
$options = array_merge([
'type' => 'jpeg'
'type' => 'jpeg',
], $options);

$response = Http::attach('image', file_get_contents($source), $fileName ?: 'image')
->withToken(config('bytepoint.token'))
->acceptJson()
->post(config('bytepoint.url'), [
'type' => $options['type']
'type' => $options['type'],
]);

if ($response->successful()) {
Expand All @@ -39,10 +33,6 @@ public function optimize(string $source, string $destination, string $fileName =

/**
* Optimize uploaded file
*
* @param UploadedFile $file
* @param array $options
* @return void
*/
public function optimizeUploadedFile(UploadedFile $file, array $options = []): void
{
Expand Down
6 changes: 3 additions & 3 deletions src/BytepointServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace FlixtechsLabs\Bytepoint;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use FlixtechsLabs\Bytepoint\Commands\BytepointCommand;
use Illuminate\Http\UploadedFile;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class BytepointServiceProvider extends PackageServiceProvider
{
Expand All @@ -29,7 +29,7 @@ public function boot(): void
parent::boot();

UploadedFile::macro('bytepoint', function (array $options = []) {
app(Bytepoint::class)->optimizeUploadedFile($this, $options);
app(Bytepoint::class)->optimizeUploadedFile($this, $options);

return new UploadedFile(
$this->getRealPath(),
Expand Down
18 changes: 5 additions & 13 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
<?php

use FlixtechsLabs\Bytepoint\Bytepoint;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Benchmark;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage;


it('can test', function () {
expect(true)->toBeTrue();
});

it('can optimize uploaded file', function () {
$file = new UploadedFile(__DIR__ . '/test.jpg', 'test.jpg', null, null, true);
$file = new UploadedFile(__DIR__.'/test.jpg', 'test.jpg', null, null, true);

$size = $file->getSize();
$type = $file->getMimeType();
$size = $file->getSize();
$type = $file->getMimeType();

$file = $file->bytepoint(['type' => 'webp']);
$file = $file->bytepoint(['type' => 'webp']);

dd($size, $type, $file->getSize(), $file->getMimeType());
dd($size, $type, $file->getSize(), $file->getMimeType());
});
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace FlixtechsLabs\Bytepoint\Tests;

use FlixtechsLabs\Bytepoint\BytepointServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use FlixtechsLabs\Bytepoint\BytepointServiceProvider;

class TestCase extends Orchestra
{
Expand Down

0 comments on commit 138a9a7

Please sign in to comment.