Code Duplication    Length = 20-20 lines in 2 locations

src/IPub/WebSocketsSession/Users/Repository.php 2 locations

@@ 72-91 (lines=20) @@
69
	 *
70
	 * @return array|bool
71
	 */
72
	public function findByUsername(string $username)
73
	{
74
		/** @var WebSocketsEntities\Clients\IClient $client */
75
		foreach ($this->storage as $client) {
76
			$user = $client->getUser();
77
78
			if (!$user || !$user->isLoggedIn()) {
79
				continue;
80
			}
81
82
			if (method_exists($user, 'getUsername') && $user->getUsername() === $username) {
83
				return [
84
					'user'   => $client,
85
					'client' => $client
86
				];
87
			}
88
		}
89
90
		return FALSE;
91
	}
92
93
	/**
94
	 * @param mixed $userId
@@ 98-117 (lines=20) @@
95
	 *
96
	 * @return array|bool
97
	 */
98
	public function findById($userId)
99
	{
100
		/** @var WebSocketsEntities\Clients\IClient $client */
101
		foreach ($this->storage as $client) {
102
			$user = $client->getUser();
103
104
			if (!$user || !$user->isLoggedIn()) {
105
				continue;
106
			}
107
108
			if ($user->getId() === $userId) {
109
				return [
110
					'user'   => $client,
111
					'client' => $client
112
				];
113
			}
114
		}
115
116
		return FALSE;
117
	}
118
119
	/**
120
	 * @param bool $anonymous