-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
36 lines (25 loc) · 953 Bytes
/
index.php
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
<?php
require __DIR__ . '/vendor/autoload.php';
use Core\Application;
use Core\Source\WeatherSource;
use Core\Source\Weather\Factory\WeatherstackFactory;
use Core\Storage\Weather\FileStorage;
use Core\Serializer\Weather\{JsonSerializer, XmlSerializer};
use Core\Sorter\Weather\Attributes\AttributesSorter;
use Core\Sorter\Weather\Attributes\Order\{OrderOne, OrderTwo};
$application = new Application();
$sorter = new AttributesSorter(new OrderOne);
$jsonSerializer = new JsonSerializer($sorter);
$source = new WeatherSource(new WeatherstackFactory(), 'Tashkent');
$storage = new FileStorage(
__DIR__ . DIRECTORY_SEPARATOR . 'runtime',
'weather.json',
$jsonSerializer
);
$application->run($source, $storage);
$xmlSerializer = new XmlSerializer($sorter->setOrder(new OrderTwo()));
$source->setLocation('Samarkand');
$storage
->setFileName('weather.xml')
->setSerializer($xmlSerializer);
$application->run($source, $storage);