Skip to content

Commit 6d18607

Browse files
committed
Add new findByIpAndPort method
1 parent b85e4df commit 6d18607

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Emmetog\ProxyPool\Exception;
4+
5+
/**
6+
* Thrown when a certain proxy is requested but it doesn't exist.
7+
*/
8+
class ProxyNotFoundException extends \RuntimeException
9+
{
10+
11+
}

src/Emmetog/ProxyPool/Repository/ProxyRepositoryInterface.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,54 @@
44

55
use Emmetog\ProxyPool\Entity\Proxy;
66
use Emmetog\ProxyPool\Entity\ProxyUse;
7+
use Emmetog\ProxyPool\Exception\ProxyNotFoundException;
78

89
interface ProxyRepositoryInterface
910
{
11+
/**
12+
* Finds all alive proxies.
13+
*
14+
* @return Proxy[]
15+
*/
1016
public function findAllAlive();
1117

18+
/**
19+
* Finds a proxy by IP and port.
20+
*
21+
* Throws a ProxyNotFoundException if no proxy is found.
22+
*
23+
* @param string $ip
24+
* @param string $port
25+
* @return Proxy
26+
* @throws ProxyNotFoundException when the proxy doesn't exist
27+
*/
28+
public function findByIpAndPort($ip, $port);
29+
30+
/**
31+
* Inserts a new proxy.
32+
*
33+
* @param Proxy $proxy
34+
*/
1235
public function insertProxy(Proxy $proxy);
1336

37+
/**
38+
* Records a proxy as "used" along with the result.
39+
*
40+
* @param ProxyUse $proxyUse
41+
*/
1442
public function insertUse(ProxyUse $proxyUse);
1543

44+
/**
45+
* Gets the next id for a proxy.
46+
*
47+
* @return string
48+
*/
1649
public function getNextIdProxy();
1750

51+
/**
52+
* Gets the next id for a proxy use.
53+
*
54+
* @return string
55+
*/
1856
public function getNextIdProxyUse();
1957
}

0 commit comments

Comments
 (0)