Conditions | 1 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
37 | 1 | public function databaseAction(Db $db) |
|
38 | { |
||
39 | 1 | $db->query('CREATE TABLE users(name varchar(255));'); |
|
40 | 1 | $db->query('INSERT INTO users VALUES (?)', ['matthew']); |
|
41 | |||
42 | 1 | $results = $db->first("SELECT * FROM users WHERE name = ?", ['matthew']); |
|
43 | |||
44 | /** Psr7 example */ |
||
45 | |||
46 | 1 | $stream = new Stream('php://memory', 'wb+'); |
|
47 | 1 | $stream->write(json_encode($results)); |
|
48 | |||
49 | 1 | return (new Response) |
|
50 | 1 | ->withStatus(200) |
|
51 | 1 | ->withBody($stream) |
|
52 | 1 | ->withHeader('Content-Type', 'application/json'); |
|
53 | |||
54 | } |
||
55 | } |
||
56 |