Conditions | 2 |
Paths | 2 |
Total Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function create($nameId, $tokenType, $institution) |
||
24 | { |
||
25 | $uuid = Uuid::uuid4()->toString(); |
||
26 | $data = [ |
||
27 | 'identityId' => $uuid, |
||
28 | 'nameId' => $nameId, |
||
29 | 'institution' => $institution, |
||
30 | 'secondFactorId' => $uuid, |
||
31 | 'secondFactorType' => $tokenType, |
||
32 | 'secondFactorIdentifier' => $uuid, |
||
33 | 'id' => $uuid, |
||
34 | 'displayLocale' => 'en_GB', |
||
35 | ]; |
||
36 | $sql = <<<SQL |
||
37 | INSERT INTO second_factor ( |
||
38 | identity_id, |
||
39 | name_id, |
||
40 | institution, |
||
41 | second_factor_id, |
||
42 | second_factor_type, |
||
43 | second_factor_identifier, |
||
44 | id, |
||
45 | display_locale |
||
46 | ) |
||
47 | VALUES ( |
||
48 | :identityId, |
||
49 | :nameId, |
||
50 | :institution, |
||
51 | :secondFactorId, |
||
52 | :secondFactorType, |
||
53 | :secondFactorIdentifier, |
||
54 | :id, |
||
55 | :displayLocale |
||
56 | ) |
||
57 | SQL; |
||
58 | $stmt = $this->connection->prepare($sql); |
||
59 | if ($stmt->execute($data)) { |
||
60 | return $data; |
||
61 | } |
||
62 | |||
63 | throw new Exception('Unable to insert the new second_factor'); |
||
64 | } |
||
65 | } |
||
66 |