24 use Psr\Log\LoggerInterface;
25 use Psr\Log\LoggerAwareInterface;
26 use Wikimedia\Timestamp\ConvertibleTimestamp;
73 if ( $val !==
'True' && $val !==
'False' ) {
74 $this->logger->info( __METHOD__ .
" Expected True or False but got $val" );
91 if ( !preg_match(
'/^(?:-?\d+)\/(?:\d+[1-9]|[1-9]\d*)$/D', $val ) ) {
92 $this->logger->info( __METHOD__ .
" Expected rational but got $val" );
108 if ( !$standalone ) {
112 if ( !preg_match(
'/^[-+]?\d*(?:\.?\d*)$/D', $val )
113 || !is_numeric( $val )
115 $this->logger->info( __METHOD__ .
" Expected rating but got $val" );
125 $this->logger->info( __METHOD__ .
" Rating too low, setting to -1 (Rejected)" );
131 $this->logger->info( __METHOD__ .
" Rating too high, setting to 5" );
147 if ( !$standalone ) {
151 if ( !preg_match(
'/^[-+]?\d+$/D', $val ) ) {
152 $this->logger->info( __METHOD__ .
" Expected integer but got $val" );
166 if ( !$standalone ) {
173 if ( isset( $info[
'rangeLow'] )
174 && isset( $info[
'rangeHigh'] )
175 && is_numeric( $val )
176 && ( intval( $val ) <= $info[
'rangeHigh'] )
177 && ( intval( $val ) >= $info[
'rangeLow'] )
182 if ( !isset( $info[
'choices'][$val] ) && !$inRange ) {
183 $this->logger->info( __METHOD__ .
" Expected closed choice, but got $val" );
200 if ( !( isset( $val[
'Fired'] )
201 && isset( $val[
'Function'] )
202 && isset( $val[
'Mode'] )
203 && isset( $val[
'RedEyeMode'] )
204 && isset( $val[
'Return'] )
206 $this->logger->info( __METHOD__ .
" Flash structure did not have all the required components" );
209 $val = (
"\0" | ( $val[
'Fired'] ===
'True' )
210 | ( intval( $val[
'Return'] ) << 1 )
211 | ( intval( $val[
'Mode'] ) << 3 )
212 | ( ( $val[
'Function'] ===
'True' ) << 5 )
213 | ( ( $val[
'RedEyeMode'] ===
'True' ) << 6 ) );
231 if ( !$standalone ) {
235 if ( !preg_match(
'/^[-A-Za-z0-9]{2,}$/D', $val ) ) {
237 $this->logger->info( __METHOD__ .
" Expected Lang code but got $val" );
260 if ( !$standalone ) {
268 '/^([0-3]\d{3})(?:-([01]\d)(?:-([0-3]\d)(?:T([0-2]\d):([0-6]\d)(?::([0-6]\d)(?:\.\d+)?)?([-+]\d{2}:\d{2}|Z)?)?)?)?$/D',
273 $this->logger->info( __METHOD__ .
" Expected date but got $val" );
290 if (
$res[1] ===
'0000' ) {
291 $this->logger->info( __METHOD__ .
" Invalid date (year 0): $val" );
297 if ( !isset(
$res[4] ) ) {
300 if ( isset(
$res[2] ) ) {
301 $val .=
':' .
$res[2];
303 if ( isset(
$res[3] ) ) {
304 $val .=
':' .
$res[3];
310 if ( !isset(
$res[7] ) ||
$res[7] ===
'Z' ) {
314 if ( isset(
$res[6] ) &&
$res[6] !==
'' ) {
315 $val .=
':' .
$res[6];
322 $stripSeconds =
false;
323 if ( !isset(
$res[6] ) ||
$res[6] ===
'' ) {
325 $stripSeconds =
true;
333 $unix = ConvertibleTimestamp::convert( TS_UNIX,
336 $offset = intval( substr(
$res[7], 1, 2 ) ) * 60 * 60;
337 $offset += intval( substr(
$res[7], 4, 2 ) ) * 60;
338 if ( substr(
$res[7], 0, 1 ) ===
'-' ) {
341 $val = ConvertibleTimestamp::convert( TS_EXIF, $unix + $offset );
343 if ( $stripSeconds ) {
345 $val = substr( $val, 0, -3 );
363 if ( !$standalone ) {
369 '/(\d{1,3}),(\d{1,2}),(\d{1,2})([NWSE])/D',
372 $coord = intval( $m[1] );
373 $coord += intval( $m[2] ) * ( 1 / 60 );
374 $coord += intval( $m[3] ) * ( 1 / 3600 );
375 if ( $m[4] ===
'S' || $m[4] ===
'W' ) {
381 } elseif ( preg_match(
382 '/(\d{1,3}),(\d{1,2}(?:.\d*)?)([NWSE])/D',
385 $coord = intval( $m[1] );
386 $coord += floatval( $m[2] ) * ( 1 / 60 );
387 if ( $m[3] ===
'S' || $m[3] ===
'W' ) {
394 $this->logger->info( __METHOD__
395 .
" Expected GPSCoordinate, but got $val." );