Page MenuHomeGitPull.it

APK.php
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
<?php
/**
* Stupid class describing a single APK and basic rendering.
*/
class APK {
private $name;
private $url;
private $sha256;
private $ABI;
/**
* Constructor
*
* @param string $name Filename of the APK (this is not a path)
* @param string $url Destination URL
* @param string $sha256 Signature of this APK
* @param string $ABI Architecture
*/
public function __construct(string $name, string $url, string $sha256, ?string $ABI = null) {
$this->name = $name;
$this->url = $url;
$this->sha256 = $sha256;
$this->ABI = $ABI;
}
/**
* @return array
*/
public function getPhorgeCommentLines() {
return [
// In Phorge the download link is inline
// $this->getPhorgeDownloadLink(),
$this->getPhorgeAPKSignatureLine(),
];
}
/**
* Get the ABI architecture.
*/
public function getABI(): string {
// TODO: calculate this.
return $this->ABI;
}
/**
* Get the final URL.
*/
public function getURL(): string {
return $this->url;
}
/**
* Get the sha256 of the APK file.
*/
public function getHash(): string {
return $this->sha256;
}
/**
* @return array
*/
public function getTelegramCommentLines() {
return [
$this->getTelegramDownloadLink(),
$this->getTelegramAPKSignatureLine()
];
}
/**
* Get a very generic download link for Phorge.
* @return string
*/
public function getPhorgeDownloadLink(): string {
return sprintf(
"[%s](%s)",
$this->name,
$this->url
);
}
/**
* Get a very generic download link for Phorge.
* @return string
*/
public function getTelegramDownloadLink(): string {
// In Telegram it seems we must escape the link text from special characters.
// The link, instead, can be returned as-is.
// For some reasons, an emoji cannot be inside the link lol.
// So the Text from: "Download asd.apk"
// to: "Download asd\\.apk"
return sprintf(
"⬇️ [%s](%s)",
TelegramStupidSDK::escapeMarkdownV2($this->name),
$this->url
);
}
/**
* Get a very generic line about the sha256sum of this APK.
* @return string
*/
private function getPhorgeAPKSignatureLine() {
return sprintf(
"sha256 for %s: `%s`",
$this->getABI(),
$this->sha256
);
}
/**
* Get a very generic line about the sha256sum of this APK.
* @return string
*/
private function getTelegramAPKSignatureLine() {
return sprintf(
"sha256 for %s: `%s`",
TelegramStupidSDK::escapeMarkdownV2($this->getABI()),
$this->sha256
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Thu, Aug 27, 14:35 (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2084084
Default Alt Text
APK.php (2 KB)

Event Timeline