title: How do I implement Dependency Injection when many new objects instances are required?
body: <p>I'm trying understand some DI concepts. One could easily convert a single instance per dependency as in this example.</p>
  
  <p><strong>Non DI</strong></p>
  
  <pre><code>$my_cal = new MyCal();
  
  class MyCal {
      public function __construct() {
          $this-&gt;date  = new MyDate();
          $this-&gt;label = new MyLabel();
      }
  }
  </code></pre>
  
  <p><strong>DI</strong></p>
  
  <pre><code>$my_date  = new MyDate();
  $my_label = new MyLabel();
  $my_cal   = new MyCal($my_date, $my_label);
  
  class MyCal {
      public function __construct(MyDate $date_class, MyLabel $label_class) {
          $this-&gt;date  = $date_class;
          $this-&gt;label = $label_class;
      }
  }
  </code></pre>
  
  <p>But how could  a class with many instance calls (say 30, for example) be converted?</p>
  
  <p><strong>Non DI</strong></p>
  
  <pre><code>$my_cal = new MyCal();
  
  class MyCal {
      public function __construct() {
          $today       = new MyDate(...);
          $tomorrow    = new MyDate(...);
          $next_day    = new MyDate(...);
          $yesterday   = new MyDate(...);
          $another_day = new MyDate(...);
          // ...
          $label1 = new MyLabel(...);
          $label2 = new MyLabel(...);
          $label3 = new MyLabel(...);
          $label4 = new MyLabel(...);
          // ...
      }
  }
  </code></pre>
  
  <p>Could this possibly be when a container or factory would be used?</p>