Skip to content

Commit

Permalink
Lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Mar 10, 2024
1 parent 29c6cc1 commit c432f39
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Brandlabs\Productiveio\Resources\People;
use Brandlabs\Productiveio\Resources\TimeEntries;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

define('ROOT_DIR', dirname(__DIR__));
Expand Down Expand Up @@ -83,11 +82,13 @@ function logger(?string $msg = ''): void
echo $msg ?? '' . PHP_EOL;
}

function get_cache(int $ttl = -1): AdapterInterface
function get_cache(int $ttl = -1): ArrayAdapter|FilesystemAdapter
{
// return new ArrayAdapter(
// defaultLifetime: $ttl,
// );
if (env('APP_CACHE') === 'false') {
return new ArrayAdapter(
defaultLifetime: $ttl,
);
}

return new FilesystemAdapter(
namespace: 'productive',
Expand Down Expand Up @@ -218,21 +219,25 @@ function format_minutes(?int $minutes): string

function format_name(array $person):string
{
/** @var null|string */
$first_name = $person['attributes']['first_name'];
/** @var null|string */
$last_name = $person['attributes']['last_name'];
$last_name_initial = strtoupper(substr($last_name, 0, 1));

if ($first_name && $last_name) {
return "{$first_name} {$last_name_initial}.";
}

if (!$first_name && $last_name) {
if (is_null($first_name) && $last_name) {
return $last_name;
}

if ($first_name && !$last_name) {
if ($first_name && is_null($last_name)) {
return $first_name;
}

return "";
}

function format_subtitle(array $items):string
Expand Down Expand Up @@ -435,8 +440,6 @@ function cmd(string $cmd, string $resource_class, array $parameters = [], ?bool
$cache = get_cache();
$cache_key = $cmd;

// $cache->delete($cache_key);

if (!$clear_cache) {
update_in_background($cmd);
}
Expand Down

0 comments on commit c432f39

Please sign in to comment.