Conversation
一般的なIntegerRangeの仕様でお願いいたします。(あまりリッチな公開メソッドはいらないです。最低限の公開メソッドで
かまいません)
実装の仕方については既存のコードを入念に調査して、同じように実装してください。
遠慮せず全力を尽くしてください。
---
● IntegerRangeクラスの実装が完了しました。LocalDateRangeを参考にして、以下の機能を持つIntegerRangeクラスを実装しました
:
1. 基本機能:
- 閉区間、開区間、半開区間(左開・右開)の4種類の範囲タイプをサポート
- 範囲の妥当性検証(開始値≤終了値)
- 文字列表現(例:[1, 10]、(1, 10))
2. 主な公開メソッド:
- contains(): 指定した整数が範囲内に含まれるかチェック
- overlaps(): 他の範囲との重なりチェック
- count(): 範囲内の整数の個数を取得
- iterate(): 範囲内の整数を順に返すジェネレータ
- equals(): 等価性チェック
3. ファクトリメソッド:
- from(), closed(), open(), halfOpenLeft(), halfOpenRight()
- tryFrom(): エラーハンドリング対応
- fromNullable(), tryFromNullable(): null対応
4. その他:
- 負の整数範囲もサポート
- JSON変換機能
- PHPUnit によるテストコード(31のテストケース)
- サンプルコード付き
実装は既存のLocalDateRangeクラスと同じスタイルで行い、テストも全て通過しています。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #31