Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerable skus instead of Collection #25

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ namespace App\Integrations\MagentoStock;

use JustBetter\MagentoStock\Repositories\Repository;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Enumerable;

class MyStockRepository extends Repository
{
public function skus(?Carbon $from = null): ?Collection
public function skus(?Carbon $from = null): ?Enumerable
{
return collect(['sku_1', 'sku_2']);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace JustBetter\MagentoStock\Repositories;

use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Enumerable;
use JustBetter\MagentoStock\Data\StockData;

abstract class BaseRepository
Expand Down Expand Up @@ -63,8 +63,8 @@ public static function resolve(): BaseRepository
return $instance;
}

/** @return Collection<int, string> */
abstract public function skus(?Carbon $from = null): Collection;
/** @return Enumerable<int, string> */
abstract public function skus(?Carbon $from = null): Enumerable;

abstract public function retrieve(string $sku): ?StockData;
}
6 changes: 3 additions & 3 deletions src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace JustBetter\MagentoStock\Repositories;

use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Enumerable;
use JustBetter\MagentoProducts\Models\MagentoProduct;
use JustBetter\MagentoStock\Data\StockData;
use JustBetter\MagentoStock\Exceptions\NotImplementedException;
Expand All @@ -15,9 +15,9 @@ public function retrieve(string $sku): ?StockData
throw new NotImplementedException;
}

public function skus(?Carbon $from = null): Collection
public function skus(?Carbon $from = null): Enumerable
{
/** @var Collection<int, string> $skus */
/** @var Enumerable<int, string> $skus */
$skus = MagentoProduct::query()
->where('exists_in_magento', '=', true)
->select(['sku'])
Expand Down