You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Period` is PHP's missing time range API. It is based on[Resolving Feature Envy in the Domain](http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/) by Mathias Verraes and extends the concept to cover all basic operations regarding time ranges.
11
+
`Period` is PHP's missing time range API. Based on ideas from[Resolving Feature Envy in the Domain](http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/) by Mathias Verraes, this package extends the concept to cover all basic operations regarding time ranges.
12
12
13
13
## Highlights
14
14
15
-
-Treats a time range as an immutable value object
16
-
- Exposes many named constructors to ease time range creation
15
+
-Represents Interval, Datepoint, Duration and Collection as value objects
16
+
- Exposes named constructors to ease object creation
17
17
- Covers all basic manipulations related to time range
18
+
- Enables working with simple or complex time ranges logic
18
19
- Fully documented
19
20
- Framework-agnostic
20
-
- Composer ready, [PSR-2], and [PSR-4] compliant
21
21
22
22
Documentation
23
23
-------
@@ -38,6 +38,22 @@ Install `Period` using Composer.
38
38
$ composer require league/period
39
39
```
40
40
41
+
or download the library and:
42
+
43
+
- use any other [PSR-4](http://www.php-fig.org/psr/psr-4/) compatible autoloader.
44
+
- use the bundle autoloader script as shown below:
`Period` is PHP's missing time range API. It is based on[Resolving Feature Envy in the Domain](//verraes.net/2014/08/resolving-feature-envy-in-the-domain/) by Mathias Verraes and extends the concept to cover all basic operations regarding interval.
15
+
`Period` is PHP's missing time range API. Based on ideas from[Resolving Feature Envy in the Domain](http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/) by Mathias Verraes, this package extends the concept to cover all basic operations regarding time ranges.
16
16
17
17
<pclass="message-info">In your code, you will always have to typehint against the <code>League\Period\Period</code> class directly because it is a immutable value object class marked as final and the library does not provide an interface.</p>
18
18
19
19
<pclass="message-info">Since <code>version 4.1</code> a <code>League\Period\Sequence</code> class is added to improve manipulating a collection of <code>Period</code> objects.</p>
20
20
21
+
<pclass="message-info">Since <code>version 4.4</code> the <code>Period</code> objects supports all types of boundary with the exception of unbounded interval.</p>
22
+
21
23
## Accessing the interval properties
22
24
23
25
~~~php
@@ -26,6 +28,7 @@ use League\Period\Period;
26
28
$interval = new Period(
27
29
new DateTime('2014-10-03 08:12:37'),
28
30
new DateTimeImmutable('2014-10-03 08:12:37')
31
+
Period::INCLUDE_START_EXCLUDE_END
29
32
);
30
33
$start = $interval->getStartDate(); //returns a DateTimeImmutable
31
34
$end = $interval->getEndDate(); //returns a DateTimeImmutable
@@ -51,13 +54,19 @@ To help easily instantiate your time range and manipulating it, the package come
Copy file name to clipboardExpand all lines: docs/4.0/upgrading.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,40 @@ The following methods were already marked as deprecated is the `3.x` line. They
40
40
41
41
### Named constructors
42
42
43
-
To reduce code and allow more flexibility all named constructors have been removed from the `Period` class. They are replaced by functions defined in the same namespace as the `Period` class.
43
+
If you are migrating from `3.x` to `4.2+` version you should use the new named constructors
44
+
45
+
| old named constructors | new named constructors |
Copy file name to clipboardExpand all lines: docs/_data/project.yml
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -25,11 +25,11 @@ author:
25
25
name: 'Ignace Nyamagana Butera'
26
26
twitter_account: 'nyamsprod'
27
27
highlights:
28
-
description: "<code>Period</code> is PHP's Time Range class. It is based on <a href=\"http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/\">Resolving Feature Envy in the Domain</a> by Mathias Verraes and extends the concept to cover all basic operations regarding time ranges."
28
+
description: "<code>Period</code> is PHP's Time Range class. Based on ideas from <a href=\"http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/\">Resolving Feature Envy in the Domain</a> by Mathias Verraes, this package extends the concept to cover all basic operations regarding time ranges."
29
29
features:
30
-
- Treats date and time range as immutable value objects
31
-
- Exposes named constructors to ease time range creation
30
+
- Uses Immutable Value Objects
31
+
- Uses named constructors to ease object creation
32
32
- Covers all basic manipulations related to time range
33
-
- Framework-agnostic
33
+
- Enables working with simple or complex time ranges logic
34
34
composer: '$ composer require league/period'
35
35
support: 'Once a new major version is released, the previous stable release remains supported for six more months through patches and security fixes.'
To help you start working with `Period` objects, the library comes bundled with many more named constructors to ease manipulating datetime intervals.
24
+
To help you start working with `Period` objects, the library comes bundled with many more named constructors to ease datepoint, duration and intervals creation.
25
25
26
26
## iterating over the interval made simple
27
27
@@ -47,15 +47,17 @@ The library also allow iterating backwards over the interval.
47
47
48
48
## compare intervals and datepoints
49
49
50
-
You can compare time ranges based on their durationand/or their datepoints.
50
+
You can compare time ranges based on their duration, their datepoints and even their boundary types.
0 commit comments