Skip to content

Commit

Permalink
Update PhotoPrism.php to pass phpcbf test
Browse files Browse the repository at this point in the history
  • Loading branch information
svanhoutte authored Aug 9, 2024
1 parent 51a2086 commit 8e72a33
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions PhotoPrism/PhotoPrism.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@

class PhotoPrism extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;
public $config;

//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST

function __construct()
{
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}
function __construct()
{
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}

function get_request_attrs()
function get_request_attrs()
{
$attrs["headers"] = ["X-Session-ID" => $this->config->session];
$attrs["headers"] = ["X-Session-ID" => $this->config->session];
return $attrs;
}

public function test()
{
public function test()
{
$attrs = $this->get_request_attrs();
$test = parent::appTest($this->url("api/v1/config"), $attrs);
echo $test->status;
}

public function livestats()
{
$status = "inactive";
$attrs = $this->get_request_attrs();
$test = parent::appTest($this->url("api/v1/config"), $attrs);
echo $test->status;
}

public function livestats()
{
$status = "inactive";
$attrs = $this->get_request_attrs();
$res = parent::execute($this->url("api/v1/config"), $attrs);
$details = json_decode($res->getBody(), true);
$data = [];

if ($details) {
$status = "active";
$data["photos"] = number_format($details["count"]["photos"]) ?? 0;
$data["videos"] = number_format($details["count"]["videos"]) ?? 0;
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
$res = parent::execute($this->url("api/v1/config"), $attrs);
$details = json_decode($res->getBody(), true);
$data = [];

if ($details) {
$status = "active";
$data["photos"] = number_format($details["count"]["photos"]) ?? 0;
$data["videos"] = number_format($details["count"]["videos"]) ?? 0;
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
}

0 comments on commit 8e72a33

Please sign in to comment.