Only improved code formatting

This commit is contained in:
Fonata
2019-02-23 12:55:10 +01:00
parent 2e94f4ad41
commit f97f03a088
15 changed files with 46 additions and 41 deletions

View File

@@ -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);
}
}

View File

@@ -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';
}

View File

@@ -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];
}

View File

@@ -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;
}