MxRecord   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A query() 0 10 2
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * Mail
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
namespace OCA\Mail\Service\AutoConfig;
22
23
use OCA\Mail\Service\Logger;
24
25
class MxRecord {
26
27
	/**
28
	 * @var Logger
29
	 */
30
	private $logger;
31
32
	/**
33
	 * @param Logger $logger
34
	 */
35
	public function __construct(Logger $logger) {
36
		$this->logger = $logger;
37
	}
38
39
	/**
40
	 * @param $host
41
	 * @return bool|array
42
	 */
43
	public function query($host) {
44
		if (getmxrr($host, $mx_records, $mx_weight) === false) {
45
			$this->logger->debug("no MX records for host <$host> found");
46
			return false;
47
		}
48
		$this->logger->debug("found " . count($mx_records) . " MX records for host <$host>");
49
50
		// TODO: sort by weight
51
		return $mx_records;
52
	}
53
54
}
55