-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
303513a
commit 58f293a
Showing
11 changed files
with
266 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
|
||
use GP; | ||
use GP_Project; | ||
use http\Exception\InvalidArgumentException; | ||
|
||
/** | ||
* Helper class to find a GlotPress project based on path, ID, or GitHub repository URL. | ||
|
@@ -22,7 +21,7 @@ class ProjectLocator { | |
* | ||
* @since 2.0.0 | ||
* | ||
* @var \Required\Traduttore\Project Project instance. | ||
* @var \Required\Traduttore\Project|null Project instance. | ||
*/ | ||
protected $project; | ||
|
||
|
@@ -31,16 +30,10 @@ class ProjectLocator { | |
* | ||
* @since 2.0.0 | ||
* | ||
* @param mixed $project Possible GlotPress project ID or path or source code repository path. | ||
* @param int|string|Project|GP_Project $project Possible GlotPress project ID or path or source code repository path. | ||
Check failure on line 33 in inc/ProjectLocator.php GitHub Actions / Lint
Check failure on line 33 in inc/ProjectLocator.php GitHub Actions / Lint
|
||
*/ | ||
public function __construct( $project ) { | ||
$found = $this->find_project( $project ); | ||
|
||
if ( ! $found ) { | ||
throw new InvalidArgumentException( __( 'Project not found', 'traduttore' ) ); | ||
} | ||
|
||
$this->project = $found; | ||
$this->project = $this->find_project( $project ); | ||
} | ||
|
||
/** | ||
|
@@ -59,7 +52,7 @@ public function get_project(): ?Project { | |
* | ||
* @since 2.0.0 | ||
* | ||
* @param mixed $project Possible GlotPress project ID or path or source code repository path. | ||
* @param int|string|Project|GP_Project $project Possible GlotPress project ID or path or source code repository path. | ||
Check failure on line 55 in inc/ProjectLocator.php GitHub Actions / Lint
Check failure on line 55 in inc/ProjectLocator.php GitHub Actions / Lint
|
||
* @return \Required\Traduttore\Project Project instance. | ||
*/ | ||
protected function find_project( $project ): ?Project { | ||
|
@@ -82,15 +75,15 @@ protected function find_project( $project ): ?Project { | |
} | ||
|
||
if ( ! $found ) { | ||
$found = $this->find_by_repository_name( $project ); | ||
$found = $this->find_by_repository_name( (string) $project ); | ||
} | ||
|
||
if ( ! $found ) { | ||
$found = $this->find_by_repository_url( $project ); | ||
$found = $this->find_by_repository_url( (string) $project ); | ||
} | ||
|
||
if ( ! $found ) { | ||
$found = $this->find_by_source_url_template( $project ); | ||
$found = $this->find_by_source_url_template( (string) $project ); | ||
} | ||
|
||
return $found ? new Project( $found ) : null; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.