Skip to content

Commit

Permalink
Added README and CHANGELOG entries
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed Aug 29, 2016
1 parent 0a7249f commit 1369cfd
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com).

## 1.0.0 - 2016-08-29

### Added

* Interval validation in boolean and/or guarding manner
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,67 @@

A validator for crontab values

## Features

* Validation of crontab interval strings like <kbd>6,21,36,51 7-23/1 * FEB-NOV/2 *</kbd>.

## Requirements

* PHP >= 7.0.0

## Usage

### Boolean validation

```php
<?php declare(strict_types=1);

namespace MyVendor\MyProject;

use hollodotme\CrontabValidator\CrontabValidator;

$validator = new CrontabValidator();
if ( $validator->isIntervalValid('6,21,36,51 7-23/1 * FEB-NOV/2 *') )
{
echo "Interval is valid.";
}
else
{
echo "Interval is invalid.";
}
```

### Guarding

```php
<?php declare(strict_types=1);

namespace MyVendor\MyProject;

use hollodotme\CrontabValidator\CrontabValidator;
use hollodotme\CrontabValidator\Exceptions\InvalidCrontabInterval;

$validator = new CrontabValidator();

try
{
# => All fine, execution continues
$validator->guardIntervalIsValid('6,21,36,51 7-23/1 * FEB-NOV/2 *');

# => This will raise an InvalidCrontabInterval exception
$validator->guardIntervalIsValid('this is not a valid interval');
}
catch (InvalidCrontabInterval $e)
{
echo $e->getMessage() . ': "' . $e->getCrontabInterval() . '"';
}
```

**Prints:**

Invalid crontab interval: "this is not a valid interval"


---

Feedback and contributions welcome!

0 comments on commit 1369cfd

Please sign in to comment.