| Conditions | 4 |
| Paths | 6 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 29 | 1 | public function create($listName, $contact, array $parameters = []) |
|
| 30 | { |
||
| 31 | $body = [ |
||
| 32 | 'Email' => $contact |
||
| 33 | 1 | ]; |
|
| 34 | 1 | $this->client->post(Resources::$Contact, ['body' => $body]); |
|
| 35 | |||
| 36 | 1 | $name = Inflector::classify($listName); |
|
| 37 | 1 | $data = []; |
|
| 38 | 1 | foreach (['content', 'subject'] as $item) { |
|
| 39 | 1 | if (array_key_exists($item, $parameters)) { |
|
| 40 | $body = [ |
||
| 41 | 1 | 'Datatype' => "str", |
|
| 42 | 1 | 'Name' => $item . "_" . $name, |
|
| 43 | 'NameSpace' => "static" |
||
| 44 | 1 | ]; |
|
| 45 | 1 | $this->client->post(Resources::$Contactmetadata, ['body' => $body]); |
|
| 46 | 1 | $data['Data'][] = [ |
|
| 47 | 1 | 'Name' => $item . "_" . $name, |
|
| 48 | 1 | 'value' => substr($parameters[$item], 0, 1000), |
|
| 49 | ]; |
||
| 50 | 1 | } |
|
| 51 | 1 | } |
|
| 52 | |||
| 53 | 1 | if (!empty($data)) { |
|
| 54 | 1 | $this->client->put(Resources::$Contactdata, ['id' => $contact, 'body' => $data]); |
|
| 55 | 1 | } |
|
| 56 | 1 | } |
|
| 57 | |||
| 75 |