Skip to content
Permalink
Browse files

slim down feed factory public api

  • Loading branch information...
Gummibeer committed Oct 8, 2019
1 parent f75c203 commit 134469b22af40b29acc5e674b665e6f64c7f4f02
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

### Removed
- `\Astrotomic\Stancy\Factories\SitemapFactory::makeFromSheetCollection()`
- `\Astrotomic\Stancy\Factories\FeedFactory::makeFromSheetCollection()`


## [v0.1.0] - 2019-10-07
@@ -2,11 +2,7 @@
namespace Astrotomic\Stancy\Contracts;
use Spatie\Sheets\Repository as SheetRepository;
interface FeedFactory
{
public function makeFromSheetCollection(SheetRepository $collection): array;
public function makeFromSheetCollectionName(string $name): array;
}
@@ -4,10 +4,8 @@
use Astrotomic\Stancy\Contracts\FeedFactory as FeedFactoryContract;
use Illuminate\Support\Facades\Facade;
use Spatie\Sheets\Repository as SheetRepository;
/**
* @method static array makeFromSheetCollection(SheetRepository $collection)
* @method static array makeFromSheetCollectionName(string $name)
*
* @see FeedFactoryContract
@@ -19,17 +19,17 @@ public function __construct(PageFactoryContract $pageFactory)
$this->pageFactory = $pageFactory;
}
public function makeFromSheetCollection(SheetRepository $collection): array
{
return $collection->all()->map(function (Sheet $sheet): PageContract {
return $this->pageFactory->makeFromSheet($sheet);
})->all();
}
public function makeFromSheetCollectionName(string $name): array
{
$collection = Sheets::collection($name);
return $this->makeFromSheetCollection($collection);
}
protected function makeFromSheetCollection(SheetRepository $collection): array
{
return $collection->all()->map(function (Sheet $sheet): PageContract {
return $this->pageFactory->makeFromSheet($sheet);
})->all();
}
}
@@ -8,7 +8,6 @@
use Astrotomic\Stancy\Tests\TestCase;
use Carbon\Carbon;
use Spatie\Feed\Feed;
use Spatie\Sheets\Facades\Sheets;
use Spatie\Snapshots\MatchesSnapshots;
final class FeedFactoryTest extends TestCase
@@ -24,9 +23,8 @@ public function it_can_resolve_instance(): void
/** @test */
public function it_can_use_facade(): void
{
FeedFactoryFacade::shouldReceive('makeFromSheetCollection', 'makeFromSheetCollectionName');
FeedFactoryFacade::shouldReceive('makeFromSheetCollectionName');
FeedFactoryFacade::makeFromSheetCollection(Sheets::collection('blog'));
FeedFactoryFacade::makeFromSheetCollectionName('blog');
}

0 comments on commit 134469b

Please sign in to comment.
You can’t perform that action at this time.