Skip to content

Commit 32a0330

Browse files
author
WorkOS Bot
committed
Translated from node PR #1273
1 parent 0f29f1e commit 32a0330

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
TARGET CODE:
2+
<?php
3+
4+
namespace Lib\UserManagement;
5+
6+
use Lib\UserManagement\Interfaces\UpdateUserOptions;
7+
use Lib\UserManagement\Interfaces\SerializedUpdateUserOptions;
8+
9+
class UpdateUserOptionsSerializer
10+
{
11+
public static function serializeUpdateUserOptions(UpdateUserOptions $options): SerializedUpdateUserOptions
12+
{
13+
return new SerializedUpdateUserOptions([
14+
'email' => $options->getEmail(),
15+
'email_verified' => $options->getEmailVerified(),
16+
'first_name' => $options->getFirstName(),
17+
'last_name' => $options->getLastName(),
18+
'password' => $options->getPassword(),
19+
'password_hash' => $options->getPasswordHash(),
20+
'password_hash_type' => $options->getPasswordHashType(),
21+
'external_id' => $options->getExternalId(),
22+
]);
23+
}
24+
}
25+
26+
NOTES:
27+
1. PHP does not have direct support for JavaScript's object literal syntax. Instead, we use an associative array to represent the serialized options.
28+
2. In PHP, we typically use getter methods to access object properties, assuming that the `UpdateUserOptions` class follows the common practice of encapsulating its properties with getter and setter methods.
29+
3. The `serializeUpdateUserOptions` function is made static, as it does not depend on any instance-specific data.
30+
4. The `SerializedUpdateUserOptions` is assumed to be a class that accepts an associative array in its constructor. If this is not the case, the implementation of this function may need to be adjusted accordingly.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
TARGET CODE:
2+
<?php
3+
4+
namespace lib\UserManagement;
5+
6+
use lib\UserManagement\PasswordHashTypeInterface;
7+
8+
interface UpdateUserOptionsInterface
9+
{
10+
public function getUserId(): string;
11+
12+
public function getEmail(): ?string;
13+
14+
public function getFirstName(): ?string;
15+
16+
public function getLastName(): ?string;
17+
18+
public function getEmailVerified(): ?bool;
19+
20+
public function getPassword(): ?string;
21+
22+
public function getPasswordHash(): ?string;
23+
24+
public function getPasswordHashType(): ?PasswordHashTypeInterface;
25+
26+
public function getExternalId(): ?string;
27+
}
28+
29+
interface SerializedUpdateUserOptionsInterface
30+
{
31+
public function getEmail(): ?string;
32+
33+
public function getFirstName(): ?string;
34+
35+
public function getLastName(): ?string;
36+
37+
public function getEmailVerified(): ?bool;
38+
39+
public function getPassword(): ?string;
40+
41+
public function getPasswordHash(): ?string;
42+
43+
public function getPasswordHashType(): ?PasswordHashTypeInterface;
44+
45+
public function getExternalId(): ?string;
46+
}
47+
48+
In PHP, interfaces are used to specify what methods a class must implement. In this case, the UpdateUserOptionsInterface and SerializedUpdateUserOptionsInterface interfaces are defined with getter methods for each property. The "?" before the type means that the return type can be that type or null. The PasswordHashTypeInterface is assumed to be in the same namespace and is used as a return type for getPasswordHashType() method.

0 commit comments

Comments
 (0)