Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Ferie
  • Weeks
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Date;
 14: 
 15: /**
 16:  * Classe Ferie
 17:  *
 18:  * Class permettant de trouver les jours fériés d'une année. Valable pour la France
 19:  *
 20:  * @category Pry
 21:  * @package Date
 22:  * @version 1.1.0
 23:  * @author Olivier ROGER <oroger.fr>
 24:  *
 25:  */
 26: class Ferie
 27: {
 28: 
 29:     /**
 30:      * Liste des jours férié
 31:      * @var array
 32:      */
 33:     private $tabDay = array();
 34: 
 35:     /**
 36:      * Année format YYYY
 37:      * @var int
 38:      */
 39:     private $annee;
 40: 
 41:     /**
 42:      * Constructeur. Initialise les jours fériés fixes
 43:      * @param int $annee
 44:      */
 45:     public function __construct($annee)
 46:     {
 47:         if (strlen($annee) < 4)
 48:             throw new \InvalidArgumentException('Annee doit être sur 4 chiffres');
 49: 
 50:         $this->annee    = $annee;
 51:         $this->tabDay[] = $annee . '-01-01';
 52:         $this->tabDay[] = ($annee + 1) . '-01-01';
 53:         $this->tabDay[] = ($annee - 1) . '-01-01';
 54:         $this->tabDay[] = $annee . '-05-01';
 55:         $this->tabDay[] = $annee . '-05-08';
 56:         $this->tabDay[] = $annee . '-07-14';
 57:         $this->tabDay[] = $annee . '-08-15';
 58:         $this->tabDay[] = $annee . '-11-01';
 59:         $this->tabDay[] = $annee . '-11-11';
 60:         $this->tabDay[] = $annee . '-12-25';
 61:         $this->computeDay();
 62:     }
 63: 
 64:     /**
 65:      * Calcul les jours fériés pouvant l'être
 66:      */
 67:     private function computeDay()
 68:     {
 69:         //Paques
 70:         $tsPaques       = @easter_date($this->annee);
 71:         $this->tabDay[] = date("Y-m-d", $tsPaques + 86400);
 72:         //Ascencion
 73:         $this->tabDay[] = date("Y-m-d", strtotime('+39 days', $tsPaques));
 74:         //Pantecote
 75:         $this->tabDay[] = date("Y-m-d", strtotime('+50 days', $tsPaques));
 76:     }
 77: 
 78:     /**
 79:      * Vérifie si un jour est férié
 80:      * @param string $date Date au format Y-m-d
 81:      * @return boolean
 82:      */
 83:     public function isFerie($date)
 84:     {
 85:         if (!is_string($date))
 86:             throw new \InvalidArgumentException('Date sous forme Y-m-d');
 87: 
 88:         return in_array($date, $this->tabDay);
 89:     }
 90: 
 91:     /**
 92:      * Liste des jours fériés
 93:      * @return array Liste des jours fériés 
 94:      */
 95:     public function getDays()
 96:     {
 97:         return $this->tabDay;
 98:     }
 99: 
100: }
101: 
102: ?>
Pry API documentation generated by ApiGen 2.8.0