Completed
Pull Request — master (#3825)
by Björn
19:11
created
apps/federation/lib/Middleware/AddServerMiddleware.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -34,45 +34,45 @@
 block discarded – undo
34 34
 
35 35
 class AddServerMiddleware extends Middleware {
36 36
 
37
-	/** @var  string */
38
-	protected $appName;
37
+    /** @var  string */
38
+    protected $appName;
39 39
 
40
-	/** @var  IL10N */
41
-	protected $l;
40
+    /** @var  IL10N */
41
+    protected $l;
42 42
 
43
-	/** @var  ILogger */
44
-	protected $logger;
43
+    /** @var  ILogger */
44
+    protected $logger;
45 45
 
46
-	public function __construct($appName, IL10N $l, ILogger $logger) {
47
-		$this->appName = $appName;
48
-		$this->l = $l;
49
-		$this->logger = $logger;
50
-	}
46
+    public function __construct($appName, IL10N $l, ILogger $logger) {
47
+        $this->appName = $appName;
48
+        $this->l = $l;
49
+        $this->logger = $logger;
50
+    }
51 51
 
52
-	/**
53
-	 * Log error message and return a response which can be displayed to the user
54
-	 *
55
-	 * @param \OCP\AppFramework\Controller $controller
56
-	 * @param string $methodName
57
-	 * @param \Exception $exception
58
-	 * @return JSONResponse
59
-	 */
60
-	public function afterException($controller, $methodName, \Exception $exception) {
61
-		if (($controller instanceof SettingsController) === false) {
62
-			throw $exception;
63
-		}
64
-		$this->logger->error($exception->getMessage(), ['app' => $this->appName]);
65
-		if ($exception instanceof HintException) {
66
-			$message = $exception->getHint();
67
-		} else {
68
-			$message = $exception->getMessage();
69
-		}
52
+    /**
53
+     * Log error message and return a response which can be displayed to the user
54
+     *
55
+     * @param \OCP\AppFramework\Controller $controller
56
+     * @param string $methodName
57
+     * @param \Exception $exception
58
+     * @return JSONResponse
59
+     */
60
+    public function afterException($controller, $methodName, \Exception $exception) {
61
+        if (($controller instanceof SettingsController) === false) {
62
+            throw $exception;
63
+        }
64
+        $this->logger->error($exception->getMessage(), ['app' => $this->appName]);
65
+        if ($exception instanceof HintException) {
66
+            $message = $exception->getHint();
67
+        } else {
68
+            $message = $exception->getMessage();
69
+        }
70 70
 
71
-		return new JSONResponse(
72
-			['message' => $message],
73
-			Http::STATUS_BAD_REQUEST
74
-		);
71
+        return new JSONResponse(
72
+            ['message' => $message],
73
+            Http::STATUS_BAD_REQUEST
74
+        );
75 75
 
76
-	}
76
+    }
77 77
 
78 78
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/Converter.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -30,117 +30,117 @@
 block discarded – undo
30 30
 
31 31
 class Converter {
32 32
 
33
-	/** @var AccountManager */
34
-	private $accountManager;
35
-
36
-	/**
37
-	 * Converter constructor.
38
-	 *
39
-	 * @param AccountManager $accountManager
40
-	 */
41
-	public function __construct(AccountManager $accountManager) {
42
-		$this->accountManager = $accountManager;
43
-	}
44
-
45
-	/**
46
-	 * @param IUser $user
47
-	 * @return VCard|null
48
-	 */
49
-	public function createCardFromUser(IUser $user) {
50
-
51
-		$userData = $this->accountManager->getUser($user);
52
-
53
-		$uid = $user->getUID();
54
-		$cloudId = $user->getCloudId();
55
-		$image = $this->getAvatarImage($user);
56
-
57
-		$vCard = new VCard();
58
-		$vCard->VERSION = '3.0';
59
-		$vCard->UID = $uid;
60
-
61
-		$publish = false;
62
-
63
-		foreach ($userData as $property => $value) {
64
-
65
-			$shareWithTrustedServers =
66
-				$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
67
-				$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
68
-
69
-			if ($shareWithTrustedServers && $value['value'] !== '') {
70
-				$publish = true;
71
-				switch ($property) {
72
-					case AccountManager::PROPERTY_DISPLAYNAME:
73
-						$vCard->add(new Text($vCard, 'FN', $value['value']));
74
-						$vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
75
-						break;
76
-					case AccountManager::PROPERTY_AVATAR:
77
-						if ($image !== null) {
78
-							$vCard->add('PHOTO', 'data:'.$image->mimeType().';base64,' . base64_encode($image->data()));
79
-						}
80
-						break;
81
-					case AccountManager::PROPERTY_EMAIL:
82
-						$vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
83
-						break;
84
-					case AccountManager::PROPERTY_WEBSITE:
85
-						$vCard->add(new Text($vCard, 'URL', $value['value']));
86
-						break;
87
-					case AccountManager::PROPERTY_PHONE:
88
-						$vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
89
-						break;
90
-					case AccountManager::PROPERTY_ADDRESS:
91
-						$vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
92
-						break;
93
-					case AccountManager::PROPERTY_TWITTER:
94
-						$vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
95
-						break;
96
-				}
97
-			}
98
-		}
99
-
100
-		if ($publish && !empty($cloudId)) {
101
-			$vCard->add(new Text($vCard, 'CLOUD', $cloudId));
102
-			$vCard->validate();
103
-			return $vCard;
104
-		}
105
-
106
-		return null;
107
-	}
108
-
109
-	/**
110
-	 * @param string $fullName
111
-	 * @return string[]
112
-	 */
113
-	public function splitFullName($fullName) {
114
-		// Very basic western style parsing. I'm not gonna implement
115
-		// https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
116
-
117
-		$elements = explode(' ', $fullName);
118
-		$result = ['', '', '', '', ''];
119
-		if (count($elements) > 2) {
120
-			$result[0] = implode(' ', array_slice($elements, count($elements)-1));
121
-			$result[1] = $elements[0];
122
-			$result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
123
-		} elseif (count($elements) === 2) {
124
-			$result[0] = $elements[1];
125
-			$result[1] = $elements[0];
126
-		} else {
127
-			$result[0] = $elements[0];
128
-		}
129
-
130
-		return $result;
131
-	}
132
-
133
-	/**
134
-	 * @param IUser $user
135
-	 * @return null|IImage
136
-	 */
137
-	private function getAvatarImage(IUser $user) {
138
-		try {
139
-			$image = $user->getAvatarImage(-1);
140
-			return $image;
141
-		} catch (\Exception $ex) {
142
-			return null;
143
-		}
144
-	}
33
+    /** @var AccountManager */
34
+    private $accountManager;
35
+
36
+    /**
37
+     * Converter constructor.
38
+     *
39
+     * @param AccountManager $accountManager
40
+     */
41
+    public function __construct(AccountManager $accountManager) {
42
+        $this->accountManager = $accountManager;
43
+    }
44
+
45
+    /**
46
+     * @param IUser $user
47
+     * @return VCard|null
48
+     */
49
+    public function createCardFromUser(IUser $user) {
50
+
51
+        $userData = $this->accountManager->getUser($user);
52
+
53
+        $uid = $user->getUID();
54
+        $cloudId = $user->getCloudId();
55
+        $image = $this->getAvatarImage($user);
56
+
57
+        $vCard = new VCard();
58
+        $vCard->VERSION = '3.0';
59
+        $vCard->UID = $uid;
60
+
61
+        $publish = false;
62
+
63
+        foreach ($userData as $property => $value) {
64
+
65
+            $shareWithTrustedServers =
66
+                $value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
67
+                $value['scope'] === AccountManager::VISIBILITY_PUBLIC;
68
+
69
+            if ($shareWithTrustedServers && $value['value'] !== '') {
70
+                $publish = true;
71
+                switch ($property) {
72
+                    case AccountManager::PROPERTY_DISPLAYNAME:
73
+                        $vCard->add(new Text($vCard, 'FN', $value['value']));
74
+                        $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
75
+                        break;
76
+                    case AccountManager::PROPERTY_AVATAR:
77
+                        if ($image !== null) {
78
+                            $vCard->add('PHOTO', 'data:'.$image->mimeType().';base64,' . base64_encode($image->data()));
79
+                        }
80
+                        break;
81
+                    case AccountManager::PROPERTY_EMAIL:
82
+                        $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
83
+                        break;
84
+                    case AccountManager::PROPERTY_WEBSITE:
85
+                        $vCard->add(new Text($vCard, 'URL', $value['value']));
86
+                        break;
87
+                    case AccountManager::PROPERTY_PHONE:
88
+                        $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
89
+                        break;
90
+                    case AccountManager::PROPERTY_ADDRESS:
91
+                        $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
92
+                        break;
93
+                    case AccountManager::PROPERTY_TWITTER:
94
+                        $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
95
+                        break;
96
+                }
97
+            }
98
+        }
99
+
100
+        if ($publish && !empty($cloudId)) {
101
+            $vCard->add(new Text($vCard, 'CLOUD', $cloudId));
102
+            $vCard->validate();
103
+            return $vCard;
104
+        }
105
+
106
+        return null;
107
+    }
108
+
109
+    /**
110
+     * @param string $fullName
111
+     * @return string[]
112
+     */
113
+    public function splitFullName($fullName) {
114
+        // Very basic western style parsing. I'm not gonna implement
115
+        // https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
116
+
117
+        $elements = explode(' ', $fullName);
118
+        $result = ['', '', '', '', ''];
119
+        if (count($elements) > 2) {
120
+            $result[0] = implode(' ', array_slice($elements, count($elements)-1));
121
+            $result[1] = $elements[0];
122
+            $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
123
+        } elseif (count($elements) === 2) {
124
+            $result[0] = $elements[1];
125
+            $result[1] = $elements[0];
126
+        } else {
127
+            $result[0] = $elements[0];
128
+        }
129
+
130
+        return $result;
131
+    }
132
+
133
+    /**
134
+     * @param IUser $user
135
+     * @return null|IImage
136
+     */
137
+    private function getAvatarImage(IUser $user) {
138
+        try {
139
+            $image = $user->getAvatarImage(-1);
140
+            return $image;
141
+        } catch (\Exception $ex) {
142
+            return null;
143
+        }
144
+    }
145 145
 
146 146
 }
Please login to merge, or discard this patch.