Applies a callback to a copy of all data in the collection and returns the result.

Parameters

  • callback $filter The filter to apply.
  • array $options The available options are: - `'collect'`: If `true`, the results will be returned wrapped in a new `Collection` object or subclass.

Returns

mixed The filtered items. Will be an array unless `'collect'` is defined in the `$options` argument, then an instance of this class will be returned.

Source

						public function map($filter, array $options = array()) {
		$defaults = array('collect' => true);
		$options += $defaults;
		$data = array_map($filter, $this->_data);

		if ($options['collect']) {
			$class = get_class($this);
			return new $class(compact('data'));
		}
		return $data;
	}