<?php

namespace PDFDraft\Core\Support\Traits;

use PDFDraft\Core\Support\HigherOrderTapProxy;

trait Tappable {

	/**
	 * Call the given Closure with this instance then return the instance.
	 *
	 * @param  callable|null $callback
	 * @return $this
	 */
	public function tap( $callback = null ) {
		if ( is_null( $callback ) ) {
			return new HigherOrderTapProxy( $this );
		}
		$callback( $this );
		return $this;
	}
}
