@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | {
|
| 8 | 8 | private $filesystem; |
| 9 | 9 | |
| 10 | - public function __construct($app, Filesystem $file=null) |
|
| 10 | + public function __construct($app, Filesystem $file = null) |
|
| 11 | 11 | {
|
| 12 | 12 | parent::__construct($app); |
| 13 | 13 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public function register() |
| 17 | 17 | {
|
| 18 | 18 | foreach ($this->filesystem->allFiles(__DIR__ . '/Helpers') as $rec) {
|
| 19 | - if (preg_match("/\.php$/",$rec->getFilename())) {
|
|
| 19 | + if (preg_match("/\.php$/", $rec->getFilename())) {
|
|
| 20 | 20 | require_once($rec->getPathname()); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $rec->children = []; |
| 26 | 26 | $tree[$rec->id] = $rec; |
| 27 | 27 | } else {
|
| 28 | - $this->addTree($tree,$rec); |
|
| 28 | + $this->addTree($tree, $rec); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | $this->tree = $tree; |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | protected function addTree(&$tree, $data) |
| 34 | 34 | {
|
| 35 | 35 | foreach ($tree as $id => &$rec) {
|
| 36 | - if ( $data->parent_id == $id ) {
|
|
| 36 | + if ($data->parent_id == $id) {
|
|
| 37 | 37 | $data->children = []; |
| 38 | 38 | $rec->children[$data->id] = $data; |
| 39 | 39 | return; |
| 40 | 40 | } elseif (count($rec->children)) {
|
| 41 | - $this->addTree($rec->children,$data); |
|
| 41 | + $this->addTree($rec->children, $data); |
|
| 42 | 42 | } |
| 43 | 43 | unset($rec); |
| 44 | 44 | } |
@@ -19,8 +19,12 @@ discard block |
||
| 19 | 19 | $tree = isset($this->tree) ? $this->tree : []; |
| 20 | 20 | |
| 21 | 21 | foreach ($data as $rec) {
|
| 22 | - if (is_object($rec) === false) throw new Exception('data record must be object.');
|
|
| 23 | - if (isset($rec->id) === false) throw new Exception('data record object does not have property => "id".');
|
|
| 22 | + if (is_object($rec) === false) {
|
|
| 23 | + throw new Exception('data record must be object.');
|
|
| 24 | + } |
|
| 25 | + if (isset($rec->id) === false) {
|
|
| 26 | + throw new Exception('data record object does not have property => "id".');
|
|
| 27 | + } |
|
| 24 | 28 | if (isset($rec->parent_id) === false || ! $rec->parent_id) {
|
| 25 | 29 | $rec->children = []; |
| 26 | 30 | $tree[$rec->id] = $rec; |
@@ -48,9 +52,15 @@ discard block |
||
| 48 | 52 | $tree = isset($this->tree) ? $this->tree : []; |
| 49 | 53 | foreach ($tree as &$rec) {
|
| 50 | 54 | foreach ($count_data as $count) {
|
| 51 | - if (isset($rec->id) === false) throw new Exception('data record object does not have property => "id".');
|
|
| 52 | - if (isset($count->id) === false) throw new Exception('count data record object does not have property => "id".');
|
|
| 53 | - if (isset($count->count) === false) throw new Exception('count data record object does not have property => "count".');
|
|
| 55 | + if (isset($rec->id) === false) {
|
|
| 56 | + throw new Exception('data record object does not have property => "id".');
|
|
| 57 | + } |
|
| 58 | + if (isset($count->id) === false) {
|
|
| 59 | + throw new Exception('count data record object does not have property => "id".');
|
|
| 60 | + } |
|
| 61 | + if (isset($count->count) === false) {
|
|
| 62 | + throw new Exception('count data record object does not have property => "count".');
|
|
| 63 | + } |
|
| 54 | 64 | if ($rec->id == $count->id) {
|
| 55 | 65 | $rec->count = $count->count; |
| 56 | 66 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | { |
| 6 | 6 | abstract public function csvRecord(array $record); |
| 7 | 7 | |
| 8 | - public function csvRead($file,$delimiter=",",$envlosure='"',$escape="\\",$length=1024*1024) |
|
| 8 | + public function csvRead($file, $delimiter = ",", $envlosure = '"', $escape = "\\", $length = 1024*1024) |
|
| 9 | 9 | { |
| 10 | - if (($fp = @fopen($file,"r")) !== false) { |
|
| 10 | + if (($fp = @fopen($file, "r")) !== false) { |
|
| 11 | 11 | |
| 12 | - while(($data = fgetcsv($fp,$length,$delimiter,$envlosure,$escape)) !== false) { |
|
| 12 | + while (($data = fgetcsv($fp, $length, $delimiter, $envlosure, $escape)) !== false) { |
|
| 13 | 13 | $this->csvRecord($data); |
| 14 | 14 | } |
| 15 | 15 | fclose($fp); |
@@ -2,28 +2,28 @@ |
||
| 2 | 2 | use Carbon\Carbon; |
| 3 | 3 | |
| 4 | 4 | if ( ! function_exists('strtodate')) {
|
| 5 | - function strtodate($date,$format='Y/m/d') |
|
| 5 | + function strtodate($date, $format = 'Y/m/d') |
|
| 6 | 6 | {
|
| 7 | 7 | if ($date) {
|
| 8 | - return date($format,strtotime($date)); |
|
| 8 | + return date($format, strtotime($date)); |
|
| 9 | 9 | } |
| 10 | 10 | return null; |
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( ! function_exists('ym') ) {
|
|
| 14 | +if ( ! function_exists('ym')) {
|
|
| 15 | 15 | function ym($ym) |
| 16 | 16 | {
|
| 17 | 17 | if ($ym && $ym > 190001) {
|
| 18 | - return (floor($ym/100)) . '年' . ( floor($ym%100)) . '月'; |
|
| 18 | + return (floor($ym/100)) . '年' . (floor($ym%100)) . '月'; |
|
| 19 | 19 | } |
| 20 | 20 | return null; |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -if ( ! function_exists('elapse_days') ) {
|
|
| 24 | +if ( ! function_exists('elapse_days')) {
|
|
| 25 | 25 | function elapse_days($timestamp) |
| 26 | 26 | {
|
| 27 | - return Carbon::createFromTimeStamp($timestamp)->diffInDays(Carbon::now(),false); |
|
| 27 | + return Carbon::createFromTimeStamp($timestamp)->diffInDays(Carbon::now(), false); |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | $str = ''; |
| 8 | 8 | |
| 9 | 9 | foreach ($args as $rec) {
|
| 10 | - if ( $rec ) {
|
|
| 10 | + if ($rec) {
|
|
| 11 | 11 | $str .= $rec; |
| 12 | 12 | } else {
|
| 13 | 13 | return null; |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! function_exists('numeric_format') ) {
|
|
| 3 | +if ( ! function_exists('numeric_format')) {
|
|
| 4 | 4 | function numeric_format($val) |
| 5 | 5 | {
|
| 6 | - $number = str_replace(",","",$val);
|
|
| 6 | + $number = str_replace(",", "", $val);
|
|
| 7 | 7 | |
| 8 | 8 | if (is_numeric($number)) {
|
| 9 | - $number = number_format($number,8); |
|
| 10 | - $number = preg_replace('/\.0+$/','',$number);
|
|
| 11 | - $number = preg_replace('/(\.[0-9]*?)0+$/',"$1",$number);
|
|
| 9 | + $number = number_format($number, 8); |
|
| 10 | + $number = preg_replace('/\.0+$/', '', $number);
|
|
| 11 | + $number = preg_replace('/(\.[0-9]*?)0+$/', "$1", $number);
|
|
| 12 | 12 | } |
| 13 | 13 | return $number; |
| 14 | 14 | } |