-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add categories on json list #149
base: main
Are you sure you want to change the base?
Changes from 10 commits
52ab9b7
9086963
56838b1
d38bd92
c4af2e4
ac58c16
b5a85a3
01f2967
62a11c0
6f4804e
274c72a
40c6ab3
287333b
f36ffe8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace App\Services; | ||
|
||
use App\Services; | ||
|
||
abstract class Category | ||
{ | ||
const CACHE = 'Cache'; | ||
|
@@ -10,4 +12,30 @@ abstract class Category | |
const SEARCH = 'Search'; | ||
const STORAGE = 'Storage'; | ||
const TOOLS = 'Tools'; | ||
|
||
public static function all(): array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would more be a method on the Service class named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
$result = [
'beanstalkd' => "Cache",
'clickhouse' => "Database",
'dynamodb' => "Cache",
'elasticsearch' => "Search",
'eventstoredb' => "Database",
'expose' => "Tools",
'influxdb' => "Database",
'mailhog' => "Mail",
'mariadb' => "Database",
'meilisearch' => "Search",
'memcached' => "Cache",
'minio' => "Storage",
'mongo' => "Database",
'mssql' => "Database",
'mysql' => "Database",
'neo4j' => "Database",
'postgis' => "Database",
'postgresql' => "Database",
'redis' => "Cache",
'sftp' => "Storage",
'sqs' => "Cache"
]; so the right name (for me) is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but I still think this is more of a list of services than a list of categories, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops sorry 🙈 I misunderstood! |
||
{ | ||
return collect((new Services)->all()) | ||
->mapWithKeys(function ($fqcn, $shortName) { | ||
return [$shortName => $fqcn::category()]; | ||
}) | ||
->toArray(); | ||
} | ||
|
||
public static function get(string $serviceName): string | ||
danielebarbaro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
$servicesByCategory = self::all(); | ||
return array_key_exists($serviceName, $servicesByCategory) ? strtolower($servicesByCategory[$serviceName]) : 'other'; | ||
} | ||
|
||
public static function fromContainerName(string $containerName): string | ||
{ | ||
$serviceName = array_slice( | ||
explode('--', $containerName), | ||
1, | ||
1 | ||
); | ||
$serviceName = reset($serviceName); | ||
return self::get($serviceName); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this has been sitting open for ages so I'm sorry to make one more request, but could you write tests for these two new methods?
Thanks so much!