public function addCollector($collector, $name = null, array $params = null) {
		// Collector instance
		if ($collector instanceof CollectorInterface) {
			if ($name === null) {
				$class = get_class($collector);
				$name  = substr($class, strrpos($class, '\\') + 1);
			}
		}
		// String definition
		else if (is_string($collector)) {
			if ($name === null) {
				$name = $collector;
			}

			$collector = $this->loadCollector($collector, $params);
		}
		// Array definition
		else if (is_array($collector)) {
			$type = isset($collector['type']) ? $collector['type'] : $collector[0];

			// Define a name
			switch (true) {
				case $name !== null:
					break;

				case isset($collector['name']):
					$name = $collector['name'];
					break;

				case count($collector) > 2:
					$name = $collector[1];
					break;

				default:
					$name = $type;
			}

			// Define a params
			switch (true) {
				case isset($collector['params']):
					$collectorParams = $collector['params'];
					break;

				case count($collector) > 2:
					$collectorParams = $collector[2];
					break;

				default:
					$collectorParams = $collector[1];
			}

			if ($params !== null) {
				$collectorParams += $params;
			}

			$collector = $this->loadCollector($type, $collectorParams);
		}
		
		// Name collision handling
		while (isset($this->collectors[$name])) {
			if (preg_match('/[0-9]+$/', $name, $matches)) {
				$name = preg_replace_callback('/([0-9]+)$/', function($match) {
					return ((int) $match[1]) + 1;
				}, $name);
			} else {
				$name .= 2;
			}
		}
		
		if ($collector !== null) {
			$this->collectors[$name] = $collector;
		}
		
		return $collector;
	}
public function addCollector($collector, $name = null, array $params = null) {
		// Collector instance
		if ($collector instanceof CollectorInterface) {
			if ($name === null) {
				$class = get_class($collector);
				$name  = substr($class, strrpos($class, '\\') + 1);
			}
		}
		// String definition
		else if (is_string($collector)) {
			if ($name === null) {
				$name = $collector;
			}

			$collector = $this->loadCollector($collector, $params);
		}
		// Array definition
		else if (is_array($collector)) {
			$type = isset($collector['type']) ? $collector['type'] : $collector[0];

			// Define a name
			switch (true) {
				case $name !== null:
					break;

				case isset($collector['name']):
					$name = $collector['name'];
					break;

				case count($collector) > 2:
					$name = $collector[1];
					break;

				default:
					$name = $type;
			}

			// Define a params
			switch (true) {
				case isset($collector['params']):
					$collectorParams = $collector['params'];
					break;

				case count($collector) > 2:
					$collectorParams = $collector[2];
					break;

				default:
					$collectorParams = $collector[1];
			}

			if ($params !== null) {
				$collectorParams += $params;
			}

			$collector = $this->loadCollector($type, $collectorParams);
		}
		
		// Name collision handling
		while (isset($this->collectors[$name])) {
			if (preg_match('/[0-9]+$/', $name, $matches)) {
				$name = preg_replace_callback('/([0-9]+)$/', function($match) {
					return ((int) $match[1]) + 1;
				}, $name);
			} else {
				$name .= 2;
			}
		}
		
		if ($collector !== null) {
			$this->collectors[$name] = $collector;
		}
		
		return $collector;
	}
public function addCollector ( $ collector , $ name = null , array $ params = null ) { // Collector instance if ( $ collector instanceof CollectorInterface ) { if ( $ name === null ) { $ class = get_class ( $ collector ) ; $ name = substr ( $ class , strrpos ( $ class , '\\' ) + 1 ) ; } } // String definition else if ( is_string ( $ collector ) ) { if ( $ name === null ) { $ name = $ collector ; } $ collector = $ this -> loadCollector ( $ collector , $ params ) ; } // Array definition else if ( is_array ( $ collector ) ) { $ type = isset ( $ collector [ 'type' ] ) ? $ collector [ 'type' ] : $ collector [ 0 ] ; // Define a name switch ( true ) { case $ name !== null : break ; case isset ( $ collector [ 'name' ] ) : $ name = $ collector [ 'name' ] ; break ; case count ( $ collector ) > 2 : $ name = $ collector [ 1 ] ; break ; default : $ name = $ type ; } // Define a params switch ( true ) { case isset ( $ collector [ 'params' ] ) : $ collectorParams = $ collector [ 'params' ] ; break ; case count ( $ collector ) > 2 : $ collectorParams = $ collector [ 2 ] ; break ; default : $ collectorParams = $ collector [ 1 ] ; } if ( $ params !== null ) { $ collectorParams += $ params ; } $ collector = $ this -> loadCollector ( $ type , $ collectorParams ) ; } // Name collision handling while ( isset ( $ this -> collectors [ $ name ] ) ) { if ( preg_match ( '/[0-9]+$/' , $ name , $ matches ) ) { $ name = preg_replace_callback ( '/([0-9]+)$/' , function ( $ match ) { return ( ( int ) $ match [ 1 ] ) + 1 ; } , $ name ) ; } else { $ name .= 2 ; } } if ( $ collector !== null ) { $ this -> collectors [ $ name ] = $ collector ; } return $ collector ; }
Add the collector

@param  CollectorInterface | string $collector
@param  string                      $name
@param  array                       $params

@return CollectorInterface
Add the collector