11<?php
2+
23namespace Guywithnose \ReleaseNotes ;
34
45use Gregwar \Cache \Cache ;
@@ -97,7 +98,13 @@ protected function configure()
9798 null ,
9899 InputOption::VALUE_NONE ,
99100 'Only include Pull Requests in the change list. '
100- )->addOption ('cache-dir ' , null , InputOption::VALUE_REQUIRED , 'The access token cache location ' , dirname (__DIR__ ))->addOption (
101+ )->addOption (
102+ 'cache-dir ' ,
103+ null ,
104+ InputOption::VALUE_REQUIRED ,
105+ 'The access token cache location ' ,
106+ dirname (__DIR__ )
107+ )->addOption (
101108 'token-file ' ,
102109 null ,
103110 InputOption::VALUE_REQUIRED ,
@@ -127,7 +134,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
127134 $ this ->versionFactory = new CalendarVersionFactory ();
128135 }
129136
130- $ promptFactory = new PromptFactory ($ input , $ output , $ this ->getHelperSet ()->get ('question ' ), $ this ->getHelperSet ()->get ('formatter ' ));
137+ $ promptFactory = new PromptFactory (
138+ $ input ,
139+ $ output ,
140+ $ this ->getHelperSet ()->get ('question ' ),
141+ $ this ->getHelperSet ()->get ('formatter ' )
142+ );
131143
132144 $ client = GithubClient::createWithToken (
133145 $ this ->_getToken ($ input , $ promptFactory ),
@@ -157,7 +169,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
157169
158170 $ done = false ;
159171 while (!$ done ) {
160- $ choice = $ promptFactory ->invoke ('What would you like to do? ' , $ defaultChoice , $ choices , $ release ->previewFormat ());
172+ $ choice = $ promptFactory ->invoke (
173+ 'What would you like to do? ' ,
174+ $ defaultChoice ,
175+ $ choices ,
176+ $ release ->previewFormat ()
177+ );
161178 $ result = $ this ->_handleUserInput ($ release , $ promptFactory , $ client , $ input , $ output , $ choice );
162179 if ($ result === true ) {
163180 $ done = true ;
@@ -189,8 +206,7 @@ private function _handleUserInput(
189206 InputInterface $ input ,
190207 OutputInterface $ output ,
191208 string $ choice
192- )
193- {
209+ ) {
194210 $ typeManager = $ this ->typeManager ;
195211 $ targetBranch = $ baseTagName = null ;
196212 switch ($ choice ) {
@@ -205,7 +221,7 @@ private function _handleUserInput(
205221 return $ this ->_buildRelease ($ input , $ output , $ client , $ targetBranch , $ baseTagName );
206222 break ;
207223 case 'c ' :
208- $ selectTypeForChange = function (Change $ change ) use ($ promptFactory , $ typeManager ) {
224+ $ selectTypeForChange = function (Change $ change ) use ($ promptFactory , $ typeManager ) {
209225 $ choice = $ promptFactory ->invoke (
210226 'What type of change is this PR? ' ,
211227 $ change ->getType ()->getCode (),
@@ -229,7 +245,13 @@ private function _handleUserInput(
229245 $ currentVersion = $ release ->currentVersion ;
230246 $ defaultVersion = $ release ->version ;
231247 $ release ->version = $ this ->versionFactory ->createVersion (
232- $ promptFactory ->invoke ("Version Number (current: {$ currentVersion }) " , $ defaultVersion , $ suggestedVersions , null , false )
248+ $ promptFactory ->invoke (
249+ "Version Number (current: {$ currentVersion }) " ,
250+ $ defaultVersion ,
251+ $ suggestedVersions ,
252+ null ,
253+ false
254+ )
233255 );
234256 break ;
235257 case 'n ' :
@@ -267,8 +289,13 @@ private function _handleUserInput(
267289 *
268290 * @throws \Exception if tag already exists
269291 */
270- private function _buildRelease (InputInterface $ input , OutputInterface $ output , GithubClient $ client , $ targetBranch , $ baseTagName )
271- {
292+ private function _buildRelease (
293+ InputInterface $ input ,
294+ OutputInterface $ output ,
295+ GithubClient $ client ,
296+ $ targetBranch ,
297+ $ baseTagName
298+ ) {
272299 $ currentVersion = $ this ->versionFactory ->createVersion ($ baseTagName );
273300
274301 $ typeSelector = null ;
@@ -294,7 +321,15 @@ private function _buildRelease(InputInterface $input, OutputInterface $output, G
294321 $ releaseName = $ this ->_getReleaseName ($ input );
295322 $ isDraft = !$ input ->getOption ('publish ' );
296323
297- return new Release ($ changes , $ currentVersion , $ newVersion , $ releaseName , $ releaseNotes , $ targetBranch , $ isDraft );
324+ return new Release (
325+ $ changes ,
326+ $ currentVersion ,
327+ $ newVersion ,
328+ $ releaseName ,
329+ $ releaseNotes ,
330+ $ targetBranch ,
331+ $ isDraft
332+ );
298333 }
299334
300335 private function _getChangesInRange (
@@ -303,8 +338,7 @@ private function _getChangesInRange(
303338 $ startCommitish ,
304339 $ endCommitish ,
305340 callable $ changePrompter = null
306- )
307- {
341+ ) {
308342 $ commitDepth = 1 ;
309343 $ argument = (int )$ input ->getOption ('commit-depth ' );
310344 if ($ argument >= 1 ) {
@@ -313,7 +347,10 @@ private function _getChangesInRange(
313347
314348 $ commitGraph = new GithubCommitGraph ($ client ->getCommitsInRange ($ startCommitish , $ endCommitish ));
315349 $ leadingCommits = $ commitGraph ->firstParents ($ commitDepth );
316- $ changeListFactory = new ChangeListFactory (new ChangeFactory ($ this ->typeManager , $ changePrompter ), $ this ->typeManager );
350+ $ changeListFactory = new ChangeListFactory (
351+ new ChangeFactory ($ this ->typeManager , $ changePrompter ),
352+ $ this ->typeManager
353+ );
317354
318355 return $ changeListFactory ->createFromCommits ($ leadingCommits );
319356 }
@@ -334,7 +371,13 @@ private function _getToken(InputInterface $input, PromptFactory $promptFactory)
334371
335372 $ cache = new Cache ($ input ->getOption ('cache-dir ' ));
336373
337- return trim ($ cache ->getOrCreate ($ input ->getOption ('token-file ' ), [], $ promptFactory ->create ('Please enter a github access token ' )));
374+ return trim (
375+ $ cache ->getOrCreate (
376+ $ input ->getOption ('token-file ' ),
377+ [],
378+ $ promptFactory ->create ('Please enter a github access token ' )
379+ )
380+ );
338381 }
339382
340383 /**
@@ -457,8 +500,7 @@ private function _submitRelease(
457500 PromptFactory $ promptFactory ,
458501 GithubClient $ client ,
459502 Release $ release
460- )
461- {
503+ ) {
462504 $ defaultResponse = !$ input ->getOption ('dry-run ' );
463505 $ output ->writeln ($ release ->previewFormat ());
464506 if ($ promptFactory ->invoke ('Are you sure? ' , $ defaultResponse )) {
0 commit comments