Search code examples
phpumlclass-diagram

Class diagram - how to document echo


Can i draw a UML class diagram that some how explain that my function do not return value, but rather echo it?

Here is an pseudoísh example of what my class looks like:

class api {
  private $data;

  public function dosomething() {
    $data = $this->getDataFromDatabase();
    echo json_encode($data);
  }

  private function getDataFromDatabase() {
    ....
  }

}

Here is a class diagram that shows my class above.

-----------------------------------
            api
-----------------------------------
    - data : string
-----------------------------------
    + dosomething() : void
    - getDataFromDatabase() : array
-----------------------------------

Solution

  • You can either use : void or leave it away to show that it does not return anything. So the above is ok and alternatively you could write

    -----------------------------------
                api
    -----------------------------------
        - data : string
    -----------------------------------
        + dosomething()
        - getDataFromDatabase() : array
    -----------------------------------