Skip to content

Commit 96195de

Browse files
committed
Convert empty string access token to null
1 parent 2e354cd commit 96195de

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Pixel/Pixel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Pixel
2121
public function __construct(string $id, string $accessToken = null)
2222
{
2323
$this->id = $id;
24-
$this->accessToken = $accessToken;
24+
$this->accessToken = '' === $accessToken ? null : $accessToken;
2525
}
2626

2727
public function __toString(): string

tests/Pixel/PixelTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ public function it_is_stringable(): void
2828
$pixel = new Pixel('id');
2929
self::assertSame('id', (string) $pixel);
3030
}
31+
32+
/**
33+
* @test
34+
*/
35+
public function it_converts_empty_string_access_token_to_null(): void
36+
{
37+
$pixel = new Pixel('id', '');
38+
self::assertNull($pixel->accessToken);
39+
}
3140
}

0 commit comments

Comments
 (0)