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 | 103 | */ |
|
| 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 | 102 | */ |
|
| 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 | 92 | */ |
|
| 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 | 88 | */ |
|
| 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 | 85 | */ |
|
| 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 | 2 | */ |
|
| 335 | public function reset($arg,$options) |
||
| 339 | |||
| 340 | /** |
||
| 341 | * Get the repository status |
||
| 342 | * |
||
| 343 | * @return Status |
||
| 344 | 5 | */ |
|
| 345 | public function getStatus() |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @return StatusWorkingTree |
||
| 352 | 1 | */ |
|
| 353 | public function getWorkingTreeStatus() |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @return StatusIndex |
||
| 360 | 4 | */ |
|
| 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 | |||
| 386 | /** |
||
| 387 | * Get the repository status as a string |
||
| 388 | * |
||
| 389 | * @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 | 4 | */ |
|
| 395 | public function getStatusOutput() { |
||
| 410 | |||
| 411 | 27 | /** |
|
| 412 | * Create a new branch |
||
| 413 | 27 | * |
|
| 414 | * @param string $name the new branch name |
||
| 415 | 27 | * @param null $startPoint the reference to create the branch from |
|
| 416 | * |
||
| 417 | * @throws \RuntimeException |
||
| 418 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 419 | * @return Repository |
||
| 420 | */ |
||
| 421 | public function createBranch($name, $startPoint = null) |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Delete a branch by its name |
||
| 430 | * This function change the state of the repository on the filesystem |
||
| 431 | 1 | * |
|
| 432 | * @param string $name The branch to delete |
||
| 433 | 1 | * @param bool $force Force the delete |
|
| 434 | * |
||
| 435 | 1 | * @throws \RuntimeException |
|
| 436 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 437 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 438 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 439 | * @return Repository |
||
| 440 | */ |
||
| 441 | public function deleteBranch($name, $force = false) |
||
| 447 | |||
| 448 | /** |
||
| 449 | * An array of Branch objects |
||
| 450 | * |
||
| 451 | 17 | * @param bool $namesOnly return an array of branch names as a string |
|
| 452 | * @param bool $all lists also remote branches |
||
| 453 | 17 | * |
|
| 454 | 17 | * @throws \RuntimeException |
|
| 455 | 6 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 456 | 6 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 457 | 6 | * @throws \InvalidArgumentException |
|
| 458 | 6 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 459 | * @return array |
||
| 460 | 6 | */ |
|
| 461 | 6 | public function getBranches($namesOnly = false, $all = false) |
|
| 493 | |||
| 494 | 5 | /** |
|
| 495 | * Return the actually checked out branch |
||
| 496 | * |
||
| 497 | * @throws \RuntimeException |
||
| 498 | * @throws \InvalidArgumentException |
||
| 499 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 500 | * @return Objects\Branch |
||
| 501 | */ |
||
| 502 | public function getMainBranch() |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Retrieve a Branch object by a branch name |
||
| 525 | * |
||
| 526 | * @param string $name The branch name |
||
| 527 | * |
||
| 528 | * @throws \RuntimeException |
||
| 529 | 1 | * @throws \InvalidArgumentException |
|
| 530 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 531 | 1 | * @return null|Branch |
|
| 532 | 1 | */ |
|
| 533 | 1 | public function getBranch($name) |
|
| 544 | 1 | ||
| 545 | 1 | /** |
|
| 546 | * Checkout all branches from the remote and make them local |
||
| 547 | 1 | * |
|
| 548 | * @param string $remote remote to fetch from |
||
| 549 | * |
||
| 550 | * @throws \RuntimeException |
||
| 551 | * @throws \InvalidArgumentException |
||
| 552 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 553 | * @return Repository |
||
| 554 | */ |
||
| 555 | public function checkoutAllRemoteBranches($remote = 'origin') |
||
| 575 | |||
| 576 | 2 | /** |
|
| 577 | 1 | * Merge a Branch in the current checked out branch |
|
| 578 | 1 | * |
|
| 579 | 2 | * @param Objects\Branch $branch The branch to merge in the current checked out branch |
|
| 580 | 2 | * @param string $message The message for the merge commit, if merge is 3-way |
|
| 581 | 1 | * @param string $mode The merge mode: ff-only, no-ff or auto |
|
| 582 | * |
||
| 583 | * @throws \RuntimeException |
||
| 584 | 2 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 585 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 586 | 2 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 587 | * @return Repository |
||
| 588 | */ |
||
| 589 | public function merge(Branch $branch, $message = '', $mode = 'auto') |
||
| 614 | |||
| 615 | /** |
||
| 616 | * Create a new tag |
||
| 617 | * This function change the state of the repository on the filesystem |
||
| 618 | 2 | * |
|
| 619 | * @param string $name The new tag name |
||
| 620 | 2 | * @param null $startPoint The reference to create the tag from |
|
| 621 | 1 | * @param null $message the tag message |
|
| 622 | 1 | * |
|
| 623 | 1 | * @throws \RuntimeException |
|
| 624 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 625 | * @return Repository |
||
| 626 | 2 | */ |
|
| 627 | public function createTag($name, $startPoint = null, $message = null) |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Delete a tag by it's name or by passing a Tag object |
||
| 636 | * This function change the state of the repository on the filesystem |
||
| 637 | * |
||
| 638 | * @param string|Tag $tag The tag name or the Tag object |
||
| 639 | * |
||
| 640 | * @throws \RuntimeException |
||
| 641 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 642 | * @return Repository |
||
| 643 | 1 | */ |
|
| 644 | public function deleteTag($tag) |
||
| 654 | |||
| 655 | /** |
||
| 656 | * add a git submodule to the repository |
||
| 657 | * |
||
| 658 | * @param string $gitUrl git url of the submodule |
||
| 659 | * @param string $path path to register the submodule to |
||
| 660 | * |
||
| 661 | * @throws \RuntimeException |
||
| 662 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 663 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 664 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 665 | * @return Repository |
||
| 666 | */ |
||
| 667 | public function addSubmodule($gitUrl, $path = null) |
||
| 673 | |||
| 674 | /** |
||
| 675 | * initialize submodules |
||
| 676 | * |
||
| 677 | * @param string $path init only submodules at the specified path |
||
| 678 | * |
||
| 679 | * @return Repository |
||
| 680 | */ |
||
| 681 | public function initSubmodule($path = null) |
||
| 686 | 2 | ||
| 687 | /** |
||
| 688 | 2 | * update submodules |
|
| 689 | 2 | * |
|
| 690 | 2 | * @param bool $recursive update recursively |
|
| 691 | 2 | * @param bool $init init before update |
|
| 692 | 2 | * @param bool $force force the checkout as part of update |
|
| 693 | 2 | * @param string $path update only a specific submodule path |
|
| 694 | 2 | * |
|
| 695 | * @return Repository |
||
| 696 | 2 | */ |
|
| 697 | public function updateSubmodule($recursive = false, $init = false, $force = false, $path = null) |
||
| 702 | |||
| 703 | /** |
||
| 704 | * Gets an array of Tag objects |
||
| 705 | * |
||
| 706 | * @throws \RuntimeException |
||
| 707 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 708 | 27 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 709 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 710 | 27 | * @return array |
|
| 711 | 27 | */ |
|
| 712 | 27 | public function getTags() |
|
| 724 | |||
| 725 | /** |
||
| 726 | * Return a tag object |
||
| 727 | * |
||
| 728 | 1 | * @param string $name The tag name |
|
| 729 | * |
||
| 730 | 1 | * @throws \RuntimeException |
|
| 731 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 732 | 1 | * @return Tag|null |
|
| 733 | 1 | */ |
|
| 734 | 1 | public function getTag($name) |
|
| 745 | |||
| 746 | /** |
||
| 747 | * Return the last created tag |
||
| 748 | * |
||
| 749 | * @throws \LogicException |
||
| 750 | * @throws \RuntimeException |
||
| 751 | * @throws \InvalidArgumentException |
||
| 752 | * @return Tag|null |
||
| 753 | */ |
||
| 754 | public function getLastTag() |
||
| 771 | |||
| 772 | /** |
||
| 773 | * Try to get a branch or a tag by its name. |
||
| 774 | * |
||
| 775 | * @param string $name the reference name (a tag name or a branch name) |
||
| 776 | * |
||
| 777 | * @throws \RuntimeException |
||
| 778 | * @throws \InvalidArgumentException |
||
| 779 | 13 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 780 | * @return \GitElephant\Objects\Tag|\GitElephant\Objects\Branch|null |
||
| 781 | 13 | */ |
|
| 782 | public function getBranchOrTag($name) |
||
| 796 | |||
| 797 | 3 | /** |
|
| 798 | * Return a Commit object |
||
| 799 | 3 | * |
|
| 800 | * @param string $ref The commit reference |
||
| 801 | * |
||
| 802 | * @throws \RuntimeException |
||
| 803 | * @return Objects\Commit |
||
| 804 | */ |
||
| 805 | public function getCommit($ref = 'HEAD') |
||
| 811 | |||
| 812 | /** |
||
| 813 | 20 | * count the commit to arrive to the given treeish |
|
| 814 | * |
||
| 815 | 20 | * @param string $start |
|
| 816 | * |
||
| 817 | * @throws \RuntimeException |
||
| 818 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 819 | * @return int|void |
||
| 820 | */ |
||
| 821 | public function countCommits($start = 'HEAD') |
||
| 827 | |||
| 828 | /** |
||
| 829 | * Get a log for a ref |
||
| 830 | * |
||
| 831 | * @param string|TreeishInterface|array $ref the treeish to check, as a string, as an object or as an array |
||
| 832 | * @param string|Object $path the physical path to the tree relative to the repository root |
||
| 833 | * @param int|null $limit limit to n entries |
||
| 834 | * @param int|null $offset skip n entries |
||
| 835 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
| 836 | * |
||
| 837 | * @return \GitElephant\Objects\Log |
||
| 838 | */ |
||
| 839 | public function getLog($ref = 'HEAD', $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 843 | |||
| 844 | /** |
||
| 845 | * Get a log for a range ref |
||
| 846 | * |
||
| 847 | * @param string $refStart |
||
| 848 | * @param string $refEnd |
||
| 849 | * @param string|Object $path the physical path to the tree relative to the repository root |
||
| 850 | * @param int|null $limit limit to n entries |
||
| 851 | * @param int|null $offset skip n entries |
||
| 852 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
| 853 | * |
||
| 854 | * @return \GitElephant\Objects\LogRange |
||
| 855 | */ |
||
| 856 | public function getLogRange($refStart, $refEnd, $path = null, $limit = 10, $offset = null, $firstParent = false) |
||
| 870 | |||
| 871 | /** |
||
| 872 | * Get a log for an object |
||
| 873 | * |
||
| 874 | * @param \GitElephant\Objects\Object $obj The Object instance |
||
| 875 | * @param null|string|\GitElephant\Objects\Branch $branch The branch to read from |
||
| 876 | * @param int $limit Limit to n entries |
||
| 877 | * @param int|null $offset Skip n entries |
||
| 878 | * |
||
| 879 | 24 | * @throws \RuntimeException |
|
| 880 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 881 | 24 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 882 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 883 | * @return \GitElephant\Objects\Log |
||
| 884 | 24 | */ |
|
| 885 | public function getObjectLog(Object $obj, $branch = null, $limit = 1, $offset = null) |
||
| 891 | |||
| 892 | /** |
||
| 893 | * Checkout a branch |
||
| 894 | * This function change the state of the repository on the filesystem |
||
| 895 | * |
||
| 896 | * @param string|TreeishInterface $ref the reference to checkout |
||
| 897 | * @param bool $create like -b on the command line |
||
| 898 | * |
||
| 899 | * @throws \RuntimeException |
||
| 900 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 901 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 902 | 15 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 903 | * @return Repository |
||
| 904 | 15 | */ |
|
| 905 | 9 | public function checkout($ref, $create = false) |
|
| 915 | |||
| 916 | /** |
||
| 917 | * Retrieve an instance of Tree |
||
| 918 | * Tree Object is Countable, Iterable and has ArrayAccess for easy manipulation |
||
| 919 | * |
||
| 920 | * @param string|TreeishInterface $ref the treeish to check |
||
| 921 | * @param string|Object $path Object or null for root |
||
| 922 | * |
||
| 923 | * @throws \RuntimeException |
||
| 924 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 925 | 2 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 926 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 927 | 2 | * @return Objects\Tree |
|
| 928 | */ |
||
| 929 | public function getTree($ref = 'HEAD', $path = null) |
||
| 940 | |||
| 941 | /** |
||
| 942 | 2 | * Get a Diff object for a commit with its parent, by default the diff is between the current head and its parent |
|
| 943 | * |
||
| 944 | 2 | * @param \GitElephant\Objects\Commit|string $commit1 A TreeishInterface instance |
|
| 945 | * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance |
||
| 946 | 2 | * @param null|string|Object $path The path to get the diff for or a Object instance |
|
| 947 | * |
||
| 948 | * @throws \RuntimeException |
||
| 949 | * @throws \InvalidArgumentException |
||
| 950 | * @return Objects\Diff\Diff |
||
| 951 | */ |
||
| 952 | public function getDiff($commit1 = null, $commit2 = null, $path = null) |
||
| 956 | |||
| 957 | /** |
||
| 958 | * Clone a repository |
||
| 959 | 7 | * |
|
| 960 | * @param string $url the repository url (i.e. git://github.com/matteosister/GitElephant.git) |
||
| 961 | 7 | * @param null $to where to clone the repo |
|
| 962 | * |
||
| 963 | 7 | * @throws \RuntimeException |
|
| 964 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 965 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 966 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 967 | * @return Repository |
||
| 968 | */ |
||
| 969 | public function cloneFrom($url, $to = null) |
||
| 975 | |||
| 976 | /** |
||
| 977 | * @param string $name remote name |
||
| 978 | * @param string $url remote url |
||
| 979 | * |
||
| 980 | * @throws \RuntimeException |
||
| 981 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 982 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 983 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 984 | * @return Repository |
||
| 985 | */ |
||
| 986 | public function addRemote($name, $url) |
||
| 992 | 1 | ||
| 993 | 1 | /** |
|
| 994 | 1 | * @param string $name remote name |
|
| 995 | 1 | * @param bool $queryRemotes Fetch new information from remotes |
|
| 996 | * |
||
| 997 | 1 | * @return \GitElephant\Objects\Remote |
|
| 998 | */ |
||
| 999 | public function getRemote($name, $queryRemotes = true) |
||
| 1003 | |||
| 1004 | /** |
||
| 1005 | * gets a list of remote objects |
||
| 1006 | * |
||
| 1007 | * @param bool $queryRemotes Fetch new information from remotes |
||
| 1008 | * |
||
| 1009 | * @throws \RuntimeException |
||
| 1010 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1011 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1012 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1013 | * @return array |
||
| 1014 | 1 | */ |
|
| 1015 | 1 | public function getRemotes($queryRemotes = true) |
|
| 1026 | |||
| 1027 | /** |
||
| 1028 | * Download objects and refs from another repository |
||
| 1029 | * |
||
| 1030 | * @param string $from |
||
| 1031 | * @param string $ref |
||
| 1032 | 2 | * @param array $args |
|
| 1033 | * @param bool $tags |
||
| 1034 | 2 | * |
|
| 1035 | 2 | * @throws \RuntimeException |
|
| 1036 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1037 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1038 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1039 | * @return string |
||
| 1040 | */ |
||
| 1041 | public function fetch($from = null, $ref = null, $args = [], $tags = false) |
||
| 1057 | 2 | ||
| 1058 | /** |
||
| 1059 | 2 | * Fetch from and merge with another repository or a local branch |
|
| 1060 | 2 | * |
|
| 1061 | 2 | * @param string $from |
|
| 1062 | * @param string $ref |
||
| 1063 | 2 | * @param bool $rebase |
|
| 1064 | * @throws \RuntimeException |
||
| 1065 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1066 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1067 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1068 | */ |
||
| 1069 | public function pull($from = null, $ref = null, $rebase = true) |
||
| 1073 | |||
| 1074 | /** |
||
| 1075 | * Push changes to remote repository |
||
| 1076 | * |
||
| 1077 | * @param string $to |
||
| 1078 | 1 | * @param string $ref |
|
| 1079 | * @throws \RuntimeException |
||
| 1080 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1081 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1082 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1083 | */ |
||
| 1084 | public function push($to = null, $ref = null) |
||
| 1088 | |||
| 1089 | /** |
||
| 1090 | * get the humanish name of the repository |
||
| 1091 | * |
||
| 1092 | * @return string |
||
| 1093 | */ |
||
| 1094 | public function getHumanishName() |
||
| 1102 | |||
| 1103 | /** |
||
| 1104 | * output a node content as an array of lines |
||
| 1105 | * |
||
| 1106 | * @param \GitElephant\Objects\Object $obj The Object of type BLOB |
||
| 1107 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
| 1108 | * |
||
| 1109 | 61 | * @throws \RuntimeException |
|
| 1110 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 1111 | 61 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
| 1112 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
| 1113 | * @return array |
||
| 1114 | */ |
||
| 1115 | public function outputContent(Object $obj, $treeish) |
||
| 1121 | 1 | ||
| 1122 | /** |
||
| 1123 | * output a node raw content |
||
| 1124 | * |
||
| 1125 | * @param \GitElephant\Objects\Object $obj The Object of type BLOB |
||
| 1126 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
| 1127 | * |
||
| 1128 | * @throws \RuntimeException |
||
| 1129 | 1 | * @throws \Symfony\Component\Process\Exception\LogicException |
|
| 1130 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
| 1131 | 1 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
| 1132 | 1 | * @return string |
|
| 1133 | */ |
||
| 1134 | public function outputRawContent(Object $obj, $treeish) |
||
| 1140 | |||
| 1141 | /** |
||
| 1142 | * Get the path |
||
| 1143 | * |
||
| 1144 | * @return string |
||
| 1145 | */ |
||
| 1146 | public function getPath() |
||
| 1150 | |||
| 1151 | 87 | /** |
|
| 1152 | * Get the repository name |
||
| 1153 | * |
||
| 1154 | * @return string |
||
| 1155 | */ |
||
| 1156 | public function getName() |
||
| 1160 | |||
| 1161 | 93 | /** |
|
| 1162 | * Set the repository name |
||
| 1163 | * |
||
| 1164 | * @param string $name the repository name |
||
| 1165 | */ |
||
| 1166 | public function setName($name) |
||
| 1170 | 1 | ||
| 1171 | /** |
||
| 1172 | 1 | * Caller setter |
|
| 1173 | 1 | * |
|
| 1174 | * @param \GitElephant\Command\Caller\Caller $caller the caller variable |
||
| 1175 | */ |
||
| 1176 | public function setCaller($caller) |
||
| 1180 | 1 | ||
| 1181 | /** |
||
| 1182 | 1 | * Caller getter |
|
| 1183 | 1 | * |
|
| 1184 | 1 | * @return \GitElephant\Command\Caller\Caller |
|
| 1185 | 1 | */ |
|
| 1186 | public function getCaller() |
||
| 1190 | |||
| 1191 | /** |
||
| 1192 | 93 | * get global config list |
|
| 1193 | * |
||
| 1194 | 93 | * @return array Global config list |
|
| 1195 | */ |
||
| 1196 | public function getGlobalConfigs() |
||
| 1200 | |||
| 1201 | /** |
||
| 1202 | * add a key/value pair to the global config list |
||
| 1203 | 1 | * |
|
| 1204 | * @param string $name The config name |
||
| 1205 | 1 | * @param string $value The config value |
|
| 1206 | 1 | */ |
|
| 1207 | public function addGlobalConfig($name, $value) |
||
| 1211 | |||
| 1212 | /** |
||
| 1213 | 1 | * remove an element form the global config list, identified by key |
|
| 1214 | * |
||
| 1215 | 1 | * @param string $name The config name |
|
| 1216 | 1 | */ |
|
| 1217 | 1 | public function removeGlobalConfig($name) |
|
| 1223 | |||
| 1224 | /** |
||
| 1225 | 93 | * get global options list |
|
| 1226 | * |
||
| 1227 | 93 | * @return array Global options list |
|
| 1228 | */ |
||
| 1229 | public function getGlobalOptions() |
||
| 1233 | |||
| 1234 | /** |
||
| 1235 | 1 | * add a key/value pair to the global option list |
|
| 1236 | * |
||
| 1237 | 1 | * @param string $name The option name |
|
| 1238 | 1 | * @param string $value The option value |
|
| 1239 | 1 | */ |
|
| 1240 | 1 | public function addGlobalOption($name, $value) |
|
| 1244 | |||
| 1245 | /** |
||
| 1246 | * remove an element form the global option list, identified by key |
||
| 1247 | * |
||
| 1248 | 1 | * @param string $name The option name |
|
| 1249 | */ |
||
| 1250 | 1 | public function removeGlobalOption($name) |
|
| 1256 | |||
| 1257 | /** |
||
| 1258 | * get global command arguments list |
||
| 1259 | * |
||
| 1260 | * @return array Global command arguments list |
||
| 1261 | */ |
||
| 1262 | public function getGlobalCommandArguments() |
||
| 1266 | |||
| 1267 | /** |
||
| 1268 | * add a value to the global command argument list |
||
| 1269 | * |
||
| 1270 | * @param string $value The command argument |
||
| 1271 | */ |
||
| 1272 | public function addGlobalCommandArgument($value) |
||
| 1278 | |||
| 1279 | /** |
||
| 1280 | * remove an element form the global command argument list, identified by |
||
| 1281 | * value |
||
| 1282 | * |
||
| 1283 | * @param string $value The command argument |
||
| 1284 | */ |
||
| 1285 | public function removeGlobalCommandArgument($value) |
||
| 1292 | |||
| 1293 | /** |
||
| 1294 | * Return the cache tag for this repository |
||
| 1295 | * |
||
| 1296 | * @return string |
||
| 1297 | */ |
||
| 1298 | private function getCacheTag() { |
||
| 1302 | |||
| 1303 | private function getCacheKey() { |
||
| 1307 | |||
| 1308 | /** |
||
| 1309 | * Flush the cache for this repository |
||
| 1310 | */ |
||
| 1311 | public function flushCache() { |
||
| 1315 | } |
||
| 1316 |
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.