Permalink
Browse files

重構 7 式 : Extract Trait

  • Loading branch information...
1 parent 0ce3069 commit 6368f9029123319026e7cc79375863cbadba8989 Sam.IO.Hsiao committed Nov 27, 2016
Showing with 17 additions and 0 deletions.
  1. +4 −0 app/Services/AbstractLogistics.php
  2. +13 −0 app/Services/LogTrait.php
@@ -6,6 +6,8 @@
abstract class AbstractLogistics implements LogisticsInterface
{
+ use LogTrait;
+
/**
* @param array $weightArray
* @return Collection
@@ -29,6 +31,8 @@ protected function loopWeights(int $amount, Collection $weights, callable $closu
$amount = $amount + $closure($weight);
}
+ $this->writeLog($amount);
+
return $amount;
}
}
@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Services;
+
+use Log;
+
+trait LogTrait
+{
+ public function writeLog(int $amount)
+ {
+ Log::info('Amount : ' . $amount);
+ }
+}

0 comments on commit 6368f90

Please sign in to comment.