Skip to content

Commit

Permalink
CS Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Feb 26, 2024
1 parent adbfe30 commit e799288
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
5 changes: 2 additions & 3 deletions web/landing/src/Flow/Website/Controller/FlowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function __construct(private readonly Github $github)
public function main() : Response
{
return $this->render('main/changelog.html.twig', [
'changelog_markdown' => file_get_contents($this->getParameter('flow_root_dir') . '/CHANGELOG.md'),
'changelog_markdown' => \file_get_contents($this->getParameter('flow_root_dir') . '/CHANGELOG.md'),
]);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public function hero() : Response
'version' => $this->github->version('flow-php/flow'),
]);
}
}
}
60 changes: 30 additions & 30 deletions web/landing/src/Flow/Website/Service/Github.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,6 @@ public function __construct(
) {
}

public function version(string $project) : string
{
$cache = $this->cache('flow-github-version');

if ($cache->has('version')) {
return $cache->get('version');
}

$factory = new Psr17Factory();
$client = new Client($factory, $factory);

$request = $factory
->createRequest('GET', 'https://api.github.com/repos/flow-php/flow/releases/latest')
->withHeader('Accept', 'application/vnd.github+json')
->withHeader('Authorization', 'Bearer ' . $this->requestFactory->githubToken)
->withHeader('X-GitHub-Api-Version', '2022-11-28')
->withHeader('User-Agent', 'flow-website-fetch');

$response = $client->sendRequest($request);

$data = \json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);

$version = $data['tag_name'];

$cache->set('version', $version);

return $version;
}

public function contributors() : array
{
$factory = new Psr17Factory();
Expand Down Expand Up @@ -96,7 +67,36 @@ public function contributors() : array
}
}

private function cache(string $directoryName): Psr16Cache
public function version(string $project) : string
{
$cache = $this->cache('flow-github-version');

if ($cache->has('version')) {
return $cache->get('version');
}

$factory = new Psr17Factory();
$client = new Client($factory, $factory);

$request = $factory
->createRequest('GET', 'https://api.github.com/repos/flow-php/flow/releases/latest')
->withHeader('Accept', 'application/vnd.github+json')
->withHeader('Authorization', 'Bearer ' . $this->requestFactory->githubToken)
->withHeader('X-GitHub-Api-Version', '2022-11-28')
->withHeader('User-Agent', 'flow-website-fetch');

$response = $client->sendRequest($request);

$data = \json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);

$version = $data['tag_name'];

$cache->set('version', $version);

return $version;
}

private function cache(string $directoryName) : Psr16Cache
{
return new Psr16Cache(
new FilesystemAdapter(
Expand Down

0 comments on commit e799288

Please sign in to comment.