--- /dev/null
+<?php
+
+namespace Friendica\Collection\Api\Mastodon;
+
+use Friendica\Api\Entity\Mastodon\Field;
+use Friendica\BaseCollection;
+
+class Fields extends BaseCollection
+{
+ /**
+ * @param Field[] $entities
+ * @param int|null $totalCount
+ */
+ public function __construct(array $entities = [], int $totalCount = null)
+ {
+ parent::__construct($entities);
+
+ $this->totalCount = $totalCount ?? count($entities);
+ }
+}
return self::$dice->create(Factory\Api\Mastodon\Emoji::class);
}
+ /**
+ * @return Factory\Api\Mastodon\Field
+ */
+ public static function mstdnField()
+ {
+ return self::$dice->create(Factory\Api\Mastodon\Field::class);
+ }
+
/**
* @return Factory\Api\Mastodon\FollowRequest
*/
--- /dev/null
+<?php
+
+namespace Friendica\Factory\Api\Mastodon;
+
+use Friendica\BaseFactory;
+use Friendica\Collection\Api\Mastodon\Fields;
+use Friendica\Collection\ProfileFields;
+use Friendica\Content\Text\BBCode;
+use Friendica\Model\ProfileField;
+use Friendica\Network\HTTPException;
+
+class Field extends BaseFactory
+{
+ /**
+ * @param ProfileField $profileField
+ * @return \Friendica\Api\Entity\Mastodon\Field
+ * @throws HTTPException\InternalServerErrorException
+ */
+ public function createFromProfileField(ProfileField $profileField)
+ {
+ return new \Friendica\Api\Entity\Mastodon\Field($profileField->label, BBCode::convert($profileField->value, false, 9));
+ }
+
+ /**
+ * @param ProfileFields $profileFields
+ * @return Fields
+ * @throws HTTPException\InternalServerErrorException
+ */
+ public function createFromProfileFields(ProfileFields $profileFields)
+ {
+ $fields = [];
+
+ foreach ($profileFields as $profileField) {
+ $fields[] = $this->createFromProfileField($profileField);
+ }
+
+ return new Fields($fields);
+ }
+}
/**
* Class Field
*
- * @see https://docs.joinmastodon.org/api/entities/#field
+ * @see https://docs.joinmastodon.org/entities/field/
*/
class Field extends BaseEntity
{
protected $value;
/** @var string (Datetime)*/
protected $verified_at;
+
+ public function __construct(string $name, string $value)
+ {
+ $this->name = $name;
+ $this->value = $value;
+ // Link verification unsupported
+ $this->verified_at = null;
+ }
}