| 1 |
<?php |
| 2 |
|
| 3 |
class ExternalStoreForTesting { |
| 4 |
|
| 5 |
|
| 6 |
protected $data = [ |
| 7 |
'cluster1' => [ |
| 8 |
'200' => 'Hello', |
| 9 |
'300' => [ |
| 10 |
'Hello', 'World', |
| 11 |
], |
| 12 |
|
| 13 |
'12345' => "sttttr\002\022\000", |
| 14 |
], |
| 15 |
]; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public function fetchFromURL( $url ) { |
| 23 |
|
| 24 |
$path = explode( '/', $url ); |
| 25 |
$cluster = $path[2]; |
| 26 |
$id = $path[3]; |
| 27 |
$itemID = $path[4] ?? false; |
| 28 |
|
| 29 |
if ( !isset( $this->data[$cluster][$id] ) ) { |
| 30 |
return null; |
| 31 |
} |
| 32 |
|
| 33 |
if ( $itemID !== false |
| 34 |
&& is_array( $this->data[$cluster][$id] ) |
| 35 |
&& isset( $this->data[$cluster][$id][$itemID] ) |
| 36 |
) { |
| 37 |
return $this->data[$cluster][$id][$itemID]; |
| 38 |
} |
| 39 |
|
| 40 |
return $this->data[$cluster][$id]; |
| 41 |
} |
| 42 |
|
| 43 |
public function store( $location, $data ) { |
| 44 |
$itemId = mt_rand( 500, 1000 ); |
| 45 |
$this->data[$location][$itemId] = $data; |
| 46 |
return "ForTesting://$location/$itemId"; |
| 47 |
} |
| 48 |
|
| 49 |
public function isReadOnly() { |
| 50 |
return false; |
| 51 |
} |
| 52 |
|
| 53 |
} |