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 |
||
| 66 | class Repository |
||
| 67 | { |
||
| 68 | /** |
||
| 69 | * the repository path |
||
| 70 | * |
||
| 71 | * @var string |
||
| 72 | */ |
||
| 73 | private $path; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * the caller instance |
||
| 77 | * |
||
| 78 | * @var \GitElephant\Command\Caller\Caller |
||
| 79 | */ |
||
| 80 | private $caller; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * A general repository name |
||
| 84 | * |
||
| 85 | * @var string $name the repository name |
||
| 86 | */ |
||
| 87 | private $name; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * A list of global configs to apply to every command |
||
| 91 | * |
||
| 92 | * @var array |
||
| 93 | */ |
||
| 94 | private $globalConfigs = array(); |
||
| 95 | |||
| 96 | /** |
||
| 97 | * A list of global options to apply to every command |
||
| 98 | * |
||
| 99 | * @var array |
||
| 100 | */ |
||
| 101 | private $globalOptions = array(); |
||
| 102 | |||
| 103 | /** |
||
| 104 | * A list of global arguments to apply to every command |
||
| 105 | * |
||
| 106 | * @var array |
||
| 107 | */ |
||
| 108 | private $globalCommandArguments = array(); |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Class constructor |
||
| 112 | * |
||
| 113 | * @param string $repositoryPath the path of the git repository |
||
| 114 | * @param GitBinary|null $binary the GitBinary instance that calls the commands |
||
| 115 | * @param string $name a repository name |
||
| 116 | * |
||
| 117 | * @throws Exception\InvalidRepositoryPathException |
||
| 118 | 100 | */ |
|
| 119 | public function __construct($repositoryPath, GitBinary $binary = null, $name = null) |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Factory method |
||
| 132 | * |
||
| 133 | * @param string $repositoryPath the path of the git repository |
||
| 134 | * @param GitBinary|null $binary the GitBinary instance that calls the commands |
||
| 135 | * @param string $name a repository name |
||
| 136 | * |
||
| 137 | * @return \GitElephant\Repository |
||
| 138 | 99 | */ |
|
| 139 | 1 | public static function open($repositoryPath, GitBinary $binary = null, $name = null) |
|
| 143 | |||
| 144 | /** |
||
| 145 | * create a repository from a remote git url, or a local filesystem |
||
| 146 | * and save it in a temp folder |
||
| 147 | * |
||
| 148 | * @param string|Repository $git the git remote url, or the filesystem path |
||
| 149 | * @param null $repositoryPath path |
||
| 150 | * @param GitBinary $binary binary |
||
| 151 | * @param null $name repository name |
||
| 152 | * |
||
| 153 | * @throws \RuntimeException |
||
| 154 | * @throws \Symfony\Component\Filesystem\Exception\IOException |
||
| 155 | * @return Repository |
||
| 156 | 1 | */ |
|
| 157 | public static function createFromRemote($git, $repositoryPath = null, GitBinary $binary = null, $name = null) |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Init the repository |
||
| 177 | * |
||
| 178 | * @param bool $bare created a bare repository |
||
| 179 | * |
||
| 180 | * @throws \RuntimeException |
||
| 181 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 182 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 183 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 184 | * @return Repository |
||
| 185 | 89 | */ |
|
| 186 | public function init($bare = false) |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Stage the working tree content |
||
| 195 | * |
||
| 196 | * @param string|Object $path the path to store |
||
| 197 | * |
||
| 198 | * @throws \RuntimeException |
||
| 199 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 200 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 201 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 202 | * @return Repository |
||
| 203 | 85 | */ |
|
| 204 | public function stage($path = '.') |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Unstage a tree content |
||
| 213 | * |
||
| 214 | * @param string|Object $path the path to unstage |
||
| 215 | * |
||
| 216 | * @throws \RuntimeException |
||
| 217 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 218 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 219 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 220 | * @return Repository |
||
| 221 | 2 | */ |
|
| 222 | public function unstage($path) |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Move a file/directory |
||
| 231 | * |
||
| 232 | * @param string|Object $from source path |
||
| 233 | * @param string|Object $to destination path |
||
| 234 | * |
||
| 235 | * @throws \RuntimeException |
||
| 236 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 237 | * @throws \InvalidArgumentException |
||
| 238 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 239 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 240 | * @return Repository |
||
| 241 | 1 | */ |
|
| 242 | public function move($from, $to) |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Remove a file/directory |
||
| 251 | * |
||
| 252 | * @param string|Object $path the path to remove |
||
| 253 | * @param bool $recursive recurse |
||
| 254 | * @param bool $force force |
||
| 255 | * |
||
| 256 | * @throws \RuntimeException |
||
| 257 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 258 | * @throws \InvalidArgumentException |
||
| 259 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 260 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 261 | * @return Repository |
||
| 262 | 1 | */ |
|
| 263 | public function remove($path, $recursive = false, $force = false) |
||
| 269 | |||
| 270 | /** |
||
| 271 | * Commit content to the repository, eventually staging all unstaged content |
||
| 272 | * |
||
| 273 | * @param string $message the commit message |
||
| 274 | * @param bool $stageAll whether to stage on not everything before commit |
||
| 275 | * @param string|null $ref the reference to commit to (checkout -> commit -> checkout previous) |
||
| 276 | * @param string|Author $author override the author for this commit |
||
| 277 | * |
||
| 278 | * @throws \RuntimeException |
||
| 279 | * @throws \InvalidArgumentException |
||
| 280 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 281 | * @return Repository |
||
| 282 | 82 | */ |
|
| 283 | public function commit($message, $stageAll = false, $ref = null, $author = null, $allowEmpty = false) |
||
| 300 | |||
| 301 | /** |
||
| 302 | * rev-parse command - often used to return a commit tag. |
||
| 303 | * |
||
| 304 | * @param array $options the options to apply to rev-parse |
||
| 305 | * @param string|Object|Commit $arg the argument (may be a branch head, etc) |
||
| 306 | * |
||
| 307 | * @throws \RuntimeException |
||
| 308 | * @throws \InvalidArgumentException |
||
| 309 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 310 | * @return array |
||
| 311 | 1 | */ |
|
| 312 | public function revParse($arg = null, Array $options = array()) |
||
| 318 | |||
| 319 | /** |
||
| 320 | * Check if this is a bare repository |
||
| 321 | * @return boolean |
||
| 322 | 1 | */ |
|
| 323 | public function isBare() |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @param TreeishInterface|Commit|string $arg |
||
| 333 | * @param array $options |
||
| 334 | */ |
||
| 335 | 5 | public function reset($arg,$options) |
|
| 339 | |||
| 340 | /** |
||
| 341 | * Get the repository status |
||
| 342 | * |
||
| 343 | 1 | * @return Status |
|
| 344 | */ |
||
| 345 | 1 | public function getStatus() |
|
| 349 | |||
| 350 | /** |
||
| 351 | 2 | * @return StatusWorkingTree |
|
| 352 | */ |
||
| 353 | 2 | public function getWorkingTreeStatus() |
|
| 357 | |||
| 358 | /** |
||
| 359 | * @return StatusIndex |
||
| 360 | */ |
||
| 361 | public function getIndexStatus() |
||
| 365 | |||
| 366 | /** |
||
| 367 | * isClean Return true if the repository is not dirty. |
||
| 368 | * |
||
| 369 | * @return boolean |
||
| 370 | */ |
||
| 371 | public function isClean() |
||
| 375 | |||
| 376 | /** |
||
| 377 | * isDirty Return true if the repository has some modified files. |
||
| 378 | * |
||
| 379 | * @return boolean |
||
| 380 | */ |
||
| 381 | public function isDirty() |
||
| 385 | 4 | ||
| 386 | /** |
||
| 387 | 4 | * Get the repository status as a string |
|
| 388 | * |
||
| 389 | 4 | * @throws \RuntimeException |
|
| 390 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 391 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 392 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 393 | * @return array |
||
| 394 | */ |
||
| 395 | public function getStatusOutput() |
||
| 401 | |||
| 402 | 26 | /** |
|
| 403 | * Create a new branch |
||
| 404 | 26 | * |
|
| 405 | * @param string $name the new branch name |
||
| 406 | 26 | * @param null $startPoint the reference to create the branch from |
|
| 407 | * |
||
| 408 | * @throws \RuntimeException |
||
| 409 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 410 | * @return Repository |
||
| 411 | */ |
||
| 412 | public function createBranch($name, $startPoint = null) |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Delete a branch by its name |
||
| 421 | * This function change the state of the repository on the filesystem |
||
| 422 | 1 | * |
|
| 423 | * @param string $name The branch to delete |
||
| 424 | 1 | * @param bool $force Force the delete |
|
| 425 | * |
||
| 426 | 1 | * @throws \RuntimeException |
|
| 427 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 428 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 429 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 430 | * @return Repository |
||
| 431 | */ |
||
| 432 | public function deleteBranch($name, $force = false) |
||
| 438 | |||
| 439 | /** |
||
| 440 | * An array of Branch objects |
||
| 441 | * |
||
| 442 | 17 | * @param bool $namesOnly return an array of branch names as a string |
|
| 443 | * @param bool $all lists also remote branches |
||
| 444 | 17 | * |
|
| 445 | 17 | * @throws \RuntimeException |
|
| 446 | 6 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 447 | 6 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 448 | 6 | * @throws \InvalidArgumentException |
|
| 449 | 6 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 450 | * @return array |
||
| 451 | 6 | */ |
|
| 452 | 6 | public function getBranches($namesOnly = false, $all = false) |
|
| 476 | |||
| 477 | 5 | /** |
|
| 478 | 5 | * Return the actually checked out branch |
|
| 479 | * |
||
| 480 | 5 | * @throws \RuntimeException |
|
| 481 | * @throws \InvalidArgumentException |
||
| 482 | 5 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 483 | 5 | * @return Objects\Branch |
|
| 484 | */ |
||
| 485 | 5 | public function getMainBranch() |
|
| 497 | |||
| 498 | 9 | /** |
|
| 499 | * Retrieve a Branch object by a branch name |
||
| 500 | * |
||
| 501 | 9 | * @param string $name The branch name |
|
| 502 | 9 | * |
|
| 503 | 9 | * @throws \RuntimeException |
|
| 504 | * @throws \InvalidArgumentException |
||
| 505 | 4 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 506 | * @return null|Branch |
||
| 507 | 1 | */ |
|
| 508 | public function getBranch($name) |
||
| 519 | |||
| 520 | 1 | /** |
|
| 521 | * Checkout all branches from the remote and make them local |
||
| 522 | 1 | * |
|
| 523 | 1 | * @param string $remote remote to fetch from |
|
| 524 | 1 | * |
|
| 525 | 1 | * @throws \RuntimeException |
|
| 526 | 1 | * @throws \InvalidArgumentException |
|
| 527 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 528 | 1 | * @return Repository |
|
| 529 | 1 | */ |
|
| 530 | 1 | public function checkoutAllRemoteBranches($remote = 'origin') |
|
| 550 | |||
| 551 | /** |
||
| 552 | * Merge a Branch in the current checked out branch |
||
| 553 | * |
||
| 554 | 2 | * @param Objects\Branch $branch The branch to merge in the current checked out branch |
|
| 555 | * @param string $message The message for the merge commit, if merge is 3-way |
||
| 556 | * @param string $mode The merge mode: ff-only, no-ff or auto |
||
| 557 | 2 | * |
|
| 558 | 2 | * @throws \RuntimeException |
|
| 559 | 2 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 560 | 2 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 561 | 2 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 562 | * @return Repository |
||
| 563 | */ |
||
| 564 | public function merge(Branch $branch, $message = '', $mode = 'auto') |
||
| 589 | |||
| 590 | /** |
||
| 591 | * Create a new tag |
||
| 592 | 25 | * This function change the state of the repository on the filesystem |
|
| 593 | * |
||
| 594 | 25 | * @param string $name The new tag name |
|
| 595 | * @param null $startPoint The reference to create the tag from |
||
| 596 | 25 | * @param null $message the tag message |
|
| 597 | * |
||
| 598 | * @throws \RuntimeException |
||
| 599 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 600 | * @return Repository |
||
| 601 | */ |
||
| 602 | public function createTag($name, $startPoint = null, $message = null) |
||
| 608 | |||
| 609 | 2 | /** |
|
| 610 | * Delete a tag by it's name or by passing a Tag object |
||
| 611 | 2 | * This function change the state of the repository on the filesystem |
|
| 612 | 1 | * |
|
| 613 | 1 | * @param string|Tag $tag The tag name or the Tag object |
|
| 614 | 1 | * |
|
| 615 | * @throws \RuntimeException |
||
| 616 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 617 | 2 | * @return Repository |
|
| 618 | */ |
||
| 619 | public function deleteTag($tag) |
||
| 629 | |||
| 630 | /** |
||
| 631 | * add a git submodule to the repository |
||
| 632 | 1 | * |
|
| 633 | * @param string $gitUrl git url of the submodule |
||
| 634 | 1 | * @param string $path path to register the submodule to |
|
| 635 | * |
||
| 636 | 1 | * @throws \RuntimeException |
|
| 637 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 638 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 639 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 640 | * @return Repository |
||
| 641 | */ |
||
| 642 | public function addSubmodule($gitUrl, $path = null) |
||
| 648 | |||
| 649 | /** |
||
| 650 | * initialize submodules |
||
| 651 | * |
||
| 652 | * @param string $path init only submodules at the specified path |
||
| 653 | * |
||
| 654 | * @return Repository |
||
| 655 | */ |
||
| 656 | public function initSubmodule($path = null) |
||
| 661 | |||
| 662 | /** |
||
| 663 | * update submodules |
||
| 664 | * |
||
| 665 | * @param bool $recursive update recursively |
||
| 666 | * @param bool $init init before update |
||
| 667 | * @param bool $force force the checkout as part of update |
||
| 668 | * @param string $path update only a specific submodule path |
||
| 669 | * |
||
| 670 | * @return Repository |
||
| 671 | */ |
||
| 672 | public function updateSubmodule($recursive = false, $init = false, $force = false, $path = null) |
||
| 677 | 2 | ||
| 678 | /** |
||
| 679 | 2 | * Gets an array of Tag objects |
|
| 680 | 2 | * |
|
| 681 | 2 | * @throws \RuntimeException |
|
| 682 | 2 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 683 | 2 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 684 | 2 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 685 | 2 | * @return array |
|
| 686 | */ |
||
| 687 | 2 | public function getTags() |
|
| 699 | 27 | ||
| 700 | /** |
||
| 701 | 27 | * Return a tag object |
|
| 702 | 27 | * |
|
| 703 | 27 | * @param string $name The tag name |
|
| 704 | 27 | * |
|
| 705 | * @throws \RuntimeException |
||
| 706 | 5 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 707 | * @return Tag|null |
||
| 708 | 1 | */ |
|
| 709 | public function getTag($name) |
||
| 720 | |||
| 721 | 1 | /** |
|
| 722 | 1 | * Return the last created tag |
|
| 723 | 1 | * |
|
| 724 | 1 | * @throws \LogicException |
|
| 725 | 1 | * @throws \RuntimeException |
|
| 726 | * @throws \InvalidArgumentException |
||
| 727 | * @return Tag|null |
||
| 728 | 1 | */ |
|
| 729 | 1 | public function getLastTag() |
|
| 746 | |||
| 747 | 1 | /** |
|
| 748 | * Try to get a branch or a tag by its name. |
||
| 749 | 1 | * |
|
| 750 | 1 | * @param string $name the reference name (a tag name or a branch name) |
|
| 751 | * |
||
| 752 | 1 | * @throws \RuntimeException |
|
| 753 | 1 | * @throws \InvalidArgumentException |
|
| 754 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 755 | 1 | * @return \GitElephant\Objects\Tag|\GitElephant\Objects\Branch|null |
|
| 756 | */ |
||
| 757 | 1 | public function getBranchOrTag($name) |
|
| 771 | |||
| 772 | 11 | /** |
|
| 773 | * Return a Commit object |
||
| 774 | 11 | * |
|
| 775 | * @param string $ref The commit reference |
||
| 776 | * |
||
| 777 | * @throws \RuntimeException |
||
| 778 | * @return Objects\Commit |
||
| 779 | */ |
||
| 780 | public function getCommit($ref = 'HEAD') |
||
| 786 | 1 | ||
| 787 | /** |
||
| 788 | 1 | * count the commit to arrive to the given treeish |
|
| 789 | * |
||
| 790 | 1 | * @param string $start |
|
| 791 | * |
||
| 792 | * @throws \RuntimeException |
||
| 793 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 794 | * @return int|void |
||
| 795 | */ |
||
| 796 | public function countCommits($start = 'HEAD') |
||
| 802 | |||
| 803 | /** |
||
| 804 | 20 | * Get a log for a ref |
|
| 805 | * |
||
| 806 | 20 | * @param string|TreeishInterface|array $ref the treeish to check, as a string, as an object or as an array |
|
| 807 | * @param string|Object $path the physical path to the tree relative to the repository root |
||
| 808 | * @param int|null $limit limit to n entries |
||
| 809 | * @param int|null $offset skip n entries |
||
| 810 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
| 811 | * |
||
| 812 | * @return \GitElephant\Objects\Log |
||
| 813 | */ |
||
| 814 | public function getLog($ref = 'HEAD', $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 818 | |||
| 819 | /** |
||
| 820 | * Get a log for a range ref |
||
| 821 | * |
||
| 822 | * @param string $refStart |
||
| 823 | * @param string $refEnd |
||
| 824 | * @param string|Object $path the physical path to the tree relative to the repository root |
||
| 825 | * @param int|null $limit limit to n entries |
||
| 826 | * @param int|null $offset skip n entries |
||
| 827 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
| 828 | * |
||
| 829 | * @return \GitElephant\Objects\LogRange |
||
| 830 | */ |
||
| 831 | public function getLogRange($refStart, $refEnd, $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 845 | |||
| 846 | /** |
||
| 847 | * Get a log for an object |
||
| 848 | * |
||
| 849 | * @param \GitElephant\Objects\Object $obj The Object instance |
||
| 850 | 3 | * @param null|string|\GitElephant\Objects\Branch $branch The branch to read from |
|
| 851 | * @param int $limit Limit to n entries |
||
| 852 | 3 | * @param int|null $offset Skip n entries |
|
| 853 | * |
||
| 854 | 3 | * @throws \RuntimeException |
|
| 855 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 856 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 857 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 858 | * @return \GitElephant\Objects\Log |
||
| 859 | */ |
||
| 860 | public function getObjectLog(Object $obj, $branch = null, $limit = 1, $offset = null) |
||
| 866 | |||
| 867 | /** |
||
| 868 | * Checkout a branch |
||
| 869 | * This function change the state of the repository on the filesystem |
||
| 870 | 24 | * |
|
| 871 | * @param string|TreeishInterface $ref the reference to checkout |
||
| 872 | 24 | * @param bool $create like -b on the command line |
|
| 873 | * |
||
| 874 | * @throws \RuntimeException |
||
| 875 | 24 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 876 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 877 | 24 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 878 | * @return Repository |
||
| 879 | */ |
||
| 880 | public function checkout($ref, $create = false) |
||
| 889 | |||
| 890 | /** |
||
| 891 | * Retrieve an instance of Tree |
||
| 892 | * Tree Object is Countable, Iterable and has ArrayAccess for easy manipulation |
||
| 893 | 15 | * |
|
| 894 | * @param string|TreeishInterface $ref the treeish to check |
||
| 895 | 15 | * @param string|Object $path Object or null for root |
|
| 896 | 9 | * |
|
| 897 | 9 | * @throws \RuntimeException |
|
| 898 | 9 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 899 | 9 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 900 | 9 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 901 | * @return Objects\Tree |
||
| 902 | 15 | */ |
|
| 903 | public function getTree($ref = 'HEAD', $path = null) |
||
| 914 | |||
| 915 | /** |
||
| 916 | 2 | * Get a Diff object for a commit with its parent, by default the diff is between the current head and its parent |
|
| 917 | * |
||
| 918 | 2 | * @param \GitElephant\Objects\Commit|string $commit1 A TreeishInterface instance |
|
| 919 | * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance |
||
| 920 | * @param null|string|Object $path The path to get the diff for or a Object instance |
||
| 921 | * |
||
| 922 | * @throws \RuntimeException |
||
| 923 | * @throws \InvalidArgumentException |
||
| 924 | * @return Objects\Diff\Diff |
||
| 925 | */ |
||
| 926 | public function getDiff($commit1 = null, $commit2 = null, $path = null) |
||
| 930 | |||
| 931 | /** |
||
| 932 | * Clone a repository |
||
| 933 | 2 | * |
|
| 934 | * @param string $url the repository url (i.e. git://github.com/matteosister/GitElephant.git) |
||
| 935 | 2 | * @param null $to where to clone the repo |
|
| 936 | * |
||
| 937 | 2 | * @throws \RuntimeException |
|
| 938 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 939 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 940 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 941 | * @return Repository |
||
| 942 | */ |
||
| 943 | public function cloneFrom($url, $to = null) |
||
| 949 | |||
| 950 | 7 | /** |
|
| 951 | * @param string $name remote name |
||
| 952 | 7 | * @param string $url remote url |
|
| 953 | * |
||
| 954 | 7 | * @throws \RuntimeException |
|
| 955 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 956 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 957 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 958 | * @return Repository |
||
| 959 | */ |
||
| 960 | public function addRemote($name, $url) |
||
| 966 | |||
| 967 | /** |
||
| 968 | * @param string $name remote name |
||
| 969 | * @param bool $queryRemotes Fetch new information from remotes |
||
| 970 | * |
||
| 971 | * @return \GitElephant\Objects\Remote |
||
| 972 | */ |
||
| 973 | public function getRemote($name, $queryRemotes = true) |
||
| 977 | |||
| 978 | /** |
||
| 979 | 1 | * gets a list of remote objects |
|
| 980 | * |
||
| 981 | 1 | * @param bool $queryRemotes Fetch new information from remotes |
|
| 982 | 1 | * |
|
| 983 | 1 | * @throws \RuntimeException |
|
| 984 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 985 | 1 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 986 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 987 | * @return array |
||
| 988 | 1 | */ |
|
| 989 | public function getRemotes($queryRemotes = true) |
||
| 1000 | |||
| 1001 | /** |
||
| 1002 | * Download objects and refs from another repository |
||
| 1003 | 1 | * |
|
| 1004 | * @param string $from |
||
| 1005 | 1 | * @param string $ref |
|
| 1006 | 1 | * @param bool $tags |
|
| 1007 | 1 | * |
|
| 1008 | 1 | * @throws \RuntimeException |
|
| 1009 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1010 | 1 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 1011 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1012 | */ |
||
| 1013 | public function fetch($from = null, $ref = null, $tags = false) |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | 2 | * Fetch from and merge with another repository or a local branch |
|
| 1024 | * |
||
| 1025 | 2 | * @param string $from |
|
| 1026 | 2 | * @param string $ref |
|
| 1027 | * @param bool $rebase |
||
| 1028 | * @throws \RuntimeException |
||
| 1029 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1030 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1031 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1032 | */ |
||
| 1033 | public function pull($from = null, $ref = null, $rebase = true) |
||
| 1037 | |||
| 1038 | 1 | /** |
|
| 1039 | * Fetch from and merge with another repository or a local branch |
||
| 1040 | 1 | * |
|
| 1041 | 1 | * @param string $to |
|
| 1042 | * @param string $ref |
||
| 1043 | * @throws \RuntimeException |
||
| 1044 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1045 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1046 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1047 | */ |
||
| 1048 | 2 | public function push($to = null, $ref = null) |
|
| 1052 | 2 | ||
| 1053 | /** |
||
| 1054 | 2 | * get the humanish name of the repository |
|
| 1055 | * |
||
| 1056 | * @return string |
||
| 1057 | */ |
||
| 1058 | public function getHumanishName() |
||
| 1066 | |||
| 1067 | /** |
||
| 1068 | * output a node content as an array of lines |
||
| 1069 | 1 | * |
|
| 1070 | * @param \GitElephant\Objects\Object $obj The Object of type BLOB |
||
| 1071 | 1 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
|
| 1072 | * |
||
| 1073 | 1 | * @throws \RuntimeException |
|
| 1074 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1075 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1076 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1077 | * @return array |
||
| 1078 | */ |
||
| 1079 | public function outputContent(Object $obj, $treeish) |
||
| 1085 | |||
| 1086 | /** |
||
| 1087 | * output a node raw content |
||
| 1088 | * |
||
| 1089 | * @param \GitElephant\Objects\Object $obj The Object of type BLOB |
||
| 1090 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
| 1091 | * |
||
| 1092 | * @throws \RuntimeException |
||
| 1093 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1094 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1095 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1096 | * @return string |
||
| 1097 | */ |
||
| 1098 | public function outputRawContent(Object $obj, $treeish) |
||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Get the path |
||
| 1107 | * |
||
| 1108 | * @return string |
||
| 1109 | */ |
||
| 1110 | 1 | public function getPath() |
|
| 1114 | |||
| 1115 | /** |
||
| 1116 | * Get the repository name |
||
| 1117 | * |
||
| 1118 | * @return string |
||
| 1119 | */ |
||
| 1120 | 1 | public function getName() |
|
| 1124 | |||
| 1125 | /** |
||
| 1126 | * Set the repository name |
||
| 1127 | * |
||
| 1128 | * @param string $name the repository name |
||
| 1129 | */ |
||
| 1130 | public function setName($name) |
||
| 1134 | |||
| 1135 | /** |
||
| 1136 | * Caller setter |
||
| 1137 | * |
||
| 1138 | * @param \GitElephant\Command\Caller\Caller $caller the caller variable |
||
| 1139 | */ |
||
| 1140 | 84 | public function setCaller($caller) |
|
| 1144 | |||
| 1145 | /** |
||
| 1146 | * Caller getter |
||
| 1147 | * |
||
| 1148 | * @return \GitElephant\Command\Caller\Caller |
||
| 1149 | */ |
||
| 1150 | 90 | public function getCaller() |
|
| 1154 | |||
| 1155 | /** |
||
| 1156 | * get global config list |
||
| 1157 | * |
||
| 1158 | * @return array Global config list |
||
| 1159 | */ |
||
| 1160 | public function getGlobalConfigs() |
||
| 1164 | 1 | ||
| 1165 | /** |
||
| 1166 | * add a key/value pair to the global config list |
||
| 1167 | * |
||
| 1168 | * @param string $name The config name |
||
| 1169 | * @param string $value The config value |
||
| 1170 | */ |
||
| 1171 | 1 | public function addGlobalConfig($name, $value) |
|
| 1175 | 1 | ||
| 1176 | 1 | /** |
|
| 1177 | * remove an element form the global config list, identified by key |
||
| 1178 | * |
||
| 1179 | * @param string $name The config name |
||
| 1180 | */ |
||
| 1181 | public function removeGlobalConfig($name) |
||
| 1187 | |||
| 1188 | /** |
||
| 1189 | * get global options list |
||
| 1190 | * |
||
| 1191 | * @return array Global options list |
||
| 1192 | */ |
||
| 1193 | public function getGlobalOptions() |
||
| 1197 | 1 | ||
| 1198 | /** |
||
| 1199 | * add a key/value pair to the global option list |
||
| 1200 | * |
||
| 1201 | * @param string $name The option name |
||
| 1202 | * @param string $value The option value |
||
| 1203 | */ |
||
| 1204 | 1 | public function addGlobalOption($name, $value) |
|
| 1208 | 1 | ||
| 1209 | 1 | /** |
|
| 1210 | * remove an element form the global option list, identified by key |
||
| 1211 | * |
||
| 1212 | * @param string $name The option name |
||
| 1213 | */ |
||
| 1214 | public function removeGlobalOption($name) |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * get global command arguments list |
||
| 1223 | * |
||
| 1224 | * @return array Global command arguments list |
||
| 1225 | */ |
||
| 1226 | 1 | public function getGlobalCommandArguments() |
|
| 1230 | 1 | ||
| 1231 | 1 | /** |
|
| 1232 | * add a value to the global command argument list |
||
| 1233 | * |
||
| 1234 | * @param string $value The command argument |
||
| 1235 | */ |
||
| 1236 | public function addGlobalCommandArgument($value) |
||
| 1242 | 1 | ||
| 1243 | 1 | /** |
|
| 1244 | 1 | * remove an element form the global command argument list, identified by |
|
| 1245 | 1 | * value |
|
| 1246 | * |
||
| 1247 | * @param string $value The command argument |
||
| 1248 | */ |
||
| 1249 | public function removeGlobalCommandArgument($value) |
||
| 1256 | } |
||
| 1257 |
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.