Skip to content

Commit 96f4924

Browse files
committed
Make createdAt and updatedAt DateTime types not string
1 parent 64e9625 commit 96f4924

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

src/Endpoints/Indexes.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Indexes extends Endpoint
2727

2828
private ?string $uid;
2929
private ?string $primaryKey;
30-
private ?string $createdAt;
31-
private ?string $updatedAt;
30+
private ?\DateTime $createdAt;
31+
private ?\DateTime $updatedAt;
3232
private Tasks $tasks;
3333

3434
public function __construct(Http $http, $uid = null, $primaryKey = null, $createdAt = null, $updatedAt = null)
@@ -48,8 +48,8 @@ protected function newInstance(array $attributes): self
4848
$this->http,
4949
$attributes['uid'],
5050
$attributes['primaryKey'],
51-
$attributes['createdAt'],
52-
$attributes['updatedAt'],
51+
static::parseDate($attributes['createdAt']),
52+
static::parseDate($attributes['updatedAt']),
5353
);
5454
}
5555

@@ -60,8 +60,8 @@ protected function fill(array $attributes): self
6060
{
6161
$this->uid = $attributes['uid'];
6262
$this->primaryKey = $attributes['primaryKey'];
63-
$this->createdAt = $attributes['createdAt'];
64-
$this->updatedAt = $attributes['updatedAt'];
63+
$this->createdAt = static::parseDate($attributes['createdAt']);
64+
$this->updatedAt = static::parseDate($attributes['updatedAt']);
6565

6666
return $this;
6767
}
@@ -112,21 +112,11 @@ public function getUid(): ?string
112112
}
113113

114114
public function getCreatedAt(): ?\DateTime
115-
{
116-
return static::parseDate($this->createdAt);
117-
}
118-
119-
public function getCreatedAtString(): ?string
120115
{
121116
return $this->createdAt;
122117
}
123118

124119
public function getUpdatedAt(): ?\DateTime
125-
{
126-
return static::parseDate($this->updatedAt);
127-
}
128-
129-
public function getUpdatedAtString(): ?string
130120
{
131121
return $this->updatedAt;
132122
}

tests/Endpoints/IndexTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,6 @@ public function testGetUpdatedAt(): void
8585
$this->assertInstanceOf(\DateTimeInterface::class, $this->index->getUpdatedAt());
8686
}
8787

88-
public function testGetCreatedAtString(): void
89-
{
90-
$indexB = $this->client->index('indexB');
91-
$rawInfo = $this->index->fetchRawInfo();
92-
93-
$this->assertNull($indexB->getCreatedAtString());
94-
$this->assertSame($rawInfo['createdAt'], $this->index->getCreatedAtString());
95-
}
96-
97-
public function testGetUpdatedAtString(): void
98-
{
99-
$indexB = $this->client->index('indexB');
100-
$rawInfo = $this->index->fetchRawInfo();
101-
102-
$this->assertNull($indexB->getUpdatedAtString());
103-
$this->assertSame($rawInfo['updatedAt'], $this->index->getUpdatedAtString());
104-
}
105-
10688
public function testFetchRawInfo(): void
10789
{
10890
$indexName = $this->safeIndexName('books-2');

0 commit comments

Comments
 (0)