Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
6 | class Stomp |
||
7 | { |
||
8 | protected $client; |
||
9 | protected $username; |
||
10 | protected $password; |
||
11 | protected $stompQueueName; |
||
12 | protected $connected = false; |
||
13 | |||
14 | /** |
||
15 | * @param array $connectionConfig keys: |
||
16 | * - connect_string |
||
17 | * - credentials (optional, must be an array with 'user' and 'password' |
||
18 | */ |
||
19 | public function __construct(array $connectionConfig) |
||
27 | |||
28 | public function __destruct() |
||
34 | |||
35 | public function setCredentials($username, $password) |
||
42 | |||
43 | /** |
||
44 | * @param bool |
||
45 | * @return Consumer |
||
46 | */ |
||
47 | public function setDebug($debug) |
||
53 | |||
54 | /** |
||
55 | * @param string $queueName NB: queue name as used by Stomp, including the prefix used by the broker to specify the |
||
56 | * message delivery pattern |
||
57 | * @return Producer |
||
58 | */ |
||
59 | public function setStompQueueName($queueName) |
||
65 | |||
66 | /** |
||
67 | * @return string the queue name as used by Stomp |
||
68 | */ |
||
69 | public function getStompQueueName() |
||
73 | |||
74 | /** |
||
75 | * Returns the full queue name to be used in stomp messages. |
||
76 | * - Apache Apollo supports using routing keys at end of queue name @see https://activemq.apache.org/apollo/documentation/stomp-manual.html#Destination_Wildcards |
||
77 | * - ActiveMQ: @see http://activemq.apache.org/wildcards.html |
||
78 | * - RabbitMQ: @see https://www.rabbitmq.com/stomp.html |
||
79 | * - Artemis: @see https://activemq.apache.org/components/artemis/documentation/latest/stomp.html |
||
80 | * |
||
81 | * @param string $routingKey assumes the amqp pattern: *=1word, #=0-or-more |
||
82 | * @return string; |
||
83 | */ |
||
84 | protected function getFullQueueName($routingKey = '') |
||
101 | |||
102 | /** |
||
103 | * Connects to the Stomp server. Attempts the connection only once by default, regardless of results |
||
104 | * |
||
105 | * @param bool $onlyOnce |
||
106 | * @throws \FuseSource\Stomp\Exception\StompException |
||
107 | */ |
||
108 | protected function connect($onlyOnce = true) |
||
116 | |||
117 | } |
||
118 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.