|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * conjoon |
| 5 | + * php-lib-conjoon |
| 6 | + * Copyright (C) 2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person |
| 9 | + * obtaining a copy of this software and associated documentation |
| 10 | + * files (the "Software"), to deal in the Software without restriction, |
| 11 | + * including without limitation the rights to use, copy, modify, merge, |
| 12 | + * publish, distribute, sublicense, and/or sell copies of the Software, |
| 13 | + * and to permit persons to whom the Software is furnished to do so, |
| 14 | + * subject to the following conditions: |
| 15 | + * |
| 16 | + * The above copyright notice and this permission notice shall be included |
| 17 | + * in all copies or substantial portions of the Software. |
| 18 | + * |
| 19 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 21 | + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 22 | + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 23 | + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 24 | + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 25 | + * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | + */ |
| 27 | + |
| 28 | +declare(strict_types=1); |
| 29 | + |
| 30 | +namespace Conjoon\Core\Contract; |
| 31 | + |
| 32 | +use Conjoon\Core\Exception\InvalidTypeException; |
| 33 | + |
| 34 | +/** |
| 35 | + * Provides a contract for the ordering of an instance of the implementing class. |
| 36 | + */ |
| 37 | +interface Comparable |
| 38 | +{ |
| 39 | + /** |
| 40 | + * Compares this instance with the $target and returns -1, 0 or 1 if this instance is |
| 41 | + * less than, equal, or greater than the $target. |
| 42 | + * |
| 43 | + * @param object $target |
| 44 | + * |
| 45 | + * @return int |
| 46 | + * |
| 47 | + * @throws InvalidTypeException if the specified $target cannot be compared with an instance of this class. |
| 48 | + */ |
| 49 | + public function compareTo(object $target): int; |
| 50 | +} |
0 commit comments