]> git.mxchange.org Git - friendica.git/blob - src/Model/Profile.php
Merge pull request #4036 from MrPetovan/task/3878-move-objects-to-model
[friendica.git] / src / Model / Profile.php
1 <?php
2
3 /**
4  * @file src/Model/Profile.php
5  */
6
7 namespace Friendica\Model;
8
9 class Profile
10 {
11         /**
12          * @brief Returns a formatted location string from the given profile array
13          *
14          * @param array $profile Profile array (Generated from the "profile" table)
15          *
16          * @return string Location string
17          */
18         public static function formatLocation(array $profile)
19         {
20                 $location = '';
21
22                 if ($profile['locality']) {
23                         $location .= $profile['locality'];
24                 }
25
26                 if ($profile['region'] && ($profile['locality'] != $profile['region'])) {
27                         if ($location) {
28                                 $location .= ', ';
29                         }
30
31                         $location .= $profile['region'];
32                 }
33
34                 if ($profile['country-name']) {
35                         if ($location) {
36                                 $location .= ', ';
37                         }
38
39                         $location .= $profile['country-name'];
40                 }
41
42                 return $location;
43         }
44 }