title: Calculate a year from a set of dates
body: <p>I am given an array containing periods for a year as following.</p>
  
  <pre><code>$year = '2016';
  $periods = [
        [
            'name' =&gt; "Name One",
            'startDate' =&gt; '01/01/2016',
            'endDate' =&gt; '03/31/2016'
        ],
          [
              'name' =&gt; "Name Two",
              'startDate' =&gt; '04/01/2016',
              'endDate' =&gt; '12/31/2016'
          ]
      ];
  </code></pre>
  
  <p>The number of periods may vary, hence, the array <em>periods</em> may have any number of elements (say 5 elements, meaning 5 periods for the given year). Now I need to make sure that <strong>the periods do really make up a year</strong>, that is, <strong>two periods cannot overlap</strong> and the <strong>periods collectively do sum up to be the specified year</strong>.</p>
  
  <p>I've tried many different ways, but failed to come up with any efficient solution at all.
  I am using Laravel 5, hence Carbon package. But I'll be glad to get this done even in Basic PHP. So all suggestions are welcome</p>