| Conditions | 4 |
| Paths | 5 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | protected function resolveConnection($connection): IntegrationConnectionInterface |
||
| 28 | { |
||
| 29 | if ($connection instanceof IntegrationConnectionInterface) { |
||
| 30 | return $connection; |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($connection === null) { |
||
| 34 | $connection = Connections::DEFAULT_INTEGRATION_CONNECTION; |
||
| 35 | } |
||
| 36 | |||
| 37 | $connection = HubSpot::getInstance()->getConnections()->get($connection); |
||
| 38 | |||
| 39 | if (!$connection instanceof IntegrationConnectionInterface) { |
||
| 40 | throw new InvalidConfigException(sprintf( |
||
| 41 | "Integration Connection must be an instance of '%s', '%s' given.", |
||
| 42 | IntegrationConnectionInterface::class, |
||
| 43 | get_class($connection) |
||
| 44 | )); |
||
| 45 | } |
||
| 46 | |||
| 47 | return $connection; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |