|
1 | | -You have been given a few pieces of code (look for `attributes.php`, `deserialize.php` & `the-attributes-of-success.php` in your working directory). |
| 1 | +You have been given a few pieces of code (look for `attributes.php`, `deserialize.php` & `the-attributes-of-success.php` in {{context cli 'your working directory'}} {{context cloud 'the editor'}}). |
2 | 2 |
|
3 | 3 | Your entry point is `the-attributes-of-success.php`. This is the file you should edit and work on. The other files should not be modified. However, they are included by `the-attributes-of-success.php`. |
4 | 4 |
|
| 5 | +{{ cli }} |
5 | 6 | You can run and verify your program like so: |
6 | 7 |
|
7 | 8 | ```sh |
8 | 9 | $ {appname} run the-attributes-of-success.php |
9 | 10 | $ {appname} verify the-attributes-of-success.php |
10 | 11 | ``` |
| 12 | +{{ cli }} |
11 | 13 |
|
12 | | -Your task is split into two sections. The overall task is to write a class using properties and attributes which describe how to map data to an instance of the class. |
| 14 | +Your task is split in to two sections. The overall task is to write a class using properties and attributes which describe how to map data to an instance of the class. |
13 | 15 |
|
14 | 16 | The data will be passed to you in a JSON encoded string via the first command line argument. |
15 | 17 |
|
@@ -68,13 +70,19 @@ Use the `Skip` attribute on the `id` property of our `Review` class to tell our |
68 | 70 |
|
69 | 71 | By now you should be able to call the `deserialize` function with the `JSON` data and your class name. |
70 | 72 |
|
| 73 | +{{ cli }} |
71 | 74 | When executing your program with |
72 | 75 |
|
73 | 76 | ```sh |
74 | 77 | $ {appname} run the-attributes-of-success.php |
75 | 78 | ``` |
76 | 79 |
|
77 | 80 | You should see a dump of your `Review` instance. |
| 81 | +{{ cli }} |
| 82 | + |
| 83 | +{{ cloud }} |
| 84 | +When you execute your program by pressing `Run` you should see a dump of your `Review` instance. |
| 85 | +{{ cloud }} |
78 | 86 |
|
79 | 87 | Here comes our problem: The reviewers name is not anonymous. We have to comply with strict privacy laws, we cannot display this data without the reviewer's permission. |
80 | 88 |
|
@@ -126,19 +134,18 @@ The last task is to dump your object instance out using the PHP function `var_du |
126 | 134 | ---------------------------------------------------------------------- |
127 | 135 | ## HINTS |
128 | 136 |
|
129 | | -Documentation on the Attributes feature can be found by pointing your browser here: |
130 | | -[https://www.php.net/manual/en/language.attributes.overview.php]() |
| 137 | +{{ doc 'Attributes' en language.attributes.overview.php }} |
131 | 138 |
|
132 | 139 | Remember, do not edit `attributes.php` or `deserialize.php` - verification will fail if you do. Feel free to read the files to get a better understanding of the deserialization process. |
133 | 140 |
|
134 | 141 | You must call the `deserialize` function and you must use the `var_dump` function to output your deserialized object. |
135 | 142 |
|
136 | 143 | If you want to see the `JSON` data - use `var_dump` to dump it out. |
137 | 144 |
|
138 | | -For verification purposes, the order the properties defined in your `Review` class is important. Define them in the same order they are described to you. |
| 145 | +For verification purposes, the order the properties are defined in your `Review` class is important. Define them in the same order they are described to you. |
139 | 146 |
|
140 | 147 | ## Extra |
141 | 148 |
|
142 | | -If you're not sure how to access command line arguments - you should maybe try a different workshop which covers that topic. Try `learnyouphp`. |
| 149 | +If you're not sure how to access command line arguments - you should maybe try a different workshop which covers that topic. Try the Learn you PHP workshop. |
143 | 150 |
|
144 | 151 | `json_decode` can fail if it is passed a malformed string. Wrap the decode in a `try\catch` statement and pass the `JSON_THROW_ON_ERROR` flag to `json_decode`'s fourth parameter. |
0 commit comments