mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Only improved code formatting
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace ParseCsv\enums;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
abstract class AbstractEnum {
|
||||
|
||||
/**
|
||||
* Creates a new value of some type
|
||||
*
|
||||
@@ -11,15 +11,14 @@ abstract class AbstractEnum {
|
||||
*
|
||||
* @throws \UnexpectedValueException if incompatible type is given.
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
public function __construct($value) {
|
||||
if (!$this->isValid($value)) {
|
||||
throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class());
|
||||
}
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public static function getConstants(){
|
||||
public static function getConstants() {
|
||||
$class = get_called_class();
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
@@ -33,8 +32,7 @@ abstract class AbstractEnum {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValid($value)
|
||||
{
|
||||
public static function isValid($value) {
|
||||
return in_array($value, static::getConstants(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class FileProcessingModeEnum {
|
||||
const MODE_FILE_OVERWRITE = false;
|
||||
|
||||
public static function getAppendMode($mode) {
|
||||
if ($mode == self::MODE_FILE_APPEND){
|
||||
if ($mode == self::MODE_FILE_APPEND) {
|
||||
return 'ab';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace ParseCsv\enums;
|
||||
|
||||
|
||||
class SortEnum extends AbstractEnum {
|
||||
|
||||
const __DEFAULT = self::SORT_TYPE_REGULAR;
|
||||
|
||||
const SORT_TYPE_REGULAR = 'regular';
|
||||
@@ -14,11 +16,11 @@ class SortEnum extends AbstractEnum {
|
||||
private static $sorting = array(
|
||||
self::SORT_TYPE_REGULAR => SORT_REGULAR,
|
||||
self::SORT_TYPE_STRING => SORT_STRING,
|
||||
self::SORT_TYPE_NUMERIC => SORT_NUMERIC
|
||||
self::SORT_TYPE_NUMERIC => SORT_NUMERIC,
|
||||
);
|
||||
|
||||
public static function getSorting($type){
|
||||
if (array_key_exists($type, self::$sorting)){
|
||||
public static function getSorting($type) {
|
||||
if (array_key_exists($type, self::$sorting)) {
|
||||
return self::$sorting[$type];
|
||||
}
|
||||
|
||||
|
||||
@@ -80,19 +80,19 @@ trait DatatypeTrait {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function autoDetectFileHasHeading(){
|
||||
if (empty($this->data)){
|
||||
public function autoDetectFileHasHeading() {
|
||||
if (empty($this->data)) {
|
||||
throw new \UnexpectedValueException('No data set yet.');
|
||||
}
|
||||
|
||||
if ($this->heading){
|
||||
if ($this->heading) {
|
||||
$firstRow = $this->titles;
|
||||
} else {
|
||||
$firstRow = $this->data[0];
|
||||
}
|
||||
|
||||
$firstRow = array_filter($firstRow);
|
||||
if (empty($firstRow)){
|
||||
if (empty($firstRow)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user