diego-ninja /
blackmine
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Blackmine\Model\Project; |
||
| 6 | |||
| 7 | use Blackmine\Collection\PaginatedCollection; |
||
| 8 | use Blackmine\Mutator\MutableInterface; |
||
| 9 | use Blackmine\Mutator\Mutation\RenameKeyMutation; |
||
| 10 | use Carbon\CarbonImmutable; |
||
| 11 | use Blackmine\Collection\IdentityCollection; |
||
| 12 | use Blackmine\Collection\RepeatableNameCollection; |
||
| 13 | use Blackmine\Collection\RepeatableIdCollection; |
||
| 14 | use Blackmine\Model\FetchableInterface; |
||
| 15 | use Blackmine\Model\NamedIdentity; |
||
| 16 | use Blackmine\Model\User\Membership; |
||
| 17 | use Blackmine\Model\User\User; |
||
| 18 | use Blackmine\Repository\Projects\Projects; |
||
| 19 | use Doctrine\Common\Collections\ArrayCollection; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @method setIdentifier(string $identifier): void |
||
| 23 | * @method setDescription(string $description): void |
||
| 24 | * @method setHomePage(string $homepage): void |
||
| 25 | * @method setStatus(int $status): void |
||
| 26 | * @method setParent(Project $parent): void |
||
| 27 | * @method setDefaultVersion(Version $version): void |
||
| 28 | * @method setDefaultAssignee(User $assignee): void |
||
| 29 | * @method setInheritMembers(bool $inherit_members): void |
||
| 30 | * @method setIsPublic(bool $is_public): void |
||
| 31 | * |
||
| 32 | * @method string getIdentifier() |
||
| 33 | * @method string getDescription() |
||
| 34 | * @method string getHomepage() |
||
| 35 | * @method int getStatus() |
||
| 36 | * @method Project|null getParent() |
||
| 37 | * @method Version|null getDefaultVersion() |
||
| 38 | * @method User|null getDefaultAssignee() |
||
| 39 | * @method bool getInheritMembers() |
||
| 40 | * @method bool isPublic() |
||
| 41 | * @method RepeatableIdCollection getTrackers() |
||
| 42 | * @method RepeatableNameCollection getEnabledModules() |
||
| 43 | * @method IdentityCollection getTimeEntries() |
||
| 44 | * @method IdentityCollection getTimeEntryActivities() |
||
| 45 | * @method IdentityCollection getIssueCategories() |
||
| 46 | * @method IdentityCollection getMemberships() |
||
| 47 | * @method IdentityCollection getVersions() |
||
| 48 | * @method IdentityCollection getFiles() |
||
| 49 | * @method IdentityCollection getNews() |
||
| 50 | * @method CarbonImmutable getCreatedOn() |
||
| 51 | * @method CarbonImmutable getUpdatedOn() |
||
| 52 | * |
||
| 53 | * @method addTracker(Tracker $tracker): void |
||
| 54 | * @method removeTracker(Tracker $tracker): void |
||
| 55 | * @method addEnabledModule(Module $module): void |
||
| 56 | * @method removeEnabledModule(Module $module): void |
||
| 57 | * @method addTimeEntry(TimeEntry $time_entry): void |
||
| 58 | * @method removeTimeEntry(TimeEntry $time_entry): void |
||
| 59 | * @method addIssueCategory(IssueCategory $issue_category): void |
||
| 60 | * @method removeIssueCategory(IssueCategory $issue_category): void |
||
| 61 | * @method addMembership(Membership $membership): void |
||
| 62 | * @method removeMembership(Membership $membership): void |
||
| 63 | * @method addVersion(Version $version): void |
||
| 64 | * @method removeVersion(Version $version): void |
||
| 65 | * @method addFile(File $file): void |
||
| 66 | * @method removeFile(File $file): void |
||
| 67 | */ |
||
| 68 | class Project extends NamedIdentity implements FetchableInterface, MutableInterface |
||
| 69 | { |
||
| 70 | public const ENTITY_NAME = "project"; |
||
| 71 | |||
| 72 | protected string $identifier; |
||
| 73 | protected string $description; |
||
| 74 | protected string $homepage; |
||
| 75 | protected int $status; |
||
| 76 | protected ?Project $parent; |
||
| 77 | protected ?Version $default_version; |
||
| 78 | protected ?User $default_assignee; |
||
| 79 | |||
| 80 | protected ?bool $inherit_members; |
||
| 81 | protected ?bool $is_public; |
||
| 82 | |||
| 83 | protected RepeatableIdCollection $trackers; |
||
| 84 | protected RepeatableNameCollection $enabled_modules; |
||
| 85 | protected IdentityCollection $time_entries; |
||
| 86 | protected IdentityCollection $time_entry_activities; |
||
| 87 | protected IdentityCollection $issue_categories; |
||
| 88 | protected IdentityCollection $memberships; |
||
| 89 | protected IdentityCollection $versions; |
||
| 90 | protected IdentityCollection $files; |
||
| 91 | protected PaginatedCollection $news; |
||
| 92 | protected ArrayCollection $wiki_pages; |
||
| 93 | |||
| 94 | protected CarbonImmutable $created_on; |
||
| 95 | protected CarbonImmutable $updated_on; |
||
| 96 | |||
| 97 | public static function getRepositoryClass(): ?string |
||
| 98 | { |
||
| 99 | return Projects::class; |
||
| 100 | } |
||
| 101 | |||
| 102 | public function addUser(User $user, array $roles): void |
||
| 103 | { |
||
| 104 | $membership = $this->getUserMembership($user); |
||
|
0 ignored issues
–
show
|
|||
| 105 | if (!$membership) { |
||
|
0 ignored issues
–
show
|
|||
| 106 | $membership = new Membership(); |
||
| 107 | $membership->setUser($user); |
||
| 108 | $membership->setRoles(new RepeatableIdCollection($roles)); |
||
| 109 | $membership->setProject($this); |
||
| 110 | } else { |
||
| 111 | foreach ($roles as $role) { |
||
| 112 | $membership->addRole($role); |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | $this->memberships->add($membership); |
||
| 117 | } |
||
| 118 | |||
| 119 | public function getUserMembership(User $user): ?Membership |
||
| 120 | { |
||
| 121 | foreach ($this->memberships as $membership) { |
||
| 122 | if ($membership->getUser()->getId() === $user->getId()) { |
||
| 123 | return $membership; |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | return null; |
||
| 128 | } |
||
| 129 | |||
| 130 | public function getMutations(): array |
||
| 131 | { |
||
| 132 | return [ |
||
| 133 | "trackers" => [RenameKeyMutation::class => ["tracker_ids"]], |
||
| 134 | "enabled_modules" => [RenameKeyMutation::class => ["enabled_modules"]], |
||
| 135 | "default_assignee_id" => [RenameKeyMutation::class => ["default_assigned_to_id"]] |
||
| 136 | ]; |
||
| 137 | } |
||
| 138 | } |
||
| 139 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.