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

Remove deprecations and harden code #837

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/Block/Service/MatomoStatisticBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@

final class MatomoStatisticBlockService extends AbstractBlockService implements EditableBlockService, LoggerAwareInterface
{
/**
* @var LoggerInterface
*/
private LoggerInterface|NullLogger $logger;
private readonly ClientFactoryInterface $factory;

private ClientFactoryInterface $factory;
private LoggerInterface $logger;

public function __construct(Environment $twig, ClientFactoryInterface $factory)
{
Expand Down Expand Up @@ -67,19 +64,19 @@
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function configureEditForm(FormMapper $formMapper, BlockInterface $block): void
public function configureEditForm(FormMapper $form, BlockInterface $block): void
{
$formMapper->add('settings', ImmutableArrayType::class, [
$form->add('settings', ImmutableArrayType::class, [

Check warning on line 69 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'keys' => [

Check warning on line 70 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
['title', TextType::class, [

Check warning on line 71 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {

Check warning on line 71 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [[TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'required' => false,

Check warning on line 72 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => true, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'label' => 'form.label_title',
]],
['translation_domain', TextType::class, [

Check warning on line 75 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {

Check warning on line 75 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], [TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'label' => 'form.label_translation_domain',
'required' => false,

Check warning on line 77 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => true]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
]],
['icon', TextType::class, [

Check warning on line 79 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {

Check warning on line 79 in src/Block/Service/MatomoStatisticBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], ['icon', TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['title', TextType::class, ['required' => false, 'label' => 'form.label_title']], ['translation_domain', TextType::class, ['label' => 'form.label_translation_domain', 'required' => false]], [TextType::class, ['label' => 'form.label_icon', 'required' => false]], ['class', TextType::class, ['label' => 'form.label_class', 'required' => false]], ['host', TextType::class, ['required' => false, 'label' => 'form.label_host']], ['token', TextType::class, ['required' => false, 'label' => 'form.label_token']], ['site', NumberType::class, ['label' => 'form.label_site']], ['method', ChoiceType::class, ['choices' => ['form.choice_visitors' => 'VisitsSummary.getVisits', 'form.choice_unique_visitors' => 'VisitsSummary.getUniqueVisitors', 'form.choice_hits' => 'VisitsSummary.getActions '], 'label' => 'form.label_method']], ['period', ChoiceType::class, ['choices' => ['form.choice_day' => 'day', 'form.choice_week' => 'week', 'form.choice_month' => 'month', 'form.choice_year' => 'year'], 'label' => 'form.label_period']], ['date', ChoiceType::class, ['choices' => ['form.choice_today' => 'last1', 'form.choice_1_week' => 'last7', 'form.choice_2_weeks' => 'last14', 'form.choice_1_month' => 'last30', 'form.choice_3_months' => 'last90', 'form.choice_6_months' => 'last180', 'form.choice_1_year' => 'last360'], 'label' => 'form.label_date']]], 'translation_domain' => 'NucleosMatomoBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'label' => 'form.label_icon',
'required' => false,
]],
Expand Down Expand Up @@ -177,7 +174,7 @@
*
* @return array<mixed>
*/
protected function getData(array $settings = []): ?array
private function getData(array $settings = []): ?array
{
try {
$client = $this->factory->createClient((string) $settings['host'], (string) $settings['token']);
Expand Down
4 changes: 2 additions & 2 deletions src/Block/Service/MatomoTrackerBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function configureCreateForm(FormMapper $form, BlockInterface $block): vo
$this->configureEditForm($form, $block);
}

public function configureEditForm(FormMapper $formMapper, BlockInterface $block): void
public function configureEditForm(FormMapper $form, BlockInterface $block): void
{
$formMapper->add('settings', ImmutableArrayType::class, [
$form->add('settings', ImmutableArrayType::class, [
'keys' => [
['host', TextType::class, [
'required' => false,
Expand Down
26 changes: 5 additions & 21 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,26 @@

final class Client implements ClientInterface
{
private ConnectionInterface $connection;
private readonly ConnectionInterface $connection;

private string $token;
private readonly string $token;

/**
* Initialize Matomo client.
*
* @param ConnectionInterface $connection Matomo active connection
* @param string $token auth token
*/
public function __construct(ConnectionInterface $connection, string $token = 'anonymous')
{
$this->connection = $connection;
$this->setToken($token);
$this->token = $token;
}

public function setToken(string $token): void
{
$this->token = $token;
}

public function call(string $method, array $params = [], string $format = 'php')
public function call(string $method, array $params = []): mixed
{
$params['method'] = $method;
$params['token_auth'] = $this->token;
$params['format'] = 'json';
$data = $this->getConnection()->send($params);

if ('php' !== $format) {
@trigger_error(sprintf('Argument #3 of %s is deprecated and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
}
$data = $this->connection->send($params);

try {
$object = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
Expand All @@ -57,9 +46,4 @@ public function call(string $method, array $params = [], string $format = 'php')

return $object;
}

public function getConnection(): ConnectionInterface
{
return $this->connection;
}
}
3 changes: 0 additions & 3 deletions src/Client/ClientFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@

interface ClientFactoryInterface
{
/**
* Creates new Matomo Client.
*/
public function createClient(string $host, string $token): ClientInterface;
}
21 changes: 1 addition & 20 deletions src/Client/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,17 @@

namespace Nucleos\MatomoBundle\Client;

use Nucleos\MatomoBundle\Connection\ConnectionInterface;
use Nucleos\MatomoBundle\Exception\MatomoException;

interface ClientInterface
{
/**
* Set Matomo API token.
*
* @param string $token auth token
*
* @deprecated use constructor to set client token
*/
public function setToken(string $token): void;

/**
* Call specific method & return it's response.
*
* @param string $method method name
* @param array<string, mixed> $params method parameters
*
* @return array<mixed>|string
*
* @throws MatomoException
*/
public function call(string $method, array $params = [], string $format = 'php');

/**
* Return active connection.
*
* @deprecated without any replacement
*/
public function getConnection(): ConnectionInterface;
public function call(string $method, array $params = []): mixed;
}
7 changes: 2 additions & 5 deletions src/Client/PsrClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@

final class PsrClientFactory implements ClientFactoryInterface
{
private PsrClientInterface $client;
private readonly PsrClientInterface $client;

private RequestFactoryInterface $requestFactory;
private readonly RequestFactoryInterface $requestFactory;

/**
* Initialize client.
*/
public function __construct(PsrClientInterface $client, RequestFactoryInterface $requestFactory)
{
$this->client = $client;
Expand Down
2 changes: 0 additions & 2 deletions src/Connection/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
interface ConnectionInterface
{
/**
* Calls specific method on Matomo API.
*
* @param array<string, mixed> $params
*
* @return string response
Expand Down
8 changes: 3 additions & 5 deletions src/Connection/PsrClientConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@

final class PsrClientConnection implements ConnectionInterface
{
private PsrClientInterface $client;
private readonly PsrClientInterface $client;

private RequestFactoryInterface $requestFactory;
private readonly RequestFactoryInterface $requestFactory;

private string $apiUrl;
private readonly string $apiUrl;

/**
* Initialize client.
*
* @param string $apiUrl base API URL
*/
public function __construct(PsrClientInterface $client, RequestFactoryInterface $requestFactory, string $apiUrl)
Expand Down
9 changes: 1 addition & 8 deletions tests/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ protected function setUp(): void
$this->connection = $this->createMock(ConnectionInterface::class);
}

public function testGetConnection(): void
{
$client = new Client($this->connection);

static::assertSame($this->connection, $client->getConnection());
}

public function testCall(): void
{
$this->connection
Expand Down Expand Up @@ -72,7 +65,7 @@ public function testCallWithCustomFormat(): void
;

$client = new Client($this->connection, 'MY_TOKEN');
$result = $client->call('foo/method', ['foo' => 'bar'], 'custom');
$result = $client->call('foo/method', ['foo' => 'bar']);

static::assertCount(30, $result);
}
Expand Down