Complex classes like Repository often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Repository, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 68 | class Repository |
||
| 69 | { |
||
| 70 | /** |
||
| 71 | * the repository path |
||
| 72 | * |
||
| 73 | * @var string |
||
| 74 | */ |
||
| 75 | private $path; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * the caller instance |
||
| 79 | * |
||
| 80 | * @var \GitElephant\Command\Caller\Caller |
||
| 81 | */ |
||
| 82 | private $caller; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * A general repository name |
||
| 86 | * |
||
| 87 | * @var string $name the repository name |
||
| 88 | */ |
||
| 89 | private $name; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * A list of global configs to apply to every command |
||
| 93 | * |
||
| 94 | * @var array |
||
| 95 | */ |
||
| 96 | private $globalConfigs = array(); |
||
| 97 | |||
| 98 | /** |
||
| 99 | * A list of global options to apply to every command |
||
| 100 | * |
||
| 101 | * @var array |
||
| 102 | */ |
||
| 103 | private $globalOptions = array(); |
||
| 104 | |||
| 105 | /** |
||
| 106 | * A list of global arguments to apply to every command |
||
| 107 | * |
||
| 108 | * @var array |
||
| 109 | */ |
||
| 110 | private $globalCommandArguments = array(); |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Class constructor |
||
| 114 | * |
||
| 115 | * @param string $repositoryPath the path of the git repository |
||
| 116 | * @param GitBinary|null $binary the GitBinary instance that calls the commands |
||
| 117 | * @param string $name a repository name |
||
| 118 | 105 | * |
|
| 119 | * @throws Exception\InvalidRepositoryPathException |
||
| 120 | 105 | */ |
|
| 121 | 105 | public function __construct($repositoryPath, GitBinary $binary = null, $name = null) |
|
| 131 | |||
| 132 | /** |
||
| 133 | * Factory method |
||
| 134 | * |
||
| 135 | * @param string $repositoryPath the path of the git repository |
||
| 136 | * @param GitBinary|null $binary the GitBinary instance that calls the commands |
||
| 137 | * @param string $name a repository name |
||
| 138 | 104 | * |
|
| 139 | * @return \GitElephant\Repository |
||
| 140 | 104 | */ |
|
| 141 | public static function open($repositoryPath, GitBinary $binary = null, $name = null) |
||
| 145 | |||
| 146 | /** |
||
| 147 | * create a repository from a remote git url, or a local filesystem |
||
| 148 | * and save it in a temp folder |
||
| 149 | * |
||
| 150 | * @param string|Repository $git the git remote url, or the filesystem path |
||
| 151 | * @param null $repositoryPath path |
||
| 152 | * @param GitBinary $binary binary |
||
| 153 | * @param null $name repository name |
||
| 154 | * |
||
| 155 | * @throws \RuntimeException |
||
| 156 | 1 | * @throws \Symfony\Component\Filesystem\Exception\IOException |
|
| 157 | * @return Repository |
||
| 158 | 1 | */ |
|
| 159 | 1 | public static function createFromRemote($git, $repositoryPath = null, GitBinary $binary = null, $name = null) |
|
| 176 | |||
| 177 | /** |
||
| 178 | * Init the repository |
||
| 179 | * |
||
| 180 | * @param bool $bare created a bare repository |
||
| 181 | * |
||
| 182 | * @throws \RuntimeException |
||
| 183 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 184 | * @throws InvalidArgumentException |
||
| 185 | 94 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 186 | * @return Repository |
||
| 187 | 94 | */ |
|
| 188 | public function init($bare = false) |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Stage the working tree content |
||
| 197 | * |
||
| 198 | * @param string|NodeObject $path the path to store |
||
| 199 | * |
||
| 200 | * @throws \RuntimeException |
||
| 201 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 202 | * @throws InvalidArgumentException |
||
| 203 | 90 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 204 | * @return Repository |
||
| 205 | 90 | */ |
|
| 206 | public function stage($path = '.') |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Unstage a tree content |
||
| 215 | * |
||
| 216 | * @param string|NodeObject $path the path to unstage |
||
| 217 | * |
||
| 218 | * @throws \RuntimeException |
||
| 219 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 220 | * @throws InvalidArgumentException |
||
| 221 | 2 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 222 | * @return Repository |
||
| 223 | 2 | */ |
|
| 224 | public function unstage($path) |
||
| 230 | |||
| 231 | /** |
||
| 232 | * Move a file/directory |
||
| 233 | * |
||
| 234 | * @param string|NodeObject $from source path |
||
| 235 | * @param string|NodeObject $to destination path |
||
| 236 | * |
||
| 237 | * @throws \RuntimeException |
||
| 238 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 239 | * @throws \InvalidArgumentException |
||
| 240 | * @throws InvalidArgumentException |
||
| 241 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 242 | * @return Repository |
||
| 243 | 1 | */ |
|
| 244 | public function move($from, $to) |
||
| 250 | |||
| 251 | /** |
||
| 252 | * Remove a file/directory |
||
| 253 | * |
||
| 254 | * @param string|NodeObject $path the path to remove |
||
| 255 | * @param bool $recursive recurse |
||
| 256 | * @param bool $force force |
||
| 257 | * |
||
| 258 | * @throws \RuntimeException |
||
| 259 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 260 | * @throws \InvalidArgumentException |
||
| 261 | * @throws InvalidArgumentException |
||
| 262 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 263 | * @return Repository |
||
| 264 | 1 | */ |
|
| 265 | public function remove($path, $recursive = false, $force = false) |
||
| 271 | |||
| 272 | /** |
||
| 273 | * Commit content to the repository, eventually staging all unstaged content |
||
| 274 | * |
||
| 275 | * @param string $message the commit message |
||
| 276 | * @param bool $stageAll whether to stage on not everything before commit |
||
| 277 | * @param string|null $ref the reference to commit to (checkout -> commit -> checkout previous) |
||
| 278 | * @param string|Author $author override the author for this commit |
||
| 279 | * @param bool $allowEmpty override the author for this commit |
||
| 280 | * |
||
| 281 | * @throws \RuntimeException |
||
| 282 | 85 | * @throws \InvalidArgumentException |
|
| 283 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 284 | 85 | * @return Repository |
|
| 285 | 85 | */ |
|
| 286 | 1 | public function commit($message, $stageAll = false, $ref = null, $author = null, $allowEmpty = false) |
|
| 303 | |||
| 304 | /** |
||
| 305 | * rev-parse command - often used to return a commit tag. |
||
| 306 | * |
||
| 307 | * @param array $options the options to apply to rev-parse |
||
| 308 | * @param string|NodeObject|Commit $arg the argument (may be a branch head, etc) |
||
| 309 | * |
||
| 310 | * @throws \RuntimeException |
||
| 311 | 1 | * @throws \InvalidArgumentException |
|
| 312 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 313 | 1 | * @return array |
|
| 314 | */ |
||
| 315 | 1 | public function revParse($arg = null, array $options = array()) |
|
| 321 | |||
| 322 | 1 | /** |
|
| 323 | * Check if this is a bare repository |
||
| 324 | 1 | * @return boolean |
|
| 325 | 1 | */ |
|
| 326 | public function isBare() |
||
| 333 | |||
| 334 | 2 | /** |
|
| 335 | * @param TreeishInterface|Commit|string $arg |
||
| 336 | 2 | * @param array $options |
|
| 337 | 2 | */ |
|
| 338 | public function reset($arg, $options) |
||
| 342 | |||
| 343 | /** |
||
| 344 | 5 | * Get the repository status |
|
| 345 | * |
||
| 346 | 5 | * @return Status |
|
| 347 | */ |
||
| 348 | public function getStatus() |
||
| 352 | 1 | ||
| 353 | /** |
||
| 354 | 1 | * @return Status |
|
| 355 | */ |
||
| 356 | public function getWorkingTreeStatus() |
||
| 360 | 4 | ||
| 361 | /** |
||
| 362 | 4 | * @return Status |
|
| 363 | */ |
||
| 364 | public function getIndexStatus() |
||
| 368 | |||
| 369 | /** |
||
| 370 | * isClean Return true if the repository is not dirty. |
||
| 371 | * |
||
| 372 | * @return boolean |
||
| 373 | */ |
||
| 374 | public function isClean() |
||
| 378 | |||
| 379 | /** |
||
| 380 | * isDirty Return true if the repository has some modified files. |
||
| 381 | * |
||
| 382 | * @return boolean |
||
| 383 | */ |
||
| 384 | public function isDirty() |
||
| 388 | |||
| 389 | /** |
||
| 390 | * Get the repository status as a string |
||
| 391 | * |
||
| 392 | * @throws \RuntimeException |
||
| 393 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 394 | 4 | * @throws InvalidArgumentException |
|
| 395 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 396 | 4 | * @return array |
|
| 397 | */ |
||
| 398 | 4 | public function getStatusOutput() |
|
| 404 | |||
| 405 | /** |
||
| 406 | * Create a new branch |
||
| 407 | * |
||
| 408 | * @param string $name the new branch name |
||
| 409 | * @param null $startPoint the reference to create the branch from |
||
| 410 | * |
||
| 411 | 27 | * @throws \RuntimeException |
|
| 412 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 413 | 27 | * @return Repository |
|
| 414 | */ |
||
| 415 | 27 | public function createBranch($name, $startPoint = null) |
|
| 421 | |||
| 422 | /** |
||
| 423 | * Delete a branch by its name |
||
| 424 | * This function change the state of the repository on the filesystem |
||
| 425 | * |
||
| 426 | * @param string $name The branch to delete |
||
| 427 | * @param bool $force Force the delete |
||
| 428 | * |
||
| 429 | * @throws \RuntimeException |
||
| 430 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 431 | 1 | * @throws InvalidArgumentException |
|
| 432 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 433 | 1 | * @return Repository |
|
| 434 | */ |
||
| 435 | 1 | public function deleteBranch($name, $force = false) |
|
| 441 | |||
| 442 | /** |
||
| 443 | * An array of Branch objects |
||
| 444 | * |
||
| 445 | * @param bool $namesOnly return an array of branch names as a string |
||
| 446 | * @param bool $all lists also remote branches |
||
| 447 | * |
||
| 448 | * @throws \RuntimeException |
||
| 449 | * @throws InvalidArgumentException |
||
| 450 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 451 | 17 | * @throws \InvalidArgumentException |
|
| 452 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 453 | 17 | * @return array |
|
| 454 | 17 | */ |
|
| 455 | 6 | public function getBranches($namesOnly = false, $all = false) |
|
| 479 | |||
| 480 | /** |
||
| 481 | * Return the actually checked out branch |
||
| 482 | * |
||
| 483 | * @throws \RuntimeException |
||
| 484 | 5 | * @throws \InvalidArgumentException |
|
| 485 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 486 | 5 | * @return Objects\Branch |
|
| 487 | 5 | */ |
|
| 488 | 5 | public function getMainBranch() |
|
| 500 | |||
| 501 | /** |
||
| 502 | * Retrieve a Branch object by a branch name |
||
| 503 | * |
||
| 504 | * @param string $name The branch name |
||
| 505 | * |
||
| 506 | * @throws \RuntimeException |
||
| 507 | 9 | * @throws \InvalidArgumentException |
|
| 508 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 509 | * @return null|Branch |
||
| 510 | 9 | */ |
|
| 511 | 9 | public function getBranch($name) |
|
| 522 | |||
| 523 | /** |
||
| 524 | * Checkout all branches from the remote and make them local |
||
| 525 | * |
||
| 526 | * @param string $remote remote to fetch from |
||
| 527 | * |
||
| 528 | * @throws \RuntimeException |
||
| 529 | 1 | * @throws \InvalidArgumentException |
|
| 530 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 531 | 1 | * @return Repository |
|
| 532 | 1 | */ |
|
| 533 | 1 | public function checkoutAllRemoteBranches($remote = 'origin') |
|
| 553 | |||
| 554 | /** |
||
| 555 | * Merge a Branch in the current checked out branch |
||
| 556 | * |
||
| 557 | * @param Objects\Branch $branch The branch to merge in the current checked out branch |
||
| 558 | * @param string $message The message for the merge commit, if merge is 3-way |
||
| 559 | * @param string $mode The merge mode: ff-only, no-ff or auto |
||
| 560 | * |
||
| 561 | * @throws \RuntimeException |
||
| 562 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 563 | 2 | * @throws InvalidArgumentException |
|
| 564 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 565 | * @return Repository |
||
| 566 | 2 | */ |
|
| 567 | public function merge(Branch $branch, $message = '', $mode = 'auto') |
||
| 592 | |||
| 593 | /** |
||
| 594 | * Create a new tag |
||
| 595 | * This function change the state of the repository on the filesystem |
||
| 596 | * |
||
| 597 | * @param string $name The new tag name |
||
| 598 | * @param null $startPoint The reference to create the tag from |
||
| 599 | * @param null $message the tag message |
||
| 600 | * |
||
| 601 | 25 | * @throws \RuntimeException |
|
| 602 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 603 | 25 | * @return Repository |
|
| 604 | */ |
||
| 605 | 25 | public function createTag($name, $startPoint = null, $message = null) |
|
| 611 | |||
| 612 | /** |
||
| 613 | * Delete a tag by it's name or by passing a Tag object |
||
| 614 | * This function change the state of the repository on the filesystem |
||
| 615 | * |
||
| 616 | * @param string|Tag $tag The tag name or the Tag object |
||
| 617 | * |
||
| 618 | 2 | * @throws \RuntimeException |
|
| 619 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 620 | 2 | * @return Repository |
|
| 621 | 1 | */ |
|
| 622 | public function deleteTag($tag) |
||
| 632 | |||
| 633 | /** |
||
| 634 | * add a git submodule to the repository |
||
| 635 | * |
||
| 636 | * @param string $gitUrl git url of the submodule |
||
| 637 | * @param string $path path to register the submodule to |
||
| 638 | * |
||
| 639 | * @throws \RuntimeException |
||
| 640 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 641 | 1 | * @throws InvalidArgumentException |
|
| 642 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 643 | 1 | * @return Repository |
|
| 644 | */ |
||
| 645 | 1 | public function addSubmodule($gitUrl, $path = null) |
|
| 651 | |||
| 652 | /** |
||
| 653 | * initialize submodules |
||
| 654 | * |
||
| 655 | * @param string $path init only submodules at the specified path |
||
| 656 | * |
||
| 657 | * @return Repository |
||
| 658 | */ |
||
| 659 | public function initSubmodule($path = null) |
||
| 664 | |||
| 665 | /** |
||
| 666 | * update submodules |
||
| 667 | * |
||
| 668 | * @param bool $recursive update recursively |
||
| 669 | * @param bool $init init before update |
||
| 670 | * @param bool $force force the checkout as part of update |
||
| 671 | * @param string $path update only a specific submodule path |
||
| 672 | * |
||
| 673 | * @return Repository |
||
| 674 | */ |
||
| 675 | public function updateSubmodule($recursive = false, $init = false, $force = false, $path = null) |
||
| 680 | |||
| 681 | /** |
||
| 682 | * Gets an array of Tag objects |
||
| 683 | * |
||
| 684 | * @throws \RuntimeException |
||
| 685 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 686 | 4 | * @throws InvalidArgumentException |
|
| 687 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 688 | 4 | * @return array |
|
| 689 | 4 | */ |
|
| 690 | 4 | public function getTags() |
|
| 702 | |||
| 703 | /** |
||
| 704 | * Return a tag object |
||
| 705 | * |
||
| 706 | * @param string $name The tag name |
||
| 707 | * |
||
| 708 | 28 | * @throws \RuntimeException |
|
| 709 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 710 | 28 | * @return Tag|null |
|
| 711 | 28 | */ |
|
| 712 | 28 | public function getTag($name) |
|
| 723 | |||
| 724 | /** |
||
| 725 | * Return the last created tag |
||
| 726 | * |
||
| 727 | * @throws \LogicException |
||
| 728 | 1 | * @throws \RuntimeException |
|
| 729 | * @throws \InvalidArgumentException |
||
| 730 | 1 | * @return Tag|null |
|
| 731 | 1 | */ |
|
| 732 | 1 | public function getLastTag() |
|
| 749 | |||
| 750 | /** |
||
| 751 | * Try to get a branch or a tag by its name. |
||
| 752 | * |
||
| 753 | * @param string $name the reference name (a tag name or a branch name) |
||
| 754 | * |
||
| 755 | * @throws \RuntimeException |
||
| 756 | 1 | * @throws \InvalidArgumentException |
|
| 757 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 758 | 1 | * @return \GitElephant\Objects\Tag|\GitElephant\Objects\Branch|null |
|
| 759 | 1 | */ |
|
| 760 | public function getBranchOrTag($name) |
||
| 774 | |||
| 775 | /** |
||
| 776 | * Return a Commit object |
||
| 777 | * |
||
| 778 | * @param string $ref The commit reference |
||
| 779 | 15 | * |
|
| 780 | * @throws \RuntimeException |
||
| 781 | 15 | * @return Objects\Commit |
|
| 782 | */ |
||
| 783 | 15 | public function getCommit($ref = 'HEAD') |
|
| 789 | |||
| 790 | /** |
||
| 791 | * count the commit to arrive to the given treeish |
||
| 792 | * |
||
| 793 | * @param string $start |
||
| 794 | * |
||
| 795 | 3 | * @throws \RuntimeException |
|
| 796 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 797 | 3 | * @return int |
|
| 798 | */ |
||
| 799 | 3 | public function countCommits($start = 'HEAD') |
|
| 805 | |||
| 806 | /** |
||
| 807 | * Get a log for a ref |
||
| 808 | * |
||
| 809 | * @param string|TreeishInterface|array $ref the treeish to check, as a string, as an object or as an array |
||
| 810 | * @param string|NodeObject $path the physical path to the tree relative to the repository root |
||
| 811 | * @param int|null $limit limit to n entries |
||
| 812 | * @param int|null $offset skip n entries |
||
| 813 | 20 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
|
| 814 | * |
||
| 815 | 20 | * @return \GitElephant\Objects\Log |
|
| 816 | */ |
||
| 817 | public function getLog($ref = 'HEAD', $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Get a log for a range ref |
||
| 824 | * |
||
| 825 | * @param string $refStart |
||
| 826 | * @param string $refEnd |
||
| 827 | * @param string|NodeObject $path the physical path to the tree relative to the repository root |
||
| 828 | * @param int|null $limit limit to n entries |
||
| 829 | * @param int|null $offset skip n entries |
||
| 830 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
| 831 | * |
||
| 832 | * @return \GitElephant\Objects\LogRange|\GitElephant\Objects\Log |
||
| 833 | */ |
||
| 834 | public function getLogRange($refStart, $refEnd, $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 848 | |||
| 849 | /** |
||
| 850 | * Get a log for an object |
||
| 851 | * |
||
| 852 | * @param \GitElephant\Objects\NodeObject $obj The Object instance |
||
| 853 | * @param null|string|\GitElephant\Objects\Branch $branch The branch to read from |
||
| 854 | * @param int $limit Limit to n entries |
||
| 855 | * @param int|null $offset Skip n entries |
||
| 856 | * |
||
| 857 | * @throws \RuntimeException |
||
| 858 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 859 | 3 | * @throws InvalidArgumentException |
|
| 860 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 861 | 3 | * @return \GitElephant\Objects\Log |
|
| 862 | */ |
||
| 863 | 3 | public function getObjectLog(NodeObject $obj, $branch = null, $limit = 1, $offset = null) |
|
| 869 | |||
| 870 | /** |
||
| 871 | * Checkout a branch |
||
| 872 | * This function change the state of the repository on the filesystem |
||
| 873 | * |
||
| 874 | * @param string|TreeishInterface $ref the reference to checkout |
||
| 875 | * @param bool $create like -b on the command line |
||
| 876 | * |
||
| 877 | * @throws \RuntimeException |
||
| 878 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 879 | 24 | * @throws InvalidArgumentException |
|
| 880 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 881 | 24 | * @return Repository |
|
| 882 | */ |
||
| 883 | public function checkout($ref, $create = false) |
||
| 892 | |||
| 893 | /** |
||
| 894 | * Retrieve an instance of Tree |
||
| 895 | * Tree Object is Countable, Iterable and has ArrayAccess for easy manipulation |
||
| 896 | * |
||
| 897 | * @param string|TreeishInterface $ref the treeish to check |
||
| 898 | * @param string|NodeObject $path Object or null for root |
||
| 899 | * |
||
| 900 | * @throws \RuntimeException |
||
| 901 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 902 | 15 | * @throws InvalidArgumentException |
|
| 903 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 904 | 15 | * @return Objects\Tree |
|
| 905 | 9 | */ |
|
| 906 | 9 | public function getTree($ref = 'HEAD', $path = null) |
|
| 917 | |||
| 918 | /** |
||
| 919 | * Get a Diff object for a commit with its parent, by default the diff is between the current head and its parent |
||
| 920 | * |
||
| 921 | * @param \GitElephant\Objects\Commit|string $commit1 A TreeishInterface instance |
||
| 922 | * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance |
||
| 923 | * @param null|string|NodeObject $path The path to get the diff for or a Object instance |
||
| 924 | * |
||
| 925 | 2 | * @throws \RuntimeException |
|
| 926 | * @throws \InvalidArgumentException |
||
| 927 | 2 | * @return Objects\Diff\Diff |
|
| 928 | */ |
||
| 929 | public function getDiff($commit1 = null, $commit2 = null, $path = null) |
||
| 933 | |||
| 934 | /** |
||
| 935 | * Clone a repository |
||
| 936 | * |
||
| 937 | * @param string $url the repository url (i.e. git://github.com/matteosister/GitElephant.git) |
||
| 938 | * @param null $to where to clone the repo |
||
| 939 | * |
||
| 940 | * @throws \RuntimeException |
||
| 941 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 942 | 2 | * @throws InvalidArgumentException |
|
| 943 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 944 | 2 | * @return Repository |
|
| 945 | */ |
||
| 946 | 2 | public function cloneFrom($url, $to = null) |
|
| 952 | |||
| 953 | /** |
||
| 954 | * @param string $name remote name |
||
| 955 | * @param string $url remote url |
||
| 956 | * |
||
| 957 | * @throws \RuntimeException |
||
| 958 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 959 | 7 | * @throws InvalidArgumentException |
|
| 960 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 961 | 7 | * @return Repository |
|
| 962 | */ |
||
| 963 | 7 | public function addRemote($name, $url) |
|
| 969 | |||
| 970 | /** |
||
| 971 | * @param string $name remote name |
||
| 972 | 1 | * @param bool $queryRemotes Fetch new information from remotes |
|
| 973 | * |
||
| 974 | 1 | * @return \GitElephant\Objects\Remote |
|
| 975 | */ |
||
| 976 | public function getRemote($name, $queryRemotes = true) |
||
| 980 | |||
| 981 | /** |
||
| 982 | * gets a list of remote objects |
||
| 983 | * |
||
| 984 | * @param bool $queryRemotes Fetch new information from remotes |
||
| 985 | * |
||
| 986 | * @throws \RuntimeException |
||
| 987 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 988 | 1 | * @throws InvalidArgumentException |
|
| 989 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 990 | 1 | * @return array |
|
| 991 | 1 | */ |
|
| 992 | 1 | public function getRemotes($queryRemotes = true) |
|
| 1003 | |||
| 1004 | /** |
||
| 1005 | * Download objects and refs from another repository |
||
| 1006 | * |
||
| 1007 | * @param string $from |
||
| 1008 | * @param string $ref |
||
| 1009 | * @param bool $tags |
||
| 1010 | * |
||
| 1011 | * @throws \RuntimeException |
||
| 1012 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1013 | * @throws InvalidArgumentException |
||
| 1014 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1015 | 1 | */ |
|
| 1016 | 1 | public function fetch($from = null, $ref = null, $tags = false) |
|
| 1024 | |||
| 1025 | /** |
||
| 1026 | * Fetch from and merge with another repository or a local branch |
||
| 1027 | * |
||
| 1028 | * @param string $from |
||
| 1029 | * @param string $ref |
||
| 1030 | * @param bool $rebase |
||
| 1031 | * @throws \RuntimeException |
||
| 1032 | 2 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1033 | * @throws InvalidArgumentException |
||
| 1034 | 2 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1035 | 2 | */ |
|
| 1036 | public function pull($from = null, $ref = null, $rebase = true) |
||
| 1040 | |||
| 1041 | /** |
||
| 1042 | * Push changes to remote repository |
||
| 1043 | * |
||
| 1044 | * @param string $to |
||
| 1045 | * @param string $ref |
||
| 1046 | * @param string $args |
||
| 1047 | 1 | * @throws \RuntimeException |
|
| 1048 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1049 | 1 | * @throws InvalidArgumentException |
|
| 1050 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1051 | */ |
||
| 1052 | public function push($to = null, $ref = null, $args = null) |
||
| 1056 | |||
| 1057 | 2 | /** |
|
| 1058 | * get the humanish name of the repository |
||
| 1059 | 2 | * |
|
| 1060 | 2 | * @return string |
|
| 1061 | 2 | */ |
|
| 1062 | public function getHumanishName() |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * output a node content as an array of lines |
||
| 1073 | * |
||
| 1074 | * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB |
||
| 1075 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
| 1076 | * |
||
| 1077 | * @throws \RuntimeException |
||
| 1078 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1079 | * @throws InvalidArgumentException |
||
| 1080 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1081 | * @return array |
||
| 1082 | 1 | */ |
|
| 1083 | public function outputContent(NodeObject $obj, $treeish) |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * output a node raw content |
||
| 1092 | * |
||
| 1093 | * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB |
||
| 1094 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
| 1095 | * |
||
| 1096 | * @throws \RuntimeException |
||
| 1097 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1098 | * @throws InvalidArgumentException |
||
| 1099 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1100 | * @return string |
||
| 1101 | */ |
||
| 1102 | public function outputRawContent(NodeObject $obj, $treeish) |
||
| 1108 | |||
| 1109 | 63 | /** |
|
| 1110 | * Get the path |
||
| 1111 | 63 | * |
|
| 1112 | * @return string |
||
| 1113 | */ |
||
| 1114 | public function getPath() |
||
| 1118 | |||
| 1119 | 1 | /** |
|
| 1120 | * Get the repository name |
||
| 1121 | 1 | * |
|
| 1122 | * @return string |
||
| 1123 | */ |
||
| 1124 | public function getName() |
||
| 1128 | |||
| 1129 | 1 | /** |
|
| 1130 | * Set the repository name |
||
| 1131 | 1 | * |
|
| 1132 | 1 | * @param string $name the repository name |
|
| 1133 | */ |
||
| 1134 | public function setName($name) |
||
| 1138 | |||
| 1139 | /** |
||
| 1140 | * Caller setter |
||
| 1141 | * |
||
| 1142 | * @param \GitElephant\Command\Caller\Caller $caller the caller variable |
||
| 1143 | */ |
||
| 1144 | public function setCaller($caller) |
||
| 1148 | |||
| 1149 | 89 | /** |
|
| 1150 | * Caller getter |
||
| 1151 | 89 | * |
|
| 1152 | * @return \GitElephant\Command\Caller\Caller |
||
| 1153 | */ |
||
| 1154 | public function getCaller() |
||
| 1158 | |||
| 1159 | 95 | /** |
|
| 1160 | * get global config list |
||
| 1161 | 95 | * |
|
| 1162 | * @return array Global config list |
||
| 1163 | */ |
||
| 1164 | public function getGlobalConfigs() |
||
| 1168 | |||
| 1169 | /** |
||
| 1170 | 1 | * add a key/value pair to the global config list |
|
| 1171 | * |
||
| 1172 | 1 | * @param string $name The config name |
|
| 1173 | 1 | * @param string $value The config value |
|
| 1174 | */ |
||
| 1175 | public function addGlobalConfig($name, $value) |
||
| 1179 | |||
| 1180 | 1 | /** |
|
| 1181 | * remove an element form the global config list, identified by key |
||
| 1182 | 1 | * |
|
| 1183 | 1 | * @param string $name The config name |
|
| 1184 | */ |
||
| 1185 | 1 | public function removeGlobalConfig($name) |
|
| 1191 | |||
| 1192 | 95 | /** |
|
| 1193 | * get global options list |
||
| 1194 | 95 | * |
|
| 1195 | * @return array Global options list |
||
| 1196 | */ |
||
| 1197 | public function getGlobalOptions() |
||
| 1201 | |||
| 1202 | /** |
||
| 1203 | 1 | * add a key/value pair to the global option list |
|
| 1204 | * |
||
| 1205 | 1 | * @param string $name The option name |
|
| 1206 | 1 | * @param string $value The option value |
|
| 1207 | */ |
||
| 1208 | public function addGlobalOption($name, $value) |
||
| 1212 | |||
| 1213 | 1 | /** |
|
| 1214 | * remove an element form the global option list, identified by key |
||
| 1215 | 1 | * |
|
| 1216 | 1 | * @param string $name The option name |
|
| 1217 | */ |
||
| 1218 | 1 | public function removeGlobalOption($name) |
|
| 1224 | |||
| 1225 | 95 | /** |
|
| 1226 | * get global command arguments list |
||
| 1227 | 95 | * |
|
| 1228 | * @return array Global command arguments list |
||
| 1229 | */ |
||
| 1230 | public function getGlobalCommandArguments() |
||
| 1234 | |||
| 1235 | 1 | /** |
|
| 1236 | * add a value to the global command argument list |
||
| 1237 | 1 | * |
|
| 1238 | 1 | * @param string $value The command argument |
|
| 1239 | */ |
||
| 1240 | 1 | public function addGlobalCommandArgument($value) |
|
| 1246 | |||
| 1247 | /** |
||
| 1248 | 1 | * remove an element form the global command argument list, identified by |
|
| 1249 | * value |
||
| 1250 | 1 | * |
|
| 1251 | 1 | * @param string $value The command argument |
|
| 1252 | 1 | */ |
|
| 1253 | public function removeGlobalCommandArgument($value) |
||
| 1260 | |||
| 1261 | /** |
||
| 1262 | * Save your local modifications to a new stash, and run git reset --hard to revert them. |
||
| 1263 | * |
||
| 1264 | * @param string|null $message |
||
| 1265 | * @param boolean $includeUntracked |
||
| 1266 | * @param boolean $keepIndex |
||
| 1267 | */ |
||
| 1268 | public function stash($message = null, $includeUntracked = false, $keepIndex = false) |
||
| 1274 | |||
| 1275 | /** |
||
| 1276 | * Shows stash list |
||
| 1277 | * |
||
| 1278 | * @param array|null $options |
||
| 1279 | * |
||
| 1280 | * @return array |
||
| 1281 | */ |
||
| 1282 | public function stashList(array $options = null) |
||
| 1289 | |||
| 1290 | /** |
||
| 1291 | * Shows details for a stash |
||
| 1292 | * |
||
| 1293 | * @param string $stash |
||
| 1294 | * |
||
| 1295 | * @return string |
||
| 1296 | */ |
||
| 1297 | public function stashShow($stash) |
||
| 1304 | |||
| 1305 | /** |
||
| 1306 | * Drops a stash |
||
| 1307 | * |
||
| 1308 | * @param string $stash |
||
| 1309 | */ |
||
| 1310 | public function stashDrop($stash) |
||
| 1316 | |||
| 1317 | /** |
||
| 1318 | * Applies a stash |
||
| 1319 | * |
||
| 1320 | * @param string $stash |
||
| 1321 | * @param boolean $index |
||
| 1322 | */ |
||
| 1323 | public function stashApply($stash, $index = false) |
||
| 1329 | |||
| 1330 | /** |
||
| 1331 | * Applies a stash, then removes it from the stash |
||
| 1332 | * |
||
| 1333 | * @param string $stash |
||
| 1334 | * @param boolean $index |
||
| 1335 | */ |
||
| 1336 | public function stashPop($stash, $index = false) |
||
| 1342 | |||
| 1343 | /** |
||
| 1344 | * Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created |
||
| 1345 | * |
||
| 1346 | * @param string $branch |
||
| 1347 | * @param string $stash |
||
| 1348 | */ |
||
| 1349 | public function stashBranch($branch, $stash) |
||
| 1355 | |||
| 1356 | /** |
||
| 1357 | * Save your local modifications to a new stash, and run git reset --hard to revert them. |
||
| 1358 | * |
||
| 1359 | */ |
||
| 1360 | public function stashClear() |
||
| 1366 | |||
| 1367 | /** |
||
| 1368 | * Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the |
||
| 1369 | * ref namespace. |
||
| 1370 | * |
||
| 1371 | * @return string |
||
| 1372 | */ |
||
| 1373 | public function stashCreate() |
||
| 1380 | } |
||
| 1381 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.