├── .gitignore
├── screenshot.png
├── composer.json
├── app.php
├── README.md
├── src
└── Command
│ └── FixturesCommand.php
└── composer.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | composer.phar
3 | .DS_Store
4 | Thumbs.db
5 | .idea
6 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emir/euro2016/HEAD/screenshot.png
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "symfony/console": "^3.1",
4 | "guzzlehttp/guzzle": "~6.0"
5 | },
6 | "autoload": {
7 | "psr-4": {
8 | "Euro2016\\": "src/"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | add(new FixturesCommand($client));
13 | $application->run();
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Euro2016
2 | =================
3 |
4 | UEFA EURO 2016 results for hackers.
5 |
6 | [http://api.football-data.org/index](http://api.football-data.org/index)
7 |
8 | Data Source: [http://api.football-data.org/v1/soccerseasons/424](http://api.football-data.org/v1/soccerseasons/424)
9 |
10 |
11 |
12 |
13 | ### Installing
14 |
15 | After cloning the repository:
16 |
17 | ```
18 | composer install
19 | ```
20 |
21 | **Important: You should set date.timezone on your php.ini**
22 |
23 |
24 | Usage
25 | ------------
26 |
27 | `php app.php fixtures`
28 |
29 | Default argument is today. Also **current**, **finished** and **all** are supported arguments.
30 | With argument **all** you can specified team you want to see schedule/results. For example:
31 |
32 | `php app.php fixtures all -t Turkey`
33 |
34 | You can always add **euro2016** alias on your .bashrc or .zshrc (That's how I use)
35 |
36 | `alias euro2016='php projects/euro2016/app.php fixtures'`
37 |
38 | and use like this:
39 |
40 | `euro2016 current`
41 |
42 | License
43 | -------------
44 |
45 | [MIT License](http://emir.mit-license.org/)
46 |
--------------------------------------------------------------------------------
/src/Command/FixturesCommand.php:
--------------------------------------------------------------------------------
1 | client = $client;
31 | }
32 |
33 | protected function configure()
34 | {
35 | $this
36 | ->setName('fixtures')
37 | ->setDescription('Fixtures')
38 | ->addArgument(
39 | 'status',
40 | InputArgument::OPTIONAL,
41 | 'TODAY, CURRENT, FINISHED, ALL are valid options. Default is today.'
42 | )
43 | ->addOption(
44 | 'team',
45 | 't',
46 | InputOption::VALUE_REQUIRED,
47 | 'Only return specified team\'s matches'
48 | )
49 | ;
50 | }
51 |
52 | protected function fetch()
53 | {
54 | try{
55 | $request = $this->client->get('http://api.football-data.org/v1/soccerseasons/424/fixtures', [
56 | 'headers' => [
57 | 'X-AUTH-TOKEN' => '53e6bee2dade46858d67b06f85972363'
58 | ]
59 | ]);
60 | } catch (\Exception $e) {
61 | return die("Looks like something wrong with API. You can always open issue here: https://github.com/emir/euro2016/issues\n");
62 | }
63 |
64 | return json_decode($request->getBody()->getContents());
65 | }
66 |
67 | protected function execute(InputInterface $input, OutputInterface $output)
68 | {
69 | $status = strtoupper($input->getArgument('status'));
70 |
71 | if(!$status) {
72 | $status = 'TODAY';
73 | }
74 |
75 | $data = $this->fetch();
76 |
77 | foreach ($data->fixtures as $fixture) {
78 | if($status == 'CURRENT' && $fixture->status == 'IN_PLAY') {
79 | $this->output($output, $fixture->status, $fixture->date, $fixture->homeTeamName, $fixture->awayTeamName,
80 | $fixture->result->goalsHomeTeam, $fixture->result->goalsAwayTeam);
81 | }
82 |
83 | if($status == 'ALL') {
84 | if ($input->getOption('team')) {
85 | if($fixture->homeTeamName === $input->getOption('team') || $fixture->awayTeamName === $input->getOption('team')) {
86 | $this->output($output, $fixture->status, $fixture->date, $fixture->homeTeamName,
87 | $fixture->awayTeamName, $fixture->result->goalsHomeTeam, $fixture->result->goalsAwayTeam);
88 | }
89 | } else {
90 | $this->output($output, $fixture->status, $fixture->date, $fixture->homeTeamName,
91 | $fixture->awayTeamName, $fixture->result->goalsHomeTeam, $fixture->result->goalsAwayTeam);
92 | }
93 | }
94 |
95 | if($status == 'FINISHED' && $fixture->status == 'FINISHED') {
96 | $this->output($output, $fixture->status, $fixture->date, $fixture->homeTeamName, $fixture->awayTeamName,
97 | $fixture->result->goalsHomeTeam, $fixture->result->goalsAwayTeam);
98 | }
99 |
100 | if($status == 'TODAY') {
101 | $match_date = new DateTime($fixture->date);
102 | $match_date->setTimezone(new DateTimeZone(date_default_timezone_get()));
103 |
104 | if($match_date->format('d') == (new DateTime())->format('d')) {
105 | $this->output($output, $fixture->status, $fixture->date, $fixture->homeTeamName,
106 | $fixture->awayTeamName, $fixture->result->goalsHomeTeam, $fixture->result->goalsAwayTeam);
107 | }
108 | }
109 | }
110 | }
111 |
112 | protected function output(OutputInterface $output, $status, $date, $homeTeam, $awayTeam, $goalsHome, $goalsAway)
113 | {
114 | if(!$date instanceof DateTime) {
115 | $date = new DateTime($date);
116 | $date->setTimezone( new DateTimeZone(date_default_timezone_get()));
117 | }
118 |
119 | return $output->writeln("($status {$date->format('l M, d - H:i')}) {$homeTeam} {$goalsHome} - {$awayTeam} {$goalsAway}");
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "hash": "9e1dda049063d618c456aa7b6bfbbfee",
8 | "content-hash": "c08947a35d81313f1a829db0a149cbbb",
9 | "packages": [
10 | {
11 | "name": "guzzlehttp/guzzle",
12 | "version": "6.2.0",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/guzzle/guzzle.git",
16 | "reference": "d094e337976dff9d8e2424e8485872194e768662"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
21 | "reference": "d094e337976dff9d8e2424e8485872194e768662",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "guzzlehttp/promises": "~1.0",
26 | "guzzlehttp/psr7": "~1.1",
27 | "php": ">=5.5.0"
28 | },
29 | "require-dev": {
30 | "ext-curl": "*",
31 | "phpunit/phpunit": "~4.0",
32 | "psr/log": "~1.0"
33 | },
34 | "type": "library",
35 | "extra": {
36 | "branch-alias": {
37 | "dev-master": "6.2-dev"
38 | }
39 | },
40 | "autoload": {
41 | "files": [
42 | "src/functions_include.php"
43 | ],
44 | "psr-4": {
45 | "GuzzleHttp\\": "src/"
46 | }
47 | },
48 | "notification-url": "https://packagist.org/downloads/",
49 | "license": [
50 | "MIT"
51 | ],
52 | "authors": [
53 | {
54 | "name": "Michael Dowling",
55 | "email": "mtdowling@gmail.com",
56 | "homepage": "https://github.com/mtdowling"
57 | }
58 | ],
59 | "description": "Guzzle is a PHP HTTP client library",
60 | "homepage": "http://guzzlephp.org/",
61 | "keywords": [
62 | "client",
63 | "curl",
64 | "framework",
65 | "http",
66 | "http client",
67 | "rest",
68 | "web service"
69 | ],
70 | "time": "2016-03-21 20:02:09"
71 | },
72 | {
73 | "name": "guzzlehttp/promises",
74 | "version": "1.2.0",
75 | "source": {
76 | "type": "git",
77 | "url": "https://github.com/guzzle/promises.git",
78 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
79 | },
80 | "dist": {
81 | "type": "zip",
82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
83 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
84 | "shasum": ""
85 | },
86 | "require": {
87 | "php": ">=5.5.0"
88 | },
89 | "require-dev": {
90 | "phpunit/phpunit": "~4.0"
91 | },
92 | "type": "library",
93 | "extra": {
94 | "branch-alias": {
95 | "dev-master": "1.0-dev"
96 | }
97 | },
98 | "autoload": {
99 | "psr-4": {
100 | "GuzzleHttp\\Promise\\": "src/"
101 | },
102 | "files": [
103 | "src/functions_include.php"
104 | ]
105 | },
106 | "notification-url": "https://packagist.org/downloads/",
107 | "license": [
108 | "MIT"
109 | ],
110 | "authors": [
111 | {
112 | "name": "Michael Dowling",
113 | "email": "mtdowling@gmail.com",
114 | "homepage": "https://github.com/mtdowling"
115 | }
116 | ],
117 | "description": "Guzzle promises library",
118 | "keywords": [
119 | "promise"
120 | ],
121 | "time": "2016-05-18 16:56:05"
122 | },
123 | {
124 | "name": "guzzlehttp/psr7",
125 | "version": "1.3.0",
126 | "source": {
127 | "type": "git",
128 | "url": "https://github.com/guzzle/psr7.git",
129 | "reference": "31382fef2889136415751badebbd1cb022a4ed72"
130 | },
131 | "dist": {
132 | "type": "zip",
133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72",
134 | "reference": "31382fef2889136415751badebbd1cb022a4ed72",
135 | "shasum": ""
136 | },
137 | "require": {
138 | "php": ">=5.4.0",
139 | "psr/http-message": "~1.0"
140 | },
141 | "provide": {
142 | "psr/http-message-implementation": "1.0"
143 | },
144 | "require-dev": {
145 | "phpunit/phpunit": "~4.0"
146 | },
147 | "type": "library",
148 | "extra": {
149 | "branch-alias": {
150 | "dev-master": "1.0-dev"
151 | }
152 | },
153 | "autoload": {
154 | "psr-4": {
155 | "GuzzleHttp\\Psr7\\": "src/"
156 | },
157 | "files": [
158 | "src/functions_include.php"
159 | ]
160 | },
161 | "notification-url": "https://packagist.org/downloads/",
162 | "license": [
163 | "MIT"
164 | ],
165 | "authors": [
166 | {
167 | "name": "Michael Dowling",
168 | "email": "mtdowling@gmail.com",
169 | "homepage": "https://github.com/mtdowling"
170 | }
171 | ],
172 | "description": "PSR-7 message implementation",
173 | "keywords": [
174 | "http",
175 | "message",
176 | "stream",
177 | "uri"
178 | ],
179 | "time": "2016-04-13 19:56:01"
180 | },
181 | {
182 | "name": "psr/http-message",
183 | "version": "1.0",
184 | "source": {
185 | "type": "git",
186 | "url": "https://github.com/php-fig/http-message.git",
187 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
188 | },
189 | "dist": {
190 | "type": "zip",
191 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
192 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
193 | "shasum": ""
194 | },
195 | "require": {
196 | "php": ">=5.3.0"
197 | },
198 | "type": "library",
199 | "extra": {
200 | "branch-alias": {
201 | "dev-master": "1.0.x-dev"
202 | }
203 | },
204 | "autoload": {
205 | "psr-4": {
206 | "Psr\\Http\\Message\\": "src/"
207 | }
208 | },
209 | "notification-url": "https://packagist.org/downloads/",
210 | "license": [
211 | "MIT"
212 | ],
213 | "authors": [
214 | {
215 | "name": "PHP-FIG",
216 | "homepage": "http://www.php-fig.org/"
217 | }
218 | ],
219 | "description": "Common interface for HTTP messages",
220 | "keywords": [
221 | "http",
222 | "http-message",
223 | "psr",
224 | "psr-7",
225 | "request",
226 | "response"
227 | ],
228 | "time": "2015-05-04 20:22:00"
229 | },
230 | {
231 | "name": "symfony/console",
232 | "version": "v3.1.0",
233 | "source": {
234 | "type": "git",
235 | "url": "https://github.com/symfony/console.git",
236 | "reference": "f62db5b8afec27073a4609b8c84b1f9936652259"
237 | },
238 | "dist": {
239 | "type": "zip",
240 | "url": "https://api.github.com/repos/symfony/console/zipball/f62db5b8afec27073a4609b8c84b1f9936652259",
241 | "reference": "f62db5b8afec27073a4609b8c84b1f9936652259",
242 | "shasum": ""
243 | },
244 | "require": {
245 | "php": ">=5.5.9",
246 | "symfony/polyfill-mbstring": "~1.0"
247 | },
248 | "require-dev": {
249 | "psr/log": "~1.0",
250 | "symfony/event-dispatcher": "~2.8|~3.0",
251 | "symfony/process": "~2.8|~3.0"
252 | },
253 | "suggest": {
254 | "psr/log": "For using the console logger",
255 | "symfony/event-dispatcher": "",
256 | "symfony/process": ""
257 | },
258 | "type": "library",
259 | "extra": {
260 | "branch-alias": {
261 | "dev-master": "3.1-dev"
262 | }
263 | },
264 | "autoload": {
265 | "psr-4": {
266 | "Symfony\\Component\\Console\\": ""
267 | },
268 | "exclude-from-classmap": [
269 | "/Tests/"
270 | ]
271 | },
272 | "notification-url": "https://packagist.org/downloads/",
273 | "license": [
274 | "MIT"
275 | ],
276 | "authors": [
277 | {
278 | "name": "Fabien Potencier",
279 | "email": "fabien@symfony.com"
280 | },
281 | {
282 | "name": "Symfony Community",
283 | "homepage": "https://symfony.com/contributors"
284 | }
285 | ],
286 | "description": "Symfony Console Component",
287 | "homepage": "https://symfony.com",
288 | "time": "2016-05-30 06:58:39"
289 | },
290 | {
291 | "name": "symfony/polyfill-mbstring",
292 | "version": "v1.2.0",
293 | "source": {
294 | "type": "git",
295 | "url": "https://github.com/symfony/polyfill-mbstring.git",
296 | "reference": "dff51f72b0706335131b00a7f49606168c582594"
297 | },
298 | "dist": {
299 | "type": "zip",
300 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594",
301 | "reference": "dff51f72b0706335131b00a7f49606168c582594",
302 | "shasum": ""
303 | },
304 | "require": {
305 | "php": ">=5.3.3"
306 | },
307 | "suggest": {
308 | "ext-mbstring": "For best performance"
309 | },
310 | "type": "library",
311 | "extra": {
312 | "branch-alias": {
313 | "dev-master": "1.2-dev"
314 | }
315 | },
316 | "autoload": {
317 | "psr-4": {
318 | "Symfony\\Polyfill\\Mbstring\\": ""
319 | },
320 | "files": [
321 | "bootstrap.php"
322 | ]
323 | },
324 | "notification-url": "https://packagist.org/downloads/",
325 | "license": [
326 | "MIT"
327 | ],
328 | "authors": [
329 | {
330 | "name": "Nicolas Grekas",
331 | "email": "p@tchwork.com"
332 | },
333 | {
334 | "name": "Symfony Community",
335 | "homepage": "https://symfony.com/contributors"
336 | }
337 | ],
338 | "description": "Symfony polyfill for the Mbstring extension",
339 | "homepage": "https://symfony.com",
340 | "keywords": [
341 | "compatibility",
342 | "mbstring",
343 | "polyfill",
344 | "portable",
345 | "shim"
346 | ],
347 | "time": "2016-05-18 14:26:46"
348 | }
349 | ],
350 | "packages-dev": [],
351 | "aliases": [],
352 | "minimum-stability": "stable",
353 | "stability-flags": [],
354 | "prefer-stable": false,
355 | "prefer-lowest": false,
356 | "platform": [],
357 | "platform-dev": []
358 | }
359 |
--------------------------------------------------------------------------------