File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
src/Object/System/Version Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1414 " headers"
1515 ],
1616 "homepage" : " https://github.com/deviscoding/objection" ,
17- "version" : " 1.0" ,
17+ "version" : " 1.0.1 " ,
1818 "license" : " MIT" ,
1919 "authors" : [
2020 {
Original file line number Diff line number Diff line change 1313 *
1414 * @author AMJones <am@jonesiscoding.com>
1515 * @license https://github.com/deviscoding/objection/blob/main/LICENSE
16+ *
1617 * @package DevCoding\Object\System\Version
1718 */
1819abstract class BaseVersion
@@ -74,23 +75,32 @@ public static function fromArray(array $array)
7475 */
7576 public function __toString ()
7677 {
77- return implode ($ this ->toArray ());
78+ // Start off with major and minor. Methods will return 0 if not set, so we'll always have these.
79+ $ str = implode ('. ' , [$ this ->getMajor (), $ this ->getMinor ()]);
80+ // Add in the patch with the period prefix, if applicable.
81+ $ str .= ($ patch = $ this ->getPatch ()) ? '. ' .$ patch : '' ;
82+ // Add in the prerelease with the dash prefix, if applicable.
83+ $ str .= ($ pre = $ this ->getPreRelease ()) ? '- ' .$ pre : '' ;
84+ // Add in the build with the plus prefix, if applicable.
85+ $ str .= ($ build = $ this ->getBuild ()) ? '+ ' .$ build : '' ;
86+
87+ return $ str ;
7888 }
7989
8090 /**
8191 * @return int
8292 */
83- public function getMajor (): int
93+ public function getMajor ()
8494 {
85- return $ this ->major ;
95+ return $ this ->major ?? 0 ;
8696 }
8797
8898 /**
8999 * @return int
90100 */
91101 public function getMinor ()
92102 {
93- return $ this ->minor ;
103+ return $ this ->minor ?? 0 ;
94104 }
95105
96106 /**
You can’t perform that action at this time.
0 commit comments