Issues (2)

src/AdventOfCode.php (1 issue)

1
<?php
2
3
require(dirname(__DIR__) . '/vendor/autoload.php');
4
5
try {
6
    $options = getopt('y:d:');
7
    if (!is_array($options) || (!isset($options['y']) || !isset($options['d']))) {
0 ignored issues
show
The condition is_array($options) is always true.
Loading history...
8
        throw new Exception("Provide a year -y and a day -d");
9
    }
10
11
    $year = is_string($options['y']) ? $options['y'] : '';
12
    $day = is_string($options['d']) ? $options['d'] : '';
13
14
    $classname = "\\DaanMooij\\AdventOfCode\\Year{$year}\\Day{$day}\\Day{$day}";
15
    if (!class_exists($classname)) {
16
        throw new Exception("Class does not exist: {$classname}");
17
    }
18
    $day = new $classname();
19
20
    $day->loadInput();
21
    $day->solve();
22
} catch (Exception $e) {
23
    print $e->getMessage() . PHP_EOL;
24
}
25