These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * @package Arastta eCommerce |
||
4 | * @copyright 2015-2017 Arastta Association. All rights reserved. |
||
5 | * @copyright See CREDITS.txt for credits and other copyright notices. |
||
6 | * @license GNU GPL version 3; see LICENSE.txt |
||
7 | * @link https://arastta.org |
||
8 | */ |
||
9 | |||
10 | defined('AREXE') or die; |
||
11 | |||
12 | /** |
||
13 | * Version information class for the Arastta eCommerce based on http://semver.org |
||
14 | * |
||
15 | * @since 1.0 |
||
16 | */ |
||
17 | final class Version extends Object |
||
18 | { |
||
19 | |||
20 | protected $name = 'Arastta'; |
||
21 | |||
22 | protected $code = 'Tianjin'; |
||
23 | |||
24 | protected $major = '1'; |
||
25 | |||
26 | protected $minor = '6'; |
||
27 | |||
28 | protected $patch = '0'; |
||
29 | |||
30 | protected $build = ''; |
||
31 | |||
32 | protected $status = 'Stable'; |
||
33 | |||
34 | protected $date = '11-April-2017'; |
||
35 | |||
36 | protected $time = '20:00'; |
||
37 | |||
38 | protected $zone = 'GMT +3'; |
||
39 | |||
40 | /** |
||
41 | * Compares two a "PHP standardized" version number against the current Arastta version. |
||
42 | * |
||
43 | * @param string $minimum The minimum version of the Arastta which is compatible. |
||
44 | * |
||
45 | * @return bool True if the version is compatible. |
||
46 | * |
||
47 | * @see http://www.php.net/version_compare |
||
48 | * @since 1.0 |
||
49 | */ |
||
50 | public function isCompatible($minimum) |
||
51 | { |
||
52 | return version_compare($this->getShortVersion(), $minimum, 'ge'); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Gets a "PHP standardized" version string for the current Arastta. |
||
57 | * |
||
58 | * @return string Version string. |
||
59 | * |
||
60 | * @since 1.0 |
||
61 | */ |
||
62 | public function getReleaseVersion() |
||
63 | { |
||
64 | return $this->get('major') . '.' . $this->get('minor'); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Gets a "PHP standardized" version string for the current Arastta. |
||
69 | * |
||
70 | * @return string Version string. |
||
71 | * |
||
72 | * @since 1.0 |
||
73 | */ |
||
74 | public function getShortVersion() |
||
75 | { |
||
76 | return $this->getReleaseVersion() . '.' . $this->get('patch'); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Gets a version string for the current Arastta with all release information. |
||
81 | * |
||
82 | * @return string Complete version string. |
||
83 | * |
||
84 | * @since 1.0 |
||
85 | */ |
||
86 | public function getLongVersion() |
||
87 | { |
||
88 | return $this->get('name') . ' ' . $this->getShortVersion() . ' ' |
||
89 | . $this->get('status') . ' [ ' . $this->get('code') . ' ] ' . $this->get('date') . ' ' |
||
90 | . $this->get('time') . ' ' . $this->get('zone'); |
||
91 | } |
||
92 | } |
||
93 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.