How to handle different types of objects?
<p>I've discovering an issue in my PHP code. I'm used to write PHP code with Objects and Managers. For example: <strong>Photo</strong> is an object and <strong>PhotoManager</strong> is a managers. I also have a <strong>User</strong> object and a <strong>UserManager</strong>.</p>

<p>See the following bit of code:</p>

<pre><code>&lt;?php

class Photo
{
    public $id;
    public $name;
    public $user;

    public function __construct($id, $name, User $user)
    {
        $this-&gt;id = $id;
        $this-&gt;name = $name;
        $this-&gt;user = $user;
    }
}

?&gt;

&lt;?php

class User
{
    public $id;
    public $name;

    public function __construct($id, $name)
    {
        $this-&gt;id = $id;
        $this-&gt;name = $name;
    }
}

?&gt;

&lt;?php

class PhotoManager
{
    public function loadAll()
    {
        // load all photos (array with objects)
    }

    public function loadById($id)
    {
        // return a single photo (object)
    }
}

?&gt;

&lt;?php

class UserManager
{
    public function loadAll()
    {
        // load all users (array with objects)
    }

    public function loadById($id)
    {
        // return a single user (object)
    }
}

?&gt;
</code></pre>

<p>This works fine. Please not that in my current code the Managers are much bigger with all kinds of functionality.</p>

<p>I use the managers like this:</p>

<pre><code>&lt;?php

$userManager = new UserManager();
$photoManager = new PhotoManager();

?&gt;
</code></pre>

<p>The problem is that I want to add a <strong>User</strong> object into a <strong>Photo</strong> object. So what is the way to go with using the <strong>UserManager</strong> in the <strong>PhotoManager</strong>?? Because I want to access the <strong>loadById</strong> function from the <strong>UserManager</strong> when I'm loading the <strong>User</strong> for the <strong>Photo</strong> object.</p>
