$usable['version'], 'checked' => $check && 'done' === $check['status'] && '' === $check['error'] && 0 === $check['nfailed'] + $check['nskipped'], 'errors' => $check ? $check['errors'] : 0, 'error' => $check ? $check['error'] : '', 'requires_php' => $usable['requires_php'], 'after_switch' => '' !== $usable['requires_php'] && version_compare( $usable['requires_php'], $job['baseline'], '>' ), ) : null; $rows[] = array( 'key' => $c['key'], 'type' => $c['type'], 'name' => $c['name'], 'version' => $c['version'], 'active' => $c['active'], 'status' => $c['status'], 'files' => $c['files'], 'done' => $c['done'], 'errors' => $c['errors'], 'warnings' => $c['warnings'], 'existing' => $c['existing'], 'guarded' => isset( $c['guarded'] ) ? $c['guarded'] : 0, 'skipped' => $c['nskipped'], 'failed' => $c['nfailed'], 'error' => $c['error'], 'update' => $update, 'directory' => $c['directory'], 'verdict' => self::verdict( $c, $update ), ); } return $rows; } private static function verdict( array $c, $update ) { if ( 'done' !== $c['status'] ) { return 'pending'; } if ( '' !== $c['error'] || ( $c['done'] > 0 && $c['nfailed'] + $c['nskipped'] >= $c['done'] ) ) { return 'failed'; } if ( 0 === $c['errors'] ) { return 0 === $c['warnings'] ? 'ready' : 'notices'; } if ( $update && ! ( $update['checked'] && $update['errors'] > 0 ) ) { return 'update'; } $dir = $c['directory']; if ( is_array( $dir ) && ! $dir['found'] ) { return 'custom'; } if ( is_array( $dir ) && ( $dir['closed'] || ( '' !== $dir['last_updated'] && strtotime( $dir['last_updated'] ) < strtotime( '-' . self::STALE_YEARS . ' years' ) ) ) ) { return 'replace'; } return false === $c['wporg'] ? 'custom' : 'report'; } public static function summary( array $rows ) { $out = array( 'total' => count( $rows ), 'blocking' => 0, 'notices' => 0, 'ready' => 0, 'failed' => 0, 'pending' => 0, ); foreach ( $rows as $r ) { if ( 'pending' === $r['verdict'] ) { ++$out['pending']; } elseif ( 'failed' === $r['verdict'] ) { ++$out['failed']; } elseif ( $r['errors'] > 0 ) { ++$out['blocking']; } elseif ( 'notices' === $r['verdict'] ) { ++$out['notices']; } else { ++$out['ready']; } } return $out; } }