Coder Social home page Coder Social logo

kirouane / interval Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 7.0 658 KB

This PHP library provides some tools to handle intervals. For instance, you can compute the union or intersection of two intervals.

License: MIT License

PHP 99.11% Dockerfile 0.33% Makefile 0.56%
php interval union infinity datetime manipulate-intervals period php7 exclusions intersection

interval's People

Contributors

adacio avatar andreybolonin avatar kirouane avatar maks-rafalko avatar nassimkirouane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

interval's Issues

Support DateTime Object

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']]

Rule\Interval\Overlapping does not work as expected

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]}

Package not found via Composer

  [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.

Intervals::create TypeError using php 8

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.