236 lines
4.6 KiB
PHP
236 lines
4.6 KiB
PHP
<?php
|
|
namespace ContentNation\ActivityPub\Response;
|
|
|
|
class Instance {
|
|
/**
|
|
* Service URI
|
|
* @var string
|
|
*/
|
|
private $uri = '';
|
|
|
|
/**
|
|
* Service title
|
|
* @var string
|
|
*/
|
|
private $title = '';
|
|
|
|
/**
|
|
* Short description
|
|
* @var string
|
|
*/
|
|
private $shortDescription = '';
|
|
|
|
/**
|
|
* Long description
|
|
* @var string
|
|
*/
|
|
private $description = '';
|
|
|
|
/**
|
|
* E-Mail
|
|
* @var string
|
|
*/
|
|
private $email = '';
|
|
|
|
/**
|
|
* Version
|
|
* @var string
|
|
*/
|
|
private $version = '';
|
|
|
|
/**
|
|
* Thumbnail URL
|
|
* @var string
|
|
*/
|
|
private $thumbnail = '';
|
|
|
|
/**
|
|
* Is registration allowed
|
|
* @var bool
|
|
*/
|
|
private $registration = false;
|
|
|
|
/**
|
|
* Is approval required
|
|
* @var bool
|
|
*/
|
|
private $approval = false;
|
|
|
|
/**
|
|
* Are invites enabled
|
|
* @var bool
|
|
*/
|
|
private $invites = false;
|
|
|
|
/**
|
|
* Languages
|
|
* @var string[]
|
|
*/
|
|
private $languages = ['en'];
|
|
|
|
/**
|
|
* Stats object
|
|
* @var ?\ContentNation\ActivityPub\Common\Stats
|
|
*/
|
|
private $stats = null;
|
|
|
|
/**
|
|
* Contact object
|
|
* @var ?\ContentNation\ActivityPub\Common\User
|
|
*/
|
|
private $contact = null;
|
|
|
|
/**
|
|
* set uri
|
|
* @param string $uri
|
|
* @return Instance current instance
|
|
*/
|
|
public function setURI(string $uri) : Instance {
|
|
$this->uri = $uri;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set title
|
|
* @param string $title
|
|
* @return Instance current instance
|
|
*/
|
|
public function setTitle(string $title) : Instance {
|
|
$this->title = $title;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set short description
|
|
* @param string $short
|
|
* @return Instance current instance
|
|
*/
|
|
public function setShortDescription(string $short) : Instance {
|
|
$this->shortDescription = $short;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set description
|
|
* @param string $description
|
|
* @return Instance current instance
|
|
*/
|
|
public function setDescription(string $description) : Instance {
|
|
$this->description = $description;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set E-Mail
|
|
* @param string $email
|
|
* @return Instance current instance
|
|
*/
|
|
public function setEmail(string $email) : Instance {
|
|
$this->email = $email;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set version
|
|
* @param string $version
|
|
* @return Instance current instance
|
|
*/
|
|
public function setVersion(string $version) : Instance {
|
|
$this->version = $version;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set thumbnail image
|
|
* @param string $thumbnail
|
|
* @return Instance current instance
|
|
*/
|
|
public function setThumbnail(string $thumbnail) : Instance {
|
|
$this->thumbnail = $thumbnail;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set registration allowed
|
|
* @param bool $allowed
|
|
* @return Instance current instance
|
|
*/
|
|
public function setRegistration(bool $allowed) : Instance {
|
|
$this->registration = $allowed;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set approval required
|
|
* @param bool $required
|
|
* @return Instance current instance
|
|
*/
|
|
public function setApproval(bool $required) : Instance {
|
|
$this->approval = $required;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set invited enabled
|
|
* @param bool $invites
|
|
* @return Instance current instance
|
|
*/
|
|
public function setInvites(bool $invites) : Instance {
|
|
$this->invites = $invites;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set languages
|
|
* @param string[] $languages
|
|
* @return Instance current instance
|
|
*/
|
|
public function setLanguages($languages) : Instance {
|
|
$this->languages = $languages;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set stats object
|
|
* @param \ContentNation\ActivityPub\Common\Stats $stats
|
|
* @return Instance current instance
|
|
*/
|
|
public function setStats($stats) : Instance {
|
|
$this->stats = $stats;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set contact object
|
|
* @param \ContentNation\ActivityPub\Common\User $user
|
|
* @return Instance current instance
|
|
*/
|
|
public function setcontact($user) : Instance {
|
|
$this->contact = $user;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* convert internal state to php array
|
|
* @return array<string,mixed>
|
|
*/
|
|
function toObject() {
|
|
$return = array(
|
|
'uri' => $this->uri,
|
|
'title' => $this->title,
|
|
'short_description' => $this->shortDescription,
|
|
'description' => $this->description,
|
|
'email' => $this->email,
|
|
'version' => $this->version,
|
|
'thumbnail' => $this->thumbnail,
|
|
'registrations' => $this->registration,
|
|
'approval_required' => $this->approval,
|
|
'invites_enabled' => $this->invites,
|
|
'languages'=> $this->languages,
|
|
);
|
|
if ($this->stats !== null) $return['stats'] = $this->stats->toObject();
|
|
if ($this->contact !== null) $return['contact_account'] = $this->contact->toObject();
|
|
return $return;
|
|
}
|
|
}
|