Passed
Push — master ( fd76bf...cd270d )
by Christoph
13:45
created
apps/contactsinteraction/lib/Db/CardSearchDao.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -33,64 +33,64 @@
 block discarded – undo
33 33
 
34 34
 class CardSearchDao {
35 35
 
36
-	/** @var IDBConnection */
37
-	private $db;
36
+    /** @var IDBConnection */
37
+    private $db;
38 38
 
39
-	public function __construct(IDBConnection $db) {
40
-		$this->db = $db;
41
-	}
39
+    public function __construct(IDBConnection $db) {
40
+        $this->db = $db;
41
+    }
42 42
 
43
-	public function findExisting(IUser $user,
44
-								 ?string $uid,
45
-								 ?string $email,
46
-								 ?string $cloudId): ?string {
47
-		$addressbooksQuery = $this->db->getQueryBuilder();
48
-		$cardQuery = $this->db->getQueryBuilder();
49
-		$propQuery = $this->db->getQueryBuilder();
43
+    public function findExisting(IUser $user,
44
+                                 ?string $uid,
45
+                                 ?string $email,
46
+                                 ?string $cloudId): ?string {
47
+        $addressbooksQuery = $this->db->getQueryBuilder();
48
+        $cardQuery = $this->db->getQueryBuilder();
49
+        $propQuery = $this->db->getQueryBuilder();
50 50
 
51
-		$propOr = $propQuery->expr()->orX();
52
-		if ($uid !== null) {
53
-			$propOr->add($propQuery->expr()->andX(
54
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')),
55
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid))
56
-			));
57
-		}
58
-		if ($email !== null) {
59
-			$propOr->add($propQuery->expr()->andX(
60
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')),
61
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email))
62
-			));
63
-		}
64
-		if ($cloudId !== null) {
65
-			$propOr->add($propQuery->expr()->andX(
66
-				$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')),
67
-				$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId))
68
-			));
69
-		}
70
-		$addressbooksQuery->selectDistinct('id')
71
-			->from('addressbooks')
72
-			->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID())));
73
-		$propQuery->selectDistinct('cardid')
74
-			->from('cards_properties')
75
-			->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
76
-			->andWhere($propOr)
77
-			->groupBy('cardid');
78
-		$cardQuery->select('carddata')
79
-			->from('cards')
80
-			->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
81
-			->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
82
-			->setMaxResults(1);
83
-		$result = $cardQuery->execute();
84
-		/** @var string|resource|false $card */
85
-		$card = $result->fetchColumn(0);
51
+        $propOr = $propQuery->expr()->orX();
52
+        if ($uid !== null) {
53
+            $propOr->add($propQuery->expr()->andX(
54
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')),
55
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid))
56
+            ));
57
+        }
58
+        if ($email !== null) {
59
+            $propOr->add($propQuery->expr()->andX(
60
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')),
61
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email))
62
+            ));
63
+        }
64
+        if ($cloudId !== null) {
65
+            $propOr->add($propQuery->expr()->andX(
66
+                $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')),
67
+                $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId))
68
+            ));
69
+        }
70
+        $addressbooksQuery->selectDistinct('id')
71
+            ->from('addressbooks')
72
+            ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID())));
73
+        $propQuery->selectDistinct('cardid')
74
+            ->from('cards_properties')
75
+            ->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
76
+            ->andWhere($propOr)
77
+            ->groupBy('cardid');
78
+        $cardQuery->select('carddata')
79
+            ->from('cards')
80
+            ->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
81
+            ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
82
+            ->setMaxResults(1);
83
+        $result = $cardQuery->execute();
84
+        /** @var string|resource|false $card */
85
+        $card = $result->fetchColumn(0);
86 86
 
87
-		if ($card === false) {
88
-			return null;
89
-		}
90
-		if (is_resource($card)) {
91
-			return stream_get_contents($card);
92
-		}
87
+        if ($card === false) {
88
+            return null;
89
+        }
90
+        if (is_resource($card)) {
91
+            return stream_get_contents($card);
92
+        }
93 93
 
94
-		return $card;
95
-	}
94
+        return $card;
95
+    }
96 96
 }
Please login to merge, or discard this patch.