Skip to content

Commit 6af7aad

Browse files
committed
Fixes #6
1 parent 9cb87c9 commit 6af7aad

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/Event/Parameters.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected static function getHashedFields(): array
5353
/**
5454
* @param mixed $data
5555
*
56-
* @return array|string|float|int|null
56+
* @return array|string|float|int|bool|null
5757
*/
5858
private static function normalize($data, string $field = null)
5959
{
@@ -65,7 +65,7 @@ private static function normalize($data, string $field = null)
6565
$data = $data->format('Ymd');
6666
}
6767

68-
if (is_object($data) && method_exists($data, '__toString')) {
68+
if ($data instanceof \Stringable) {
6969
$data = (string) $data;
7070
}
7171

@@ -82,7 +82,7 @@ private static function normalize($data, string $field = null)
8282
return $data;
8383
}
8484

85-
if (is_int($data) || is_float($data)) {
85+
if (is_int($data) || is_float($data) || is_bool($data)) {
8686
return $data;
8787
}
8888

tests/Client/ClientTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function it_sends_event(): void
3939

4040
$request = $httpClient->requests[0];
4141
self::assertSame('POST', $request->getMethod());
42-
self::assertSame('https://graph.facebook.com/v14.0/pixel_id/events', (string) $request->getUri());
42+
self::assertSame('https://graph.facebook.com/v22.0/pixel_id/events', (string) $request->getUri());
4343
self::assertSame('data=%5B%7B%22event_name%22%3A%22Purchase%22%2C%22event_time%22%3A1658743659123%2C%22event_id%22%3A%22event_id%22%2C%22action_source%22%3A%22website%22%7D%5D', (string) $request->getBody());
4444
}
4545

tests/Event/EventTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ public function it_normalizes_correct_fields(): void
2020
$event->testEventCode = 'TestEventCode';
2121
$event->eventSourceUrl = 'https://example.com/products/productId=123';
2222
$event->actionSource = Event::ACTION_SOURCE_SYSTEM_GENERATED;
23+
$event->optOut = true;
2324

2425
self::assertSame([
2526
'event_name' => Event::EVENT_ADD_TO_CART,
2627
'event_time' => 123,
2728
'event_source_url' => 'https://example.com/products/productId=123',
29+
'opt_out' => true,
2830
'event_id' => 'EventId',
2931
'action_source' => Event::ACTION_SOURCE_SYSTEM_GENERATED,
3032
], $event->getPayload());

0 commit comments

Comments
 (0)