kirouane / interval Goto Github PK
View Code? Open in Web Editor NEWThis PHP library provides some tools to handle intervals. For instance, you can compute the union or intersection of two intervals.
License: MIT License
This PHP library provides some tools to handle intervals. For instance, you can compute the union or intersection of two intervals.
License: MIT License
Like :
If we have
$Intervale = new Interval(new DateTime('2016-01-01'), new DateTime('2016-01-02'));
$intervals = $Intervale->union(new Interval(new DateTime('2016-01-02'), new DateTime('2016-01-03')));
The when shoold get $intervals : [['2016-01-01', '2016-01-03']]
doesIntersect()
doesInclude
etc
Rule overlaps
should identify starting and ending number of closed boundary interval as overlapping (true). As a result of this issue, the exclude
method does not work as expected too.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$int = \Interval\Interval::create('[4,6]');
$test1 = \Interval\Interval::create('[4,4]');
$test2 = \Interval\Interval::create('[6,6]');
var_dump($int->overlaps($test1)); // expected true got false
var_dump($int->overlaps($test2)); // expected true got false
var_dump((string)$int->exclude($test1)); // expected {]4,6]} got {[4, 6]}
var_dump((string)$int->exclude($test2)); // expected {[4,6[} got {[4, 6]}
$intervals = new Intervals([
new Interval(1, 10),
new Interval(9, 15)
]);
$intervals->exclude(new Intervals([
new Interval(5, 6),
new Interval(7, 14)
]);)
[InvalidArgumentException]
Could not find package nassimkirouane/interval at any version for your minimum-stability (stable). Check the package spel
ling or your minimum-stability
Also not found in packagist.org.
An interval could be created with excluded end points like :
]10, 20] or [10, 20[ OR ]10, 20[
the following code results in a TypeError when using php 8.
$intArrr = [
'[1300,1330]',
'[2130,2200]',
'[2230,2300]',
'[2230,2300]',
'[1530,1600]',
'[0,700]',
'[2300,2400]'
];
Intervals::create($intArr);
Problem is in IntervalParser isInt method. The php funciton round expects an int and this always results in it being passed a string. The class has declare(strict_types=1); and in php 8 this means it errors when you pass round a string. Without this or in php 7.4 it works fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.