MediaWiki  master
DiffOp.php
Go to the documentation of this file.
1 <?php
28 namespace Wikimedia\Diff;
29 
38 abstract class DiffOp {
39 
44  public $type;
45 
50  public $orig;
51 
56  public $closing;
57 
61  public function getType() {
62  return $this->type;
63  }
64 
71  public function getOrig() {
72  return $this->orig;
73  }
74 
84  public function getClosing( $i = null ) {
85  if ( $i === null ) {
86  return $this->closing;
87  }
88  if ( array_key_exists( $i, $this->closing ) ) {
89  return $this->closing[$i];
90  }
91  return null;
92  }
93 
97  abstract public function reverse();
98 
102  public function norig() {
103  return $this->orig ? count( $this->orig ) : 0;
104  }
105 
109  public function nclosing() {
110  return $this->closing ? count( $this->closing ) : 0;
111  }
112 }
113 
115 class_alias( DiffOp::class, 'DiffOp' );
The base class for all other DiffOp classes.
Definition: DiffOp.php:38
getClosing( $i=null)
Without a line number this returns either all lines on the right ("new") side of the diff,...
Definition: DiffOp.php:84
getOrig()
Returns either all lines on the left ("old") side of the diff, or false when it's an add operation.
Definition: DiffOp.php:71
string[] false $closing
The right ("new") side of the diff, or false when it's a "delete".
Definition: DiffOp.php:56
string[] false $orig
The left ("old") side of the diff, or false when it's an "add".
Definition: DiffOp.php:50