Skip to content

Commit

Permalink
Add pint.json, reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
tansautn committed Oct 14, 2024
1 parent 9568d60 commit 81e96f1
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 148 deletions.
79 changes: 40 additions & 39 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
{
"name": "zuko/flex2cell",
"description": "A flexible and efficient library for exporting data to Excel (XLS, XLSX) with support for mappings, formatters, and handling large datasets. Working with less dependencies, avoid future breaks & conclusions.",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Zuko\\Flex2Cell\\": "src/"
},
"files": [
"src/aliases.php"
]
"name" : "zuko/flex2cell",
"description" : "A flexible and efficient library for exporting data to Excel (XLS, XLSX) with support for mappings, formatters, and handling large datasets. Working with less dependencies, avoid future breaks & conclusions.",
"type" : "library",
"license" : "MIT",
"autoload" : {
"psr-4" : {
"Zuko\\Flex2Cell\\" : "src/"
},
"authors": [
{
"name": "Zuko",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^7.0|^8.0",
"phpoffice/phpspreadsheet": "^1.29"
},
"require-dev": {
"laravel/pint": "^1.18"
},
"extra": {
"laravel": {
"providers": [
"Zuko\\Flex2Cell\\Flex2CellServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"support": {
"issues": "https://github.com/ultra-bugs/flex2cell/issues",
"source": "https://github.com/ultra-bugs/flex2cell"
"files" : [
"src/aliases.php"
]
},
"authors" : [
{
"name" : "Zuko",
"email" : "[email protected]"
}
],
"minimum-stability" : "stable",
"prefer-stable" : true,
"require" : {
"php" : ">=7.0 <9",
"phpoffice/phpspreadsheet" : "^1.29",
"ext-ctype" : "*"
},
"require-dev" : {
"laravel/pint" : "^1.18"
},
"extra" : {
"laravel" : {
"providers" : [
"Zuko\\Flex2Cell\\Flex2CellServiceProvider"
]
}
},
"config" : {
"sort-packages" : true
},
"support" : {
"issues" : "https://github.com/ultra-bugs/flex2cell/issues",
"source" : "https://github.com/ultra-bugs/flex2cell"
}
}
14 changes: 14 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"preset": "laravel",
"rules": {
"simplified_null_return": false,
"no_superfluous_phpdoc_tags": {
"allow_mixed" : true,
"remove_inheritdoc" : false
},
"new_with_braces": {
"anonymous_class": false,
"named_class": false
}
}
}
20 changes: 12 additions & 8 deletions src/ExcelExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ class ExcelExporter
use ExcelExportable {
export as private exportExcel;
}
public static function make()
{
return new static;
}

/**
* @param array|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection $data
* @param string $filename
* @param array $options
* @param string $filename
* @param array $options
*
* @return mixed
*/
public static function export($data, $filename, array $options = [])
Expand Down Expand Up @@ -89,14 +86,21 @@ public static function export($data, $filename, array $options = [])
// 'E' => ['field' => 'category.name']
// ])
// ->export('export.xlsx');

return static::make()
->setData($data)
->setHeaders($options['headers'] ?? array_keys(first($data)))
->setMapping($options['mapping'] ?? array_combine(array_keys(first($data)), array_keys(first($data))))
->setMapping($options['mapping']
??
array_combine(array_keys(first($data)),
array_keys(first($data))))
->setFormatters($options['formatters'] ?? [])
->setColumnMergeRules($options['columnMergeRules'] ?? [])
->setRowMergeRules($options['rowMergeRules'] ?? [])
->exportExcel($filename);
}

public static function make()
{
return new static;
}
}
4 changes: 1 addition & 3 deletions src/Flex2CellServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ public function register()
});
}

public function boot()
{
}
public function boot() {}
}
Loading

0 comments on commit 81e96f1

Please sign in to comment.