1<?php
2
3/**
4 * FINE granularity DIFF
5 *
6 * Computes a set of instructions to convert the content of
7 * one string into another.
8 *
9 * Originally created by Raymond Hill (https://github.com/gorhill/PHP-FineDiff), brought up
10 * to date by Cog Powered (https://github.com/cogpowered/FineDiff).
11 *
12 * @copyright Copyright 2011 (c) Raymond Hill (http://raymondhill.net/blog/?p=441)
13 * @copyright Copyright 2013 (c) Robert Crowe (http://cogpowered.com)
14 * @link https://github.com/cogpowered/FineDiff
15 * @version 0.0.1
16 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
17 */
18
19namespace cogpowered\FineDiff\Parser;
20
21use cogpowered\FineDiff\Granularity\GranularityInterface;
22
23interface ParserInterface
24{
25    /**
26     * Creates an instance.
27     *
28     * @param cogpowered\FineDiff\Granularity\GranularityInterface
29     */
30    public function __construct(GranularityInterface $granularity);
31
32    /**
33     * Granularity the parser is working with.
34     *
35     * Default is cogpowered\FineDiff\Granularity\Character.
36     *
37     * @see cogpowered\FineDiff\Granularity\Character
38     * @see cogpowered\FineDiff\Granularity\Word
39     * @see cogpowered\FineDiff\Granularity\Sentence
40     * @see cogpowered\FineDiff\Granularity\Paragraph
41     *
42     * @return cogpowered\FineDiff\Granularity\GranularityInterface
43     */
44    public function getGranularity();
45
46    /**
47     * Set the granularity that the parser is working with.
48     *
49     * @see cogpowered\FineDiff\Granularity\Character
50     * @see cogpowered\FineDiff\Granularity\Word
51     * @see cogpowered\FineDiff\Granularity\Sentence
52     * @see cogpowered\FineDiff\Granularity\Paragraph
53     *
54     * @param cogpowered\FineDiff\Granularity\GranularityInterface
55     * @return void
56     */
57    public function setGranularity(GranularityInterface $granularity);
58
59    /**
60     * Get the opcodes object that is used to store all the opcodes.
61     *
62     * @return cogpowered\FineDiff\Parser\OpcodesInterface
63     */
64    public function getOpcodes();
65
66    /**
67     * Set the opcodes object used to store all the opcodes for this parse.
68     *
69     * @param cogpowered\FineDiff\Parser\OpcodesInterface $opcodes.
70     * @return void
71     */
72    public function setOpcodes(OpcodesInterface $opcodes);
73
74    /**
75     * Generates the opcodes needed to transform one string to another.
76     *
77     * @param string $from_text
78     * @param string $to_text
79     * @throws cogpowered\FineDiff\Exceptions\GranularityCountException
80     * @return cogpowered\FineDiff\Parser\OpcodesInterface
81     */
82    public function parse($from_text, $to_text);
83}