Skip to content

Commit dba938f

Browse files
committedJul 10, 2024
Initial commit
0 parents  commit dba938f

27 files changed

+2993
-0
lines changed
 

‎.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.phpunit.result.cache
3+
vendor

‎README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ExampleCom client
2+
3+
## Часть 1:
4+
5+
Задача:
6+
> Есть список директорий неизвестно насколько большой вложенности
7+
> В директории может быть файл count
8+
> Нужно пройтись по всем директориям и вернуть сумму всех чисел из файла count (файлов count может быть много)
9+
10+
Пример: `examples/part_1.php`
11+
12+
## Часть 2:
13+
14+
Задача:
15+
> Необходимо реализовать клиент для абстрактного (вымышленного) сервиса комментариев "example.com". Проект должен представлять класс или набор классов, который будет делать http запросы к серверу.
16+
> На выходе должна получиться библиотека, который можно будет подключить через composer к любому другому проекту.
17+
> У этого сервиса есть 3 метода:
18+
>
19+
> GET http://example.com/comments - возвращает список комментариев
20+
>
21+
> POST http://example.com/comment - добавить комментарий.
22+
>
23+
> PUT http://example.com/comment/{id} - по идентификатору комментария обновляет поля, которые были в в запросе
24+
>
25+
> Объект comment содержит поля:
26+
> id - тип int. Не нужно указывать при добавлении.
27+
> name - тип string.
28+
> text - тип string.
29+
>
30+
> Написать phpunit тесты, на которых будет проверяться работоспособность клиента.
31+
> Сервер example.com писать не надо! Только библиотеку для работы с ним.
32+
33+
Пример: `examples/part_2.php`
34+
35+
# Lint & Tests:
36+
37+
```bash
38+
docker compose up
39+
```
40+
41+
# Setup
42+
43+
```bash
44+
composer require flexnst/example-com-client
45+
```

‎compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
composer:
3+
image: composer:2
4+
pull_policy: always
5+
restart: no
6+
volumes:
7+
- '.:/app'
8+
working_dir: '/app'
9+
entrypoint: [ "/bin/bash", "-c" ]
10+
command:
11+
- |
12+
composer install --ignore-platform-reqs
13+
vendor/bin/phpstan analyse examples src tests
14+
echo -e "\n=== Задача №1: ==="
15+
php examples/part_1.php
16+
echo -e "\n\n=== Задача №2: ==="
17+
vendor/bin/phpunit -c phpunit.xml --testsuite Unit
18+
vendor/bin/phpunit -c phpunit.xml --testsuite Feature

‎composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "flexnst/example-com-client",
3+
"description": "Example.com comments client",
4+
"version": "1.0.0",
5+
"type": "library",
6+
"keywords": [
7+
"tz",
8+
"example.com",
9+
"comments",
10+
"client"
11+
],
12+
"authors": [
13+
{
14+
"name": "Alexandr Chernov",
15+
"email": "flex.nst@gmail.com"
16+
}
17+
],
18+
"require": {
19+
"php": "8.2",
20+
"guzzlehttp/guzzle": "^7.0"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^10.0",
24+
"phpstan/phpstan": "^1.11"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"ExampleCom\\": "src/"
29+
}
30+
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"Tests\\": "tests/"
34+
}
35+
},
36+
"config": {
37+
"optimize-autoloader": true,
38+
"preferred-install": "dist",
39+
"sort-packages": true
40+
},
41+
"prefer-stable": true
42+
}

0 commit comments

Comments
 (0)
Please sign in to comment.