Updated how script recognizes CLI
Fixed a few PHPMD warnings