Debian Codegraph @

vendor/ramsey/uuid/src/Codec/CodecInterface.php

raw
1 <?php
2 /**
3 * This file is part of the ramsey/uuid library
4 *
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @copyright Copyright (c) Ben Ramsey <[email protected]>
9 * @license http://opensource.org/licenses/MIT MIT
10 * @link https://benramsey.com/projects/ramsey-uuid/ Documentation
11 * @link https://packagist.org/packages/ramsey/uuid Packagist
12 * @link https://github.com/ramsey/uuid GitHub
13 */
14
15 namespace Ramsey\Uuid\Codec;
16
17 use InvalidArgumentException;
18 use Ramsey\Uuid\Exception\InvalidUuidStringException;
19 use Ramsey\Uuid\UuidInterface;
20
21 /**
22 * CodecInterface represents a UUID coder-decoder
23 */
24 interface CodecInterface
25 {
26 /**
27 * Encodes a UuidInterface as a string representation of a UUID
28 *
29 * @param UuidInterface $uuid
30 * @return string Hexadecimal string representation of a UUID
31 */
32 public function encode(UuidInterface $uuid);
33
34 /**
35 * Encodes a UuidInterface as a binary representation of a UUID
36 *
37 * @param UuidInterface $uuid
38 * @return string Binary string representation of a UUID
39 */
40 public function encodeBinary(UuidInterface $uuid);
41
42 /**
43 * Decodes a string representation of a UUID into a UuidInterface object instance
44 *
45 * @param string $encodedUuid
46 * @return UuidInterface
47 * @throws InvalidUuidStringException
48 */
49 public function decode($encodedUuid);
50
51 /**
52 * Decodes a binary representation of a UUID into a UuidInterface object instance
53 *
54 * @param string $bytes
55 * @return UuidInterface
56 * @throws InvalidUuidStringException
57 * @throws InvalidArgumentException if string has not 16 characters
58 */
59 public function decodeBytes($bytes);
60 }