String concatenation of name parts
I assume the class this method resides in represents a person's full name (and title). 

Two remarks before suggesting major refactorings:


You are using a getter getTitle and direct access to $this-&gt;title: stick for one. Usually I prefer to use getters within the class as well (as usual they contain some logic beside returning). Your other variables don't have getters at all. Also, getting a value just for checking for its existence is bad practice. Introduce some existence method for this (e.g. hasTitle). 
Don't store information serialized during runtime ($middlenames). As you obviously need the middle names as an array, store them accordingly. 


Now looking at your class, it has two responsibilities: (1) representing a name, and (2) formating a name. Moving the name formatting into a separate class decouples representation and formating. It allows you to have different means to format at name at the same time and when you want to change the formatting you don't have to touch the name class at all. This is how such a formatter might look like (untested):

class NameFormater {
    private $seperator;
    private $includeTitle;
    private $includeMiddleNames;

    public function __construct($seperator, $includeTitle, $includeMiddleNames) {
        // argument validation here
        $this-&gt;seperator = $seperator;
        $this-&gt;includeTitle = $includeTitle;
        $this-&gt;includeMiddleName = $includeMiddleName;
    }

    public function format(Name $name) {
        $nameParts = array();

        if ($this-&gt;includeTitle &amp;&amp; $name-&gt;hasTitle()) {
            $nameParts[] = $name-&gt;getTitle();
        }
        if ($name-&gt;hasForName()) {
            $nameParts[] = $name-&gt;getForName();
        }
        if ($this-&gt;includeMiddleNames &amp;&amp; $name-&gt;hasMiddleNames()) {
            $nameParts = array_merge($nameParts, $name-&gt;getMiddleNames());
        }
        if ($name-&gt;hasLastName()) {
            $nameParts[] = $name-&gt;getLastName;
        }

        return implode($this-&gt;seperator, $nameParts);
    }
}


Now this method could be refined further. E.g. we first could allow $nameParts to contain null values if the respective part was not set and filter them before implodeing. This would make it more challenging to read though and I prefer a bit more verbosity over compactness. The current version is trivial to follow and understand. This is due to no complex nesting or logic and names that speak for themselves (e.g. hasTitle) - and in my opinion this is the most important point in programming :)