@@ -49,16 +49,16 @@ protected function initialize()
49
49
50
50
$ this ->entries = [];
51
51
$ this ->entriesByType = [
52
- TreeType:: BLOB -> value => [],
53
- TreeType:: TREE -> value => [],
54
- TreeType:: COMMIT -> value => [],
52
+ ' blob ' => [],
53
+ ' tree ' => [],
54
+ ' commit ' => [],
55
55
];
56
56
57
57
foreach ($ parser ->entries as $ entry ) {
58
58
list ($ mode , $ type , $ hash , $ name ) = $ entry ;
59
- if ($ type == TreeType:: BLOB -> value ) {
59
+ if ($ type == ' blob ' ) {
60
60
$ treeEntry = [$ mode , $ this ->repository ->getBlob ($ hash )];
61
- } elseif ($ type == TreeType:: TREE -> value ) {
61
+ } elseif ($ type == ' tree ' ) {
62
62
$ treeEntry = [$ mode , $ this ->repository ->getTree ($ hash )];
63
63
} else {
64
64
$ treeEntry = [$ mode , new CommitReference ($ hash )];
@@ -71,13 +71,43 @@ protected function initialize()
71
71
}
72
72
73
73
/**
74
- * @return array An associative array name => $object
74
+ * @return array<string, array{string, CommitReference|Tree|Blob}> An associative array name => $object
75
75
*/
76
- public function getEntries (? TreeType $ type = null )
76
+ public function getEntries (): array
77
77
{
78
78
$ this ->initialize ();
79
79
80
- return $ type ? $ this ->entriesByType [$ type ->value ] : $ this ->entries ;
80
+ return $ this ->entries ;
81
+ }
82
+
83
+ /**
84
+ * @return array<string, array{string, CommitReference}> An associative array of name => [mode, commit reference]
85
+ */
86
+ public function getCommitReferenceEntries (): array
87
+ {
88
+ $ this ->initialize ();
89
+
90
+ return $ this ->entriesByType ['commit ' ];
91
+ }
92
+
93
+ /**
94
+ * @return array<string, array{string, Tree}> An associative array of name => [mode, tree]
95
+ */
96
+ public function getTreeEntries (): array
97
+ {
98
+ $ this ->initialize ();
99
+
100
+ return $ this ->entriesByType ['tree ' ];
101
+ }
102
+
103
+ /**
104
+ * @return array<string, array{string, Blob}> An associative array of name => [mode, blob]
105
+ */
106
+ public function getBlobEntries (): array
107
+ {
108
+ $ this ->initialize ();
109
+
110
+ return $ this ->entriesByType ['blob ' ];
81
111
}
82
112
83
113
public function getEntry ($ name )
0 commit comments