HeadingRowImport.php 952 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Maatwebsite\Excel;
  3. use Maatwebsite\Excel\Concerns\Importable;
  4. use Maatwebsite\Excel\Concerns\WithLimit;
  5. use Maatwebsite\Excel\Concerns\WithMapping;
  6. use Maatwebsite\Excel\Concerns\WithStartRow;
  7. use Maatwebsite\Excel\Imports\HeadingRowFormatter;
  8. class HeadingRowImport implements WithStartRow, WithLimit, WithMapping
  9. {
  10. use Importable;
  11. /**
  12. * @var int
  13. */
  14. private $headingRow;
  15. /**
  16. * @param int $headingRow
  17. */
  18. public function __construct(int $headingRow = 1)
  19. {
  20. $this->headingRow = $headingRow;
  21. }
  22. /**
  23. * @return int
  24. */
  25. public function startRow(): int
  26. {
  27. return $this->headingRow;
  28. }
  29. /**
  30. * @return int
  31. */
  32. public function limit(): int
  33. {
  34. return 1;
  35. }
  36. /**
  37. * @param mixed $row
  38. * @return array
  39. */
  40. public function map($row): array
  41. {
  42. return HeadingRowFormatter::format($row);
  43. }
  44. }