]> git.mxchange.org Git - friendica.git/commitdiff
Changes:
authorRoland Häder <roland@mxchange.org>
Fri, 12 Aug 2022 11:08:32 +0000 (13:08 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 12 Aug 2022 11:09:59 +0000 (13:09 +0200)
- added type-hint for $type parameter
- documented method
- unsupported verbs logged

src/Factory/Api/Friendica/Activities.php

index 7b8f458b048268787b8b5863c3205182d3f7e757..102ae382d4501a49b522f0336c4fca5c2c48b523 100644 (file)
@@ -42,11 +42,16 @@ class Activities extends BaseFactory
        }
 
        /**
+        * Creates activities array from URI id, user id
+        *
         * @param int $uriId Uri-ID of the item
-        * @return Array
+        * @param int $uid User id
+        * @param string $type Type of returned activities, can be 'json' or 'xml', default: json
+        *
+        * @return array Array of found activities
         * @throws HTTPException\InternalServerErrorException
         */
-       public function createFromUriId(int $uriId, int $uid, $type = 'json'): array
+       public function createFromUriId(int $uriId, int $uid, string $type = 'json'): array
        {
                $activities = [
                        'like'        => [],
@@ -68,22 +73,29 @@ class Activities extends BaseFactory
                                case Activity::LIKE:
                                        $activities['like'][] = $user;
                                        break;
+
                                case Activity::DISLIKE:
                                        $activities['dislike'][] = $user;
                                        break;
+
                                case Activity::ATTEND:
                                        $activities['attendyes'][] = $user;
                                        break;
+
                                case Activity::ATTENDNO:
                                        $activities['attendno'][] = $user;
                                        break;
+
                                case Activity::ATTENDMAYBE:
                                        $activities['attendmaybe'][] = $user;
                                        break;
+
                                case Activity::ANNOUNCE:
                                        $activities['announce'][] = $user;
                                        break;
+
                                default:
+                                       $this->logger->warning('Unsupported verb in parent item:', ['parent_item' => $parent_item]);
                                        break;
                        }
                }
@@ -94,7 +106,7 @@ class Activities extends BaseFactory
                        $xml_activities = [];
                        foreach ($activities as $k => $v) {
                                // change xml element from "like" to "friendica:like"
-                               $xml_activities["friendica:".$k] = $v;
+                               $xml_activities['friendica:' . $k] = $v;
                                // add user data into xml output
                                $k_user = 0;
                                foreach ($v as $user) {