• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grueneschweiz / mailchimpservice / 17108843290

20 Aug 2025 07:54PM UTC coverage: 68.598% (-2.3%) from 70.885%
17108843290

push

github

Michael-Schaer
Fix webling sync

51 of 66 new or added lines in 4 files covered. (77.27%)

105 existing lines in 6 files now uncovered.

959 of 1398 relevant lines covered (68.6%)

11.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/app/Synchronizer/MailchimpToCrmSynchronizer.php
1
<?php
2

3
namespace App\Synchronizer;
4

5
use App\Http\CrmClient;
6
use App\Http\MailChimpClient;
7
use App\Synchronizer\Mapper\Mapper;
8
use App\Synchronizer\Config;
9
use App\Synchronizer\LogTrait;
10

11
/**
12
 * Abstract base class for synchronizer implementations
13
 */
14
abstract class MailchimpToCrmSynchronizer
15
{
16
    use LogTrait;
17

18
    /**
19
     * @var Config
20
     */
21
    protected $config;
22

23
    /**
24
     * @var string
25
     */
26
    protected $configName;
27

28
    /**
29
     * @var MailChimpClient
30
     */
31
    protected $mcClient;
32

33
    /**
34
     * @var CrmClient
35
     */
36
    protected $crmClient;
37

38
    /**
39
     * @var Mapper
40
     */
41
    protected $mapper;
42

43
    /**
44
     * MailchimpToCrmSynchronizer constructor.
45
     *
46
     * @param string $configFileName file name of the config file
47
     *
48
     * @throws \App\Exceptions\ConfigException
49
     * @throws \Exception
50
     */
51
    public function __construct(string $configFileName)
52
    {
53
        $this->config = new Config($configFileName);
1✔
UNCOV
54
        $this->configName = $configFileName;
×
55

UNCOV
56
        $this->initializeClients();
×
57
    }
58

59
    /**
60
     * Initialize the clients based on configuration
61
     *
62
     * @throws \App\Exceptions\ConfigException
63
     */
64
    protected function initializeClients(): void
65
    {
66
        $crmCred = $this->config->getCrmCredentials();
×
UNCOV
67
        $this->crmClient = new CrmClient($crmCred['clientId'], $crmCred['clientSecret'], $crmCred['url']);
×
68

69
        $this->mcClient = new MailChimpClient($this->config->getMailchimpCredentials()['apikey'], $this->config->getMailchimpListId());
×
UNCOV
70
        $this->initializeMapper();
×
71
    }
72

73
    /**
74
     * Initialize the mapper with field mappings from config
75
     */
76
    protected function initializeMapper(): void
77
    {
78
        $this->mapper = new Mapper($this->config->getFieldMaps());
13✔
79
    }
80

81
    /**
82
     * Log webhook events with consistent formatting
83
     *
84
     * @param string $method The log level (debug, info, error, etc.)
85
     * @param string $webhook The webhook type
86
     * @param string $record The record identifier
87
     * @param string $message The log message
88
     * @param mixed $crmId The CRM ID (can be string or int)
89
     */
90
    protected function logWebhook(string $method, string $webhook, string $record, string $message, $crmId = -1): void
91
    {
92
        $crmIdParam = $crmId !== -1 && $crmId !== '' ? " crmId=\"$crmId\" " : " ";
7✔
93
        $this->log($method, $message, "webhook=\"$webhook\" record=\"$record\"$crmIdParam");
7✔
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc