Rules I Follow

Best Practices / Design Patterns

  • Repository pattern.
  • Laravel's API resources
  • API versioning + namespaces
  • PHP 7 features
  • Correct API responses
  • Class validations
  • Policies

Comments

All functions have comments so me and other developers know exactly what is going on with that function.

Same applies for the class itself.

Readable code

I keep my functions small, around 5-15 lines. That means that the functions are small enough to read and understand.

Swagger documentation

Swagger annotations are used to document that function with Swagger.io.

Tests

@see annotation is used so the developer can immediately jump to the tests of that function.

By using the @see annotation we can also see what is tested for that function.

Database Transactions

Unfortunately, transactions are something that developers don't use!

Error handling and logging

Another important step that developers tend to omit. NOT WITH ME!

Laravel Controller Class

This class is a good example of how my controllers look like.

The class

<?php

namespace App\Http\Controllers\Api\v1;

use App\Exceptions\Error500Exception;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\v1\TargetProfileCloneRequest;
use App\Http\Requests\Api\v1\TargetProfileStoreRequest;
use App\Http\Requests\Api\v1\TargetProfileUpdateRequest;
use App\Http\Resources\Api\v1\TargetProfileCollection;
use App\Http\Resources\Api\v1\TargetProfileResource;
use App\Utopia\Repositories\Interfaces\TargetProfileRepoInterface;
use Illuminate\Http\JsonResponse;
use Tests\Feature\Http\Controllers\Api\v1\TargetProfileControllerTest;

/**
 * Class TargetProfileController
 *
 * This class is responsible for creating, updating, deleting and showing target profiles.
 *
 * @package App\Http\Controllers\Api\v1;
 */
class TargetProfileController extends Controller
{
    protected $targetProfileRepo;

    /**
     * TargetProfileController constructor.
     *
     * @param TargetProfileRepoInterface $targetProfileRepo
     */
    public function __construct(TargetProfileRepoInterface $targetProfileRepo)
    {
        $this->targetProfileRepo = $targetProfileRepo;
    }

    /**
     * @OA\Get(
     *     path="/api/v1/target_profiles",
     *     description="Get list of target profiles for authenticated user.",
     *     tags={"Target profile"},
     *     security={
     *      {"passport": {}},
     *     },
     *     @OA\Response(response="200", description="Success"),
     *     @OA\Response(response="500", description="Server error")
     * )
     *
     * Get list of target profiles for authenticated user.
     *
     * @see TargetProfileControllerTest::will_return_empty_data_if_user_has_no_target_profiles_saved
     * @see TargetProfileControllerTest::will_return_public_target_profiles
     * @see TargetProfileControllerTest::will_return_private_target_profiles
     * @see TargetProfileControllerTest::will_return_private_and_public_target_profiles()
     *
     * @return TargetProfileCollection
     * @throws Error500Exception
     */
    public function index()
    {
        try {
            $publicTargetProfiles = $this->targetProfileRepo->getPublicTargetProfiles('plan1');

            $targetProfiles = $publicTargetProfiles->merge(auth()->user()->targetProfiles()->get())
                ->sortByDesc('created_at')
                ->unique();

            return new TargetProfileCollection($targetProfiles);
        } catch (\Exception $e) {
            throw new Error500Exception($e);
        }
    }


    /**
     * @OA\Get(
     *     path="/api/v1/target_profiles/{id}",
     *     description="Get a single target profile.",
     *     tags={"Target profile"},
     *     security={
     *      {"passport": {}},
     *     },
     *      @OA\Parameter(name="id", in="path", description="ID", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *     @OA\Response(response="200", description="Success"),
     *     @OA\Response(response="403", description="Unauthorized"),
     *     @OA\Response(response="404", description="Not found"),
     *     @OA\Response(response="500", description="Server error")
     * )
     *
     * Get a single target profile.
     *
     * @see TargetProfileControllerTest::will_fail_with_404_if_target_profile_does_not_exist()
     * @see TargetProfileControllerTest::will_fail_with_403_if_target_profile_does_not_belong_to_user()
     * @see TargetProfileControllerTest::will_return_target_profile()
     *
     * @param string $id
     * @return TargetProfileResource|JsonResponse
     * @throws Error500Exception
     */
    public function show(string $id)
    {
        try {
            if (!($targetProfile = $this->targetProfileRepo->byID($id)))
                return $this->notFound();

            if (auth()->user()->cannot('view', $targetProfile))
                return $this->notAuthorized();

            return new TargetProfileResource($targetProfile);
        } catch (\Exception $e) {
            throw new Error500Exception($e);
        }
    }

    /**
     * @OA\Post(
     *     path="/api/v1/target_profiles",
     *     description="Create target profile.",
     *     tags={"Target profile"},
     *     security={
     *      {"passport": {}},
     *     },
     *      @OA\Parameter(name="name", in="query", description="Name", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *      @OA\Parameter(name="description", in="query", description="Description",
     *         @OA\Schema(type="string")
     *     ),
     *      @OA\Parameter(name="data", in="query", description="Data", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *     @OA\Response(response="201", description="Created"),
     *     @OA\Response(response="422", description="Validation errors"),
     *     @OA\Response(response="500", description="Server error")
     * )
     *
     * Create target profile.
     *
     * @see TargetProfileControllerTest::will_fail_with_validation_errors_when_creating_target_profile()
     * @see TargetProfileControllerTest::will_create_target_profile
     *
     * @param TargetProfileStoreRequest $request
     * @return TargetProfileResource
     * @throws Error500Exception
     */
    public function store(TargetProfileStoreRequest $request): TargetProfileResource
    {
        try {
            $this->beginTransaction();

            $targetProfile = $this->targetProfileRepo->create([
                'user_id' => auth()->id(),
                'name' => $request->name,
                'description' => $request->description,
                'data' => $request->data,
                'scope' => 'private'
            ]);

            $this->commit();

            return new TargetProfileResource($targetProfile);
        } catch (\Exception $e) {
            $this->rollBack();

            throw new Error500Exception($e);
        }
    }

    /**
     * @OA\Put(
     *     path="/api/v1/target_profiles/{id}",
     *     description="Update target profile.",
     *     tags={"Target profile"},
     *     security={
     *      {"passport": {}},
     *     },
     *      @OA\Parameter(name="id", in="path", description="ID", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *      @OA\Parameter(name="name", in="query", description="Name", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *      @OA\Parameter(name="description", in="query", description="Description",
     *         @OA\Schema(type="string")
     *     ),
     *      @OA\Parameter(name="data", in="query", description="Data", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *     @OA\Response(response="200", description="Success"),
     *     @OA\Response(response="403", description="Unauthorized"),
     *     @OA\Response(response="404", description="Not found"),
     *     @OA\Response(response="422", description="Validation errors"),
     *     @OA\Response(response="500", description="Server error")
     * )
     *
     * Update target profile.
     *
     * @see TargetProfileControllerTest::will_fail_with_validation_errors_when_updating_target_profile()
     * @see TargetProfileControllerTest::will_fail_with_404_when_profile_does_not_exist_for_update()
     * @see TargetProfileControllerTest::will_update_target_profile_if_user_is_owner
     * @see TargetProfileControllerTest::will_update_target_profile_if_user_is_part_of_the_company
     * @see TargetProfileControllerTest::will_create_a_new_target_profile_from_public_template_if_user_plan_allows_it
     * @see TargetProfileControllerTest::will_fail_with_403_if_user_cannot_update_or_create_target_profile()
     *
     * @param TargetProfileUpdateRequest $request
     * @param string $id
     * @return JsonResponse|TargetProfileResource
     * @throws Error500Exception
     */
    public function update(TargetProfileUpdateRequest $request, string $id)
    {
        try {
            $this->beginTransaction();

            if (!($targetProfile = $this->targetProfileRepo->byID($id)))
                return $this->notFound();

            if ($this->isOwner(auth()->user(), $targetProfile))
                $targetProfile = $this->targetProfileRepo->update($targetProfile, [
                    'name' => $request->name,
                    'description' => $request->description,
                    'data' => $request->data
                ]);
            else if ($targetProfile->scope === auth()->user()->plan)
                $targetProfile = $this->targetProfileRepo->create([
                    'user_id' => auth()->id(),
                    'name' => $request->name,
                    'description' => $request->description,
                    'data' => $request->data,
                    'scope' => 'private'
                ]);
            else return $this->notAuthorized();

            $this->commit();

            return new TargetProfileResource($targetProfile);
        } catch (\Exception $e) {
            $this->rollBack();

            throw new Error500Exception($e);
        }
    }

    /**
     * @OA\Delete(
     *     path="/api/v1/target_profiles/{id}",
     *     description="Delete target profile.",
     *     tags={"Target profile"},
     *     security={
     *      {"passport": {}},
     *     },
     *      @OA\Parameter(name="id", in="path", description="ID", required=true,
     *         @OA\Schema(type="string")
     *     ),
     *     @OA\Response(response="204", description="No content"),
     *     @OA\Response(response="403", description="Unauthorized"),
     *     @OA\Response(response="404", description="Not found"),
     *     @OA\Response(response="500", description="Server error")
     * )
     *
     * Delete target profile.
     *
     * @see TargetProfileControllerTest::will_fail_with_404_if_target_profile_does_not_exist_when_deleting
     * @see TargetProfileControllerTest::will_fail_with_403_if_target_profile_does_not_belong_to_user_when_deleting
     * @see TargetProfileControllerTest::will_delete_target_profile
     *
     * @param string $id
     * @return JsonResponse
     * @throws Error500Exception
     */
    public function destroy(string $id)
    {
        try {
            $this->beginTransaction();

            if (!($targetProfile = $this->targetProfileRepo->byID($id)))
                return $this->notFound();

            if ($this->notOwner(auth()->user(), $targetProfile))
                return $this->notAuthorized();

            $this->targetProfileRepo->delete($targetProfile);

            $this->commit();

            return response()->json(null, 204);
        } catch (\Exception $e) {
            $this->rollBack();

            throw new Error500Exception($e);
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295

Laravel Controller Test Class

This is the test class for the controller above.

This is going to be long, prepare yourself!

<?php

namespace Tests\Feature\Http\Controllers\Api\v1;

use App\Http\Controllers\Api\v1\TargetProfileController;
use Carbon\Carbon;
use Illuminate\Support\Str;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class TargetProfileControllerTest extends TestCase
{
    use RefreshDatabase;

    private $user;

    protected function setUp(): void
    {
        parent::setUp();

        $this->user = $this->create('User', [], false);
    }

    protected function tearDown(): void
    {
        parent::tearDown();

        $this->user = null;
    }

    /**
     * @covers TargetProfileController::index()
     * @test
     */
    public function will_return_empty_data_if_user_has_no_target_profiles_saved()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('GET', '/api/v1/target_profiles');

        $response->assertStatus(200)
            ->assertExactJson([
                'data' => []
            ]);
    }

    /**
     * @covers TargetProfileController::index()
     * @test
     */
    public function will_return_public_target_profiles()
    {
        $targetProfile = $this->create('TargetProfile', [
            'scope' => 'plan1'
        ]);

        $response = $this->actingAs($this->user, 'api')
            ->json('GET', '/api/v1/target_profiles');

        $response->assertStatus(200)
            ->assertExactJson([
                'data' => [
                    $targetProfile
                ]
            ]);
    }

    /**
     * @covers TargetProfileController::index()
     * @test
     */
    public function will_return_private_target_profiles()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => $this->user->id
        ], true);

        $response = $this->actingAs($this->user, 'api')
            ->json('GET', '/api/v1/target_profiles');

        $response->assertStatus(200)
            ->assertExactJson([
                'data' => [
                    $targetProfile
                ]
            ]);
    }

    /**
     * @covers TargetProfileController::index()
     * @test
     */
    public function will_return_private_and_public_target_profiles()
    {
        $publicTargetProfile = $this->create('TargetProfile', [
            'scope' => 'plan1',
            'created_at' => Carbon::yesterday()
        ]);

        $privateTargetProfile = $this->create('TargetProfile', [
            'user_id' => $this->user->id,
            'created_at' => Carbon::now()
        ]);

        $response = $this->actingAs($this->user, 'api')
            ->json('GET', '/api/v1/target_profiles');

        $response->assertStatus(200)
            ->assertJsonStructure([
                'data' => [
                    '*' => [
                        'description', 'id', 'json', 'name', 'scope'
                    ]
                ]
            ]);
    }

    /**
     * @covers TargetProfileController::show()
     * @test
     */
    public function will_fail_with_404_if_target_profile_does_not_exist()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('GET', '/api/v1/target_profiles/not_valid');

        $response->assertStatus(404)
            ->assertExactJson([
                'message' => 'Resource not found'
            ]);
    }

    /**
     * @covers TargetProfileController::show()
     * @test
     */
    public function will_fail_with_403_if_target_profile_does_not_belong_to_user()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => 'not_auth_user'
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('GET', "/api/v1/target_profiles/$targetProfile->id");

        $response->assertStatus(403)
            ->assertExactJson([
                'message' => 'Unauthorized'
            ]);
    }

    /**
     * @covers TargetProfileController::show()
     * @test
     */
    public function will_return_target_profile()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => $this->user->id
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('GET', "/api/v1/target_profiles/$targetProfile->id");

        $response->assertStatus(200)
            ->assertExactJson([
                'data' => [
                    'id' => $targetProfile->id,
                    'name' => $targetProfile->name,
                    'description' => $targetProfile->description,
                    'json' => '{"test": 123}',
                    'scope' => 'private'
                ]
            ]);
    }

    /**
     * @covers TargetProfileController::store()
     * @test
     */
    public function will_fail_with_validation_errors_when_creating_target_profile()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('POST', '/api/v1/target_profiles');

        $response->assertStatus(422)
            ->assertExactJson([
                'errors' => [
                    'name' => ['The name field is required.'],
                    'data' => ['The data field is required.']
                ],

                'message' => 'The given data was invalid.'
            ]);

        $response = $this->actingAs($this->user, 'api')
            ->json('POST', '/api/v1/target_profiles', [
                'name' => Str::random(256),
                'data' => 'not_valid'
            ]);

        $response->assertStatus(422)
            ->assertExactJson([
                'errors' => [
                    'name' => ['The name may not be greater than 255 characters.'],
                    'data' => ['The data must be a valid JSON string.']
                ],

                'message' => 'The given data was invalid.'
            ]);
    }

    /**
     * @covers TargetProfileController::store()
     * @test
     */
    public function will_create_target_profile()
    {
        $name = Str::random(200);
        $description = Str::random();

        $response = $this->actingAs($this->user, 'api')
            ->json('POST', '/api/v1/target_profiles', [
                'name' => $name,
                'description' => $description,
                'data' => '{"test": 123}'
            ]);

        $response->assertStatus(201)
            ->assertExactJson([
                'data' => [
                    'id' => $response->getOriginalContent()->id,
                    'name' => $name,
                    'description' => $description,
                    'json' => '{"test": 123}',
                    'scope' => 'private'
                ]
            ]);

        $this->assertDatabaseHas('target_profiles', [
            'id' => $response->getOriginalContent()->id,
            'user_id' => auth()->id(),
            'name' => $name,
            'description' => $description,
            'data' => '{"test": 123}',
            'scope' => 'private'
        ]);
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_fail_with_validation_errors_when_updating_target_profile()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', '/api/v1/target_profiles/not_valid');

        $response->assertStatus(422)
            ->assertExactJson([
                'errors' => [
                    'data' => [
                        'The data field is required.'
                    ],

                    'name' => [
                        'The name field is required.'
                    ]
                ],

                'message' => 'The given data was invalid.'
            ]);

        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', '/api/v1/target_profiles/not_valid', [
                'name' => Str::random(256),
                'data' => 'not_valid_json'
            ]);

        $response->assertStatus(422)
            ->assertExactJson([
                'errors' => [
                    'data' => [
                        'The data must be a valid JSON string.'
                    ],

                    'name' => [
                        'The name may not be greater than 255 characters.'
                    ]
                ],

                'message' => 'The given data was invalid.'
            ]);
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_fail_with_404_when_profile_does_not_exist_for_update()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', '/api/v1/target_profiles/not_valid', [
                'name' => 'test',
                'data' => '{"test": "test"}'
            ]);

        $response->assertStatus(404)
            ->assertExactJson([
                'message' => 'Resource not found'
            ]);
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_update_target_profile_if_user_is_owner()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => $this->user->id
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', "/api/v1/target_profiles/$targetProfile->id", [
                'name' => $name = Str::random(),
                'description' => $description = Str::random(),
                'data' => '{"updated": true}'
            ]);

        $response->assertStatus(200)
            ->assertExactJson([
                'data' => [
                    'id' => $response->getOriginalContent()->id,
                    'name' => $name,
                    'description' => $description,
                    'json' => '{"updated": true}',
                    'scope' => 'private'
                ]
            ]);

        $this->assertDatabaseHas('target_profiles', [
            'id' => $response->getOriginalContent()->id,
            'user_id' => $this->user->id,
            'name' => $name,
            'description' => $description,
            'data' => '{"updated": true}',
            'scope' => 'private'
        ]);
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_update_target_profile_if_user_is_part_of_the_company()
    {
        $this->markTestIncomplete();
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_create_a_new_target_profile_from_public_template_if_user_plan_allows_it()
    {
        $targetProfile = $this->create('TargetProfile', [
            'scope' => 'plan1',
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', "/api/v1/target_profiles/$targetProfile->id", [
                'name' => $name = Str::random(),
                'description' => $description = Str::random(),
                'data' => '{"updated": true}'
            ]);

        $response->assertStatus(201)
            ->assertExactJson([
                'data' => [
                    'description' => $description,
                    'id' => $response->getOriginalContent()->id,
                    'json' => '{"updated": true}',
                    'name' => $name,
                    'scope' => 'private'
                ]
            ]);

        $this->assertDatabaseHas('target_profiles', [
            'id' => $response->getOriginalContent()->id,
            'name' => $name,
            'description' => $description,
            'data' => '{"updated": true}',
            'scope' => 'private'
        ]);
    }

    /**
     * @covers TargetProfileController::update()
     * @test
     */
    public function will_fail_with_403_if_user_cannot_update_or_create_target_profile()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => 'not_auth_user'
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('PUT', "/api/v1/target_profiles/$targetProfile->id", [
                'name' => 'test',
                'data' => '{"test": "test"}',
                'scope' => 'private'
            ]);

        $response->assertStatus(403)
            ->assertExactJson([
                'message' => 'Unauthorized'
            ]);
    }

    /**
     * @covers TargetProfileController::destroy()
     * @test
     */
    public function will_fail_with_404_if_target_profile_does_not_exist_when_deleting()
    {
        $response = $this->actingAs($this->user, 'api')
            ->json('DELETE', '/api/v1/target_profiles/not_valid');

        $response->assertStatus(404)
            ->assertExactJson([
                'message' => 'Resource not found'
            ]);
    }

    /**
     * @covers TargetProfileController::destroy()
     * @test
     */
    public function will_fail_with_403_if_target_profile_does_not_belong_to_user_when_deleting()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => 'not_auth_user'
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('DELETE', "/api/v1/target_profiles/$targetProfile->id");

        $response->assertStatus(403)
            ->assertExactJson([
                'message' => 'Unauthorized'
            ]);
    }

    /**
     * @covers TargetProfileController::destroy()
     * @test
     */
    public function will_delete_target_profile()
    {
        $targetProfile = $this->create('TargetProfile', [
            'user_id' => $this->user->id
        ], false);

        $response = $this->actingAs($this->user, 'api')
            ->json('DELETE', "/api/v1/target_profiles/$targetProfile->id");

        $response->assertStatus(204)
            ->assertSee(null);

        $this->assertDatabaseMissing('target_profiles', [
            'id' => $targetProfile->id
        ]);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474