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

}

猜你喜欢

转载自my.oschina.net/u/1579560/blog/1589842
今日推荐