root/components/codeInstrumentation/CodeInstrumentationReceiver.class.php
| 105 | 142 | ||
|---|---|---|---|
83 | protected $arrMessages = array(); | 83 | protected $arrMessages = array(); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Array with the name of the classes what should NOT enter into the diagram | 86 | * Gate keeper of the classes into the diagram |
87 | * | ||
88 | * If this array is empty, no class will be ignored to the diagram | ||
89 | * | ||
90 | * @var String[] | ||
91 | */ | ||
92 | protected $arrIgnoredClasses = array(); | ||
93 | | ||
94 | /** | ||
95 | * Array with the name of the exclusive classes what should be into the diagram | ||
96 | * | ||
97 | * If this array is empty, any class can enter into the diagram. | ||
98 | * | ||
99 | * @var String[] | ||
100 | */ | ||
101 | protected $arrExclusiveClasses = array(); | ||
102 | | ||
103 | /** | ||
104 | * Array with the name of the methods what should NOT enter into the diagram | ||
105 | * | 87 | * |
106 | * If this array is empty, no methods will be ignored to the diagram | 88 | * @var MatchGatekeeper |
107 | * The value can be just the "<method name>" or "<class name>::<method name>", | ||
108 | * in this last case just in the informed class the method it is considered | ||
109 | * | ||
110 | * @var String[] | ||
111 | */ | 89 | */ |
112 | protected $arrIgnoredMethods = array(); | 90 | protected $objGatekeeperClasses; |
113 | 91 | ||
114 | /** | 92 | /** |
115 | * Array with the Regex of the methods what should NOT enter into the diagram | 93 | * Gate keeper of the methods into the diagram |
116 | * | 94 | * |
117 | * If this array is empty, no methods will be ignored to the diagram | 95 | * @var MatchGatekeeper |
118 | * The value can be any regular expression what will be match with the | ||
119 | * "<method name>" or "<class name>::<method name>", | ||
120 | * | ||
121 | * @var String[] | ||
122 | */ | 96 | */ |
123 | protected $arrIgnoredMethodsRegex = array(); | 97 | protected $objGatekeeperMethods; |
124 | 98 | ||
125 | /** | 99 | /** |
126 | * Array with the exclusive methods name what should be into the diagram | ||
127 | * | ||
128 | * If this array is empty, any method can enter into the diagram. | ||
129 | * The value can be just the "<method name>" or "<class name>::<method name>", | ||
130 | * in this last case just in the informed class the method it is considered | ||
131 | * | ||
132 | * @var String[] | ||
133 | */ | ||
134 | protected $arrExclusiveMethods = array(); | ||
135 | |||
136 | /** | ||
137 | * Array with the exclusive methods regex what should be into the diagram | ||
138 | * | ||
139 | * If this array is empty, any method can enter into the diagram. | ||
140 | * The value can be any regular expression what will be match with | ||
141 | * the "<method name>" or "<class name>::<method name>" | ||
142 | * | ||
143 | * @var String[] | ||
144 | */ | ||
145 | protected $arrExclusiveMethodsRegex = array(); | ||
146 | |||
147 | /** | ||
148 | * Object of the uml sequence diagram what will be feed into the execution | 100 | * Object of the uml sequence diagram what will be feed into the execution |
149 | * | 101 | * |
150 | * @var UmlSequenceDiagram | 102 | * @var UmlSequenceDiagram |
... | ... | ||
238 | } | 190 | } |
239 | 191 | ||
240 | /** | 192 | /** |
241 | * Set the array with the ignored class into the diagram | 193 | * Set the gate keeper to the classes into the diagram |
242 | * | ||
243 | * @see CodeInstrumentationReceiver->arrIgnoredClasses | ||
244 | * @see CodeInstrumentationReceiver::getIgnoredClasses() | ||
245 | * @param String[] $arrIgnoredClasses | ||
246 | * @return CodeInstrumentationReceiver me | ||
247 | */ | ||
248 | public function setIgnoredClasses( array $arrIgnoredClasses ) | ||
249 | { | ||
250 | $this->arrIgnoredClasses = $arrIgnoredClasses; | ||
251 | return $this; | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * get the array with the ignored class into the diagram | ||
256 | * | ||
257 | * @see CodeInstrumentationReceiver->arrIgnoredClasses | ||
258 | * @see CodeInstrumentationReceiver::setIgnoredClasses( String[] ) | ||
259 | * @see CodeInstrumentationReceiver::getIgnoredClasses() | ||
260 | * @return String[] $arrIgnoredClasses | ||
261 | */ | ||
262 | public function getIgnoredClasses() | ||
263 | { | ||
264 | return $this->arrIgnoredClasses; | ||
265 | } | ||
266 | | ||
267 | /** | ||
268 | * Add a class name into the ignored class list | ||
269 | * | 194 | * |
270 | * @see CodeInstrumentationReceiver->arrIgnoredClasses | 195 | * @param MatchGatekeeper $objGatekeeperClasses |
271 | * @see CodeInstrumentationReceiver::setIgnoredClasses( String[] ) | ||
272 | * @param string $strIgnoredClass | ||
273 | * @return CodeInstrumentationReceiver me | ||
274 | */ | 196 | */ |
275 | public function addIgnoredClass( $strIgnoredClass ) | 197 | public function setGatekeeperClasses( MatchGatekeeper $objGatekeeperClasses ) |
276 | { | 198 | { |
277 | $this->arrIgnoredClasses[] = $strIgnoredClass; | 199 | $this->objGatekeeperClasses = $objGatekeeperClasses; |
278 | return $this; | ||
279 | } | ||
280 | | ||
281 | /** | ||
282 | * Set the array with the exclusive class into the diagram | ||
283 | * | ||
284 | * @see CodeInstrumentationReceiver->arrExclusiveClasses | ||
285 | * @see CodeInstrumentationReceiver::getExclusiveClasses() | ||
286 | * @param String[] $arrExclusiveClasses | ||
287 | * @return CodeInstrumentationReceiver me | ||
288 | */ | ||
289 | public function setExclusiveClasses( $arrExclusiveClasses ) | ||
290 | { | ||
291 | $this->arrExclusiveClasses = $arrExclusiveClasses; | ||
292 | return $this; | ||
293 | } | 200 | } |
294 | | ||
295 | /** | ||
296 | * get the array with the exclusive class into the diagram | ||
297 | * | ||
298 | * @see CodeInstrumentationReceiver->arrExclusiveClasses | ||
299 | * @see CodeInstrumentationReceiver::setExclusiveClasses( String[] ) | ||
300 | * @return String[] $arrExclusiveClasses | ||
301 | */ | ||
302 | public function getExclusiveClasses() | ||
303 | { | ||
304 | return $this->arrExclusiveClasses; | ||
305 | } | ||
306 | | ||
307 | /** | ||
308 | * Add a class name into the exclusive class list | ||
309 | * | ||
310 | * @see CodeInstrumentationReceiver->arrExclusiveClasses | ||
311 | * @see CodeInstrumentationReceiver::setExclusiveClasses( String[] ) | ||
312 | * @see CodeInstrumentationReceiver::getExclusiveClasses() | ||
313 | * @param string $strExclusiveClass | ||
314 | * @return CodeInstrumentationReceiver me | ||
315 | */ | ||
316 | public function addExclusiveClass( $strExclusiveClass ) | ||
317 | { | ||
318 | $this->arrExclusiveClasses[] = $strExclusiveClass; | ||
319 | return $this; | ||
320 | } | ||
321 | | ||
322 | /** | ||
323 | * Set the array with the exclusive methods into the diagram | ||
324 | * | ||
325 | * @see CodeInstrumentationReceiver->arrExclusiveMethods | ||
326 | * @see CodeInstrumentationReceiver::getExclusiveMethods() | ||
327 | * @param String[] $arrExclusiveMethods | ||
328 | * @return CodeInstrumentationReceiver me | ||
329 | */ | ||
330 | public function setExclusiveMethods( $arrExclusiveMethods ) | ||
331 | { | ||
332 | $this->arrExclusiveMethods = $arrExclusiveMethods; | ||
333 | return $this; | ||
334 | } | ||
335 | 201 | ||
336 | /** | 202 | /** |
337 | * get the array with the exclusive method into the diagram | 203 | * Get the gate keeper to the classes into the diagram |
338 | * | 204 | * |
339 | * @see CodeInstrumentationReceiver->arrExclusiveMethods | 205 | * @return MatchGatekeeper |
340 | * @see CodeInstrumentationReceiver::setExclusiveMethods( String[] ) | ||
341 | * @return String[] $arrExclusiveMethods | ||
342 | */ | 206 | */ |
343 | public function getExclusiveMethods() | 207 | public function getGatekeeperClasses() |
344 | { | 208 | { |
345 | return $this->arrExclusiveMethods; | 209 | return $this->objGatekeeperClasses; |
346 | } | 210 | } |
347 | 211 | ||
348 | /** | 212 | /** |
349 | * Add a class method into the exclusive method list | 213 | * Set the gate keeper to the classes into the method |
350 | * | 214 | * |
351 | * @see CodeInstrumentationReceiver->arrExclusiveMethods | 215 | * @param MatchGatekeeper $objGatekeeperMethods |
352 | * @see CodeInstrumentationReceiver::setExclusiveMethods( String[] ) | ||
353 | * @see CodeInstrumentationReceiver::getExclusiveMethod() | ||
354 | * @param string $strExclusiveMethod | ||
355 | * @return CodeInstrumentationReceiver me | ||
356 | */ | 216 | */ |
357 | public function addExclusiveMethod( $strExclusiveMethod ) | 217 | public function setGatekeeperMethods( MatchGatekeeper $objGatekeeperMethods ) |
358 | { | 218 | { |
359 | $this->arrExclusiveMethods[] = $strExclusiveMethod; | 219 | $this->objGatekeeperMethods = $objGatekeeperMethods; |
360 | return $this; | ||
361 | } | 220 | } |
362 | 221 | ||
363 | |||
364 | /** | 222 | /** |
365 | * Set the array with the regular expression of the | 223 | * Get the gate keeper to the classes into the method |
366 | * exclusive methods into the diagram | ||
367 | * | 224 | * |
368 | * @see CodeInstrumentationReceiver->arrExclusiveMethodsRegex | 225 | * @return MatchGatekeeper $objGatekeeperMethods |
369 | * @see CodeInstrumentationReceiver::getExclusiveMethodsRegex() | ||
370 | * @param String[] $arrExclusiveMethodsRegex | ||
371 | * @return CodeInstrumentationReceiver me | ||
372 | */ | 226 | */ |
373 | public function setExclusiveMethodsRegex( $arrExclusiveMethodsRegex ) | 227 | public function getGatekeeperMethods() |
374 | { | 228 | { |
375 | $this->arrExclusiveMethodsRegex = $arrExclusiveMethodsRegex; | 229 | return $this->objGatekeeperMethods; |
376 | return $this; | ||
377 | } | 230 | } |
378 | 231 | ||
379 | /** | 232 | /** |
380 | * get the array with the regular expressions of the | ||
381 | * exclusive method into the diagram | ||
382 | * | ||
383 | * @see CodeInstrumentationReceiver->arrExclusiveMethodsRegex | ||
384 | * @see CodeInstrumentationReceiver::setExclusiveMethodsRegex( String[] ) | ||
385 | * @return String[] $arrExclusiveMethodsRegex | ||
386 | */ | ||
387 | public function getExclusiveMethodsRegex() | ||
388 | { | ||
389 | return $this->arrExclusiveMethodsRegex; | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Add a regular expression into the | ||
394 | * exclusive method regular expression list | ||
395 | * | ||
396 | * @see CodeInstrumentationReceiver->arrExclusiveMethodsRegex | ||
397 | * @see CodeInstrumentationReceiver::setExclusiveMethodsRegex( String[] ) | ||
398 | * @see CodeInstrumentationReceiver::getExclusiveMethodRegex() | ||
399 | * @param string $strExclusiveMethodRegex | ||
400 | * @return CodeInstrumentationReceiver me | ||
401 | */ | ||
402 | public function addExclusiveMethodRegex( $strExclusiveMethodRegex ) | ||
403 | { | ||
404 | $this->arrExclusiveMethodsRegex[] = $strExclusiveMethodRegex; | ||
405 | return $this; | ||
406 | } | ||
407 | |||
408 | |||
409 | /** | ||
410 | * Set the array with the ignored methods list into the diagram | ||
411 | * | ||
412 | * @see CodeInstrumentationReceiver->arrIgnoredMethods | ||
413 | * @see CodeInstrumentationReceiver::getIgnoredMethods() | ||
414 | * @param String[] $arrIgnoredMethods | ||
415 | * @return CodeInstrumentationReceiver me | ||
416 | */ | ||
417 | public function setIgnoredMethods( array $arrIgnoredMethods ) | ||
418 | { | ||
419 | $this->arrIgnoredMethods = $arrIgnoredMethods; | ||
420 | return $this; | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * get the array with the ignored methods into the diagram | ||
425 | * | ||
426 | * @see CodeInstrumentationReceiver->arrIgnoredMethods | ||
427 | * @see CodeInstrumentationReceiver::setIgnoredMethods( String[] ) | ||
428 | * @see CodeInstrumentationReceiver::getIgnoredMethods() | ||
429 | * @return String[] $arrIgnoredMethods | ||
430 | */ | ||
431 | public function getIgnoredMethods() | ||
432 | { | ||
433 | return $this->arrIgnoredMethods; | ||
434 | } | ||
435 | | ||
436 | /** | ||
437 | * Add a class method into the ignored methods list | ||
438 | * | ||
439 | * @see CodeInstrumentationReceiver->arrIgnoredMethods | ||
440 | * @see CodeInstrumentationReceiver::setIgnoredMethods( String[] ) | ||
441 | * @param string $strIgnoredMethod | ||
442 | * @return CodeInstrumentationReceiver me | ||
443 | */ | ||
444 | public function addIgnoredMethod( $strIgnoredMethod ) | ||
445 | { | ||
446 | $this->arrIgnoredMethods[] = $strIgnoredMethod; | ||
447 | return $this; | ||
448 | } | ||
449 | | ||
450 | /** | ||
451 | * Set the array with the ignored regular expressions | ||
452 | * methods list into the diagram | ||
453 | * | ||
454 | * @see CodeInstrumentationReceiver->arrIgnoredMethodsRegex | ||
455 | * @see CodeInstrumentationReceiver::getIgnoredMethodsRegex() | ||
456 | * @param String[] $arrIgnoredMethodsRegex | ||
457 | * @return CodeInstrumentationReceiver me | ||
458 | */ | ||
459 | public function setIgnoredMethodsRegex( array $arrIgnoredMethodsRegex ) | ||
460 | { | ||
461 | $this->arrIgnoredMethodsRegex = $arrIgnoredMethodsRegex; | ||
462 | return $this; | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * get the array with the ignored methods regex list of the diagram | ||
467 | * | ||
468 | * @see CodeInstrumentationReceiver->arrIgnoredMethodsRegex | ||
469 | * @see CodeInstrumentationReceiver::setIgnoredMethodsRegex( String[] ) | ||
470 | * @see CodeInstrumentationReceiver::getIgnoredMethodsRegex() | ||
471 | * @return String[] $arrIgnoredMethodsRegex | ||
472 | */ | ||
473 | public function getIgnoredMethodsRegex() | ||
474 | { | ||
475 | return $this->arrIgnoredMethodsRegex; | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Add a regex into the ignored methods regex list | ||
480 | * | ||
481 | * @see CodeInstrumentationReceiver->arrIgnoredMethodsRegex | ||
482 | * @see CodeInstrumentationReceiver::setIgnoredMethodsRegex( String[] ) | ||
483 | * @param string $strIgnoredMethodRegex | ||
484 | * @return CodeInstrumentationReceiver me | ||
485 | */ | ||
486 | public function addIgnoredMethodRegex( $strIgnoredMethodRegex ) | ||
487 | { | ||
488 | $this->arrIgnoredMethodsRegex[] = $strIgnoredMethodRegex; | ||
489 | return $this; | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * prepare the code instrumentation receiver to start to receive the informations about | 233 | * prepare the code instrumentation receiver to start to receive the informations about |
494 | * the execution. | 234 | * the execution. |
495 | * | 235 | * |
496 | * 1. create the uml sequence diagram object | 236 | * @plan{ |
497 | * 2. create the user actor | 237 | * <ol> |
238 | * <li> create the internal objects </li> | ||
239 | * <li> create the uml sequence diagram object </li> | ||
240 | * <li> create the user actor </li> | ||
241 | * </ol> | ||
242 | * } | ||
498 | * | 243 | * |
499 | * @return null | 244 | * @return null |
500 | */ | 245 | */ |
501 | public function __construct() | 246 | public function __construct() |
502 | { | 247 | { |
503 | // 1. create the uml sequence diagram object // | 248 | // create the internal objects // |
249 | $objGatekeeperClasses = new MatchGatekeeper(); | ||
250 | $this->setGatekeeperClasses( $objGatekeeperClasses ); | ||
251 | |||
252 | $objGatekeeperMethods = new MatchGatekeeper(); | ||
253 | $this->setGatekeeperMethods( $objGatekeeperMethods ); | ||
254 | |||
255 | // create the uml sequence diagram object // | ||
504 | $this->objUmlSequence = new UmlSequenceDiagram(); | 256 | $this->objUmlSequence = new UmlSequenceDiagram(); |
505 | 257 | ||
506 | // 2. create the user actor // | 258 | // create the user actor // |
507 | $objActorFrom = new UmlSequenceDiagramActor(); | 259 | $objActorFrom = new UmlSequenceDiagramActor(); |
508 | $objActorFrom->setType( 'user' ); | 260 | $objActorFrom->setType( 'user' ); |
509 | $objActorFrom->setName( "user" ); | 261 | $objActorFrom->setName( "user" ); |
... | ... | ||
531 | /** | 283 | /** |
532 | * Rename the method to which they are in accordance | 284 | * Rename the method to which they are in accordance |
533 | * with the standarts of the diagram | 285 | * with the standarts of the diagram |
534 | * | 286 | * |
535 | * 1. if __construct replace by <<create>> | 287 | * @plan{ |
536 | * 2. if __destruct replace by <<destroy>> | 288 | * <ol> |
537 | * 3. other cases should append the "()" | 289 | * <li> if __construct replace by >>create<< </li> |
538 | * | 290 | * <li> if __destruct replace by >>destroy<< </li> |
291 | * <li> other cases should append the "()" </li> | ||
292 | * </ol> | ||
293 | * } | ||
294 | * | ||
539 | * @param string $strMethod old method name | 295 | * @param string $strMethod old method name |
540 | * @return string new method name | 296 | * @return string new method name |
541 | */ | 297 | */ |
... | ... | ||
574 | } | 330 | } |
575 | 331 | ||
576 | /** | 332 | /** |
577 | * Return if the class should be ignored | ||
578 | * | ||
579 | * @param String $strClass | ||
580 | */ | ||
581 | protected function isIgnoredClass( $strClass ) | ||
582 | { | ||
583 | // returns if it is into ignore list | ||
584 | if( | ||
585 | ( count( $this->getIgnoredClasses() ) > 0 ) | ||
586 | and | ||
587 | ( in_array( $strClass , $this->getIgnoredClasses() ) ) | ||
588 | ) | ||
589 | { | ||
590 | return true; | ||
591 | } | ||
592 | |||
593 | // returns if it is not into the exclusive class | ||
594 | if( | ||
595 | ( count( $this->getExclusiveClasses() ) > 0 ) | ||
596 | and | ||
597 | ( !in_array( $strClass , $this->getExclusiveClasses() ) ) | ||
598 | ) | ||
599 | { | ||
600 | return true; | ||
601 | } | ||
602 | |||
603 | return false; | ||
604 | } | ||
605 | |||
606 | protected function isIgnoredMethod( $strClass , $strMethod ) | ||
607 | { | ||
608 | $strFullName = $strClass . '::' . $strMethod; | ||
609 | | ||
610 | // returns if it is into ignore list | ||
611 | if( | ||
612 | ( count( $this->getIgnoredMethods() ) > 0 ) | ||
613 | and | ||
614 | ( | ||
615 | ( in_array( $strMethod , $this->getIgnoredMethods() ) ) | ||
616 | || | ||
617 | ( in_array( $strFullName , $this->getIgnoredMethods() ) ) | ||
618 | ) | ||
619 | ) | ||
620 | { | ||
621 | return true; | ||
622 | } | ||
623 | |||
624 | // returns if it is not into the exclusive list | ||
625 | if( | ||
626 | ( count( $this->getExclusiveMethods() ) > 0 ) | ||
627 | and | ||
628 | ( | ||
629 | ( ! in_array( $strMethod , $this->getExclusiveMethods() ) ) | ||
630 | && | ||
631 | ( ! in_array( $strFullName , $this->getExclusiveMethods() ) ) | ||
632 | ) | ||
633 | ) | ||
634 | { | ||
635 | return true; | ||
636 | } | ||
637 | |||
638 | // exists a ignore methods regular expression list // | ||
639 | if( count( $this->getIgnoredMethodsRegex() ) > 0 ) | ||
640 | { | ||
641 | foreach( $this->getIgnoredMethodsRegex() as $strRegex ) | ||
642 | { | ||
643 | if( ereg( $strRegex , $strMethod ) || ereg( $strRegex , $strFullName ) ) | ||
644 | { | ||
645 | // and the method match into // | ||
646 | return true; | ||
647 | } | ||
648 | } | ||
649 | } | ||
650 | |||
651 | // exists a exclusive methods regular expression list // | ||
652 | if( count( $this->getExclusiveMethodsRegex() ) > 0 ) | ||
653 | { | ||
654 | foreach( $this->getExclusiveMethodsRegex() as $strRegex ) | ||
655 | { | ||
656 | if( ereg( $strRegex , $strMethod ) || ereg( $strRegex , $strFullName ) ) | ||
657 | { | ||
658 | // and the method match into // | ||
659 | return false; | ||
660 | } | ||
661 | } | ||
662 | // and the method not match into // | ||
663 | return true; | ||
664 | } | ||
665 | |||
666 | // not reasons was founded to ignore this class // | ||
667 | return false; | ||
668 | } | ||
669 | |||
670 | /** | ||
671 | * Check if the method should be loged into the uml sequence diagram | 333 | * Check if the method should be loged into the uml sequence diagram |
672 | * | 334 | * |
673 | * @param String $strClass | 335 | * @param String $strClass |
... | ... | ||
676 | */ | 338 | */ |
677 | protected function shouldBeLog( $strClass , $strMethod ) | 339 | protected function shouldBeLog( $strClass , $strMethod ) |
678 | { | 340 | { |
679 | // returns if is a ignored class | 341 | if( $this->getGatekeeperClasses()->match( $strClass ) == false ) |
680 | if( $this->isIgnoredClass( $strClass ) ) | ||
681 | { | 342 | { |
682 | return false; | 343 | return false; |
683 | } | 344 | } |
684 | 345 | ||
685 | // returns of it is a ignored method | 346 | // returns of it is a ignored method |
686 | if( $this->isIgnoredMethod( $strClass , $strMethod ) ) | 347 | if( $this->getGatekeeperMethods()->match( $strMethod ) == false ) |
687 | { | 348 | { |
688 | return false; | 349 | return false; |
689 | } | 350 | } |
... | ... | ||
695 | * Receive a message of enter into some method and append it as a uml sequence diagram message | 356 | * Receive a message of enter into some method and append it as a uml sequence diagram message |
696 | * into the uml sequence diagram object, creating if necessary the uml sequence diagram actor | 357 | * into the uml sequence diagram object, creating if necessary the uml sequence diagram actor |
697 | * | 358 | * |
698 | * 1. get the name of method as the diagram standart | 359 | * @plan{ |
699 | * 2. get the namespace name | 360 | * <ol> |
700 | * 3. get the actor what the message is bring from | 361 | * <li> get the name of method as the diagram standart </li> |
701 | * 4. get the actor what the message is bring to | 362 | * <li> get the namespace name </li> |
702 | * 4.1 create the actor to if he not exists | 363 | * <li> get the actor what the message is bring from </li> |
703 | * 5. create the message | 364 | * <li> get the actor what the message is bring to |
704 | * 5.1 set the message attributes | 365 | * <ol> |
705 | * 5.2 set the message values | 366 | * <li> create the actor to if he not exists </li> |
706 | * 6. append the message | 367 | * </ol> |
368 | * </li> | ||
369 | * <li> create the message | ||
370 | * <ol> | ||
371 | * <li> set the message attributes </li> | ||
372 | * <li> set the message values </li> | ||
373 | * </ol> | ||
374 | * </li> | ||
375 | * <li> append the message </li> | ||
376 | * </ol> | ||
377 | * } | ||
707 | * | 378 | * |
708 | * @param string $uid | 379 | * @param string $uid |
709 | * @param string $strClassDefinition | 380 | * @param string $strClassDefinition |
... | ... | ||
713 | */ | 384 | */ |
714 | public function onEnterMethod( $uid , $strClassDefinition , $strMethod, $arrArguments ) | 385 | public function onEnterMethod( $uid , $strClassDefinition , $strMethod, $arrArguments ) |
715 | { | 386 | { |
716 | // 1. get the name of method as the diagram standart // | 387 | // get the name of method as the diagram standart // |
717 | $strClass = CorujaClassManipulation::getClassNameFromClassDefinition( $strClassDefinition ); | 388 | $strClass = CorujaClassManipulation::getClassNameFromClassDefinition( $strClassDefinition ); |
718 | $arrMethod = explode( "::" , $strMethod ); | 389 | $arrMethod = explode( "::" , $strMethod ); |
719 | $strRealMethod = array_pop( $arrMethod ); | 390 | $strRealMethod = array_pop( $arrMethod ); |
720 | $strMethod = $this->renameMethod( $strRealMethod , $strClass); | 391 | $strMethod = $this->renameMethod( $strRealMethod , $strClass); |
721 | 392 | ||
722 | // 2. get the namespace name // | 393 | // get the namespace name // |
723 | $strNamespace = CorujaClassManipulation::getNamespaceFromClassDefinition( $strClassDefinition ); | 394 | $strNamespace = CorujaClassManipulation::getNamespaceFromClassDefinition( $strClassDefinition ); |
724 | 395 | ||
725 | if( ! array_key_exists( $strClass, $this->arrClasses ) ) | 396 | if( ! array_key_exists( $strClass, $this->arrClasses ) ) |
... | ... | ||
738 | return $this; | 409 | return $this; |
739 | } | 410 | } |
740 | 411 | ||
741 | // 3. get the actor what the message is bring from // | 412 | // get the actor what the message is bring from // |
742 | $objActorFrom = current( $this->arrStack ); | 413 | $objActorFrom = current( $this->arrStack ); |
743 | if( $objActorFrom === false ) | 414 | if( $objActorFrom === false ) |
744 | { | 415 | { |
745 | return $this; | 416 | return $this; |
746 | } | 417 | } |
747 | 418 | ||
748 | // 4. get the actor what the message is bring to // | 419 | // get the actor what the message is bring to // |
749 | if( ! array_key_exists( $uid , $this->arrActors ) ) | 420 | if( ! array_key_exists( $uid , $this->arrActors ) ) |
750 | { | 421 | { |
751 | // 4.1 create the actor to if he not exists // | 422 | // create the actor to if he not exists // |
752 | $this->arrClasses[ $strClass ]++; | 423 | $this->arrClasses[ $strClass ]++; |
753 | $objActorTo = new UmlSequenceDiagramActor(); | 424 | $objActorTo = new UmlSequenceDiagramActor(); |
754 | $objActorTo->setType( 'system' ); | 425 | $objActorTo->setType( 'system' ); |
... | ... | ||
776 | 447 | ||
777 | if( !$this->getIgnoreRecursiveCalls() || ( $objActorFrom != $objActorTo ) ) | 448 | if( !$this->getIgnoreRecursiveCalls() || ( $objActorFrom != $objActorTo ) ) |
778 | { | 449 | { |
779 | // 5. create the message // | 450 | // create the message // |
780 | $objMessage = new UmlSequenceDiagramMessage(); | 451 | $objMessage = new UmlSequenceDiagramMessage(); |
781 | 452 | ||
782 | // 5.1 set the message attributes // | 453 | // set the message attributes // |
783 | $objMessage->setMethod( $strRealMethod ); | 454 | $objMessage->setMethod( $strRealMethod ); |
784 | $objMessage->setText( $strMethod ); | 455 | $objMessage->setText( $strMethod ); |
785 | $objMessage->setActorFrom( $objActorFrom ); | 456 | $objMessage->setActorFrom( $objActorFrom ); |
... | ... | ||
790 | $objReflectedMethod = $objReflectedClass->getMethod( $strRealMethod ); | 461 | $objReflectedMethod = $objReflectedClass->getMethod( $strRealMethod ); |
791 | $arrReflectedParameter = $objReflectedMethod->getParameters(); | 462 | $arrReflectedParameter = $objReflectedMethod->getParameters(); |
792 | 463 | ||
793 | // 5.2 set the message values // | 464 | // set the message values // |
794 | foreach( $arrArguments as $intPos => $mixValue ) | 465 | foreach( $arrArguments as $intPos => $mixValue ) |
795 | { | 466 | { |
796 | $objValue = new UmlSequenceDiagramValue(); | 467 | $objValue = new UmlSequenceDiagramValue(); |
... | ... | ||
802 | } | 473 | } |
803 | $objMessage->setTimeStart( microtime( true ) ); | 474 | $objMessage->setTimeStart( microtime( true ) ); |
804 | 475 | ||
805 | // 6. append the message // | 476 | // append the message // |
806 | $this->objUmlSequence->addMessage( $objMessage ); | 477 | $this->objUmlSequence->addMessage( $objMessage ); |
807 | $this->arrMessages[] = $objMessage; | 478 | $this->arrMessages[] = $objMessage; |
808 | } | 479 | } |
... | ... | ||
813 | 484 | ||
814 | /** | 485 | /** |
815 | * Receive the message of leave some method and append it message into the uml sequence diagram object | 486 | * Receive the message of leave some method and append it message into the uml sequence diagram object |
487 | * | ||
488 | * @plan{ | ||
489 | * <ol> | ||
490 | * <li> get the name of method as the diagram standart </li> | ||
491 | * <li> get the namespace name </li> | ||
492 | * <li> get the actor what the message is bring from </li> | ||
493 | * <li> get the actor what the message is bring to </li> | ||
494 | * <li> | ||
495 | * create the message | ||
496 | * <ol> | ||
497 | * <li> set the message attributes </li> | ||
498 | * <li> set the message values </li> | ||
499 | * </ol> | ||
500 | * </li> | ||
501 | * <li> append the message </li> | ||
502 | * </ol> | ||
503 | * } | ||
816 | * | 504 | * |
817 | * 1. get the name of method as the diagram standart | ||
818 | * 2. get the namespace name | ||
819 | * 3. get the actor what the message is bring from | ||
820 | * 4. get the actor what the message is bring to | ||
821 | * 5. create the message | ||
822 | * 5.1 set the message attributes | ||
823 | * 5.2 set the message values | ||
824 | * 6. append the message | ||
825 | * | ||
826 | * @param integer $uid | 505 | * @param integer $uid |
827 | * @param string $strClassDefinition | 506 | * @param string $strClassDefinition |
828 | * @param string $strMethod | 507 | * @param string $strMethod |
... | ... | ||
831 | */ | 510 | */ |
832 | public function onLeaveMethod( $uid , $strClassDefinition, $strMethod, $mixReturn ) | 511 | public function onLeaveMethod( $uid , $strClassDefinition, $strMethod, $mixReturn ) |
833 | { | 512 | { |
834 | // 1. get the name of method as the diagram standart // | 513 | // get the name of method as the diagram standart // |
835 | $strClass = CorujaClassManipulation::getClassNameFromClassDefinition( $strClassDefinition ); | 514 | $strClass = CorujaClassManipulation::getClassNameFromClassDefinition( $strClassDefinition ); |
836 | $arrMethod = explode( "::" , $strMethod ); | 515 | $arrMethod = explode( "::" , $strMethod ); |
837 | $strRealMethod = array_pop( $arrMethod ); | 516 | $strRealMethod = array_pop( $arrMethod ); |
838 | $strMethod = $this->renameMethod( $strRealMethod , $strClass ); | 517 | $strMethod = $this->renameMethod( $strRealMethod , $strClass ); |
839 | 518 | ||
840 | // 2. get the namespace name // | 519 | // get the namespace name // |
841 | $strNamespace = CorujaClassManipulation::getNamespaceFromClassDefinition( $strClassDefinition ); | 520 | $strNamespace = CorujaClassManipulation::getNamespaceFromClassDefinition( $strClassDefinition ); |
842 | 521 | ||
843 | if( ! $this->shouldBeLog( $strClass , $strRealMethod ) ) | 522 | if( ! $this->shouldBeLog( $strClass , $strRealMethod ) ) |
... | ... | ||
845 | return $this; | 524 | return $this; |
846 | } | 525 | } |
847 | 526 | ||
848 | // 3. get the actor what the message is bring from // | 527 | // get the actor what the message is bring from // |
849 | $objActorFrom = array_shift( $this->arrStack ); | 528 | $objActorFrom = array_shift( $this->arrStack ); |
850 | 529 | ||
851 | // 4. get the actor what the message is bring to // | 530 | // get the actor what the message is bring to // |
852 | $objActorTo = current( $this->arrStack ); | 531 | $objActorTo = current( $this->arrStack ); |
853 | 532 | ||
854 | $boolCreateMessage = true; | 533 | $boolCreateMessage = true; |
... | ... | ||
865 | 544 | ||
866 | if( $boolCreateMessage ) | 545 | if( $boolCreateMessage ) |
867 | { | 546 | { |
868 | // 5. create the message // | 547 | // create the message // |
869 | $objMessage = new UmlSequenceDiagramMessage(); | 548 | $objMessage = new UmlSequenceDiagramMessage(); |
870 | 549 | ||
871 | // 5.1 set the message attributes // | 550 | // set the message attributes // |
872 | $objMessage->setMethod( $strRealMethod ); | 551 | $objMessage->setMethod( $strRealMethod ); |
873 | $objMessage->setText( $strMethod ); | 552 | $objMessage->setText( $strMethod ); |
874 | $objMessage->setActorFrom( $objActorFrom ); | 553 | $objMessage->setActorFrom( $objActorFrom ); |
875 | $objMessage->setActorTo( $objActorTo ); | 554 | $objMessage->setActorTo( $objActorTo ); |
876 | $objMessage->setType( 'return' ); | 555 | $objMessage->setType( 'return' ); |
877 | 556 | ||
878 | // 5.2 set the message values // | 557 | // set the message values // |
879 | if( $mixReturn !== null ) | 558 | if( $mixReturn !== null ) |
880 | { | 559 | { |
881 | $objValue = new UmlSequenceDiagramValue(); | 560 | $objValue = new UmlSequenceDiagramValue(); |
... | ... | ||
884 | $objMessage->addValue( $objValue ); | 563 | $objMessage->addValue( $objValue ); |
885 | } | 564 | } |
886 | 565 | ||
887 | // 6. append the message // | 566 | // append the message // |
888 | $this->objUmlSequence->addMessage( $objMessage ); | 567 | $this->objUmlSequence->addMessage( $objMessage ); |
889 | $objMessage->setTimeEnd( microtime( true ) ); | 568 | $objMessage->setTimeEnd( microtime( true ) ); |
890 | } | 569 | } |
... | ... | ||
920 | /** | 599 | /** |
921 | * Clean the attributes of the uml sequence diagram existing | 600 | * Clean the attributes of the uml sequence diagram existing |
922 | * | 601 | * |
923 | * 1. clean actors | 602 | * <ol> |
924 | * 2. clean classes | 603 | * <li> clean actors </li> |
925 | * 3. clean messages | 604 | * <li> clean classes </li> |
926 | * 4. clean stack | 605 | * <li> clean messages </li> |
927 | * 5. clean object uml sequence diagram | 606 | * <li> clean stack </li> |
928 | * 6. restart the receiver | 607 | * <li> clean object uml sequence diagram </li> |
608 | * <li> restart the receiver </li> | ||
609 | * </ol> | ||
929 | * | 610 | * |
930 | * @return CodeInstrumentationReceiver | 611 | * @return CodeInstrumentationReceiver |
931 | */ | 612 | */ |
932 | public function restart() | 613 | public function restart() |
933 | { | 614 | { |
934 | // 1. clean actors // | 615 | // clean actors // |
935 | $this->arrActors = array(); | 616 | $this->arrActors = array(); |
936 | // 2. clean classes // | 617 | // clean classes // |
937 | $this->arrClasses = array(); | 618 | $this->arrClasses = array(); |
938 | // 3. clean messages // | 619 | // clean messages // |
939 | $this->arrMessages = array(); | 620 | $this->arrMessages = array(); |
940 | // 4. clean stack // | 621 | // clean stack // |
941 | $this->arrStack = array(); | 622 | $this->arrStack = array(); |
942 | // 5. clean object uml sequence diagram // | 623 | // clean object uml sequence diagram // |
943 | $this->objUmlSequence->restart(); | 624 | $this->objUmlSequence->restart(); |
944 | // 6. restart the receiver // | 625 | // restart the receiver // |
945 | $this->__construct(); | 626 | $this->__construct(); |
946 | return $this; | 627 | return $this; |
947 | } | 628 | } |
Download diff