123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace Maatwebsite\Excel\Tests\Data\Stubs;
- use Illuminate\Support\Collection;
- use Maatwebsite\Excel\Concerns\Exportable;
- use Maatwebsite\Excel\Concerns\FromCollection;
- use Maatwebsite\Excel\Concerns\RegistersEventListeners;
- use Maatwebsite\Excel\Concerns\ShouldAutoSize;
- use Maatwebsite\Excel\Concerns\WithEvents;
- use Maatwebsite\Excel\Concerns\WithTitle;
- use Maatwebsite\Excel\Events\BeforeWriting;
- use Maatwebsite\Excel\Tests\TestCase;
- use Maatwebsite\Excel\Writer;
- class SheetWith100Rows implements FromCollection, WithTitle, ShouldAutoSize, WithEvents
- {
- use Exportable, RegistersEventListeners;
- /**
- * @var string
- */
- private $title;
- /**
- * @param string $title
- */
- public function __construct(string $title)
- {
- $this->title = $title;
- }
- /**
- * @return Collection
- */
- public function collection()
- {
- $collection = new Collection;
- for ($i = 0; $i < 100; $i++) {
- $row = new Collection();
- for ($j = 0; $j < 5; $j++) {
- $row[] = $this->title() . '-' . $i . '-' . $j;
- }
- $collection->push($row);
- }
- return $collection;
- }
- /**
- * @return string
- */
- public function title(): string
- {
- return $this->title;
- }
- /**
- * @param BeforeWriting $event
- */
- public static function beforeWriting(BeforeWriting $event)
- {
- TestCase::assertInstanceOf(Writer::class, $event->writer);
- }
- }
|