-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
4 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,30 +17,19 @@ | |
* @author Roman Ožana <[email protected]> | ||
*/ | ||
class IcalParser { | ||
|
||
/** @var ?DateTimeZone */ | ||
public ?DateTimeZone $timezone = null; | ||
|
||
/** @var array|null */ | ||
public ?array $data = null; | ||
|
||
/** @var array */ | ||
protected array $counters = []; | ||
|
||
/** @var array */ | ||
private array $windowsTimezones; | ||
|
||
public function __construct() { | ||
$this->windowsTimezones = require __DIR__ . '/WindowsTimezones.php'; // load Windows timezones from separate file | ||
} | ||
|
||
/** | ||
* @param string $file | ||
* @param callable|null $callback | ||
* @return array|null | ||
* @throws Exception | ||
*/ | ||
public function parseFile(string $file, callable $callback = null): ?array { | ||
public function parseFile(string $file, ?callable $callback = null): ?array { | ||
if (!$handle = fopen($file, 'rb')) { | ||
throw new RuntimeException('Can\'t open file' . $file . ' for reading.'); | ||
} | ||
|
@@ -50,13 +39,10 @@ public function parseFile(string $file, callable $callback = null): ?array { | |
} | ||
|
||
/** | ||
* @param string $string | ||
* @param callable|null $callback | ||
* @param boolean $add if true the parsed string is added to existing data | ||
* @return array|null | ||
* @throws Exception | ||
*/ | ||
public function parseString(string $string, callable $callback = null, bool $add = false): ?array { | ||
public function parseString(string $string, ?callable $callback = null, bool $add = false): ?array { | ||
if ($add === false) { | ||
// delete old data | ||
$this->data = []; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters