Completed
Push — master ( 5b5cdc...a6b764 )
by Sam
02:28
created

ConnectionQuery::hasConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Jalle19\StatusManager\Database;
4
5
use Jalle19\StatusManager\Database\Base\ConnectionQuery as BaseConnectionQuery;
6
use Jalle19\tvheadend\model\ConnectionStatus;
7
8
/**
9
 * @package   Jalle19\StatusManager\Database
10
 * @copyright Copyright &copy; Sam Stenvall 2015-
11
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
12
 */
13
class ConnectionQuery extends BaseConnectionQuery
14
{
15
16
	/**
17
	 * @param string           $instanceName
18
	 * @param ConnectionStatus $connectionStatus
19
	 *
20
	 * @return bool whether the connection exists in the database
21
	 */
22
	public function hasConnection($instanceName, ConnectionStatus $connectionStatus)
23
	{
24
		return $this->filterByInstanceName($instanceName)
25
		            ->filterByPeer($connectionStatus->peer)
26
		            ->filterByStarted($connectionStatus->started)
27
		            ->findOne() !== null;
28
	}
29
30
}
31