laravel 優化順序

<?php
/**
 * Created by PhpStorm.
 * User: zhangchao
 * Date: 2017/12/14
 * Time: 14:32
 */

namespace App\Services;


class ShippingService
{

    /**
     * @param array $weightArray
     * @param LogisticsInterface $logistics
     * @return mixed
     * @data
     * if ---> switch ----> method --->  class -----> superclass  -----> interface ----> di
     *
     *
     *  外部一致, 內部變化 closure ;
     *  method ----> class :  全部的操做都是一致的, 能夠構成一個獨立的類..
     *  class  ----> superclass : 將類中相同的部分抽取成方法, 在超類中,
     *  block  ----> closure : 將相同方法中,局部不一樣的邏輯轉換爲closure;
     *  class ----> interface : 將類中必需要實現的方法定義爲接口層面的, 起到一個約束的做用, 不是必須的.
     *  interface ---> di   : 若是一個函數中調用的類都來自於一個接口,那麼這個接口能夠做爲di,
     *                        注意記得綁定相關的內容便可.
     */
    public function calculateFee(array $weightArray,  LogisticsInterface $logistics)
    {
        $amount = 0;
        return $logistics->calculateFee($weightArray,$amount);
    }

}
相關文章
相關標籤/搜索