API / Minn\Ops / Releases

Releases final class

Minn\Ops\Releases · public/minn/src/Minn/Ops/Releases.php · 87 lines

Whether a newer Minn is out, asked of the Minn update service at most once a day: its latest installable release (published on GitHub, read by the service), kept in the minn_release option (JSON) with the time it was asked. A check the service does not answer (offline, GitHub rate limiting it) keeps the last answer and waits a day like any other; no installable release (a 404) offers nothing. This is Minn asking Minn, never wordpress.org, and never GitHub directly.

Constants and properties

constOPTION = 'minn_release'
constTTL = 86400
constSOURCE = 'https://updates.minn.run/v1/minn/releases/latest'
privatereadonly Closure $load

Promoted from the constructor.

privatereadonly Closure $save

Promoted from the constructor.

privatereadonly string $installed

Promoted from the constructor.

privatereadonly string $source

Promoted from the constructor.

privatereadonly Minn\Http $http

Promoted from the constructor.

Public

new__construct(Closure $load, Closure $save, string $installed, string $source = self::SOURCE, Minn\Http $http = \Minn\Http::__set_state(array( 'within' => array ( ), 'fake' => NULL, 'refusal' => NULL, )))#
$loadClosure(): ?stringthe stored answer, as JSON
$saveClosure(string): voidkeeps the answer, as JSON
staticforSite(Minn\Content\Site $site, string $installed): self#

The check for a site, its answer kept in the site's minn_release option.

methodstored(): array#

The stored answer: when GitHub was last asked and the latest release then.

@return array{checked: int, latest: ?array<string, string>}
methoddue(): bool#

Whether the stored answer is a day old, or there is none.

methodrefresh(): array#

Asks the service now and keeps the answer; `answered` says whether it did (when it did not, `latest` is the last answer kept).

@return array{checked: int, latest: ?array<string, string>, answered: bool}
methodoffer(): ?Minn\Ops\Release#

The release on offer: the latest one, when it is newer than the running engine.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateorigin(string $url): string#