Skip to content

Commit

Permalink
Add new findByIpAndPort method
Browse files Browse the repository at this point in the history
  • Loading branch information
emmetog committed Jan 22, 2017
1 parent b85e4df commit 6d18607
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Emmetog/ProxyPool/Exception/ProxyNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Emmetog\ProxyPool\Exception;

/**
* Thrown when a certain proxy is requested but it doesn't exist.
*/
class ProxyNotFoundException extends \RuntimeException
{

}
38 changes: 38 additions & 0 deletions src/Emmetog/ProxyPool/Repository/ProxyRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,54 @@

use Emmetog\ProxyPool\Entity\Proxy;
use Emmetog\ProxyPool\Entity\ProxyUse;
use Emmetog\ProxyPool\Exception\ProxyNotFoundException;

interface ProxyRepositoryInterface
{
/**
* Finds all alive proxies.
*
* @return Proxy[]
*/
public function findAllAlive();

/**
* Finds a proxy by IP and port.
*
* Throws a ProxyNotFoundException if no proxy is found.
*
* @param string $ip
* @param string $port
* @return Proxy
* @throws ProxyNotFoundException when the proxy doesn't exist
*/
public function findByIpAndPort($ip, $port);

/**
* Inserts a new proxy.
*
* @param Proxy $proxy
*/
public function insertProxy(Proxy $proxy);

/**
* Records a proxy as "used" along with the result.
*
* @param ProxyUse $proxyUse
*/
public function insertUse(ProxyUse $proxyUse);

/**
* Gets the next id for a proxy.
*
* @return string
*/
public function getNextIdProxy();

/**
* Gets the next id for a proxy use.
*
* @return string
*/
public function getNextIdProxyUse();
}

0 comments on commit 6d18607

Please sign in to comment.