Skip to content
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

Extract the access to the user config in its own helper class #926

Merged
merged 6 commits into from
Mar 23, 2022

Conversation

christianlupus
Copy link
Collaborator

This should encapsulate the access to the user settings.

Signed-off-by: Christian Wolf <github@christianwolf.email>
Signed-off-by: Christian Wolf <github@christianwolf.email>
Signed-off-by: Christian Wolf <github@christianwolf.email>
@github-actions
Copy link

github-actions bot commented Mar 22, 2022

Unit Test Results

  22 files    22 suites   9m 7s ⏱️
  74 tests   74 ✔️ 0 💤 0
814 runs  814 ✔️ 0 💤 0

Results for commit 8a1242d.

♻️ This comment has been updated with latest results.

Signed-off-by: Christian Wolf <github@christianwolf.email>
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #926 (8a1242d) into master (30a0f04) will increase coverage by 2.21%.
The diff coverage is 76.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #926      +/-   ##
==========================================
+ Coverage   20.20%   22.42%   +2.21%     
==========================================
  Files          20       21       +1     
  Lines        1440     1476      +36     
==========================================
+ Hits          291      331      +40     
+ Misses       1149     1145       -4     
Flag Coverage Δ
integration 5.75% <0.00%> (-0.15%) ⬇️
unittests 16.66% <76.92%> (+2.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/Service/DbCacheService.php 0.00% <0.00%> (ø)
lib/Service/RecipeService.php 0.00% <0.00%> (ø)
lib/Helper/UserConfigHelper.php 100.00% <100.00%> (ø)

seyfeb
seyfeb previously approved these changes Mar 22, 2022
Copy link
Collaborator

@seyfeb seyfeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be fine

* @return integer The timestamp of the last index rebuild
*/
public function getLastIndexUpdate(): int {
$rawValue = $this->getRawValue('last_index_update');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a sensible way to get rid of those magic strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was exactly the reason for introducing this class. Until now, these magic strings were distributed in the complete code. Now, they are at least condensed into a single file/class.

One could at most introduce constants of the class to use them. But the effect would be similar. The thing is that the server provides just a string based key-value interface. We could as well store one JSON object there. (Now easier as all is contained in the class)

lib/Helper/UserConfigHelper.php Outdated Show resolved Hide resolved
lib/Helper/UserConfigHelper.php Outdated Show resolved Hide resolved
*
* @return string The name of the folder within the users files
*/
public function getFolderName(): string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we think of having multiple cookbooks here? As discussed in #340
You probably just want to provide the same functionality as the current code but in a nicer package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. For now, I wanted to create something like a DBAL.

Extending this and returning an array of strings (and storing appropriately), is just a small change in this class plus the corresponding upper layers. These upper layers I wanted to generate some abstractions as well. So the switch from one to many cookbooks should be a smaller one.

When separating file system access from business logic, we can work towards the discussed results in #340 in the classes there.

lib/Helper/UserConfigHelper.php Outdated Show resolved Hide resolved
christianlupus and others added 2 commits March 23, 2022 07:27
Review by @seyfeb

Co-authored-by: Sebastian Fey <info@sebastianfey.de>
Signed-off-by: Christian Wolf <github@christianwolf.email>
Signed-off-by: Christian Wolf <github@christianwolf.email>
@christianlupus christianlupus merged commit ee393d6 into master Mar 23, 2022
@christianlupus christianlupus deleted the dev/config-abstraction branch March 23, 2022 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants