Transport\Entity\Transportations::reduceTransportationsDec PHP Method

reduceTransportationsDec() public static method

public static reduceTransportationsDec ( $transportations = [], $limit = 16 )
    public static function reduceTransportationsDec($transportations = [], $limit = 16)
    {
        if (in_array('all', $transportations)) {
            $dec = pow(2, $limit) - 1;
        } else {
            $map = self::$transportationBits;
            $dec = array_reduce($transportations, function ($aggr, $val) use($map) {
                return $aggr + $map[$val];
            }, 0);
        }
        return $dec;
    }

Usage Example

Example #1
0
 public function toArray()
 {
     return ['performLocating' => '2', 'tpl' => 'stop2json', 'look_maxno' => $this->limit, 'look_stopclass' => Transportations::reduceTransportationsDec($this->transportations, 10), 'look_maxdist' => 5000, 'look_y' => Coordinate::floatToInt($this->lat), 'look_x' => Coordinate::floatToInt($this->lon)];
 }