public function getUnits($type = null)
    {
        if (!isset($type)) {
            return $this->units;
        }

        $filtered = array();
        foreach ($this->units as $key => $value) {
            if (isset($value['type']) && $value['type'] === $type) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
public function getUnits($type = null)
    {
        if (!isset($type)) {
            return $this->units;
        }

        $filtered = array();
        foreach ($this->units as $key => $value) {
            if (isset($value['type']) && $value['type'] === $type) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
public function getUnits ( $ type = null ) { if ( ! isset ( $ type ) ) { return $ this -> units ; } $ filtered = array ( ) ; foreach ( $ this -> units as $ key => $ value ) { if ( isset ( $ value [ 'type' ] ) && $ value [ 'type' ] === $ type ) { $ filtered [ $ key ] = $ value ; } } return $ filtered ; }
Returns an array of units
@param null|string $type Filter by this type
@return array
Returns an array of units