<?php namespace Illuminate\Cache;

use Memcached;
use RuntimeException;

class MemcachedConnector {

	/**
	 * Create a new Memcached connection.
	 *
	 * @param  array  $servers
	 * @return \Memcached
	 *
	 * @throws \RuntimeException
	 */
	public function connect(array $servers)
	{
		$memcached = $this->getMemcached();

		// For each server in the array, we'll just extract the configuration and add
		// the server to the Memcached connection. Once we have added all of these
		// servers we'll verify the connection is successful and return it back.
		foreach ($servers as $server)
		{
			$memcached->addServer(
				$server['host'], $server['port'], $server['weight']
			);
		}

		if (in_array('255.255.255', $memcached->getVersion()))
		{
			throw new RuntimeException("Could not establish connection to one or more Memcached servers.");
		}

		return $memcached;
	}

	/**
	 * Get a new Memcached instance.
	 *
	 * @return \Memcached
	 */
	protected function getMemcached()
	{
		return new Memcached;
	}

}

<?php namespace Illuminate\Cache;

use Memcached;
use RuntimeException;

class MemcachedConnector {

	/**
	 * Create a new Memcached connection.
	 *
	 * @param  array  $servers
	 * @return \Memcached
	 *
	 * @throws \RuntimeException
	 */
	public function connect(array $servers)
	{
		$memcached = $this->getMemcached();

		// For each server in the array, we'll just extract the configuration and add
		// the server to the Memcached connection. Once we have added all of these
		// servers we'll verify the connection is successful and return it back.
		foreach ($servers as $server)
		{
			$memcached->addServer(
				$server['host'], $server['port'], $server['weight']
			);
		}

		$memcachedStatus = $memcached->getVersion();

		if (!is_array($memcachedStatus))
		{
			throw new RuntimeException("No Memcached servers added.");
		}

		if (in_array('255.255.255', $memcachedStatus) AND count(array_unique($memcachedStatus)) === 1)
		{
			throw new RuntimeException("Could not establish Memcached connection.");
		}

		return $memcached;
	}

	/**
	 * Get a new Memcached instance.
	 *
	 * @return \Memcached
	 */
	protected function getMemcached()
	{
		return new Memcached;
	}

}

Handle where no servers are added.
Handle where no servers are added.

Memcached::getVersion() does return false when no servers are added. Handle this case.