-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ClassNames to open to handling parent class names
- Loading branch information
1 parent
ed4843a
commit beb5e6e
Showing
13 changed files
with
204 additions
and
37 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TomasVotruba\ClassLeak\Reporting; | ||
|
||
use TomasVotruba\ClassLeak\ValueObject\FileWithClass; | ||
use TomasVotruba\ClassLeak\ValueObject\UnusedClassesResult; | ||
|
||
final class UnusedClassesResultFactory | ||
{ | ||
/** | ||
* @param FileWithClass[] $unusedFilesWithClasses | ||
*/ | ||
public function create(array $unusedFilesWithClasses): UnusedClassesResult | ||
{ | ||
$parentLessFileWithClasses = []; | ||
$withParentsFileWithClasses = []; | ||
|
||
foreach ($unusedFilesWithClasses as $unusedFileWithClass) { | ||
if ($unusedFileWithClass->hasParentClassOrInterface()) { | ||
$withParentsFileWithClasses[] = $unusedFileWithClass; | ||
} else { | ||
$parentLessFileWithClasses[] = $unusedFileWithClass; | ||
} | ||
} | ||
|
||
return new UnusedClassesResult($parentLessFileWithClasses, $withParentsFileWithClasses); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TomasVotruba\ClassLeak\ValueObject; | ||
|
||
final class ClassNames | ||
{ | ||
public function __construct( | ||
private readonly string $className, | ||
private readonly bool $hasParentClassOrInterface | ||
) { | ||
} | ||
|
||
public function getClassName(): string | ||
{ | ||
return $this->className; | ||
} | ||
|
||
public function hasParentClassOrInterface(): bool | ||
{ | ||
return $this->hasParentClassOrInterface; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TomasVotruba\ClassLeak\ValueObject; | ||
|
||
final class UnusedClassesResult | ||
{ | ||
/** | ||
* @param FileWithClass[] $withParentsFileWithClasses | ||
* @param FileWithClass[] $parentLessFileWithClasses | ||
*/ | ||
public function __construct( | ||
private readonly array $parentLessFileWithClasses, | ||
private readonly array $withParentsFileWithClasses, | ||
) { | ||
} | ||
|
||
/** | ||
* @return FileWithClass[] | ||
*/ | ||
public function getParentLessFileWithClasses(): array | ||
{ | ||
return $this->parentLessFileWithClasses; | ||
} | ||
|
||
/** | ||
* @return FileWithClass[] | ||
*/ | ||
public function getWithParentsFileWithClasses(): array | ||
{ | ||
return $this->withParentsFileWithClasses; | ||
} | ||
|
||
public function hasFilesWithClasses(): bool | ||
{ | ||
if ($this->parentLessFileWithClasses !== []) { | ||
return false; | ||
} | ||
|
||
return $this->withParentsFileWithClasses !== []; | ||
} | ||
|
||
public function getCount(): int | ||
{ | ||
return count($this->parentLessFileWithClasses) + count($this->withParentsFileWithClasses); | ||
} | ||
} |
Oops, something went wrong.