-
-
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.
Merge pull request #25 from TomasVotruba/tv-highlihgh-without-parent
- Loading branch information
Showing
13 changed files
with
195 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,39 @@ | ||
<?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 getCount(): int | ||
{ | ||
return count($this->parentLessFileWithClasses) + count($this->withParentsFileWithClasses); | ||
} | ||
} |
Oops, something went wrong.