3 * @package WPSEO\Admin|Google_Search_Console
7 * Class WPSEO_GSC_Issue
9 class WPSEO_GSC_Issue {
19 private $first_detected;
24 private $last_crawled;
29 private $response_code;
35 * @param DateTime $first_detected
36 * @param DateTime $last_crawled
37 * @param string $response_code
39 public function __construct( $url, DateTime $first_detected, DateTime $last_crawled, $response_code ) {
41 $this->first_detected = $first_detected;
42 $this->last_crawled = $last_crawled;
43 $this->response_code = $response_code;
47 * Put the class properties in array
51 public function to_array() {
54 'first_detected' => $this->to_date_format( $this->first_detected ),
55 'first_detected_raw' => $this->to_timestamp( $this->first_detected ),
56 'last_crawled' => $this->to_date_format( $this->last_crawled ),
57 'last_crawled_raw' => $this->to_timestamp( $this->last_crawled ),
58 'response_code' => $this->response_code,
63 * Converting the date to a date format
65 * @param DateTime $date_to_convert
66 * @param string $format
70 private function to_date_format( DateTime $date_to_convert, $format = 'Y-m-d H:i:s' ) {
71 return (string) strftime( '%x', strtotime( $date_to_convert->format( $format ) ) );
75 * Converting the date to a timestamp
77 * @param DateTime $date_to_convert
81 private function to_timestamp( DateTime $date_to_convert ) {
82 return $date_to_convert->format( 'U' );