SendGrid_loader was matching classes not part of it's library
SendGrid_loader was matching classes not part of it's library

The Autoloader wasn't strict enough in which classes would trigger it.

I'm using the API class together with SendGrid-PHP-Library (because that one offers the Newsletter API not offered by this class). The autoloader was matching code for the other library as well. It would then try to require the file, which would fail.

I've made the matching stricter. Either the class being loaded must be exactly 'SendGrid', or the class must start with 'SendGrid\' (including the namespace). This used to be a preg_match, but was just as easily done using a stripos, which is faster.

An even better, but more time-consuming, solution would be making the library PSR-0 compliant. In that case, we could remove the custom autoloader completely.
taz77/sendgrid-php,tonyle/sendgrid-php,matthiaz/sendgrid-php,ninsuo/sendgrid-php,matthiaz/sendgrid-php,sendgrid/sendgrid-php,lucasmezencio/sendgrid-php,karlpitcher/MeterReadings,karlpitcher/MeterReadings,admiraalmichiel/sendgrid-php,taz77/sendgrid-php,ninsuo/sendgrid-php,tonyle/sendgrid-php,sendgrid/sendgrid-php,steptan/sendgrid-php,admiraalmichiel/sendgrid-php,steptan/sendgrid-php,lucasmezencio/sendgrid-php