static function parse($jobLine)
    {
        // split the line
        $parts = preg_split('@ @', $jobLine, NULL, PREG_SPLIT_NO_EMPTY);

        // check the number of part
        if (count($parts) < 5) {
            throw new \InvalidArgumentException('Wrong job number of arguments.');
        }

        // analyse command
        $command = implode(' ', array_slice($parts, 5));

        // prepare variables
        $lastRunTime = $logFile = $logSize = $errorFile = $errorSize = $comments = null;

        // extract comment
        if (strpos($command, '#')) {
            list($command, $comment) = explode('#', $command);
            $comments = trim($comment);
        }

        // extract error file
        if (strpos($command, '2>>')) {
            list($command, $errorFile) = explode('2>>', $command);
            $errorFile = trim($errorFile);
        }

        // extract log file
        if (strpos($command, '>>')) {
            list($command, $logPart) = explode('>>', $command);
            $logPart = explode(' ', trim($logPart));
            $logFile = trim($logPart[0]);
        }

        // compute last run time, and file size
        if (isset($logFile) && file_exists($logFile)) {
            $lastRunTime = filemtime($logFile);
            $logSize = filesize($logFile);
        }
        if (isset($errorFile) && file_exists($errorFile)) {
            $lastRunTime = max($lastRunTime ? : 0, filemtime($errorFile));
            $errorSize = filesize($errorFile);
        }

        $command = trim($command);

        // compute status
        $status = 'error';
        if ($logSize === null && $errorSize === null) {
            $status = 'unknown';
        } else if ($errorSize === null || $errorSize == 0) {
            $status =  'success';
        }

        // set the Job object
        $job = new Job();
        $job
            ->setMinute($parts[0])
            ->setHour($parts[1])
            ->setDayOfMonth($parts[2])
            ->setMonth($parts[3])
            ->setDayOfWeek($parts[4])
            ->setCommand($command)
            ->setErrorFile($errorFile)
            ->setErrorSize($errorSize)
            ->setLogFile($logFile)
            ->setLogSize($logSize)
            ->setComments($comments)
            ->setLastRunTime($lastRunTime)
            ->setStatus($status)
        ;

        return $job;
    }
static function parse($jobLine)
    {
        // split the line
        $parts = preg_split('@ @', $jobLine, NULL, PREG_SPLIT_NO_EMPTY);

        // check the number of part
        if (count($parts) < 5) {
            throw new \InvalidArgumentException('Wrong job number of arguments.');
        }

        // analyse command
        $command = implode(' ', array_slice($parts, 5));

        // prepare variables
        $lastRunTime = $logFile = $logSize = $errorFile = $errorSize = $comments = null;

        // extract comment
        if (strpos($command, '#')) {
            list($command, $comment) = explode('#', $command);
            $comments = trim($comment);
        }

        // extract error file
        if (strpos($command, '2>>')) {
            list($command, $errorFile) = explode('2>>', $command);
            $errorFile = trim($errorFile);
        }

        // extract log file
        if (strpos($command, '>>')) {
            list($command, $logPart) = explode('>>', $command);
            $logPart = explode(' ', trim($logPart));
            $logFile = trim($logPart[0]);
        }

        // compute last run time, and file size
        if (isset($logFile) && file_exists($logFile)) {
            $lastRunTime = filemtime($logFile);
            $logSize = filesize($logFile);
        }
        if (isset($errorFile) && file_exists($errorFile)) {
            $lastRunTime = max($lastRunTime ? : 0, filemtime($errorFile));
            $errorSize = filesize($errorFile);
        }

        $command = trim($command);

        // compute status
        $status = 'error';
        if ($logSize === null && $errorSize === null) {
            $status = 'unknown';
        } else if ($errorSize === null || $errorSize == 0) {
            $status =  'success';
        }

        // set the Job object
        $job = new Job();
        $job
            ->setMinute($parts[0])
            ->setHour($parts[1])
            ->setDayOfMonth($parts[2])
            ->setMonth($parts[3])
            ->setDayOfWeek($parts[4])
            ->setCommand($command)
            ->setErrorFile($errorFile)
            ->setErrorSize($errorSize)
            ->setLogFile($logFile)
            ->setLogSize($logSize)
            ->setComments($comments)
            ->setLastRunTime($lastRunTime)
            ->setStatus($status)
        ;

        return $job;
    }
static function parse ( $ jobLine ) { // split the line $ parts = preg_split ( '@ @' , $ jobLine , NULL , PREG_SPLIT_NO_EMPTY ) ; // check the number of part if ( count ( $ parts ) < 5 ) { throw new \ InvalidArgumentException ( 'Wrong job number of arguments.' ) ; } // analyse command $ command = implode ( ' ' , array_slice ( $ parts , 5 ) ) ; // prepare variables $ lastRunTime = $ logFile = $ logSize = $ errorFile = $ errorSize = $ comments = null ; // extract comment if ( strpos ( $ command , '#' ) ) { list ( $ command , $ comment ) = explode ( '#' , $ command ) ; $ comments = trim ( $ comment ) ; } // extract error file if ( strpos ( $ command , '2>>' ) ) { list ( $ command , $ errorFile ) = explode ( '2>>' , $ command ) ; $ errorFile = trim ( $ errorFile ) ; } // extract log file if ( strpos ( $ command , '>>' ) ) { list ( $ command , $ logPart ) = explode ( '>>' , $ command ) ; $ logPart = explode ( ' ' , trim ( $ logPart ) ) ; $ logFile = trim ( $ logPart [ 0 ] ) ; } // compute last run time, and file size if ( isset ( $ logFile ) && file_exists ( $ logFile ) ) { $ lastRunTime = filemtime ( $ logFile ) ; $ logSize = filesize ( $ logFile ) ; } if ( isset ( $ errorFile ) && file_exists ( $ errorFile ) ) { $ lastRunTime = max ( $ lastRunTime ? : 0 , filemtime ( $ errorFile ) ) ; $ errorSize = filesize ( $ errorFile ) ; } $ command = trim ( $ command ) ; // compute status $ status = 'error' ; if ( $ logSize === null && $ errorSize === null ) { $ status = 'unknown' ; } else if ( $ errorSize === null || $ errorSize == 0 ) { $ status = 'success' ; } // set the Job object $ job = new Job ( ) ; $ job -> setMinute ( $ parts [ 0 ] ) -> setHour ( $ parts [ 1 ] ) -> setDayOfMonth ( $ parts [ 2 ] ) -> setMonth ( $ parts [ 3 ] ) -> setDayOfWeek ( $ parts [ 4 ] ) -> setCommand ( $ command ) -> setErrorFile ( $ errorFile ) -> setErrorSize ( $ errorSize ) -> setLogFile ( $ logFile ) -> setLogSize ( $ logSize ) -> setComments ( $ comments ) -> setLastRunTime ( $ lastRunTime ) -> setStatus ( $ status ) ; return $ job ; }
Parse crontab line into Job object

@param $jobLine

@return Job
@throws \InvalidArgumentException
Parse crontab line into Job object