承接 ujamii/osm-opening-hours 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ujamii/osm-opening-hours

Composer 安装命令:

composer require ujamii/osm-opening-hours

包简介

Parser for Openstreetmap opening hours format

README 文档

README

Packagist Minimum PHP Version Continuous Integration

Parser for the Openstreetmap opening hours format as connector for the library spatie/opening-hours.

Installation

composer require ujamii/osm-opening-hours

Usage

$hours = OsmStringToOpeningHoursConverter::openingHoursFromOsmString('Mo-Sa 10:00-18:00');
$hours->isOpenAt(new \DateTimeImmutable('2022-01-10 16:00:00')); // true, this is a monday
$hours->isOpenAt(new \DateTimeImmutable('2022-03-06 16:00:00')); // false, as this is a sunday

There are a lot more methods on the $hours object, please check the docs of that library. Of course, you can also use some more complex input like (please also check the docs) and the list of missing features below to see what's actually possible:

Mo-Fr 08:00-12:00,13:00-17:30; Sa 08:00-12:00
Sa 08:00-12:00; Mo 11:30-17:00; Tu 11:30-18:00; Dec 23-31 off; Jan 24 off; Oct 10 off; PH off; Apr 16 off

If you also need to support the public holiday feature (like PH off in the example above), you have to pass in a filter like this:

$hours = OsmStringToOpeningHoursConverter::openingHoursFromOsmString('Mo-Su 10:00-18:00; PH 09:00-12:00', ['PH' => new GermanPublicHolidayFilter()]);
$hours->isOpenAt(new \DateTimeImmutable('2022-01-10 16:00:00')); // true, open late on normal day
$hours->isOpenAt(new \DateTimeImmutable('2022-01-01 16:00:00')); // false, closed late on holiday
$hours->isOpenAt(new \DateTimeImmutable('2022-01-01 11:00:00')); // true, open early on holiday

The filter for German holidays is included already, so please take at look at this and the corresponding interface, if you want to implement something specific for you. The expected config array may look like ['PH' => new GermanPublicHolidayFilter()] where the key PH has to match the beginning of the ruleset in the given OSM string and the value is an instance of your filter class. Input values like PH 09:00-12:00 or PH off will be parsed and given to the filter in the setOpeningHours method. The spatie/opening-hours library will call the applyFilter(\DateTimeImmutable $date) method internally when something like isOpenAt is requested.

Running tests

You can run the tests with composer run phpunit or composer run testall for test and static analysis.

License and Contribution

MIT

As this is OpenSource, you are very welcome to contribute by reporting bugs, improve the code, write tests or whatever you are able to do to improve the project. Just fork and PR.

If you want to do me a favour, buy me something from my Amazon wishlist.

Known issues / missing features

  • the spatie/opening-hours library does not support different settings for a weekday based on the week (like week 01-53/2 Fr 09:00-12:00; week 02-52/2 Fr 14:00-18:00), so we have to add this information via the data attribute which the library supports for each given opening hour value (this may be solved by another filter)
  • constraint features like years, year_range, year, months, monthdays and week_range are not or not completely supported. This may also be solved by the filter feature later
  • things like week 14-24 and week 1,3,7,34 are not supported yet
  • the OSM input string is not validated yet
  • No support for constrained weekdays yet Th[1,2-3], Fr[-1]
  • No support for calculations yet Sa[-1],Sa[-1] +1 day

ujamii/osm-opening-hours 适用场景与选型建议

ujamii/osm-opening-hours 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.77k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2022 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ujamii/osm-opening-hours 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ujamii/osm-opening-hours 我们能提供哪些服务?
定制开发 / 二次开发

基于 ujamii/osm-opening-hours 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 29
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-04